From a553f5bca5636375477f3d88822ed41b34867fba Mon Sep 17 00:00:00 2001 From: dchagin Date: Wed, 26 Jan 2011 06:36:14 +0000 Subject: Add -H flag to print thread id. --- usr.bin/ktrdump/ktrdump.8 | 4 +++- usr.bin/ktrdump/ktrdump.c | 14 ++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) (limited to 'usr.bin/ktrdump') diff --git a/usr.bin/ktrdump/ktrdump.8 b/usr.bin/ktrdump/ktrdump.8 index 1e0e8c9..9a77bfc 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 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 diff --git a/usr.bin/ktrdump/ktrdump.c b/usr.bin/ktrdump/ktrdump.c index c700526..5129545 100644 --- a/usr.bin/ktrdump/ktrdump.c +++ b/usr.bin/ktrdump/ktrdump.c @@ -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"); -- cgit v1.1