From owner-svn-src-head@freebsd.org Wed Aug 30 15:45:25 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4A16AE04816; Wed, 30 Aug 2017 15:45:25 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 2411F716A6; Wed, 30 Aug 2017 15:45:25 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7UFjNEq099753; Wed, 30 Aug 2017 15:45:23 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7UFjNuN099749; Wed, 30 Aug 2017 15:45:23 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201708301545.v7UFjNuN099749@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Wed, 30 Aug 2017 15:45:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r323021 - head/usr.bin/truss X-SVN-Group: head X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: head/usr.bin/truss X-SVN-Commit-Revision: 323021 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Aug 2017 15:45:25 -0000 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, "\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; }