From owner-svn-src-head@freebsd.org Mon Aug 17 17:52:29 2015 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 AE43A9BBC1A; Mon, 17 Aug 2015 17:52:29 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::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 97BE11B7D; Mon, 17 Aug 2015 17:52:29 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t7HHqTp2055888; Mon, 17 Aug 2015 17:52:29 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t7HHqTEB055884; Mon, 17 Aug 2015 17:52:29 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201508171752.t7HHqTEB055884@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Mon, 17 Aug 2015 17:52:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r286848 - head/usr.bin/truss X-SVN-Group: head 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.20 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: Mon, 17 Aug 2015 17:52:29 -0000 Author: jhb Date: Mon Aug 17 17:52:28 2015 New Revision: 286848 URL: https://svnweb.freebsd.org/changeset/base/286848 Log: - Decode the arguments for several signal-related system calls: sigpending, sigqueue, sigreturn, sigsuspend, sigtimedwait, sigwait, sigwaitinfo, and thr_kill. - Print signal sets as a structure (with {}'s) and in particular use this to differentiate empty sets from a NULL pointer. - Decode arguments for some other system calls: issetugid, pipe2, sysarch (operations are only decoded for amd64 and i386), and thr_self. Modified: head/usr.bin/truss/syscall.h head/usr.bin/truss/syscalls.c Modified: head/usr.bin/truss/syscall.h ============================================================================== --- head/usr.bin/truss/syscall.h Mon Aug 17 17:09:57 2015 (r286847) +++ head/usr.bin/truss/syscall.h Mon Aug 17 17:52:28 2015 (r286848) @@ -41,7 +41,8 @@ enum Argtype { None = 1, Hex, Octal, Int Sigset, Sigprocmask, Kevent, Sockdomain, Socktype, Open, Fcntlflag, Rusage, BinString, Shutdown, Resource, Rlimit, Timeval2, Pathconf, Rforkflags, ExitStatus, Waitoptions, Idtype, Procctl, - LinuxSockArgs, Umtxop, Atfd, Atflags, Timespec2, Accessmode }; + LinuxSockArgs, Umtxop, Atfd, Atflags, Timespec2, Accessmode, Long, + Sysarch }; #define ARG_MASK 0xff #define OUT 0x100 Modified: head/usr.bin/truss/syscalls.c ============================================================================== --- head/usr.bin/truss/syscalls.c Mon Aug 17 17:09:57 2015 (r286847) +++ head/usr.bin/truss/syscalls.c Mon Aug 17 17:52:28 2015 (r286848) @@ -56,6 +56,7 @@ static const char rcsid[] = #include #include #include +#include #include #include @@ -113,6 +114,7 @@ static struct syscall syscalls[] = { { .name = "getsid", .ret_type = 1, .nargs = 1, .args = { { Int, 0 } } }, { .name = "getuid", .ret_type = 1, .nargs = 0 }, + { .name = "issetugid", .ret_type = 1, .nargs = 0 }, { .name = "readlink", .ret_type = 1, .nargs = 3, .args = { { Name, 0 }, { Readlinkres | OUT, 1 }, { Int, 2 } } }, { .name = "readlinkat", .ret_type = 1, .nargs = 4, @@ -280,8 +282,22 @@ static struct syscall syscalls[] = { { .name = "kevent", .ret_type = 0, .nargs = 6, .args = { { Int, 0 }, { Kevent, 1 }, { Int, 2 }, { Kevent | OUT, 3 }, { Int, 4 }, { Timespec, 5 } } }, + { .name = "sigpending", .ret_type = 0, .nargs = 1, + .args = { { Sigset | OUT, 0 } } }, { .name = "sigprocmask", .ret_type = 0, .nargs = 3, .args = { { Sigprocmask, 0 }, { Sigset, 1 }, { Sigset | OUT, 2 } } }, + { .name = "sigqueue", .ret_type = 0, .nargs = 3, + .args = { { Int, 0 }, { Signal, 1 }, { LongHex, 2 } } }, + { .name = "sigreturn", .ret_type = 0, .nargs = 1, + .args = { { Ptr, 0 } } }, + { .name = "sigsuspend", .ret_type = 0, .nargs = 1, + .args = { { Sigset | IN, 0 } } }, + { .name = "sigtimedwait", .ret_type = 1, .nargs = 3, + .args = { { Sigset | IN, 0 }, { Ptr, 1 }, { Timespec | IN, 2 } } }, + { .name = "sigwait", .ret_type = 1, .nargs = 2, + .args = { { Sigset | IN, 0 }, { Ptr, 1 } } }, + { .name = "sigwaitinfo", .ret_type = 1, .nargs = 2, + .args = { { Sigset | IN, 0 }, { Ptr, 1 } } }, { .name = "unmount", .ret_type = 1, .nargs = 2, .args = { { Name, 0 }, { Int, 1 } } }, { .name = "socket", .ret_type = 1, .nargs = 3, @@ -317,6 +333,8 @@ static struct syscall syscalls[] = { .args = { { Name | IN, 0 }, { Pathconf, 1 } } }, { .name = "pipe", .ret_type = 1, .nargs = 1, .args = { { Ptr, 0 } } }, + { .name = "pipe2", .ret_type = 1, .nargs = 2, + .args = { { Ptr, 0 }, { Open, 1 } } }, { .name = "truncate", .ret_type = 1, .nargs = 3, .args = { { Name | IN, 0 }, { Int | IN, 1 }, { Quad | IN, 2 } } }, { .name = "ftruncate", .ret_type = 1, .nargs = 3, @@ -345,9 +363,15 @@ static struct syscall syscalls[] = { { Waitoptions, 3 }, { Rusage | OUT, 4 }, { Ptr, 5 } } }, { .name = "procctl", .ret_type = 1, .nargs = 4, .args = { { Idtype, 0 }, { Int, 1 }, { Procctl, 2 }, { Ptr, 3 } } }, + { .name = "sysarch", .ret_type = 1, .nargs = 2, + .args = { { Sysarch, 0 }, { Ptr, 1 } } }, { .name = "_umtx_op", .ret_type = 1, .nargs = 5, .args = { { Ptr, 0 }, { Umtxop, 1 }, { LongHex, 2 }, { Ptr, 3 }, { Ptr, 4 } } }, + { .name = "thr_kill", .ret_type = 0, .nargs = 2, + .args = { { Long, 0 }, { Signal, 1 } } }, + { .name = "thr_self", .ret_type = 0, .nargs = 1, + .args = { { Ptr, 0 } } }, { .name = 0 }, }; @@ -511,6 +535,16 @@ static struct xlat access_modes[] = { X(R_OK) X(W_OK) X(X_OK) XEND }; +static struct xlat sysarch_ops[] = { +#if defined(__i386__) || defined(__amd64__) + X(I386_GET_LDT) X(I386_SET_LDT) X(I386_GET_IOPERM) X(I386_SET_IOPERM) + X(I386_VM86) X(I386_GET_FSBASE) X(I386_SET_FSBASE) X(I386_GET_GSBASE) + X(I386_SET_GSBASE) X(I386_GET_XFPUSTATE) X(AMD64_GET_FSBASE) + X(AMD64_SET_FSBASE) X(AMD64_GET_GSBASE) X(AMD64_SET_GSBASE) + X(AMD64_GET_XFPUSTATE) +#endif + XEND +}; #undef X #undef XEND @@ -721,7 +755,10 @@ print_arg(struct syscall_args *sc, unsig break; case LongHex: asprintf(&tmp, "0x%lx", args[sc->offset]); - break; + break; + case Long: + asprintf(&tmp, "%ld", args[sc->offset]); + break; case Name: { /* NULL-terminated string. */ char *tmp2; @@ -1089,8 +1126,10 @@ print_arg(struct syscall_args *sc, unsig asprintf(&tmp, "0x%lx", args[sc->offset]); break; } - tmp = malloc(sys_nsig * 8); /* 7 bytes avg per signal name */ + tmp = malloc(sys_nsig * 8 + 2); /* 7 bytes avg per signal name */ used = 0; + tmp[used++] = '{'; + tmp[used++] = ' '; for (i = 1; i < sys_nsig; i++) { if (sigismember(&ss, i)) { signame = strsig(i); @@ -1098,10 +1137,11 @@ print_arg(struct syscall_args *sc, unsig free(signame); } } - if (used) - tmp[used-1] = 0; - else - strcpy(tmp, "0x0"); + if (tmp[used - 1] == '|') + used--; + tmp[used++] = ' '; + tmp[used++] = '}'; + tmp[used++] = '\0'; break; } case Sigprocmask: { @@ -1447,6 +1487,9 @@ print_arg(struct syscall_args *sc, unsig tmp = strdup(xlookup_bits(access_modes, args[sc->offset])); break; + case Sysarch: + tmp = strdup(xlookup(sysarch_ops, args[sc->offset])); + break; default: errx(1, "Invalid argument type %d\n", sc->type & ARG_MASK); }