Date: Wed, 30 Aug 2017 15:45:23 +0000 (UTC) From: John Baldwin <jhb@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r323021 - head/usr.bin/truss Message-ID: <201708301545.v7UFjNuN099749@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: jhb Date: Wed Aug 30 15:45:23 2017 New Revision: 323021 URL: https://svnweb.freebsd.org/changeset/base/323021 Log: Decode signal information returned by system calls. Specifically, decode the siginfo structure returned by sigtimedwait(), sigwaitinfo(), and wait6(). While here, also decode the signal number returned in the second argument to sigwait(). Modified: head/usr.bin/truss/extern.h head/usr.bin/truss/setup.c head/usr.bin/truss/syscall.h head/usr.bin/truss/syscalls.c Modified: head/usr.bin/truss/extern.h ============================================================================== --- head/usr.bin/truss/extern.h Wed Aug 30 15:32:47 2017 (r323020) +++ head/usr.bin/truss/extern.h Wed Aug 30 15:45:23 2017 (r323021) @@ -35,4 +35,5 @@ extern int print_line_prefix(struct trussinfo *); extern void setup_and_wait(struct trussinfo *, char **); extern void start_tracing(struct trussinfo *, pid_t); extern void restore_proc(int); +extern void decode_siginfo(FILE *, siginfo_t *); extern void eventloop(struct trussinfo *); Modified: head/usr.bin/truss/setup.c ============================================================================== --- head/usr.bin/truss/setup.c Wed Aug 30 15:32:47 2017 (r323020) +++ head/usr.bin/truss/setup.c Wed Aug 30 15:45:23 2017 (r323021) @@ -584,7 +584,7 @@ report_new_child(struct trussinfo *info) fprintf(info->outfile, "<new process>\n"); } -static void +void decode_siginfo(FILE *fp, siginfo_t *si) { const char *str; Modified: head/usr.bin/truss/syscall.h ============================================================================== --- head/usr.bin/truss/syscall.h Wed Aug 30 15:32:47 2017 (r323020) +++ head/usr.bin/truss/syscall.h Wed Aug 30 15:45:23 2017 (r323021) @@ -52,6 +52,7 @@ enum Argtype { None = 1, Hex, Octal, Int, UInt, LongHe Sockoptname, Msgflags, CapRights, PUInt, PQuadHex, Acltype, Extattrnamespace, Minherit, Mlockall, Mountflags, Msync, Priowhich, Ptraceop, Quotactlcmd, Reboothowto, Rtpriofunc, Schedpolicy, Schedparam, + PSig, Siginfo, CloudABIAdvice, CloudABIClockID, ClouduABIFDSFlags, CloudABIFDStat, CloudABIFileStat, CloudABIFileType, Modified: head/usr.bin/truss/syscalls.c ============================================================================== --- head/usr.bin/truss/syscalls.c Wed Aug 30 15:32:47 2017 (r323020) +++ head/usr.bin/truss/syscalls.c Wed Aug 30 15:45:23 2017 (r323021) @@ -462,11 +462,12 @@ static struct syscall decoded_syscalls[] = { { .name = "sigsuspend", .ret_type = 1, .nargs = 1, .args = { { Sigset | IN, 0 } } }, { .name = "sigtimedwait", .ret_type = 1, .nargs = 3, - .args = { { Sigset | IN, 0 }, { Ptr, 1 }, { Timespec | IN, 2 } } }, + .args = { { Sigset | IN, 0 }, { Siginfo | OUT, 1 }, + { Timespec | IN, 2 } } }, { .name = "sigwait", .ret_type = 1, .nargs = 2, - .args = { { Sigset | IN, 0 }, { Ptr, 1 } } }, + .args = { { Sigset | IN, 0 }, { PSig | OUT, 1 } } }, { .name = "sigwaitinfo", .ret_type = 1, .nargs = 2, - .args = { { Sigset | IN, 0 }, { Ptr, 1 } } }, + .args = { { Sigset | IN, 0 }, { Siginfo | OUT, 1 } } }, { .name = "socket", .ret_type = 1, .nargs = 3, .args = { { Sockdomain, 0 }, { Socktype, 1 }, { Sockprotocol, 2 } } }, { .name = "stat", .ret_type = 1, .nargs = 2, @@ -510,7 +511,8 @@ static struct syscall decoded_syscalls[] = { { Rusage | OUT, 3 } } }, { .name = "wait6", .ret_type = 1, .nargs = 6, .args = { { Idtype, 0 }, { Quad, 1 }, { ExitStatus | OUT, 2 }, - { Waitoptions, 3 }, { Rusage | OUT, 4 }, { Ptr, 5 } } }, + { Waitoptions, 3 }, { Rusage | OUT, 4 }, + { Siginfo | OUT, 5 } } }, { .name = "write", .ret_type = 1, .nargs = 3, .args = { { Int, 0 }, { BinString | IN, 1 }, { Sizet, 2 } } }, @@ -2161,6 +2163,28 @@ print_arg(struct syscall_args *sc, unsigned long *args sizeof(sp)) != -1) fprintf(fp, "{ %d }", sp.sched_priority); else + fprintf(fp, "0x%lx", args[sc->offset]); + break; + } + case PSig: { + int sig; + + if (get_struct(pid, (void *)args[sc->offset], &sig, + sizeof(sig)) == 0) + fprintf(fp, "{ %s }", strsig2(sig)); + else + fprintf(fp, "0x%lx", args[sc->offset]); + break; + } + case Siginfo: { + siginfo_t si; + + if (get_struct(pid, (void *)args[sc->offset], &si, + sizeof(si)) != -1) { + fprintf(fp, "{ signo=%s", strsig2(si.si_signo)); + decode_siginfo(fp, &si); + fprintf(fp, " }"); + } else fprintf(fp, "0x%lx", args[sc->offset]); break; }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201708301545.v7UFjNuN099749>