1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
# This file is part of ltrace.
# Copyright (C) 2013, 2014 Petr Machata, Red Hat Inc.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
# 02110-1301 USA
set bin [ltraceCompile {} [ltraceSource c {
#define _GNU_SOURCE
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/syscall.h> /* For SYS_xxx definitions */
#ifndef SYS_open
# if defined(__aarch64__)
# /* Linux doesn't actually implement SYS_open on AArch64, but for merely
# * recording the syscall, it's fine. */
# define SYS_open 1024
# else
# error SYS_open not available.
# endif
#endif
int main(void) {
syscall(SYS_open, "/some/path", O_RDONLY);
write(1, "something", 10);
mount("source", "target", "filesystemtype", 0, 0);
}
}]]
set dir [ltraceDir]
set conf [ltraceNamedSource "$dir/syscalls.conf" {
int open(string, int);
long write(int, string[arg3], ulong);
int mount(string, string, string, ulong, addr);
}]
# When given the file directly via -F, ltrace should not use it for
# formatting system calls. The reason is that libraries are generally
# allowed to have functions with the same names as system calls
# (there's no interference between those two). In particular,
# readdir@SYS has a different prototype from readdir@libc. If a -F
# somelib.conf is passed, and syscalls.conf is not available, or
# doesn't list readdir, that would be taken from somelib.conf with a
# wrong prototype.
ltraceMatch1 [ltraceRun -L -S -F $conf -- $bin] {^open@SYS\("/some/path"} == 0
# On the other hand, if -F somedir/ is given, we want to accept
# syscalls.conf found there.
ltraceMatch [ltraceRun -L -S -F $dir -- $bin] {
{{^open@SYS\("/some/path"} == 1}
{{^write@SYS\(1, "something", 10\)} == 1}
{{^mount@SYS\("source", "target", "filesystemtype"} == 1}
}
ltraceDone
|