From owner-svn-src-all@FreeBSD.ORG Tue Dec 16 21:57:57 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id BB58D294; Tue, 16 Dec 2014 21:57:57 +0000 (UTC) Received: from svn.freebsd.org (svn.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 A59B291C; Tue, 16 Dec 2014 21:57:57 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id sBGLvvMP033819; Tue, 16 Dec 2014 21:57:57 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id sBGLvu5n033815; Tue, 16 Dec 2014 21:57:56 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201412162157.sBGLvu5n033815@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Tue, 16 Dec 2014 21:57:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r275843 - in stable/10/usr.bin: kdump truss X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Dec 2014 21:57:57 -0000 Author: jhb Date: Tue Dec 16 21:57:55 2014 New Revision: 275843 URL: https://svnweb.freebsd.org/changeset/base/275843 Log: MFC 273053: Decode the arguments passed to _umtx_op(). In particular, decode the opcode. Modified: stable/10/usr.bin/kdump/kdump.c stable/10/usr.bin/kdump/mksubr stable/10/usr.bin/truss/syscall.h stable/10/usr.bin/truss/syscalls.c Directory Properties: stable/10/ (props changed) Modified: stable/10/usr.bin/kdump/kdump.c ============================================================================== --- stable/10/usr.bin/kdump/kdump.c Tue Dec 16 21:51:21 2014 (r275842) +++ stable/10/usr.bin/kdump/kdump.c Tue Dec 16 21:57:55 2014 (r275843) @@ -57,6 +57,7 @@ extern int errno; #include #include #include +#include #include #include #include @@ -1187,6 +1188,26 @@ ktrsyscall(struct ktr_syscall *ktr, u_in ip++; narg--; break; + case SYS__umtx_op: + print_number(ip, narg, c); + putchar(','); + umtxopname(*ip); + switch (*ip) { + case UMTX_OP_CV_WAIT: + ip++; + narg--; + putchar(','); + umtxcvwaitflags(*ip); + break; + case UMTX_OP_RW_RDLOCK: + ip++; + narg--; + putchar(','); + umtxrwlockflags(*ip); + break; + } + ip++; + narg--; } } while (narg > 0) { Modified: stable/10/usr.bin/kdump/mksubr ============================================================================== --- stable/10/usr.bin/kdump/mksubr Tue Dec 16 21:51:21 2014 (r275842) +++ stable/10/usr.bin/kdump/mksubr Tue Dec 16 21:57:55 2014 (r275843) @@ -156,6 +156,7 @@ _EOF_ # C start cat <<_EOF_ +#include #include #include #include @@ -185,6 +186,8 @@ cat <<_EOF_ #include #include #include +#include +#include #include #include #include @@ -489,6 +492,7 @@ auto_if_type "sockipprotoname" " auto_switch_type "sockoptname" "SO_[A-Z]+[[:space:]]+0x[0-9]+" "sys/socket.h" auto_switch_type "socktypename" "SOCK_[A-Z]+[[:space:]]+[1-9]+[0-9]*" "sys/socket.h" auto_or_type "thrcreateflagsname" "THR_[A-Z]+[[:space:]]+0x[0-9]+" "sys/thr.h" +auto_switch_type "umtxopname" "UMTX_OP_[[:alnum:]_]+[[:space:]]+[0-9]+" "sys/umtx.h" auto_switch_type "vmresultname" "KERN_[A-Z]+[[:space:]]+[0-9]+" "vm/vm_param.h" auto_or_type "wait6optname" "W[A-Z]+[[:space:]]+[0-9]+" "sys/wait.h" auto_switch_type "whencename" "SEEK_[A-Z]+[[:space:]]+[0-9]+" "sys/unistd.h" @@ -677,6 +681,62 @@ cat <<_EOF_ } } +/* + * AUTO - Special + * + * Just print 0 as 0. + */ +void +umtxcvwaitflags(intmax_t arg) +{ + int or = 0; + if (arg == 0) { + printf("0"); + return; + } + printf("%#jx<", (uintmax_t)arg); +_EOF_ + egrep "^#[[:space:]]*define[[:space:]]+CVWAIT_[A-Z_]+[[:space:]]+0x[0-9]+[[:space:]]*" \ + $include_dir/sys/umtx.h | \ + awk '{ for (i = 1; i <= NF; i++) \ + if ($i ~ /define/) \ + break; \ + ++i; \ + printf "\tif (!((arg > 0) ^ ((%s) > 0)))\n\t\tif_print_or(arg, %s, or);\n", $i, $i }' +cat <<_EOF_ + printf(">"); + if (or == 0) + printf("%jd", arg); +} + + +/* + * AUTO - Special + * + * Just print 0 as 0. + */ +void +umtxrwlockflags(intmax_t arg) +{ + int or = 0; + if (arg == 0) { + printf("0"); + return; + } + printf("%#jx<", (uintmax_t)arg); +_EOF_ + egrep "^#[[:space:]]*define[[:space:]]+URWLOCK_PREFER_READER[[:space:]]+0x[0-9]+[[:space:]]*" \ + $include_dir/sys/umtx.h | \ + awk '{ for (i = 1; i <= NF; i++) \ + if ($i ~ /define/) \ + break; \ + ++i; \ + printf "\tif (!((arg > 0) ^ ((%s) > 0)))\n\t\tif_print_or(arg, %s, or);\n", $i, $i }' +cat <<_EOF_ + printf(">"); + if (or == 0) + printf("%jd", arg); +} _EOF_ egrep '#define[[:space:]]+CAP_[A-Z_]+[[:space:]]+CAPRIGHT\([0-9],[[:space:]]+0x[0-9]{16}ULL\)' \ $include_dir/sys/capability.h | \ Modified: stable/10/usr.bin/truss/syscall.h ============================================================================== --- stable/10/usr.bin/truss/syscall.h Tue Dec 16 21:51:21 2014 (r275842) +++ stable/10/usr.bin/truss/syscall.h Tue Dec 16 21:57:55 2014 (r275843) @@ -5,6 +5,7 @@ * Hex -- values that should be printed in hex (addresses) * Octal -- Same as above, but octal * Int -- normal integer values (file descriptors, for example) + * LongHex -- long value that should be printed in hex * Name -- pointer to a NULL-terminated string. * BinString -- pointer to an array of chars, printed via strvisx(). * Ptr -- pointer to some unspecified structure. Just print as hex for now. @@ -35,13 +36,13 @@ * $FreeBSD$ */ -enum Argtype { None = 1, Hex, Octal, Int, Name, Ptr, Stat, Ioctl, Quad, +enum Argtype { None = 1, Hex, Octal, Int, LongHex, Name, Ptr, Stat, Ioctl, Quad, Signal, Sockaddr, StringArray, Timespec, Timeval, Itimerval, Pollfd, Fd_set, Sigaction, Fcntl, Mprot, Mmapflags, Whence, Readlinkres, Umtx, Sigset, Sigprocmask, Kevent, Sockdomain, Socktype, Open, Fcntlflag, Rusage, BinString, Shutdown, Resource, Rlimit, Timeval2, Pathconf, Rforkflags, ExitStatus, Waitoptions, Idtype, Procctl, - LinuxSockArgs }; + LinuxSockArgs, Umtxop }; #define ARG_MASK 0xff #define OUT 0x100 Modified: stable/10/usr.bin/truss/syscalls.c ============================================================================== --- stable/10/usr.bin/truss/syscalls.c Tue Dec 16 21:51:21 2014 (r275842) +++ stable/10/usr.bin/truss/syscalls.c Tue Dec 16 21:57:55 2014 (r275843) @@ -283,6 +283,9 @@ 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 = "_umtx_op", .ret_type = 1, .nargs = 5, + .args = { { Ptr, 0 }, { Umtxop, 1 }, { LongHex, 2 }, { Ptr, 3 }, + { Ptr, 4 } } }, { .name = 0 }, }; @@ -416,6 +419,18 @@ static struct xlat procctl_arg[] = { X(PROC_SPROTECT) XEND }; +static struct xlat umtx_ops[] = { + X(UMTX_OP_LOCK) X(UMTX_OP_UNLOCK) X(UMTX_OP_WAIT) + X(UMTX_OP_WAKE) X(UMTX_OP_MUTEX_TRYLOCK) X(UMTX_OP_MUTEX_LOCK) + X(UMTX_OP_MUTEX_UNLOCK) X(UMTX_OP_SET_CEILING) X(UMTX_OP_CV_WAIT) + X(UMTX_OP_CV_SIGNAL) X(UMTX_OP_CV_BROADCAST) X(UMTX_OP_WAIT_UINT) + X(UMTX_OP_RW_RDLOCK) X(UMTX_OP_RW_WRLOCK) X(UMTX_OP_RW_UNLOCK) + X(UMTX_OP_WAIT_UINT_PRIVATE) X(UMTX_OP_WAKE_PRIVATE) + X(UMTX_OP_MUTEX_WAIT) X(UMTX_OP_MUTEX_WAKE) X(UMTX_OP_SEM_WAIT) + X(UMTX_OP_SEM_WAKE) X(UMTX_OP_NWAKE_PRIVATE) X(UMTX_OP_MUTEX_WAKE2) + XEND +}; + #undef X #undef XEND @@ -612,6 +627,9 @@ print_arg(struct syscall_args *sc, unsig case Int: asprintf(&tmp, "%d", (int)args[sc->offset]); break; + case LongHex: + asprintf(&tmp, "0x%lx", args[sc->offset]); + break; case Name: { /* NULL-terminated string. */ char *tmp2; @@ -1288,6 +1306,9 @@ print_arg(struct syscall_args *sc, unsig case Procctl: tmp = strdup(xlookup(procctl_arg, args[sc->offset])); break; + case Umtxop: + tmp = strdup(xlookup(umtx_ops, args[sc->offset])); + break; default: errx(1, "Invalid argument type %d\n", sc->type & ARG_MASK); }