From: Eugene Syromyatnikov Date: Mon, 17 Apr 2017 23:02:09 +0000 (+0200) Subject: qualify: add syntax for optional non-matching syscall qualification X-Git-Tag: v4.17~48 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=777626eb355f2b8e797640130f14fff19391054f;p=strace qualify: add syntax for optional non-matching syscall qualification It may be useful in case syscall is not present on the target architecture. * qualify.c (qualify_syscall): Add ignore_fail flag, set it to true in case syscall qualification is led by a question mark(s). * strace.1 (.SS Filtering): Document ability to use question marks in syscall qualification. --- diff --git a/qualify.c b/qualify.c index ca72d93e..1cf3e2db 100644 --- a/qualify.c +++ b/qualify.c @@ -325,12 +325,19 @@ qualify_syscall_name(const char *s, struct number_set *set) static bool qualify_syscall(const char *token, struct number_set *set) { + bool ignore_fail = false; + + while (*token == '?') { + token++; + ignore_fail = true; + } if (*token >= '0' && *token <= '9') - return qualify_syscall_number(token, set); + return qualify_syscall_number(token, set) || ignore_fail; if (*token == '/') - return qualify_syscall_regex(token + 1, set); + return qualify_syscall_regex(token + 1, set) || ignore_fail; return qualify_syscall_class(token, set) - || qualify_syscall_name(token, set); + || qualify_syscall_name(token, set) + || ignore_fail; } /* diff --git a/strace.1 b/strace.1 index 23ae3900..df78e66b 100644 --- a/strace.1 +++ b/strace.1 @@ -330,7 +330,7 @@ A qualifying expression which modifies which events to trace or how to trace them. The format of the expression is: .RS 15 .IP -[\,\fIqualifier\/\fB=\fR][\fB!\fR]\,\fIvalue1\/\fR[\fB,\,\fIvalue2\/\fR]... +[\,\fIqualifier\/\fB=\fR][\fB!\fR][\fB?\fR]\,\fIvalue1\/\fR[\fB,\fR[\fB?\fR]\,\fIvalue2\/\fR]... .RE .IP where @@ -361,6 +361,8 @@ system call. By contrast, .BR \-e "\ " trace "=!" open means to trace every system call except .BR open . +Question mark before the syscall qualification allows suppression of error +in case no syscalls matched the qualification provided. In addition, the special values .B all and