diff options
author | ngie <ngie@FreeBSD.org> | 2015-10-10 01:29:50 +0000 |
---|---|---|
committer | ngie <ngie@FreeBSD.org> | 2015-10-10 01:29:50 +0000 |
commit | 8cba005f9017c6488f98dc8807baf3e179fd1577 (patch) | |
tree | 071532f10dbdbb6b52de155638f7fa14bc62b54d /usr.bin | |
parent | 2d18671fe9e57ce3bf842fb654693fdbcfa49eb5 (diff) | |
parent | 8d135240735275b0d2f31b6fdc119fb32ac79117 (diff) | |
download | FreeBSD-src-8cba005f9017c6488f98dc8807baf3e179fd1577.zip FreeBSD-src-8cba005f9017c6488f98dc8807baf3e179fd1577.tar.gz |
MFhead @ r289100
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/fortune/strfile/strfile.c | 8 | ||||
-rw-r--r-- | usr.bin/kdump/Makefile | 2 | ||||
-rw-r--r-- | usr.bin/kdump/kdump.c | 144 | ||||
-rw-r--r-- | usr.bin/kdump/utrace.c | 187 | ||||
-rw-r--r-- | usr.bin/truss/Makefile | 5 | ||||
-rw-r--r-- | usr.bin/truss/Makefile.depend.amd64 | 2 | ||||
-rw-r--r-- | usr.bin/truss/amd64-cloudabi64.c | 93 | ||||
-rw-r--r-- | usr.bin/truss/main.c | 2 | ||||
-rw-r--r-- | usr.bin/truss/syscall.h | 16 | ||||
-rw-r--r-- | usr.bin/truss/syscalls.c | 393 | ||||
-rw-r--r-- | usr.bin/truss/truss.1 | 7 | ||||
-rw-r--r-- | usr.bin/truss/truss.h | 2 |
12 files changed, 688 insertions, 173 deletions
diff --git a/usr.bin/fortune/strfile/strfile.c b/usr.bin/fortune/strfile/strfile.c index c88d997..f0a8ed2 100644 --- a/usr.bin/fortune/strfile/strfile.c +++ b/usr.bin/fortune/strfile/strfile.c @@ -438,10 +438,6 @@ randomize(void) off_t tmp; off_t *sp; -#if __FreeBSD_version < 800041 - srandomdev(); -#endif - Tbl.str_flags |= STR_RANDOM; cnt = Tbl.str_numstr; @@ -450,11 +446,7 @@ randomize(void) */ for (sp = Seekpts; cnt > 0; cnt--, sp++) { -#if __FreeBSD_version < 800041 - i = random() % cnt; -#else i = arc4random_uniform(cnt); -#endif tmp = sp[0]; sp[0] = sp[i]; sp[i] = tmp; diff --git a/usr.bin/kdump/Makefile b/usr.bin/kdump/Makefile index 72e6305..6f196ac 100644 --- a/usr.bin/kdump/Makefile +++ b/usr.bin/kdump/Makefile @@ -6,7 +6,7 @@ .PATH: ${.CURDIR}/../ktrace PROG= kdump -SRCS= kdump_subr.c kdump.c ioctl.c subr.c +SRCS= kdump_subr.c kdump.c ioctl.c subr.c utrace.c DPSRCS= kdump_subr.h CFLAGS+= -I${.CURDIR}/../ktrace -I${.CURDIR} -I${.CURDIR}/../.. -I. diff --git a/usr.bin/kdump/kdump.c b/usr.bin/kdump/kdump.c index d8b6ccd..4804a81 100644 --- a/usr.bin/kdump/kdump.c +++ b/usr.bin/kdump/kdump.c @@ -67,7 +67,6 @@ extern int errno; #include <arpa/inet.h> #include <netinet/in.h> #include <ctype.h> -#include <dlfcn.h> #include <err.h> #include <grp.h> #include <inttypes.h> @@ -117,6 +116,7 @@ void ktrfaultend(struct ktr_faultend *); void limitfd(int fd); void usage(void); void ioctlname(unsigned long, int); +int kdump_print_utrace(FILE *, void *, size_t, int); #define TIMESTAMP_NONE 0x0 #define TIMESTAMP_ABSOLUTE 0x1 @@ -1536,151 +1536,13 @@ ktrcsw(struct ktr_csw *cs) cs->user ? "user" : "kernel", cs->wmesg); } -#define UTRACE_DLOPEN_START 1 -#define UTRACE_DLOPEN_STOP 2 -#define UTRACE_DLCLOSE_START 3 -#define UTRACE_DLCLOSE_STOP 4 -#define UTRACE_LOAD_OBJECT 5 -#define UTRACE_UNLOAD_OBJECT 6 -#define UTRACE_ADD_RUNDEP 7 -#define UTRACE_PRELOAD_FINISHED 8 -#define UTRACE_INIT_CALL 9 -#define UTRACE_FINI_CALL 10 -#define UTRACE_DLSYM_START 11 -#define UTRACE_DLSYM_STOP 12 - -struct utrace_rtld { - char sig[4]; /* 'RTLD' */ - int event; - void *handle; - void *mapbase; - size_t mapsize; - int refcnt; - char name[MAXPATHLEN]; -}; - -void -ktruser_rtld(int len, void *p) -{ - struct utrace_rtld *ut = p; - unsigned char *cp; - void *parent; - int mode; - - switch (ut->event) { - case UTRACE_DLOPEN_START: - mode = ut->refcnt; - printf("dlopen(%s, ", ut->name); - switch (mode & RTLD_MODEMASK) { - case RTLD_NOW: - printf("RTLD_NOW"); - break; - case RTLD_LAZY: - printf("RTLD_LAZY"); - break; - default: - printf("%#x", mode & RTLD_MODEMASK); - } - if (mode & RTLD_GLOBAL) - printf(" | RTLD_GLOBAL"); - if (mode & RTLD_TRACE) - printf(" | RTLD_TRACE"); - if (mode & ~(RTLD_MODEMASK | RTLD_GLOBAL | RTLD_TRACE)) - printf(" | %#x", mode & - ~(RTLD_MODEMASK | RTLD_GLOBAL | RTLD_TRACE)); - printf(")\n"); - break; - case UTRACE_DLOPEN_STOP: - printf("%p = dlopen(%s) ref %d\n", ut->handle, ut->name, - ut->refcnt); - break; - case UTRACE_DLCLOSE_START: - printf("dlclose(%p) (%s, %d)\n", ut->handle, ut->name, - ut->refcnt); - break; - case UTRACE_DLCLOSE_STOP: - printf("dlclose(%p) finished\n", ut->handle); - break; - case UTRACE_LOAD_OBJECT: - printf("RTLD: loaded %p @ %p - %p (%s)\n", ut->handle, - ut->mapbase, (char *)ut->mapbase + ut->mapsize - 1, - ut->name); - break; - case UTRACE_UNLOAD_OBJECT: - printf("RTLD: unloaded %p @ %p - %p (%s)\n", ut->handle, - ut->mapbase, (char *)ut->mapbase + ut->mapsize - 1, - ut->name); - break; - case UTRACE_ADD_RUNDEP: - parent = ut->mapbase; - printf("RTLD: %p now depends on %p (%s, %d)\n", parent, - ut->handle, ut->name, ut->refcnt); - break; - case UTRACE_PRELOAD_FINISHED: - printf("RTLD: LD_PRELOAD finished\n"); - break; - case UTRACE_INIT_CALL: - printf("RTLD: init %p for %p (%s)\n", ut->mapbase, ut->handle, - ut->name); - break; - case UTRACE_FINI_CALL: - printf("RTLD: fini %p for %p (%s)\n", ut->mapbase, ut->handle, - ut->name); - break; - case UTRACE_DLSYM_START: - printf("RTLD: dlsym(%p, %s)\n", ut->handle, ut->name); - break; - case UTRACE_DLSYM_STOP: - printf("RTLD: %p = dlsym(%p, %s)\n", ut->mapbase, ut->handle, - ut->name); - break; - default: - cp = p; - cp += 4; - len -= 4; - printf("RTLD: %d ", len); - while (len--) - if (decimal) - printf(" %d", *cp++); - else - printf(" %02x", *cp++); - printf("\n"); - } -} - -struct utrace_malloc { - void *p; - size_t s; - void *r; -}; - -void -ktruser_malloc(void *p) -{ - struct utrace_malloc *ut = p; - - if (ut->p == (void *)(intptr_t)(-1)) - printf("malloc_init()\n"); - else if (ut->s == 0) - printf("free(%p)\n", ut->p); - else if (ut->p == NULL) - printf("%p = malloc(%zu)\n", ut->r, ut->s); - else - printf("%p = realloc(%p, %zu)\n", ut->r, ut->p, ut->s); -} - void ktruser(int len, void *p) { unsigned char *cp; - if (len >= 8 && bcmp(p, "RTLD", 4) == 0) { - ktruser_rtld(len, p); - return; - } - - if (len == sizeof(struct utrace_malloc)) { - ktruser_malloc(p); + if (kdump_print_utrace(stdout, p, len, decimal)) { + printf("\n"); return; } diff --git a/usr.bin/kdump/utrace.c b/usr.bin/kdump/utrace.c new file mode 100644 index 0000000..e719365 --- /dev/null +++ b/usr.bin/kdump/utrace.c @@ -0,0 +1,187 @@ +/*- + * Copyright (c) 1988, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <sys/param.h> +#include <dlfcn.h> +#include <stdio.h> +#include <strings.h> + +int kdump_print_utrace(FILE *, void *, size_t, int); + +#define UTRACE_DLOPEN_START 1 +#define UTRACE_DLOPEN_STOP 2 +#define UTRACE_DLCLOSE_START 3 +#define UTRACE_DLCLOSE_STOP 4 +#define UTRACE_LOAD_OBJECT 5 +#define UTRACE_UNLOAD_OBJECT 6 +#define UTRACE_ADD_RUNDEP 7 +#define UTRACE_PRELOAD_FINISHED 8 +#define UTRACE_INIT_CALL 9 +#define UTRACE_FINI_CALL 10 +#define UTRACE_DLSYM_START 11 +#define UTRACE_DLSYM_STOP 12 + +struct utrace_rtld { + char sig[4]; /* 'RTLD' */ + int event; + void *handle; + void *mapbase; + size_t mapsize; + int refcnt; + char name[MAXPATHLEN]; +}; + +static void +print_utrace_rtld(FILE *fp, void *p, size_t len, int decimal) +{ + struct utrace_rtld *ut = p; + unsigned char *cp; + void *parent; + int mode; + + switch (ut->event) { + case UTRACE_DLOPEN_START: + mode = ut->refcnt; + fprintf(fp, "dlopen(%s, ", ut->name); + switch (mode & RTLD_MODEMASK) { + case RTLD_NOW: + fprintf(fp, "RTLD_NOW"); + break; + case RTLD_LAZY: + fprintf(fp, "RTLD_LAZY"); + break; + default: + fprintf(fp, "%#x", mode & RTLD_MODEMASK); + } + if (mode & RTLD_GLOBAL) + fprintf(fp, " | RTLD_GLOBAL"); + if (mode & RTLD_TRACE) + fprintf(fp, " | RTLD_TRACE"); + if (mode & ~(RTLD_MODEMASK | RTLD_GLOBAL | RTLD_TRACE)) + fprintf(fp, " | %#x", mode & + ~(RTLD_MODEMASK | RTLD_GLOBAL | RTLD_TRACE)); + fprintf(fp, ")"); + break; + case UTRACE_DLOPEN_STOP: + fprintf(fp, "%p = dlopen(%s) ref %d", ut->handle, ut->name, + ut->refcnt); + break; + case UTRACE_DLCLOSE_START: + fprintf(fp, "dlclose(%p) (%s, %d)", ut->handle, ut->name, + ut->refcnt); + break; + case UTRACE_DLCLOSE_STOP: + fprintf(fp, "dlclose(%p) finished", ut->handle); + break; + case UTRACE_LOAD_OBJECT: + fprintf(fp, "RTLD: loaded %p @ %p - %p (%s)", ut->handle, + ut->mapbase, (char *)ut->mapbase + ut->mapsize - 1, + ut->name); + break; + case UTRACE_UNLOAD_OBJECT: + fprintf(fp, "RTLD: unloaded %p @ %p - %p (%s)", ut->handle, + ut->mapbase, (char *)ut->mapbase + ut->mapsize - 1, + ut->name); + break; + case UTRACE_ADD_RUNDEP: + parent = ut->mapbase; + fprintf(fp, "RTLD: %p now depends on %p (%s, %d)", parent, + ut->handle, ut->name, ut->refcnt); + break; + case UTRACE_PRELOAD_FINISHED: + fprintf(fp, "RTLD: LD_PRELOAD finished"); + break; + case UTRACE_INIT_CALL: + fprintf(fp, "RTLD: init %p for %p (%s)", ut->mapbase, ut->handle, + ut->name); + break; + case UTRACE_FINI_CALL: + fprintf(fp, "RTLD: fini %p for %p (%s)", ut->mapbase, ut->handle, + ut->name); + break; + case UTRACE_DLSYM_START: + fprintf(fp, "RTLD: dlsym(%p, %s)", ut->handle, ut->name); + break; + case UTRACE_DLSYM_STOP: + fprintf(fp, "RTLD: %p = dlsym(%p, %s)", ut->mapbase, ut->handle, + ut->name); + break; + default: + cp = p; + cp += 4; + len -= 4; + fprintf(fp, "RTLD: %zu ", len); + while (len--) + if (decimal) + fprintf(fp, " %d", *cp++); + else + fprintf(fp, " %02x", *cp++); + } +} + +struct utrace_malloc { + void *p; + size_t s; + void *r; +}; + +static void +print_utrace_malloc(FILE *fp, void *p) +{ + struct utrace_malloc *ut = p; + + if (ut->p == (void *)(intptr_t)(-1)) + fprintf(fp, "malloc_init()"); + else if (ut->s == 0) + fprintf(fp, "free(%p)", ut->p); + else if (ut->p == NULL) + fprintf(fp, "%p = malloc(%zu)", ut->r, ut->s); + else + fprintf(fp, "%p = realloc(%p, %zu)", ut->r, ut->p, ut->s); +} + +int +kdump_print_utrace(FILE *fp, void *p, size_t len, int decimal) +{ + + if (len >= 8 && bcmp(p, "RTLD", 4) == 0) { + print_utrace_rtld(fp, p, len, decimal); + return (1); + } + + if (len == sizeof(struct utrace_malloc)) { + print_utrace_malloc(fp, p); + return (1); + } + + return (0); +} diff --git a/usr.bin/truss/Makefile b/usr.bin/truss/Makefile index 1cd0a9c..869d479 100644 --- a/usr.bin/truss/Makefile +++ b/usr.bin/truss/Makefile @@ -10,7 +10,10 @@ SRCS+= ${MACHINE_ARCH}-fbsd.c SRCS+= ${MACHINE_CPUARCH}-fbsd.c .endif -CFLAGS+= -I${.CURDIR} -I. +.PATH: ${.CURDIR:H}/kdump +SRCS+= utrace.c + +CFLAGS+= -I${.CURDIR} -I. -I${.CURDIR}/../../sys CLEANFILES= syscalls.master syscalls.h ioctl.c .SUFFIXES: .master diff --git a/usr.bin/truss/Makefile.depend.amd64 b/usr.bin/truss/Makefile.depend.amd64 index fa75c7d..210685b 100644 --- a/usr.bin/truss/Makefile.depend.amd64 +++ b/usr.bin/truss/Makefile.depend.amd64 @@ -17,6 +17,8 @@ DIRDEPS = \ .if ${DEP_RELDIR} == ${_DEP_RELDIR} # local dependencies - needed for -jN in clean tree +amd64-cloudabi64.o: cloudabi64_syscalls.h +amd64-cloudabi64.po: cloudabi64_syscalls.h amd64-fbsd.o: syscalls.h amd64-fbsd.po: syscalls.h amd64-fbsd32.o: freebsd32_syscalls.h diff --git a/usr.bin/truss/amd64-cloudabi64.c b/usr.bin/truss/amd64-cloudabi64.c index 797c62a..e65d8cb 100644 --- a/usr.bin/truss/amd64-cloudabi64.c +++ b/usr.bin/truss/amd64-cloudabi64.c @@ -34,6 +34,8 @@ __FBSDID("$FreeBSD$"); #include <errno.h> #include <stdio.h> +#include <compat/cloudabi/cloudabi_syscalldefs.h> + #include "cloudabi64_syscalls.h" #include "truss.h" @@ -67,18 +69,82 @@ amd64_cloudabi64_fetch_args(struct trussinfo *trussinfo, unsigned int narg) } static const int cloudabi_errno_table[] = { - 0, E2BIG, EACCES, EADDRINUSE, EADDRNOTAVAIL, EAFNOSUPPORT, - EAGAIN, EALREADY, EBADF, EBADMSG, EBUSY, ECANCELED, ECHILD, - ECONNABORTED, ECONNREFUSED, ECONNRESET, EDEADLK, EDESTADDRREQ, - EDOM, EDQUOT, EEXIST, EFAULT, EFBIG, EHOSTUNREACH, EIDRM, - EILSEQ, EINPROGRESS, EINTR, EINVAL, EIO, EISCONN, EISDIR, ELOOP, - EMFILE, EMLINK, EMSGSIZE, EMULTIHOP, ENAMETOOLONG, ENETDOWN, - ENETRESET, ENETUNREACH, ENFILE, ENOBUFS, ENODEV, ENOENT, - ENOEXEC, ENOLCK, ENOLINK, ENOMEM, ENOMSG, ENOPROTOOPT, ENOSPC, - ENOSYS, ENOTCONN, ENOTDIR, ENOTEMPTY, ENOTRECOVERABLE, ENOTSOCK, - ENOTSUP, ENOTTY, ENXIO, EOVERFLOW, EOWNERDEAD, EPERM, EPIPE, - EPROTO, EPROTONOSUPPORT, EPROTOTYPE, ERANGE, EROFS, ESPIPE, - ESRCH, ESTALE, ETIMEDOUT, ETXTBSY, EXDEV, ENOTCAPABLE, + [CLOUDABI_E2BIG] = E2BIG, + [CLOUDABI_EACCES] = EACCES, + [CLOUDABI_EADDRINUSE] = EADDRINUSE, + [CLOUDABI_EADDRNOTAVAIL] = EADDRNOTAVAIL, + [CLOUDABI_EAFNOSUPPORT] = EAFNOSUPPORT, + [CLOUDABI_EAGAIN] = EAGAIN, + [CLOUDABI_EALREADY] = EALREADY, + [CLOUDABI_EBADF] = EBADF, + [CLOUDABI_EBADMSG] = EBADMSG, + [CLOUDABI_EBUSY] = EBUSY, + [CLOUDABI_ECANCELED] = ECANCELED, + [CLOUDABI_ECHILD] = ECHILD, + [CLOUDABI_ECONNABORTED] = ECONNABORTED, + [CLOUDABI_ECONNREFUSED] = ECONNREFUSED, + [CLOUDABI_ECONNRESET] = ECONNRESET, + [CLOUDABI_EDEADLK] = EDEADLK, + [CLOUDABI_EDESTADDRREQ] = EDESTADDRREQ, + [CLOUDABI_EDOM] = EDOM, + [CLOUDABI_EDQUOT] = EDQUOT, + [CLOUDABI_EEXIST] = EEXIST, + [CLOUDABI_EFAULT] = EFAULT, + [CLOUDABI_EFBIG] = EFBIG, + [CLOUDABI_EHOSTUNREACH] = EHOSTUNREACH, + [CLOUDABI_EIDRM] = EIDRM, + [CLOUDABI_EILSEQ] = EILSEQ, + [CLOUDABI_EINPROGRESS] = EINPROGRESS, + [CLOUDABI_EINTR] = EINTR, + [CLOUDABI_EINVAL] = EINVAL, + [CLOUDABI_EIO] = EIO, + [CLOUDABI_EISCONN] = EISCONN, + [CLOUDABI_EISDIR] = EISDIR, + [CLOUDABI_ELOOP] = ELOOP, + [CLOUDABI_EMFILE] = EMFILE, + [CLOUDABI_EMLINK] = EMLINK, + [CLOUDABI_EMSGSIZE] = EMSGSIZE, + [CLOUDABI_EMULTIHOP] = EMULTIHOP, + [CLOUDABI_ENAMETOOLONG] = ENAMETOOLONG, + [CLOUDABI_ENETDOWN] = ENETDOWN, + [CLOUDABI_ENETRESET] = ENETRESET, + [CLOUDABI_ENETUNREACH] = ENETUNREACH, + [CLOUDABI_ENFILE] = ENFILE, + [CLOUDABI_ENOBUFS] = ENOBUFS, + [CLOUDABI_ENODEV] = ENODEV, + [CLOUDABI_ENOENT] = ENOENT, + [CLOUDABI_ENOEXEC] = ENOEXEC, + [CLOUDABI_ENOLCK] = ENOLCK, + [CLOUDABI_ENOLINK] = ENOLINK, + [CLOUDABI_ENOMEM] = ENOMEM, + [CLOUDABI_ENOMSG] = ENOMSG, + [CLOUDABI_ENOPROTOOPT] = ENOPROTOOPT, + [CLOUDABI_ENOSPC] = ENOSPC, + [CLOUDABI_ENOSYS] = ENOSYS, + [CLOUDABI_ENOTCONN] = ENOTCONN, + [CLOUDABI_ENOTDIR] = ENOTDIR, + [CLOUDABI_ENOTEMPTY] = ENOTEMPTY, + [CLOUDABI_ENOTRECOVERABLE] = ENOTRECOVERABLE, + [CLOUDABI_ENOTSOCK] = ENOTSOCK, + [CLOUDABI_ENOTSUP] = ENOTSUP, + [CLOUDABI_ENOTTY] = ENOTTY, + [CLOUDABI_ENXIO] = ENXIO, + [CLOUDABI_EOVERFLOW] = EOVERFLOW, + [CLOUDABI_EOWNERDEAD] = EOWNERDEAD, + [CLOUDABI_EPERM] = EPERM, + [CLOUDABI_EPIPE] = EPIPE, + [CLOUDABI_EPROTO] = EPROTO, + [CLOUDABI_EPROTONOSUPPORT] = EPROTONOSUPPORT, + [CLOUDABI_EPROTOTYPE] = EPROTOTYPE, + [CLOUDABI_ERANGE] = ERANGE, + [CLOUDABI_EROFS] = EROFS, + [CLOUDABI_ESPIPE] = ESPIPE, + [CLOUDABI_ESRCH] = ESRCH, + [CLOUDABI_ESTALE] = ESTALE, + [CLOUDABI_ETIMEDOUT] = ETIMEDOUT, + [CLOUDABI_ETXTBSY] = ETXTBSY, + [CLOUDABI_EXDEV] = EXDEV, + [CLOUDABI_ENOTCAPABLE] = ENOTCAPABLE, }; static int @@ -97,7 +163,8 @@ amd64_cloudabi64_fetch_retval(struct trussinfo *trussinfo, long *retval, retval[0] = regs.r_rax; retval[1] = regs.r_rdx; *errorp = (regs.r_rflags & PSL_C) != 0; - if (*errorp && *retval >= 0 && *retval < nitems(cloudabi_errno_table)) + if (*errorp && *retval >= 0 && *retval < nitems(cloudabi_errno_table) && + cloudabi_errno_table[*retval] != 0) *retval = cloudabi_errno_table[*retval]; return (0); } diff --git a/usr.bin/truss/main.c b/usr.bin/truss/main.c index d46d01e..5eec953 100644 --- a/usr.bin/truss/main.c +++ b/usr.bin/truss/main.c @@ -111,7 +111,7 @@ main(int ac, char **av) trussinfo->flags |= EXECVEARGS; break; case 'c': /* Count number of system calls and time. */ - trussinfo->flags |= COUNTONLY; + trussinfo->flags |= (COUNTONLY | NOSIGS); break; case 'e': /* Print execve() environment strings. */ trussinfo->flags |= EXECVEENVS; diff --git a/usr.bin/truss/syscall.h b/usr.bin/truss/syscall.h index 3e3a1b9..41ac6e0 100644 --- a/usr.bin/truss/syscall.h +++ b/usr.bin/truss/syscall.h @@ -27,6 +27,7 @@ * Sigprocmask -- the first argument to sigprocmask(). Prints the name. * Kevent -- a pointer to an array of struct kevents. Prints all elements. * Pathconf -- the 2nd argument of pathconf(). + * Utrace -- utrace(2) buffer. * * In addition, the pointer types (String, Ptr) may have OUT masked in -- * this means that the data is set on *return* from the system call -- or @@ -36,14 +37,21 @@ * $FreeBSD$ */ -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, +enum Argtype { None = 1, Hex, Octal, Int, UInt, LongHex, Name, Ptr, Stat, Ioctl, + Quad, Signal, Sockaddr, StringArray, Timespec, Timeval, Itimerval, + Pollfd, Fd_set, Sigaction, Fcntl, Mprot, Mmapflags, Whence, Readlinkres, Sigset, Sigprocmask, StatFs, Kevent, Sockdomain, Socktype, Open, Fcntlflag, Rusage, BinString, Shutdown, Resource, Rlimit, Timeval2, Pathconf, Rforkflags, ExitStatus, Waitoptions, Idtype, Procctl, LinuxSockArgs, Umtxop, Atfd, Atflags, Timespec2, Accessmode, Long, - Sysarch, ExecArgs, ExecEnv, PipeFds, QuadHex }; + Sysarch, ExecArgs, ExecEnv, PipeFds, QuadHex, Utrace, IntArray, + + CloudABIAdvice, CloudABIClockID, ClouduABIFDSFlags, + CloudABIFDStat, CloudABIFileStat, CloudABIFileType, + CloudABIFSFlags, CloudABILookup, CloudABIMFlags, CloudABIMProt, + CloudABIMSFlags, CloudABIOFlags, CloudABISDFlags, + CloudABISignal, CloudABISockStat, CloudABISSFlags, + CloudABITimestamp, CloudABIULFlags, CloudABIWhence }; #define ARG_MASK 0xff #define OUT 0x100 diff --git a/usr.bin/truss/syscalls.c b/usr.bin/truss/syscalls.c index 540138d..ec74de9 100644 --- a/usr.bin/truss/syscalls.c +++ b/usr.bin/truss/syscalls.c @@ -59,6 +59,7 @@ __FBSDID("$FreeBSD$"); #include <fcntl.h> #include <poll.h> #include <signal.h> +#include <stdbool.h> #include <stddef.h> #include <stdint.h> #include <stdio.h> @@ -68,10 +69,15 @@ __FBSDID("$FreeBSD$"); #include <unistd.h> #include <vis.h> +#include <compat/cloudabi/cloudabi_syscalldefs.h> + #include "truss.h" #include "extern.h" #include "syscall.h" +/* usr.bin/kdump/utrace.c */ +int kdump_print_utrace(FILE *, void *, size_t, int); + /* 64-bit alignment on 32-bit platforms. */ #if !defined(__LP64__) && defined(__powerpc__) #define QUAD_ALIGN 1 @@ -342,6 +348,8 @@ static struct syscall decoded_syscalls[] = { { Atflags, 3 } } }, { .name = "utimes", .ret_type = 1, .nargs = 2, .args = { { Name | IN, 0 }, { Timeval2 | IN, 1 } } }, + { .name = "utrace", .ret_type = 1, .nargs = 1, + .args = { { Utrace, 0 } } }, { .name = "wait4", .ret_type = 1, .nargs = 4, .args = { { Int, 0 }, { ExitStatus | OUT, 1 }, { Waitoptions, 2 }, { Rusage | OUT, 3 } } }, @@ -377,6 +385,120 @@ static struct syscall decoded_syscalls[] = { { .name = "linux_stat64", .ret_type = 1, .nargs = 3, .args = { { Name | IN, 0 }, { Ptr | OUT, 1 }, { Ptr | IN, 1 } } }, + /* CloudABI system calls. */ + { .name = "cloudabi_sys_clock_res_get", .ret_type = 1, .nargs = 1, + .args = { { CloudABIClockID, 0 } } }, + { .name = "cloudabi_sys_clock_time_get", .ret_type = 1, .nargs = 2, + .args = { { CloudABIClockID, 0 }, { CloudABITimestamp, 1 } } }, + { .name = "cloudabi_sys_condvar_signal", .ret_type = 1, .nargs = 3, + .args = { { Ptr, 0 }, { CloudABIMFlags, 1 }, { UInt, 2 } } }, + { .name = "cloudabi_sys_fd_close", .ret_type = 1, .nargs = 1, + .args = { { Int, 0 } } }, + { .name = "cloudabi_sys_fd_create1", .ret_type = 1, .nargs = 1, + .args = { { CloudABIFileType, 0 } } }, + { .name = "cloudabi_sys_fd_create2", .ret_type = 1, .nargs = 2, + .args = { { CloudABIFileType, 0 }, { PipeFds | OUT, 0 } } }, + { .name = "cloudabi_sys_fd_datasync", .ret_type = 1, .nargs = 1, + .args = { { Int, 0 } } }, + { .name = "cloudabi_sys_fd_dup", .ret_type = 1, .nargs = 1, + .args = { { Int, 0 } } }, + { .name = "cloudabi_sys_fd_replace", .ret_type = 1, .nargs = 2, + .args = { { Int, 0 }, { Int, 1 } } }, + { .name = "cloudabi_sys_fd_seek", .ret_type = 1, .nargs = 3, + .args = { { Int, 0 }, { Int, 1 }, { CloudABIWhence, 2 } } }, + { .name = "cloudabi_sys_fd_stat_get", .ret_type = 1, .nargs = 2, + .args = { { Int, 0 }, { CloudABIFDStat | OUT, 1 } } }, + { .name = "cloudabi_sys_fd_stat_put", .ret_type = 1, .nargs = 3, + .args = { { Int, 0 }, { CloudABIFDStat | IN, 1 }, + { ClouduABIFDSFlags, 2 } } }, + { .name = "cloudabi_sys_fd_sync", .ret_type = 1, .nargs = 1, + .args = { { Int, 0 } } }, + { .name = "cloudabi_sys_file_advise", .ret_type = 1, .nargs = 4, + .args = { { Int, 0 }, { Int, 1 }, { Int, 2 }, + { CloudABIAdvice, 3 } } }, + { .name = "cloudabi_sys_file_allocate", .ret_type = 1, .nargs = 3, + .args = { { Int, 0 }, { Int, 1 }, { Int, 2 } } }, + { .name = "cloudabi_sys_file_create", .ret_type = 1, .nargs = 3, + .args = { { Int, 0 }, { BinString | IN, 1 }, + { CloudABIFileType, 3 } } }, + { .name = "cloudabi_sys_file_link", .ret_type = 1, .nargs = 4, + .args = { { CloudABILookup, 0 }, { BinString | IN, 1 }, + { Int, 3 }, { BinString | IN, 4 } } }, + { .name = "cloudabi_sys_file_open", .ret_type = 1, .nargs = 4, + .args = { { Int, 0 }, { BinString | IN, 1 }, + { CloudABIOFlags, 3 }, { CloudABIFDStat | IN, 4 } } }, + { .name = "cloudabi_sys_file_readdir", .ret_type = 1, .nargs = 4, + .args = { { Int, 0 }, { BinString | OUT, 1 }, { Int, 2 }, + { Int, 3 } } }, + { .name = "cloudabi_sys_file_readlink", .ret_type = 1, .nargs = 4, + .args = { { Int, 0 }, { BinString | IN, 1 }, + { BinString | OUT, 3 }, { Int, 4 } } }, + { .name = "cloudabi_sys_file_rename", .ret_type = 1, .nargs = 4, + .args = { { Int, 0 }, { BinString | IN, 1 }, + { Int, 3 }, { BinString | IN, 4 } } }, + { .name = "cloudabi_sys_file_stat_fget", .ret_type = 1, .nargs = 2, + .args = { { Int, 0 }, { CloudABIFileStat | OUT, 1 } } }, + { .name = "cloudabi_sys_file_stat_fput", .ret_type = 1, .nargs = 3, + .args = { { Int, 0 }, { CloudABIFileStat | IN, 1 }, + { CloudABIFSFlags, 2 } } }, + { .name = "cloudabi_sys_file_stat_get", .ret_type = 1, .nargs = 3, + .args = { { CloudABILookup, 0 }, { BinString | IN, 1 }, + { CloudABIFileStat | OUT, 3 } } }, + { .name = "cloudabi_sys_file_stat_put", .ret_type = 1, .nargs = 4, + .args = { { CloudABILookup, 0 }, { BinString | IN, 1 }, + { CloudABIFileStat | IN, 3 }, { CloudABIFSFlags, 4 } } }, + { .name = "cloudabi_sys_file_symlink", .ret_type = 1, .nargs = 3, + .args = { { BinString | IN, 0 }, + { Int, 2 }, { BinString | IN, 3 } } }, + { .name = "cloudabi_sys_file_unlink", .ret_type = 1, .nargs = 3, + .args = { { Int, 0 }, { BinString | IN, 1 }, + { CloudABIULFlags, 3 } } }, + { .name = "cloudabi_sys_lock_unlock", .ret_type = 1, .nargs = 2, + .args = { { Ptr, 0 }, { CloudABIMFlags, 1 } } }, + { .name = "cloudabi_sys_mem_advise", .ret_type = 1, .nargs = 3, + .args = { { Ptr, 0 }, { Int, 1 }, { CloudABIAdvice, 2 } } }, + { .name = "cloudabi_sys_mem_lock", .ret_type = 1, .nargs = 2, + .args = { { Ptr, 0 }, { Int, 1 } } }, + { .name = "cloudabi_sys_mem_map", .ret_type = 1, .nargs = 6, + .args = { { Ptr, 0 }, { Int, 1 }, { CloudABIMProt, 2 }, + { CloudABIMFlags, 3 }, { Int, 4 }, { Int, 5 } } }, + { .name = "cloudabi_sys_mem_protect", .ret_type = 1, .nargs = 3, + .args = { { Ptr, 0 }, { Int, 1 }, { CloudABIMProt, 2 } } }, + { .name = "cloudabi_sys_mem_sync", .ret_type = 1, .nargs = 3, + .args = { { Ptr, 0 }, { Int, 1 }, { CloudABIMSFlags, 2 } } }, + { .name = "cloudabi_sys_mem_unlock", .ret_type = 1, .nargs = 2, + .args = { { Ptr, 0 }, { Int, 1 } } }, + { .name = "cloudabi_sys_mem_unmap", .ret_type = 1, .nargs = 2, + .args = { { Ptr, 0 }, { Int, 1 } } }, + { .name = "cloudabi_sys_proc_exec", .ret_type = 1, .nargs = 5, + .args = { { Int, 0 }, { BinString | IN, 1 }, { Int, 2 }, + { IntArray, 3 }, { Int, 4 } } }, + { .name = "cloudabi_sys_proc_exit", .ret_type = 1, .nargs = 1, + .args = { { Int, 0 } } }, + { .name = "cloudabi_sys_proc_fork", .ret_type = 1, .nargs = 0 }, + { .name = "cloudabi_sys_proc_raise", .ret_type = 1, .nargs = 1, + .args = { { CloudABISignal, 0 } } }, + { .name = "cloudabi_sys_random_get", .ret_type = 1, .nargs = 2, + .args = { { BinString | OUT, 0 }, { Int, 1 } } }, + { .name = "cloudabi_sys_sock_accept", .ret_type = 1, .nargs = 2, + .args = { { Int, 0 }, { CloudABISockStat | OUT, 1 } } }, + { .name = "cloudabi_sys_sock_bind", .ret_type = 1, .nargs = 3, + .args = { { Int, 0 }, { Int, 1 }, { BinString | IN, 2 } } }, + { .name = "cloudabi_sys_sock_connect", .ret_type = 1, .nargs = 3, + .args = { { Int, 0 }, { Int, 1 }, { BinString | IN, 2 } } }, + { .name = "cloudabi_sys_sock_listen", .ret_type = 1, .nargs = 2, + .args = { { Int, 0 }, { Int, 1 } } }, + { .name = "cloudabi_sys_sock_shutdown", .ret_type = 1, .nargs = 2, + .args = { { Int, 0 }, { CloudABISDFlags, 1 } } }, + { .name = "cloudabi_sys_sock_stat_get", .ret_type = 1, .nargs = 3, + .args = { { Int, 0 }, { CloudABISockStat | OUT, 1 }, + { CloudABISSFlags, 2 } } }, + { .name = "cloudabi_sys_thread_exit", .ret_type = 1, .nargs = 2, + .args = { { Ptr, 0 }, { CloudABIMFlags, 1 } } }, + { .name = "cloudabi_sys_thread_tcb_set", .ret_type = 1, .nargs = 1, + .args = { { Ptr, 0 } } }, + { .name = "cloudabi_sys_thread_yield", .ret_type = 1, .nargs = 0 }, + { .name = 0 }, }; static STAILQ_HEAD(, syscall) syscalls; @@ -593,6 +715,126 @@ static struct xlat sigprocmask_ops[] = { }; #undef X +#define X(a) { CLOUDABI_##a, #a }, + +static struct xlat cloudabi_advice[] = { + X(ADVICE_DONTNEED) X(ADVICE_NOREUSE) X(ADVICE_NORMAL) + X(ADVICE_RANDOM) X(ADVICE_SEQUENTIAL) X(ADVICE_WILLNEED) + XEND +}; + +static struct xlat cloudabi_clockid[] = { + X(CLOCK_MONOTONIC) X(CLOCK_PROCESS_CPUTIME_ID) + X(CLOCK_REALTIME) X(CLOCK_THREAD_CPUTIME_ID) + XEND +}; + +static struct xlat cloudabi_errno[] = { + X(E2BIG) X(EACCES) X(EADDRINUSE) X(EADDRNOTAVAIL) + X(EAFNOSUPPORT) X(EAGAIN) X(EALREADY) X(EBADF) X(EBADMSG) + X(EBUSY) X(ECANCELED) X(ECHILD) X(ECONNABORTED) X(ECONNREFUSED) + X(ECONNRESET) X(EDEADLK) X(EDESTADDRREQ) X(EDOM) X(EDQUOT) + X(EEXIST) X(EFAULT) X(EFBIG) X(EHOSTUNREACH) X(EIDRM) X(EILSEQ) + X(EINPROGRESS) X(EINTR) X(EINVAL) X(EIO) X(EISCONN) X(EISDIR) + X(ELOOP) X(EMFILE) X(EMLINK) X(EMSGSIZE) X(EMULTIHOP) + X(ENAMETOOLONG) X(ENETDOWN) X(ENETRESET) X(ENETUNREACH) + X(ENFILE) X(ENOBUFS) X(ENODEV) X(ENOENT) X(ENOEXEC) X(ENOLCK) + X(ENOLINK) X(ENOMEM) X(ENOMSG) X(ENOPROTOOPT) X(ENOSPC) + X(ENOSYS) X(ENOTCONN) X(ENOTDIR) X(ENOTEMPTY) X(ENOTRECOVERABLE) + X(ENOTSOCK) X(ENOTSUP) X(ENOTTY) X(ENXIO) X(EOVERFLOW) + X(EOWNERDEAD) X(EPERM) X(EPIPE) X(EPROTO) X(EPROTONOSUPPORT) + X(EPROTOTYPE) X(ERANGE) X(EROFS) X(ESPIPE) X(ESRCH) X(ESTALE) + X(ETIMEDOUT) X(ETXTBSY) X(EXDEV) X(ENOTCAPABLE) + XEND +}; + +static struct xlat cloudabi_fdflags[] = { + X(FDFLAG_APPEND) X(FDFLAG_DSYNC) X(FDFLAG_NONBLOCK) + X(FDFLAG_RSYNC) X(FDFLAG_SYNC) + XEND +}; + +static struct xlat cloudabi_fdsflags[] = { + X(FDSTAT_FLAGS) X(FDSTAT_RIGHTS) + XEND +}; + +static struct xlat cloudabi_filetype[] = { + X(FILETYPE_UNKNOWN) X(FILETYPE_BLOCK_DEVICE) + X(FILETYPE_CHARACTER_DEVICE) X(FILETYPE_DIRECTORY) + X(FILETYPE_FIFO) X(FILETYPE_POLL) X(FILETYPE_PROCESS) + X(FILETYPE_REGULAR_FILE) X(FILETYPE_SHARED_MEMORY) + X(FILETYPE_SOCKET_DGRAM) X(FILETYPE_SOCKET_SEQPACKET) + X(FILETYPE_SOCKET_STREAM) X(FILETYPE_SYMBOLIC_LINK) + XEND +}; + +static struct xlat cloudabi_fsflags[] = { + X(FILESTAT_ATIM) X(FILESTAT_ATIM_NOW) X(FILESTAT_MTIM) + X(FILESTAT_MTIM_NOW) X(FILESTAT_SIZE) + XEND +}; + +static struct xlat cloudabi_mflags[] = { + X(MAP_ANON) X(MAP_FIXED) X(MAP_PRIVATE) X(MAP_SHARED) + XEND +}; + +static struct xlat cloudabi_mprot[] = { + X(PROT_EXEC) X(PROT_WRITE) X(PROT_READ) + XEND +}; + +static struct xlat cloudabi_msflags[] = { + X(MS_ASYNC) X(MS_INVALIDATE) X(MS_SYNC) + XEND +}; + +static struct xlat cloudabi_oflags[] = { + X(O_CREAT) X(O_DIRECTORY) X(O_EXCL) X(O_TRUNC) + XEND +}; + +static struct xlat cloudabi_sa_family[] = { + X(AF_UNSPEC) X(AF_INET) X(AF_INET6) X(AF_UNIX) + XEND +}; + +static struct xlat cloudabi_sdflags[] = { + X(SHUT_RD) X(SHUT_WR) + XEND +}; + +static struct xlat cloudabi_signal[] = { + X(SIGABRT) X(SIGALRM) X(SIGBUS) X(SIGCHLD) X(SIGCONT) X(SIGFPE) + X(SIGHUP) X(SIGILL) X(SIGINT) X(SIGKILL) X(SIGPIPE) X(SIGQUIT) + X(SIGSEGV) X(SIGSTOP) X(SIGSYS) X(SIGTERM) X(SIGTRAP) X(SIGTSTP) + X(SIGTTIN) X(SIGTTOU) X(SIGURG) X(SIGUSR1) X(SIGUSR2) + X(SIGVTALRM) X(SIGXCPU) X(SIGXFSZ) + XEND +}; + +static struct xlat cloudabi_ssflags[] = { + X(SOCKSTAT_CLEAR_ERROR) + XEND +}; + +static struct xlat cloudabi_ssstate[] = { + X(SOCKSTAT_ACCEPTCONN) + XEND +}; + +static struct xlat cloudabi_ulflags[] = { + X(UNLINK_REMOVEDIR) + XEND +}; + +static struct xlat cloudabi_whence[] = { + X(WHENCE_CUR) X(WHENCE_END) X(WHENCE_SET) + XEND +}; + +#undef X #undef XEND /* @@ -860,6 +1102,24 @@ print_kevent(FILE *fp, struct kevent *ke, int input) fprintf(fp, ",%p,%p", (void *)ke->data, (void *)ke->udata); } +static void +print_utrace(FILE *fp, void *utrace_addr, size_t len) +{ + unsigned char *utrace_buffer; + + fprintf(fp, "{ "); + if (kdump_print_utrace(fp, utrace_addr, len, 0)) { + fprintf(fp, " }"); + return; + } + + utrace_buffer = utrace_addr; + fprintf(fp, "%zu:", len); + while (len--) + fprintf(fp, " %02x", *utrace_buffer++); + fprintf(fp, " }"); +} + /* * Converts a syscall argument into a string. Said string is * allocated via malloc(), so needs to be free()'d. sc is @@ -887,6 +1147,9 @@ print_arg(struct syscall_args *sc, unsigned long *args, long *retval, case Int: fprintf(fp, "%d", (int)args[sc->offset]); break; + case UInt: + fprintf(fp, "%u", (unsigned int)args[sc->offset]); + break; case LongHex: fprintf(fp, "0x%lx", args[sc->offset]); break; @@ -1601,6 +1864,136 @@ print_arg(struct syscall_args *sc, unsigned long *args, long *retval, fprintf(fp, "{ %ld, %ld }", retval[0], retval[1]); retval[0] = 0; break; + case Utrace: { + size_t len; + void *utrace_addr; + + len = args[sc->offset + 1]; + utrace_addr = calloc(1, len); + if (get_struct(pid, (void *)args[sc->offset], + (void *)utrace_addr, len) != -1) + print_utrace(fp, utrace_addr, len); + else + fprintf(fp, "0x%lx", args[sc->offset]); + free(utrace_addr); + break; + } + case IntArray: { + int descriptors[16]; + unsigned long i, ndescriptors; + bool truncated; + + ndescriptors = args[sc->offset + 1]; + truncated = false; + if (ndescriptors > nitems(descriptors)) { + ndescriptors = nitems(descriptors); + truncated = true; + } + if (get_struct(pid, (void *)args[sc->offset], + descriptors, ndescriptors * sizeof(descriptors[0])) != -1) { + fprintf(fp, "{"); + for (i = 0; i < ndescriptors; i++) + fprintf(fp, i == 0 ? " %d" : ", %d", + descriptors[i]); + fprintf(fp, truncated ? ", ... }" : " }"); + } else + fprintf(fp, "0x%lx", args[sc->offset]); + break; + } + + case CloudABIAdvice: + fputs(xlookup(cloudabi_advice, args[sc->offset]), fp); + break; + case CloudABIClockID: + fputs(xlookup(cloudabi_clockid, args[sc->offset]), fp); + break; + case ClouduABIFDSFlags: + fputs(xlookup_bits(cloudabi_fdsflags, args[sc->offset]), fp); + break; + case CloudABIFDStat: { + cloudabi_fdstat_t fds; + if (get_struct(pid, (void *)args[sc->offset], &fds, sizeof(fds)) + != -1) { + fprintf(fp, "{ %s, ", + xlookup(cloudabi_filetype, fds.fs_filetype)); + fprintf(fp, "%s, ... }", + xlookup_bits(cloudabi_fdflags, fds.fs_flags)); + } else + fprintf(fp, "0x%lx", args[sc->offset]); + break; + } + case CloudABIFileStat: { + cloudabi_filestat_t fsb; + if (get_struct(pid, (void *)args[sc->offset], &fsb, sizeof(fsb)) + != -1) + fprintf(fp, "{ %s, %lu }", + xlookup(cloudabi_filetype, fsb.st_filetype), + fsb.st_size); + else + fprintf(fp, "0x%lx", args[sc->offset]); + break; + } + case CloudABIFileType: + fputs(xlookup(cloudabi_filetype, args[sc->offset]), fp); + break; + case CloudABIFSFlags: + fputs(xlookup_bits(cloudabi_fsflags, args[sc->offset]), fp); + break; + case CloudABILookup: + if ((args[sc->offset] & CLOUDABI_LOOKUP_SYMLINK_FOLLOW) != 0) + fprintf(fp, "%d|LOOKUP_SYMLINK_FOLLOW", + (int)args[sc->offset]); + else + fprintf(fp, "%d", (int)args[sc->offset]); + break; + case CloudABIMFlags: + fputs(xlookup_bits(cloudabi_mflags, args[sc->offset]), fp); + break; + case CloudABIMProt: + fputs(xlookup_bits(cloudabi_mprot, args[sc->offset]), fp); + break; + case CloudABIMSFlags: + fputs(xlookup_bits(cloudabi_msflags, args[sc->offset]), fp); + break; + case CloudABIOFlags: + fputs(xlookup_bits(cloudabi_oflags, args[sc->offset]), fp); + break; + case CloudABISDFlags: + fputs(xlookup_bits(cloudabi_sdflags, args[sc->offset]), fp); + break; + case CloudABISignal: + fputs(xlookup(cloudabi_signal, args[sc->offset]), fp); + break; + case CloudABISockStat: { + cloudabi_sockstat_t ss; + if (get_struct(pid, (void *)args[sc->offset], &ss, sizeof(ss)) + != -1) { + fprintf(fp, "{ %s, ", xlookup( + cloudabi_sa_family, ss.ss_sockname.sa_family)); + fprintf(fp, "%s, ", xlookup( + cloudabi_sa_family, ss.ss_peername.sa_family)); + fprintf(fp, "%s, ", xlookup( + cloudabi_errno, ss.ss_error)); + fprintf(fp, "%s }", xlookup_bits( + cloudabi_ssstate, ss.ss_state)); + } else + fprintf(fp, "0x%lx", args[sc->offset]); + break; + } + case CloudABISSFlags: + fputs(xlookup_bits(cloudabi_ssflags, args[sc->offset]), fp); + break; + case CloudABITimestamp: + fprintf(fp, "%lu.%09lus", args[sc->offset] / 1000000000, + args[sc->offset] % 1000000000); + break; + case CloudABIULFlags: + fputs(xlookup_bits(cloudabi_ulflags, args[sc->offset]), fp); + break; + case CloudABIWhence: + fputs(xlookup(cloudabi_whence, args[sc->offset]), fp); + break; + default: errx(1, "Invalid argument type %d\n", sc->type & ARG_MASK); } diff --git a/usr.bin/truss/truss.1 b/usr.bin/truss/truss.1 index 6a01451..fb02cb4 100644 --- a/usr.bin/truss/truss.1 +++ b/usr.bin/truss/truss.1 @@ -1,6 +1,6 @@ .\" $FreeBSD$ .\" -.Dd May 12, 2009 +.Dd October 9, 2015 .Dt TRUSS 1 .Os .Sh NAME @@ -37,7 +37,7 @@ Show the argument strings that are passed in each .Xr execve 2 system call. .It Fl c -Do not display individual system calls. +Do not display individual system calls or signals. Instead, before exiting, print a summary containing for each system call: the total system time used, the number of times the call was invoked, @@ -95,7 +95,8 @@ options are mutually exclusive.) .Sh SEE ALSO .Xr kdump 1 , .Xr ktrace 1 , -.Xr ptrace 2 +.Xr ptrace 2 , +.Xr utrace 2 .Sh HISTORY The .Nm diff --git a/usr.bin/truss/truss.h b/usr.bin/truss/truss.h index 0f58bd8..5a57de7 100644 --- a/usr.bin/truss/truss.h +++ b/usr.bin/truss/truss.h @@ -51,7 +51,7 @@ struct procabi { /* * This is confusingly named. It holds per-thread state about the - * currently executing system call. syscalls.h defines a struct + * currently executing system call. syscall.h defines a struct * syscall that holds metadata used to format system call arguments. * * NB: args[] stores the raw argument values (e.g. from registers) |