only seeing successful system calls
Marty Leisner
leisner at rochester.rr.com
Sat Nov 2 23:07:23 UTC 2002
When using strace I sometimes like to see the system calls
which work (instead of all the system calls).
I've been porting this patch for years, it seems very useful.
With the -z option, you don't see opens on files which aren't there
(very useful tracking down what a program actually does, instead of
trying to do).
+++ strace.c 2002/11/03 05:23:31
@@ -67,6 +67,9 @@
int iflag = 0, xflag = 0, qflag = 0;
int pflag_seen = 0;
+/* set when only successful syscalls are printed */
+int only_zeros = 0;
+
char *username = NULL;
uid_t run_uid;
gid_t run_gid;
@@ -154,6 +157,7 @@
-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 sys calls returning 0 (normally succeeding)\n\
", DEFAULT_ACOLUMN, DEFAULT_STRLEN, DEFAULT_SORTBY);
exit(exitval);
}
@@ -190,7 +194,7 @@
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 @@
printf("%s\n", version);
exit(0);
break;
+ case 'z':
+ only_zeros = 1;
+ break;
case 'a':
acolumn = atoi(optarg);
break;
--- syscall.c 2002/10/07 14:31:11 1.38
+++ syscall.c 2002/11/03 05:23:31
@@ -1742,8 +1742,13 @@
if (tcp->scno >= nsyscalls || tcp->scno < 0
|| (qual_flags[tcp->scno] & QUAL_RAW))
sys_res = printargs(tcp);
- else
+ else {
+ extern int only_zeros;
+
+ if(only_zeros && tcp->u_error)
+ return; /* ignore non-working syscalls */
sys_res = (*sysent[tcp->scno].sys_func)(tcp);
+ }
u_error = tcp->u_error;
tprintf(") ");
tabto(acolumn);
marty leisner
More information about the Strace-devel
mailing list