From owner-p4-projects@FreeBSD.ORG Sun Jun 1 13:45:26 2003 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 60B8537B404; Sun, 1 Jun 2003 13:45:25 -0700 (PDT) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0190F37B401 for ; Sun, 1 Jun 2003 13:45:25 -0700 (PDT) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8E61043F93 for ; Sun, 1 Jun 2003 13:45:24 -0700 (PDT) (envelope-from peter@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.6/8.12.6) with ESMTP id h51KjO0U069527 for ; Sun, 1 Jun 2003 13:45:24 -0700 (PDT) (envelope-from peter@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.6/8.12.6/Submit) id h51KjNLa069524 for perforce@freebsd.org; Sun, 1 Jun 2003 13:45:23 -0700 (PDT) Date: Sun, 1 Jun 2003 13:45:23 -0700 (PDT) Message-Id: <200306012045.h51KjNLa069524@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to peter@freebsd.org using -f From: Peter Wemm To: Perforce Change Reviews Subject: PERFORCE change 32321 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 01 Jun 2003 20:45:26 -0000 http://perforce.freebsd.org/chv.cgi?CH=32321 Change 32321 by peter@peter_daintree on 2003/06/01 13:45:03 GRRR! I'm sick of kdump being so lousy. add a -p pid argument so kdump can single out a particular pid from a ktrace -i dump. hexdump the binary genio data instead of strvis. strvis for binary sucks. Affected files ... .. //depot/projects/hammer/usr.bin/kdump/kdump.c#3 edit Differences ... ==== //depot/projects/hammer/usr.bin/kdump/kdump.c#3 (text+ko) ==== @@ -72,6 +72,7 @@ void ktrsyscall(struct ktr_syscall *); void ktrsysret(struct ktr_sysret *); void ktrnamei(char *, int); +void hd(void *, int); void ktrgenio(struct ktr_genio *, int); void ktrpsig(struct ktr_psig *); void ktrcsw(struct ktr_csw *); @@ -91,10 +92,11 @@ void *m; int trpoints = ALL_POINTS; int drop_logged; + pid_t pid = 0; (void) setlocale(LC_CTYPE, ""); - while ((ch = getopt(argc,argv,"f:dlm:nRTt:")) != -1) + while ((ch = getopt(argc,argv,"f:dlm:np:RTt:")) != -1) switch((char)ch) { case 'f': tracefile = optarg; @@ -111,6 +113,9 @@ case 'n': fancy = 0; break; + case 'p': + pid = atoi(optarg); + break; case 'R': timestamp = 2; /* relative timestamp */ break; @@ -146,7 +151,8 @@ } } if (trpoints & (1< size) { @@ -157,6 +163,8 @@ } if (ktrlen && fread_tail(m, ktrlen, 1) == 0) errx(1, "data too short"); + if (pid && ktr_header.ktr_pid != pid) + continue; if ((trpoints & (1<= len) + break; + if (p[i] >= ' ' && p[i] <= '~') + printf("%c", p[i]); + else + printf("."); + } + printf("\n"); + } + if ((i % 16) != 0) { + printf("\n"); + } +} + +void ktrgenio(struct ktr_genio *ktr, int len) { int datalen = len - sizeof (struct ktr_genio); @@ -397,6 +441,7 @@ int width; char visbuf[5]; static int screenwidth = 0; + int i, binary; if (screenwidth == 0) { struct winsize ws; @@ -412,42 +457,54 @@ datalen == 1 ? "" : "s"); if (maxdata && datalen > maxdata) datalen = maxdata; - (void)printf(" \""); - col = 8; - for (;datalen > 0; datalen--, dp++) { - (void) vis(visbuf, *dp, VIS_CSTYLE, *(dp+1)); - cp = visbuf; - /* - * Keep track of printables and - * space chars (like fold(1)). - */ - if (col == 0) { - (void)putchar('\t'); - col = 8; - } - switch(*cp) { - case '\n': - col = 0; - (void)putchar('\n'); + + for (i = 0, binary = 0; i < datalen && binary == 0; i++) { + if (dp[i] >= 32 && dp[i] < 127) + continue; + if (dp[i] == 10 || dp[i] == 13 || dp[i] == 0 || dp[i] == 9) continue; - case '\t': - width = 8 - (col&07); - break; - default: - width = strlen(cp); + binary = 1; + } + if (binary) { + hd(dp, datalen); + } else { + (void)printf(" \""); + col = 8; + for (;datalen > 0; datalen--, dp++) { + (void) vis(visbuf, *dp, VIS_CSTYLE, *(dp+1)); + cp = visbuf; + /* + * Keep track of printables and + * space chars (like fold(1)). + */ + if (col == 0) { + (void)putchar('\t'); + col = 8; + } + switch(*cp) { + case '\n': + col = 0; + (void)putchar('\n'); + continue; + case '\t': + width = 8 - (col&07); + break; + default: + width = strlen(cp); + } + if (col + width > (screenwidth-2)) { + (void)printf("\\\n\t"); + col = 8; + } + col += width; + do { + (void)putchar(*cp++); + } while (*cp); } - if (col + width > (screenwidth-2)) { - (void)printf("\\\n\t"); - col = 8; - } - col += width; - do { - (void)putchar(*cp++); - } while (*cp); + if (col == 0) + (void)printf(" "); + (void)printf("\"\n"); } - if (col == 0) - (void)printf(" "); - (void)printf("\"\n"); } const char *signames[] = {