From: Denys Vlasenko Date: Mon, 27 Feb 2012 13:18:02 +0000 (+0100) Subject: Alias a few more syscall printing functions X-Git-Tag: v4.7~148 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=72879c6a35cd5afa7f58ee7bc32e4dcd8e65bd9a;p=strace Alias a few more syscall printing functions 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 --- diff --git a/defs.h b/defs.h index f8e5b1a9..9c3b234c 100644 --- 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 a207d2fe..932c66f2 100644 --- 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[] = { diff --git a/linux/dummy.h b/linux/dummy.h index 0def94c4..26afbbc3 100644 --- a/linux/dummy.h +++ b/linux/dummy.h @@ -75,9 +75,14 @@ #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 @@ -96,17 +100,16 @@ /* 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 @@ -114,6 +117,14 @@ #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 diff --git a/linux/syscall.h b/linux/syscall.h index 23c67c7e..4eb7368b 100644 --- a/linux/syscall.h +++ b/linux/syscall.h @@ -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(); diff --git a/process.c b/process.c index de305144..621cad8e 100644 --- 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) { diff --git a/resource.c b/resource.c index 1aaf7d79..09744d74 100644 --- a/resource.c +++ b/resource.c @@ -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) { diff --git a/syscall.c b/syscall.c index 7360f4fc..dce70564 100644 --- 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) {