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/ktrdump.c | |
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/ktrdump.c')
-rw-r--r-- | usr.bin/ktrdump/ktrdump.c | 47 |
1 files changed, 27 insertions, 20 deletions
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. |