From: Michal Ludvig Date: Wed, 6 Nov 2002 13:17:21 +0000 (+0000) Subject: Added switch for printing only succeeding syscalls. X-Git-Tag: v4.5.18~969 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=17f8fb3484e94976882f65b7a3aaffc6f24cd75d;p=strace Added switch for printing only succeeding syscalls. --- diff --git a/ChangeLog b/ChangeLog index 43c16a09..5e8ade9d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2002-11-06 Michal Ludvig + + From Marty Leisner , + rewritten my mludvig: + * strace.c (not_failing_only): New. + (usage): Added -z switch description. + (main): Added -z switch parsing to not_failing_only variable. + * syscall.c (trace_syscall): Added not_failing_only handling. + 2002-10-08 Heiko Carstens Missing complete changelog for 2002-10-07 commit: diff --git a/defs.h b/defs.h index 74c9fb1a..43036852 100644 --- a/defs.h +++ b/defs.h @@ -553,3 +553,5 @@ do { \ #ifdef IA64 extern long ia32; #endif + +extern int not_failing_only; diff --git a/strace.c b/strace.c index 9d1f4270..15aea5aa 100644 --- a/strace.c +++ b/strace.c @@ -67,6 +67,9 @@ int rflag = 0, tflag = 0, dtime = 0, cflag = 0; int iflag = 0, xflag = 0, qflag = 0; int pflag_seen = 0; +/* Sometimes we want to print only succeeding syscalls. */ +int not_failing_only = 0; + char *username = NULL; uid_t run_uid; gid_t run_gid; @@ -154,6 +157,7 @@ usage: strace [-dffhiqrtttTvVxx] [-a column] [-e expr] ... [-o file]\n\ -s strsize -- limit length of print strings to STRSIZE chars (default %d)\n\ -S sortby -- sort syscall counts by: time, calls, name, nothing (default %s)\n\ -u username -- run command as username handling setuid and/or setgid\n\ +-z -- print only succeeding syscalls\n\ ", DEFAULT_ACOLUMN, DEFAULT_STRLEN, DEFAULT_SORTBY); exit(exitval); } @@ -190,7 +194,7 @@ char *argv[]; set_sortby(DEFAULT_SORTBY); set_personality(DEFAULT_PERSONALITY); while ((c = getopt(argc, argv, - "+cdfFhiqrtTvVxa:e:o:O:p:s:S:u:")) != EOF) { + "+cdfFhiqrtTvVxza:e:o:O:p:s:S:u:")) != EOF) { switch (c) { case 'c': cflag++; @@ -234,6 +238,9 @@ char *argv[]; printf("%s\n", version); exit(0); break; + case 'z': + not_failing_only = 1; + break; case 'a': acolumn = atoi(optarg); break; diff --git a/syscall.c b/syscall.c index 51196681..1f98de01 100644 --- a/syscall.c +++ b/syscall.c @@ -1742,8 +1742,11 @@ struct tcb *tcp; if (tcp->scno >= nsyscalls || tcp->scno < 0 || (qual_flags[tcp->scno] & QUAL_RAW)) sys_res = printargs(tcp); - else + else { + if (not_failing_only && tcp->u_error) + return; /* ignore failed syscalls */ sys_res = (*sysent[tcp->scno].sys_func)(tcp); + } u_error = tcp->u_error; tprintf(") "); tabto(acolumn);