]> granicus.if.org Git - strace/commitdiff
qualify: add syntax for optional non-matching syscall qualification
authorEugene Syromyatnikov <evgsyr@gmail.com>
Mon, 17 Apr 2017 23:02:09 +0000 (01:02 +0200)
committerDmitry V. Levin <ldv@altlinux.org>
Fri, 21 Apr 2017 19:49:03 +0000 (19:49 +0000)
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.

qualify.c
strace.1

index ca72d93e9e350fa87d46a56d29e531f043e65fc9..1cf3e2db4c625c696472ff4dd152c7be60691867 100644 (file)
--- 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;
 }
 
 /*
index 23ae3900609429ec24fb8827042bd6776c133e77..df78e66b3955ea8437fed950c57d1b4b763f8107 100644 (file)
--- 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