Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/kdump Add an argument to the -x flag to choose betwe...
details: https://anonhg.NetBSD.org/src/rev/96ad2b987af6
branches: trunk
changeset: 555390:96ad2b987af6
user: manu <manu%NetBSD.org@localhost>
date: Sun Nov 16 10:13:48 2003 +0000
description:
Add an argument to the -x flag to choose between byte per byte display
and word per word display in hex dumps.
-x1 gives you byte per byte, -x4 word per word, and -x defaults to -x1
diffstat:
usr.bin/kdump/kdump.1 | 12 +++++--
usr.bin/kdump/kdump.c | 73 +++++++++++++++++++++++++++++++++++++++-----------
2 files changed, 65 insertions(+), 20 deletions(-)
diffs (197 lines):
diff -r b1ec88a48d24 -r 96ad2b987af6 usr.bin/kdump/kdump.1
--- a/usr.bin/kdump/kdump.1 Sun Nov 16 10:13:12 2003 +0000
+++ b/usr.bin/kdump/kdump.1 Sun Nov 16 10:13:48 2003 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: kdump.1,v 1.22 2003/08/07 11:14:12 agc Exp $
+.\" $NetBSD: kdump.1,v 1.23 2003/11/16 10:13:48 manu Exp $
.\"
.\" Copyright (c) 1990, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -37,12 +37,13 @@
.Nd display kernel trace data
.Sh SYNOPSIS
.Nm
-.Op Fl dlNnRTx
+.Op Fl dlNnRT
.Op Fl e Ar emulation
.Op Fl f Ar file
.Op Fl m Ar maxdata
.Op Fl p Ar pid
.Op Fl t Ar trstr
+.Op Fl x Op Ar size
.Op Ar file
.Sh DESCRIPTION
.Nm
@@ -103,10 +104,13 @@
.Fl t
option of
.Xr ktrace 1 .
-.It Fl x
+.It Fl x Op Ar size
Display GIO data in hex and ascii instead of
.Xr vis 3
-format.
+format. The optional
+.Ar size
+argument force byte groupping in the display. Supported values are 1
+(byte per byte) and 4 (word per word). Default is 1.
.El
.Sh SEE ALSO
.Xr ktrace 1
diff -r b1ec88a48d24 -r 96ad2b987af6 usr.bin/kdump/kdump.c
--- a/usr.bin/kdump/kdump.c Sun Nov 16 10:13:12 2003 +0000
+++ b/usr.bin/kdump/kdump.c Sun Nov 16 10:13:48 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kdump.c,v 1.63 2003/11/15 23:10:31 manu Exp $ */
+/* $NetBSD: kdump.c,v 1.64 2003/11/16 10:13:48 manu Exp $ */
/*-
* Copyright (c) 1988, 1993
@@ -39,7 +39,7 @@
#if 0
static char sccsid[] = "@(#)kdump.c 8.4 (Berkeley) 4/28/95";
#else
-__RCSID("$NetBSD: kdump.c,v 1.63 2003/11/15 23:10:31 manu Exp $");
+__RCSID("$NetBSD: kdump.c,v 1.64 2003/11/16 10:13:48 manu Exp $");
#endif
#endif /* not lint */
@@ -112,7 +112,7 @@
void rprint __P((register_t));
char *ioctlname __P((long));
static const char *signame __P((long, int));
-static void hexdump_buf(const void *, int);
+static void hexdump_buf(const void *, int, int);
static void visdump_buf(const void *, int, int);
int
@@ -127,7 +127,7 @@
const char *emul_name = "netbsd";
int col;
- while ((ch = getopt(argc, argv, "e:f:dlm:Nnp:RTt:x")) != -1)
+ while ((ch = getopt(argc, argv, "e:f:dlm:Nnp:RTt:x:")) != -1)
switch (ch) {
case 'e':
emul_name = strdup(optarg); /* it's safer to copy it */
@@ -166,7 +166,18 @@
errx(1, "unknown trace point in %s", optarg);
break;
case 'x':
- hexdump = 1;
+ hexdump = atoi(optarg);
+ switch (hexdump) {
+ case 1:
+ case 4:
+ break;
+ case 0:
+ hexdump = 1;
+ break;
+ default:
+ errx(1, "Only -x1 and -x4 are supported");
+ break;
+ }
break;
default:
usage();
@@ -255,7 +266,7 @@
break;
default:
printf("\n");
- hexdump_buf(m, ktrlen);
+ hexdump_buf(m, ktrlen, hexdump);
}
if (tail)
(void)fflush(stdout);
@@ -572,26 +583,56 @@
}
static void
-hexdump_buf(const void *vdp, int datalen)
+hexdump_buf(vdp, datalen, dumpsize)
+ const void *vdp;
+ int datalen;
+ int dumpsize;
{
char chars[16];
const unsigned char *dp = vdp;
int line_end, off, l, c;
char *cp;
+ int divmask, cdisp, pad, padbase;
+ const char *bdelim;
+ const char *gdelim;
+
+ switch (dumpsize) {
+ case 4:
+ divmask = 3;
+ cdisp = 39;
+ bdelim = "";
+ gdelim = " ";
+ padbase = -2;
+ break;
+ case 1:
+ default:
+ divmask = 7;
+ cdisp = 50;
+ bdelim = " ";
+ gdelim = " ";
+ padbase = 0;
+ break;
+ }
for (off = 0; off < datalen;) {
line_end = off + 16;
- if (line_end > datalen)
+ pad = 0;
+ if (line_end > datalen) {
line_end = datalen;
+ pad = padbase;
+ }
+
printf("\t%3.3x ", off);
for (l = 0, cp = chars; off < line_end; off++) {
c = *dp++;
- if ((off & 7) == 0)
- l += printf(" ");
- l += printf(" %2.2x", c);
+ if ((off & divmask) == 0)
+ l += printf(gdelim);
+ l += printf("%s%2.2x", bdelim, c);
*cp++ = isgraph(c) ? c : '.';
};
- printf("%*s %.*s\n", 50 - l, "", (int)(cp - chars), chars);
+
+ l += pad;
+ printf("%*s %.*s\n", cdisp - l , "", (int)(cp - chars), chars);
}
}
@@ -668,7 +709,7 @@
if (maxdata > 0 && datalen > maxdata)
datalen = maxdata;
if (hexdump) {
- hexdump_buf(dp, datalen);
+ hexdump_buf(dp, datalen, hexdump);
return;
}
(void)printf(" ");
@@ -825,7 +866,7 @@
else
printf("unknown service%s [%d]\n", reply, mmsg->ktr_id);
- hexdump_buf(mmsg, len);
+ hexdump_buf(mmsg, len, hexdump);
}
static const char *
@@ -846,8 +887,8 @@
usage()
{
- (void)fprintf(stderr, "usage: kdump [-dlNnRTx] [-e emulation] "
+ (void)fprintf(stderr, "usage: kdump [-dlNnRT] [-e emulation] "
"[-f file] [-m maxdata] [-p pid]\n [-t trstr] "
- "[file]\n");
+ "[-x [size]] [file]\n");
exit(1);
}
Home |
Main Index |
Thread Index |
Old Index