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.
This commit is contained in:
parent
dd6cf019f3
commit
7ddc893717
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=129559
@ -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
|
||||
|
@ -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,6 +180,7 @@ main(int ac, char **av)
|
||||
/*
|
||||
* Print a nice header.
|
||||
*/
|
||||
if (!qflag) {
|
||||
fprintf(out, "%-6s ", "index");
|
||||
if (cflag)
|
||||
fprintf(out, "%-3s ", "cpu");
|
||||
@ -192,9 +197,11 @@ main(int ac, char **av)
|
||||
if (tflag)
|
||||
fprintf(out, "---------------- ");
|
||||
if (fflag)
|
||||
fprintf(out, "---------------------------------------- ");
|
||||
fprintf(out,
|
||||
"---------------------------------------- ");
|
||||
fprintf(out, "----- ");
|
||||
fprintf(out, "\n");
|
||||
}
|
||||
|
||||
/*
|
||||
* Now tear through the trace buffer.
|
||||
|
Loading…
Reference in New Issue
Block a user