diff options
author | sjg <sjg@FreeBSD.org> | 2014-11-19 01:07:58 +0000 |
---|---|---|
committer | sjg <sjg@FreeBSD.org> | 2014-11-19 01:07:58 +0000 |
commit | b137080f19736ee33fede2e88bb54438604cf86b (patch) | |
tree | 377ac0ac449528621eb192cd245adadb5fd53668 /usr.bin/kdump | |
parent | ab21a29eb607d4dfe389b965fbdee27558e791aa (diff) | |
parent | 4a8d07956d121238d006d34ffe7d6269744e8b1a (diff) | |
download | FreeBSD-src-b137080f19736ee33fede2e88bb54438604cf86b.zip FreeBSD-src-b137080f19736ee33fede2e88bb54438604cf86b.tar.gz |
Merge from head@274682
Diffstat (limited to 'usr.bin/kdump')
-rw-r--r-- | usr.bin/kdump/kdump.c | 74 | ||||
-rw-r--r-- | usr.bin/kdump/mksubr | 58 |
2 files changed, 113 insertions, 19 deletions
diff --git a/usr.bin/kdump/kdump.c b/usr.bin/kdump/kdump.c index f6e1c79..e0a6079 100644 --- a/usr.bin/kdump/kdump.c +++ b/usr.bin/kdump/kdump.c @@ -57,6 +57,7 @@ extern int errno; #include <sys/socket.h> #include <sys/stat.h> #include <sys/sysent.h> +#include <sys/umtx.h> #include <sys/un.h> #include <sys/queue.h> #include <sys/wait.h> @@ -103,9 +104,9 @@ void ktrgenio(struct ktr_genio *, int); void ktrpsig(struct ktr_psig *); void ktrcsw(struct ktr_csw *); void ktrcsw_old(struct ktr_csw_old *); -void ktruser_malloc(unsigned char *); -void ktruser_rtld(int, unsigned char *); -void ktruser(int, unsigned char *); +void ktruser_malloc(void *); +void ktruser_rtld(int, void *); +void ktruser(int, void *); void ktrcaprights(cap_rights_t *); void ktrsockaddr(struct sockaddr *); void ktrstat(struct stat *); @@ -122,10 +123,13 @@ void ioctlname(unsigned long, int); #define TIMESTAMP_ELAPSED 0x2 #define TIMESTAMP_RELATIVE 0x4 -int timestamp, decimal, fancy = 1, suppressdata, tail, threads, maxdata, +extern const char *signames[], *syscallnames[]; +extern int nsyscalls; + +static int timestamp, decimal, fancy = 1, suppressdata, tail, threads, maxdata, resolv = 0, abiflag = 0, syscallno = 0; -const char *tracefile = DEF_TRACEFILE; -struct ktr_header ktr_header; +static const char *tracefile = DEF_TRACEFILE; +static struct ktr_header ktr_header; #define TIME_FORMAT "%b %e %T %Y" #define eqs(s1, s2) (strcmp((s1), (s2)) == 0) @@ -172,7 +176,7 @@ struct proc_info pid_t pid; }; -TAILQ_HEAD(trace_procs, proc_info) trace_procs; +static TAILQ_HEAD(trace_procs, proc_info) trace_procs; #ifdef HAVE_LIBCAPSICUM static cap_channel_t *cappwd, *capgrp; @@ -456,7 +460,7 @@ limitfd(int fd) unsigned long cmd; cap_rights_init(&rights, CAP_FSTAT); - cmd = -1; + cmd = 0; switch (fd) { case STDIN_FILENO: @@ -479,7 +483,7 @@ limitfd(int fd) if (cap_rights_limit(fd, &rights) < 0 && errno != ENOSYS) err(1, "unable to limit rights for descriptor %d", fd); - if (cmd != -1 && cap_ioctls_limit(fd, &cmd, 1) < 0 && errno != ENOSYS) + if (cmd != 0 && cap_ioctls_limit(fd, &cmd, 1) < 0 && errno != ENOSYS) err(1, "unable to limit ioctls for descriptor %d", fd); } @@ -1089,6 +1093,14 @@ ktrsyscall(struct ktr_syscall *ktr, u_int flags) ip++; narg--; break; + case SYS_shm_open: + print_number(ip, narg, c); + putchar(','); + flagsname(ip[0]); + printf(",0%o", (unsigned int)ip[1]); + ip += 3; + narg -= 3; + break; case SYS_minherit: print_number(ip, narg, c); print_number(ip, narg, c); @@ -1257,6 +1269,26 @@ ktrsyscall(struct ktr_syscall *ktr, u_int flags) 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) { @@ -1507,9 +1539,10 @@ struct utrace_rtld { }; void -ktruser_rtld(int len, unsigned char *p) +ktruser_rtld(int len, void *p) { - struct utrace_rtld *ut = (struct utrace_rtld *)p; + struct utrace_rtld *ut = p; + unsigned char *cp; void *parent; int mode; @@ -1574,14 +1607,15 @@ ktruser_rtld(int len, unsigned char *p) ut->name); break; default: - p += 4; + cp = p; + cp += 4; len -= 4; printf("RTLD: %d ", len); while (len--) if (decimal) - printf(" %d", *p++); + printf(" %d", *cp++); else - printf(" %02x", *p++); + printf(" %02x", *cp++); printf("\n"); } } @@ -1593,9 +1627,9 @@ struct utrace_malloc { }; void -ktruser_malloc(unsigned char *p) +ktruser_malloc(void *p) { - struct utrace_malloc *ut = (struct utrace_malloc *)p; + struct utrace_malloc *ut = p; if (ut->p == (void *)(intptr_t)(-1)) printf("malloc_init()\n"); @@ -1608,8 +1642,9 @@ ktruser_malloc(unsigned char *p) } void -ktruser(int len, unsigned char *p) +ktruser(int len, void *p) { + unsigned char *cp; if (len >= 8 && bcmp(p, "RTLD", 4) == 0) { ktruser_rtld(len, p); @@ -1622,11 +1657,12 @@ ktruser(int len, unsigned char *p) } printf("%d ", len); + cp = p; while (len--) if (decimal) - printf(" %d", *p++); + printf(" %d", *cp++); else - printf(" %02x", *p++); + printf(" %02x", *cp++); printf("\n"); } diff --git a/usr.bin/kdump/mksubr b/usr.bin/kdump/mksubr index d8d803f..aa001f8 100644 --- a/usr.bin/kdump/mksubr +++ b/usr.bin/kdump/mksubr @@ -185,6 +185,7 @@ cat <<_EOF_ #include <sys/ipc.h> #include <sys/rtprio.h> #include <sys/shm.h> +#include <sys/umtx.h> #include <nfsserver/nfs.h> #include <ufs/ufs/quota.h> #include <sys/capsicum.h> @@ -489,6 +490,7 @@ auto_if_type "sockipprotoname" "IPPROTO_[[:alnum:]]+[[:space:]]+" 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 +679,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("<invalid>%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("<invalid>%jd", arg); +} _EOF_ egrep '#define[[:space:]]+CAP_[A-Z_]+[[:space:]]+CAPRIGHT\([0-9],[[:space:]]+0x[0-9]{16}ULL\)' \ $include_dir/sys/capsicum.h | \ |