]> granicus.if.org Git - strace/commitdiff
Alias a few more syscall printing functions
authorDenys Vlasenko <vda.linux@googlemail.com>
Mon, 27 Feb 2012 13:18:02 +0000 (14:18 +0100)
committerDenys Vlasenko <vda.linux@googlemail.com>
Mon, 27 Feb 2012 13:18:02 +0000 (14:18 +0100)
   text    data     bss     dec     hex filename
 237384     672   19044  257100   3ec4c strace.before
 236448     672   19044  256164   3e8a4 strace

* defs.h: Declare new functions printargs_lu(), printargs_ld()
which simply print syscall all args as unsigned or signed longs.
* desc.c (sys_epoll_create): Call printargs_ld() instead of open-coding it.
* linux/syscall.h: Remove declarations of the following functions:
sys_alarm, sys_getresgid, sys_getsid, sys_nice, sys_setgid, sys_setpgid,
sys_setpgrp, sys_setregid, sys_setresgid.
* process.c (sys_setgid): Delete this function: now aliased to sys_setuid().
(sys_getresgid): Delete this function: now aliased to sys_getresuid().
(sys_setregid): Delete this function: now aliased to sys_setreuid().
(sys_setresgid): Delete this function: now aliased to sys_setresuid().
(sys_setpgrp): Delete this function: now aliased to printargs_lu().
(sys_getsid): Likewise.
(sys_setpgid): Likewise.
(sys_alarm): Likewise.
(sys_getpgrp): Delete this function: was unused - was already shadowed
by a define in linux/dummy.h.
(sys_setsid): Likewise.
(sys_getpgid): Likewise.
* resource.c (sys_nice): Delete this function: now aliased to printargs_ld().
* linux/dummy.h: Define new aliases (see above for the list).
* syscall.c (printargs_lu): New function.
(printargs_ld): New function.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
defs.h
desc.c
linux/dummy.h
linux/syscall.h
process.c
resource.c
syscall.c

diff --git a/defs.h b/defs.h
index f8e5b1a90cdd59bf0af8d5cd29bed31561545286..9c3b234ce9772c586ef3a5e8d81c9b566c49e29b 100644 (file)
--- a/defs.h
+++ b/defs.h
@@ -472,6 +472,8 @@ extern int trace_syscall(struct tcb *);
 extern void count_syscall(struct tcb *, struct timeval *);
 extern void printxval(const struct xlat *, int, const char *);
 extern int printargs(struct tcb *);
+extern int printargs_lu(struct tcb *);
+extern int printargs_ld(struct tcb *);
 extern void addflags(const struct xlat *, int);
 extern int printflags(const struct xlat *, int, const char *);
 extern const char *sprintflags(const char *, const struct xlat *, int);
diff --git a/desc.c b/desc.c
index a207d2fe130d5f6095fb7f59e7ab5d89c945e188..932c66f2a3a10770ad35b82fad64736ee08cb86b 100644 (file)
--- a/desc.c
+++ b/desc.c
@@ -668,12 +668,11 @@ static const struct xlat epollevents[] = {
        { 0,            NULL            }
 };
 
+/* Not aliased to printargs_ld: we want it to have a distinct address */
 int
 sys_epoll_create(struct tcb *tcp)
 {
-       if (entering(tcp))
-               tprintf("%ld", tcp->u_arg[0]);
-       return 0;
+       return printargs_ld(tcp);
 }
 
 static const struct xlat epollflags[] = {
index 0def94c4ae98baec17583405d9b2324cb18bb3af..26afbbc38dd3b30ebb0c0bd797e71fa8540c69ca 100644 (file)
 #define        sys_dup                 sys_close
 #define        sys_fchdir              sys_close
 #define        sys_fdatasync           sys_close
-#define        sys_getegid             sys_getuid
 #define        sys_geteuid             sys_getuid
+#define        sys_getegid             sys_getuid
 #define        sys_getgid              sys_getuid
+#define        sys_getresgid           sys_getresuid
+#define        sys_setgid              sys_setuid
+#define        sys_setregid            sys_setreuid
+#define        sys_setresgid           sys_setresuid
+#define        sys_setfsgid            sys_setfsuid
 #define        sys_mlock               sys_munmap
 #define        sys_mq_unlink           sys_chdir
 #define        sys_munlock             sys_munmap
@@ -85,7 +90,6 @@
 #define        sys_rename              sys_link
 #define        sys_rmdir               sys_chdir
 #define        sys_sched_get_priority_max sys_sched_get_priority_min
-#define        sys_setfsgid            sys_setfsuid
 #define        sys_swapoff             sys_chdir
 #define        sys_swapon              sys_chdir
 #define        sys_symlink             sys_link
 
 /* printargs does the right thing */
 #define        sys_getpgid             printargs
-#define        sys_getpgrp             printargs
 #define        sys_getpid              printargs
 #define        sys_getppid             printargs
 #define        sys_gettid              printargs
+#define        sys_setsid              printargs
 #define        sys_idle                printargs
 #define        sys_inotify_init        printargs
 #define        sys_munlockall          printargs
 #define        sys_pause               printargs
 #define        sys_rt_sigreturn        printargs
 #define        sys_sched_yield         printargs
-#define        sys_setsid              printargs
 #define        sys_setup               printargs
 #define        sys_set_tid_address     printargs
 #define        sys_sync                printargs
 #define        sys_timer_getoverrun    printargs
 #define        sys_vhangup             printargs
 
+/* printargs_lu/ld does the right thing */
+#define        sys_getsid              printargs_lu
+#define        sys_getpgrp             printargs_lu
+#define        sys_setpgid             printargs_lu
+#define        sys_setpgrp             printargs_lu
+#define        sys_alarm               printargs_lu
+#define        sys_nice                printargs_ld
+
 /* unimplemented */
 #define        sys_afs_syscall         printargs
 #define        sys_break               printargs
index 23c67c7e0c063fe97c0fade158d724a424585d78..4eb7368b1ce0f8a9a8a7736a05e88131e079f017 100644 (file)
@@ -36,7 +36,6 @@ int sys_accept();
 int sys_accept4();
 int sys_access();
 int sys_adjtimex();
-int sys_alarm();
 int sys_arch_prctl();
 int sys_bind();
 int sys_brk();
@@ -102,11 +101,9 @@ int sys_getitimer();
 int sys_getpeername();
 int sys_getpmsg();
 int sys_getpriority();
-int sys_getresgid();
 int sys_getresuid();
 int sys_getrlimit();
 int sys_getrusage();
-int sys_getsid();
 int sys_getsockname();
 int sys_getsockopt();
 int sys_gettimeofday();
@@ -159,7 +156,6 @@ int sys_msync();
 int sys_munmap();
 int sys_nanosleep();
 int sys_newfstatat();
-int sys_nice();
 int sys_old_mmap();
 int sys_oldfstat();
 int sys_oldlstat();
@@ -226,16 +222,11 @@ int sys_set_mempolicy();
 int sys_set_thread_area();
 int sys_setdomainname();
 int sys_setfsuid();
-int sys_setgid();
 int sys_setgroups();
 int sys_setgroups32();
 int sys_sethostname();
 int sys_setitimer();
-int sys_setpgid();
-int sys_setpgrp();
 int sys_setpriority();
-int sys_setregid();
-int sys_setresgid();
 int sys_setresuid();
 int sys_setreuid();
 int sys_setrlimit();
index de305144189bc07d8db11003014874f6adaf77fe..621cad8e3254d02ace3075271521439b77edad03 100644 (file)
--- a/process.c
+++ b/process.c
@@ -720,15 +720,6 @@ sys_setuid(struct tcb *tcp)
        return 0;
 }
 
-int
-sys_setgid(struct tcb *tcp)
-{
-       if (entering(tcp)) {
-               tprintf("%u", (gid_t) tcp->u_arg[0]);
-       }
-       return 0;
-}
-
 int
 sys_getresuid(struct tcb *tcp)
 {
@@ -755,32 +746,6 @@ sys_getresuid(struct tcb *tcp)
        return 0;
 }
 
-int
-sys_getresgid(struct tcb *tcp)
-{
-       if (exiting(tcp)) {
-               __kernel_gid_t gid;
-               if (syserror(tcp))
-                       tprintf("%#lx, %#lx, %#lx", tcp->u_arg[0],
-                               tcp->u_arg[1], tcp->u_arg[2]);
-               else {
-                       if (umove(tcp, tcp->u_arg[0], &gid) < 0)
-                               tprintf("%#lx, ", tcp->u_arg[0]);
-                       else
-                               tprintf("[%lu], ", (unsigned long) gid);
-                       if (umove(tcp, tcp->u_arg[1], &gid) < 0)
-                               tprintf("%#lx, ", tcp->u_arg[1]);
-                       else
-                               tprintf("[%lu], ", (unsigned long) gid);
-                       if (umove(tcp, tcp->u_arg[2], &gid) < 0)
-                               tprintf("%#lx", tcp->u_arg[2]);
-                       else
-                               tprintf("[%lu]", (unsigned long) gid);
-               }
-       }
-       return 0;
-}
-
 int
 sys_setreuid(struct tcb *tcp)
 {
@@ -791,16 +756,6 @@ sys_setreuid(struct tcb *tcp)
        return 0;
 }
 
-int
-sys_setregid(struct tcb *tcp)
-{
-       if (entering(tcp)) {
-               printuid("", tcp->u_arg[0]);
-               printuid(", ", tcp->u_arg[1]);
-       }
-       return 0;
-}
-
 int
 sys_setresuid(struct tcb *tcp)
 {
@@ -811,16 +766,6 @@ sys_setresuid(struct tcb *tcp)
        }
        return 0;
 }
-int
-sys_setresgid(struct tcb *tcp)
-{
-       if (entering(tcp)) {
-               printuid("", tcp->u_arg[0]);
-               printuid(", ", tcp->u_arg[1]);
-               printuid(", ", tcp->u_arg[2]);
-       }
-       return 0;
-}
 
 int
 sys_setgroups(struct tcb *tcp)
@@ -1052,59 +997,6 @@ sys_getgroups32(struct tcb *tcp)
        return 0;
 }
 
-#if defined(ALPHA)
-int
-sys_setpgrp(struct tcb *tcp)
-{
-       if (entering(tcp)) {
-               tprintf("%lu, %lu", tcp->u_arg[0], tcp->u_arg[1]);
-       }
-       return 0;
-}
-#endif
-
-int
-sys_getpgrp(struct tcb *tcp)
-{
-       if (entering(tcp)) {
-               tprintf("%lu", tcp->u_arg[0]);
-       }
-       return 0;
-}
-
-int
-sys_getsid(struct tcb *tcp)
-{
-       if (entering(tcp)) {
-               tprintf("%lu", tcp->u_arg[0]);
-       }
-       return 0;
-}
-
-int
-sys_setsid(struct tcb *tcp)
-{
-       return 0;
-}
-
-int
-sys_getpgid(struct tcb *tcp)
-{
-       if (entering(tcp)) {
-               tprintf("%lu", tcp->u_arg[0]);
-       }
-       return 0;
-}
-
-int
-sys_setpgid(struct tcb *tcp)
-{
-       if (entering(tcp)) {
-               tprintf("%lu, %lu", tcp->u_arg[0], tcp->u_arg[1]);
-       }
-       return 0;
-}
-
 static void
 printargv(struct tcb *tcp, long addr)
 {
@@ -1432,14 +1324,6 @@ sys_waitid(struct tcb *tcp)
        return 0;
 }
 
-int
-sys_alarm(struct tcb *tcp)
-{
-       if (entering(tcp))
-               tprintf("%lu", tcp->u_arg[0]);
-       return 0;
-}
-
 int
 sys_uname(struct tcb *tcp)
 {
index 1aaf7d797a8d91a829251b4241c246b4933276c1..09744d746518e3be5cfcacb7c5575d93413dbf43 100644 (file)
@@ -430,14 +430,6 @@ sys_setpriority(struct tcb *tcp)
        return 0;
 }
 
-int
-sys_nice(struct tcb *tcp)
-{
-       if (entering(tcp))
-               tprintf("%ld", tcp->u_arg[0]);
-       return 0;
-}
-
 int
 sys_times(struct tcb *tcp)
 {
index 7360f4fc73f1024bb02a71bf981060d9c10d2f51..dce705641328f02ecaf2c7a21a283bbef8ef60ea 100644 (file)
--- a/syscall.c
+++ b/syscall.c
@@ -599,6 +599,30 @@ printargs(struct tcb *tcp)
        return 0;
 }
 
+int
+printargs_lu(struct tcb *tcp)
+{
+       if (entering(tcp)) {
+               int i;
+
+               for (i = 0; i < tcp->u_nargs; i++)
+                       tprintf("%s%lu", i ? ", " : "", tcp->u_arg[i]);
+       }
+       return 0;
+}
+
+int
+printargs_ld(struct tcb *tcp)
+{
+       if (entering(tcp)) {
+               int i;
+
+               for (i = 0; i < tcp->u_nargs; i++)
+                       tprintf("%s%ld", i ? ", " : "", tcp->u_arg[i]);
+       }
+       return 0;
+}
+
 long
 getrval2(struct tcb *tcp)
 {