diff options
author | Philip Guenther <guenther@cvs.openbsd.org> | 2015-10-03 23:52:31 +0000 |
---|---|---|
committer | Philip Guenther <guenther@cvs.openbsd.org> | 2015-10-03 23:52:31 +0000 |
commit | b5a5d8dcf906287868f5e87a123a3bd25fbdfa81 (patch) | |
tree | 16d6edb68eb0749e8843d4eb5d79e581fa6d3915 /usr.bin | |
parent | b7f7993b1f6617ea9d343ad1ab807d442183299d (diff) |
Add ktracing of tame()'s arguments' values
"every tool helps" deraadt@
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/kdump/kdump.c | 40 | ||||
-rw-r--r-- | usr.bin/kdump/kdump.h | 1 | ||||
-rw-r--r-- | usr.bin/kdump/kdump_subr.h | 5 | ||||
-rw-r--r-- | usr.bin/kdump/ktrstruct.c | 10 |
4 files changed, 30 insertions, 26 deletions
diff --git a/usr.bin/kdump/kdump.c b/usr.bin/kdump/kdump.c index c0a03c8af39..809cecd80e9 100644 --- a/usr.bin/kdump/kdump.c +++ b/usr.bin/kdump/kdump.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kdump.c,v 1.110 2015/10/03 21:47:40 guenther Exp $ */ +/* $OpenBSD: kdump.c,v 1.111 2015/10/03 23:52:30 guenther Exp $ */ /*- * Copyright (c) 1988, 1993 @@ -72,7 +72,7 @@ #include "extern.h" int timestamp, decimal, iohex, fancy = 1, maxdata = INT_MAX; -int needtid, tail; +int needtid, tail, basecol; char *tracefile = DEF_TRACEFILE; struct ktr_header ktr_header; pid_t pid_opt = -1; @@ -404,20 +404,20 @@ dumpheader(struct ktr_header *kth) type = unknown; } - (void)printf("%6ld", (long)kth->ktr_pid); + basecol = printf("%6ld", (long)kth->ktr_pid); if (needtid) - (void)printf("/%-7ld", (long)kth->ktr_tid); - (void)printf(" %-8.*s ", MAXCOMLEN, kth->ktr_comm); + basecol += printf("/%-7ld", (long)kth->ktr_tid); + basecol += printf(" %-8.*s ", MAXCOMLEN, kth->ktr_comm); if (timestamp) { if (timestamp == 2) { timespecsub(&kth->ktr_time, &prevtime, &temp); prevtime = kth->ktr_time; } else temp = kth->ktr_time; - printf("%lld.%06ld ", (long long)temp.tv_sec, + basecol += printf("%lld.%06ld ", (long long)temp.tv_sec, temp.tv_nsec / 1000); } - (void)printf("%s ", type); + basecol += printf("%s ", type); } /* @@ -1213,22 +1213,15 @@ ktremul(char *cp, size_t len) setemul(name); } -static void -showbufc(const char *prefix, unsigned char *dp, size_t datalen) +void +showbufc(int col, unsigned char *dp, size_t datalen) { int i, j; - int col, width, bpl; + int width, bpl; unsigned char visbuf[5], *cp, c; - (void)printf(" "); - - col = 8; - if (prefix != NULL) { - printf("%s", prefix); - col += strlen(prefix); - } - putchar('"'); + col++; for (; datalen > 0; datalen--, dp++) { (void)vis(visbuf, *dp, VIS_CSTYLE, *(dp+1)); cp = visbuf; @@ -1315,7 +1308,9 @@ showbuf(unsigned char *dp, size_t datalen) } return; } - showbufc(NULL, dp, datalen); + + (void)printf(" "); + showbufc(7, dp, datalen); } static void @@ -1411,15 +1406,16 @@ static void ktrexec(const char *ptr, size_t len) { char buf[sizeof("[2147483648] = ")]; - int i; + int i, col; size_t l; putchar('\n'); i = 0; while (len > 0) { l = strnlen(ptr, len); - snprintf(buf, sizeof(buf), "[%d] = ", i++); - showbufc(buf, (unsigned char *)ptr, l); + col = printf("\t[%d] = ", i++); + col += 7; /* tab expands from 1 to 8 columns */ + showbufc(col, (unsigned char *)ptr, l); if (l == len) { printf("\tunterminated argument\n"); break; diff --git a/usr.bin/kdump/kdump.h b/usr.bin/kdump/kdump.h index 3e9c1facba9..6ab27f40d8a 100644 --- a/usr.bin/kdump/kdump.h +++ b/usr.bin/kdump/kdump.h @@ -19,6 +19,7 @@ const char *ioctlname(unsigned long); /* kdump.c */ void sigset(int); +void showbufc(int _column, unsigned char *_dp, size_t _datalen); /* ktrstruct.c */ void ktrstruct(char *, size_t); diff --git a/usr.bin/kdump/kdump_subr.h b/usr.bin/kdump/kdump_subr.h index d2b354b418e..71eec04e909 100644 --- a/usr.bin/kdump/kdump_subr.h +++ b/usr.bin/kdump/kdump_subr.h @@ -1,4 +1,4 @@ -/* $OpenBSD: kdump_subr.h,v 1.16 2014/12/15 01:48:54 guenther Exp $ */ +/* $OpenBSD: kdump_subr.h,v 1.17 2015/10/03 23:52:30 guenther Exp $ */ /* * Copyright(c) 2006 2006 David Kirchner <dpk@dpk.net> * @@ -93,5 +93,4 @@ void sigchld_name(int); void ktracefacname(int); void itimername(int); -extern int decimal, fancy; -extern int arg1; +extern int decimal, fancy, basecol, arg1; diff --git a/usr.bin/kdump/ktrstruct.c b/usr.bin/kdump/ktrstruct.c index 2fc328d7c68..6adffa3ecc6 100644 --- a/usr.bin/kdump/ktrstruct.c +++ b/usr.bin/kdump/ktrstruct.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ktrstruct.c,v 1.10 2015/07/28 05:50:41 guenther Exp $ */ +/* $OpenBSD: ktrstruct.c,v 1.11 2015/10/03 23:52:30 guenther Exp $ */ /*- * Copyright (c) 1988, 1993 @@ -560,6 +560,14 @@ ktrstruct(char *buf, size_t buflen) memcpy(cmsg, data, datalen); ktrcmsghdr(cmsg, datalen); free(cmsg); + } else if (strcmp(name, "tamereq") == 0) { + printf("tame request="); + showbufc(basecol + sizeof("tame request=") - 1, + (unsigned char *)data, datalen); + } else if (strcmp(name, "tamepath") == 0) { + printf("tame path="); + showbufc(basecol + sizeof("tame path=") - 1, + (unsigned char *)data, datalen); } else { printf("unknown structure %s\n", name); } |