diff options
author | rwatson <rwatson@FreeBSD.org> | 2004-05-21 21:24:58 +0000 |
---|---|---|
committer | rwatson <rwatson@FreeBSD.org> | 2004-05-21 21:24:58 +0000 |
commit | 222404c032773fbff208ba88e1b1dbf36a2d7c04 (patch) | |
tree | ac9f69ad7945442a4d99d5cb8eac32601c18b5a3 /usr.bin/ktrdump | |
parent | bc5a4332ffe1a4e8e18be591ae04b502caf44fe3 (diff) | |
download | FreeBSD-src-222404c032773fbff208ba88e1b1dbf36a2d7c04.zip FreeBSD-src-222404c032773fbff208ba88e1b1dbf36a2d7c04.tar.gz |
Add a quiet mode to ktrdump(1): if the "-q" flag is used, don't print
the pretty text header on top of the output. Simplifies feeding the
results of tracing into a script for mechanical processing.
Diffstat (limited to 'usr.bin/ktrdump')
-rw-r--r-- | usr.bin/ktrdump/ktrdump.8 | 4 | ||||
-rw-r--r-- | usr.bin/ktrdump/ktrdump.c | 47 |
2 files changed, 30 insertions, 21 deletions
diff --git a/usr.bin/ktrdump/ktrdump.8 b/usr.bin/ktrdump/ktrdump.8 index f5df3e9..db931a6 100644 --- a/usr.bin/ktrdump/ktrdump.8 +++ b/usr.bin/ktrdump/ktrdump.8 @@ -33,7 +33,7 @@ .Nd print kernel ktr trace buffer .Sh SYNOPSIS .Nm -.Op Fl cft +.Op Fl cfqt .Op Fl e Ar execfile .Op Fl m Ar corefile .Op Fl o Ar outfile @@ -48,6 +48,8 @@ The following options are available: Print the CPU number that each entry was logged from. .It Fl f Print the file and line number that each entry was logged from. +.It Fl q +Quiet mode; don't print the column header. .It Fl t Print the timestamp for each entry. .It Fl e Ar execfile diff --git a/usr.bin/ktrdump/ktrdump.c b/usr.bin/ktrdump/ktrdump.c index dcae2a7..a4319d3 100644 --- a/usr.bin/ktrdump/ktrdump.c +++ b/usr.bin/ktrdump/ktrdump.c @@ -45,7 +45,7 @@ __FBSDID("$FreeBSD$"); #define SBUFLEN 128 #define USAGE \ - "usage: ktrdump [-c] [-f] [-t] [-e execfile] [-i ktrfile ] [-m corefile] [-o outfile]" + "usage: ktrdump [-c] [-f] [-q] [-t] [-e execfile] [-i ktrfile ] [-m corefile] [-o outfile]" extern char *optarg; extern int optind; @@ -64,6 +64,7 @@ static int cflag; static int eflag; static int fflag; static int mflag; +static int qflag; static int tflag; static int iflag; @@ -100,7 +101,7 @@ main(int ac, char **av) * Parse commandline arguments. */ out = stdout; - while ((c = getopt(ac, av, "cfte:i:m:o:")) != -1) + while ((c = getopt(ac, av, "cfqte:i:m:o:")) != -1) switch (c) { case 'c': cflag = 1; @@ -129,6 +130,9 @@ main(int ac, char **av) if ((out = fopen(optarg, "w")) == NULL) err(1, "%s", optarg); break; + case 'q': + qflag++; + break; case 't': tflag = 1; break; @@ -176,25 +180,28 @@ main(int ac, char **av) /* * Print a nice header. */ - fprintf(out, "%-6s ", "index"); - if (cflag) - fprintf(out, "%-3s ", "cpu"); - if (tflag) - fprintf(out, "%-16s ", "timestamp"); - if (fflag) - fprintf(out, "%-40s ", "file and line"); - fprintf(out, "%s", "trace"); - fprintf(out, "\n"); + if (!qflag) { + fprintf(out, "%-6s ", "index"); + if (cflag) + fprintf(out, "%-3s ", "cpu"); + if (tflag) + fprintf(out, "%-16s ", "timestamp"); + if (fflag) + fprintf(out, "%-40s ", "file and line"); + fprintf(out, "%s", "trace"); + fprintf(out, "\n"); - fprintf(out, "------ "); - if (cflag) - fprintf(out, "--- "); - if (tflag) - fprintf(out, "---------------- "); - if (fflag) - fprintf(out, "---------------------------------------- "); - fprintf(out, "----- "); - fprintf(out, "\n"); + fprintf(out, "------ "); + if (cflag) + fprintf(out, "--- "); + if (tflag) + fprintf(out, "---------------- "); + if (fflag) + fprintf(out, + "---------------------------------------- "); + fprintf(out, "----- "); + fprintf(out, "\n"); + } /* * Now tear through the trace buffer. |