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