Add -H flag to print thread id.

This commit is contained in:
Dmitry Chagin 2011-01-26 06:36:14 +00:00
parent 3e03585fb5
commit 718f2aed09
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=217873
2 changed files with 15 additions and 3 deletions

View File

@ -33,7 +33,7 @@
.Nd print kernel ktr trace buffer
.Sh SYNOPSIS
.Nm
.Op Fl cfqrt
.Op Fl cfqrtH
.Op Fl e Ar execfile
.Op Fl i Ar ktrfile
.Op Fl m Ar corefile
@ -55,6 +55,8 @@ Quiet mode; do not print the column header.
Print relative timestamps rather than absolute timestamps.
.It Fl t
Print the timestamp for each entry.
.It Fl H
Print the thread ID for each entry.
.It Fl i Ar ktrfile
File containing saved ktr trace events; for more information see the
.Xr ktr 4

View File

@ -46,7 +46,7 @@ __FBSDID("$FreeBSD$");
#define SBUFLEN 128
#define USAGE \
"usage: ktrdump [-cfqrt] [-e execfile] [-i ktrfile] [-m corefile] [-o outfile]\n"
"usage: ktrdump [-cfqrtH] [-e execfile] [-i ktrfile] [-m corefile] [-o outfile]\n"
static void usage(void);
@ -66,6 +66,7 @@ static int qflag;
static int rflag;
static int tflag;
static int iflag;
static int hflag;
static char corefile[PATH_MAX];
static char execfile[PATH_MAX];
@ -101,7 +102,7 @@ main(int ac, char **av)
* Parse commandline arguments.
*/
out = stdout;
while ((c = getopt(ac, av, "cfqrte:i:m:o:")) != -1)
while ((c = getopt(ac, av, "cfqrtHe:i:m:o:")) != -1)
switch (c) {
case 'c':
cflag = 1;
@ -139,6 +140,9 @@ main(int ac, char **av)
case 't':
tflag = 1;
break;
case 'H':
hflag = 1;
break;
case '?':
default:
usage();
@ -191,6 +195,8 @@ main(int ac, char **av)
fprintf(out, "%-16s ", "timestamp");
if (fflag)
fprintf(out, "%-40s ", "file and line");
if (hflag)
fprintf(out, "%-18s ", "tid");
fprintf(out, "%s", "trace");
fprintf(out, "\n");
@ -202,6 +208,8 @@ main(int ac, char **av)
if (fflag)
fprintf(out,
"---------------------------------------- ");
if (hflag)
fprintf(out, "------------------ ");
fprintf(out, "----- ");
fprintf(out, "\n");
}
@ -270,6 +278,8 @@ next: if ((c = *p++) == '\0')
buf[i].ktr_line);
fprintf(out, "%-40s ", obuf);
}
if (hflag)
fprintf(out, "%p ", buf[i].ktr_thread);
fprintf(out, desc, parms[0], parms[1], parms[2], parms[3],
parms[4], parms[5]);
fprintf(out, "\n");