summaryrefslogtreecommitdiffstats
path: root/usr.bin
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2004-05-22 08:26:10 +0000
committerrwatson <rwatson@FreeBSD.org>2004-05-22 08:26:10 +0000
commitba22e917d3f615aec4c841bf6eb16544dd1105fb (patch)
tree18b245f16eff90a657b08eb88d0a8cf58e4197ac /usr.bin
parent5d0912f6d822aa43b6aee5b532f4748d03c89146 (diff)
downloadFreeBSD-src-ba22e917d3f615aec4c841bf6eb16544dd1105fb.zip
FreeBSD-src-ba22e917d3f615aec4c841bf6eb16544dd1105fb.tar.gz
Add a "-r" flag to ktrdump(1) to print relative timestamps when used
with "-t" rather than absolute timestamps. This allows the reader to get a better sense of latency between events, such as time to schedule an interrupt thread from time the interrupt occurred. Assert a copyright on ktrdump.c since I seem to be modifying it more than I thought.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/ktrdump/ktrdump.84
-rw-r--r--usr.bin/ktrdump/ktrdump.c24
2 files changed, 22 insertions, 6 deletions
diff --git a/usr.bin/ktrdump/ktrdump.8 b/usr.bin/ktrdump/ktrdump.8
index db931a6..ec235e5 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 cfqt
+.Op Fl cfqrt
.Op Fl e Ar execfile
.Op Fl m Ar corefile
.Op Fl o Ar outfile
@@ -50,6 +50,8 @@ Print the CPU number that each entry was logged from.
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 r
+Print relative timestamps rather than absolute timestamps.
.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 a4319d3..f187723 100644
--- a/usr.bin/ktrdump/ktrdump.c
+++ b/usr.bin/ktrdump/ktrdump.c
@@ -1,5 +1,6 @@
/*-
* Copyright (c) 2002 Jake Burkholder
+ * Copyright (c) 2004 Robert Watson
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -45,7 +46,7 @@ __FBSDID("$FreeBSD$");
#define SBUFLEN 128
#define USAGE \
- "usage: ktrdump [-c] [-f] [-q] [-t] [-e execfile] [-i ktrfile ] [-m corefile] [-o outfile]"
+ "usage: ktrdump [-c] [-f] [-q] [-r] [-t] [-e execfile] [-i ktrfile ] [-m corefile] [-o outfile]"
extern char *optarg;
extern int optind;
@@ -65,6 +66,7 @@ static int eflag;
static int fflag;
static int mflag;
static int qflag;
+static int rflag;
static int tflag;
static int iflag;
@@ -85,6 +87,7 @@ main(int ac, char **av)
{
u_long parms[KTR_PARMS];
struct ktr_entry *buf;
+ uintmax_t tlast, tnow;
struct stat sb;
kvm_t *kd;
FILE *out;
@@ -101,7 +104,7 @@ main(int ac, char **av)
* Parse commandline arguments.
*/
out = stdout;
- while ((c = getopt(ac, av, "cfqte:i:m:o:")) != -1)
+ while ((c = getopt(ac, av, "cfqrte:i:m:o:")) != -1)
switch (c) {
case 'c':
cflag = 1;
@@ -133,6 +136,9 @@ main(int ac, char **av)
case 'q':
qflag++;
break;
+ case 'r':
+ rflag = 1;
+ break;
case 't':
tflag = 1;
break;
@@ -208,6 +214,7 @@ main(int ac, char **av)
*/
if (!iflag)
i = (index - 1) & (entries - 1);
+ tlast = -1;
for (;;) {
if (buf[i].ktr_desc == NULL)
break;
@@ -241,9 +248,16 @@ main(int ac, char **av)
fprintf(out, "%6d ", i);
if (cflag)
fprintf(out, "%3d ", buf[i].ktr_cpu);
- if (tflag)
- fprintf(out, "%16ju ",
- (uintmax_t)buf[i].ktr_timestamp);
+ if (tflag) {
+ tnow = (uintmax_t)buf[i].ktr_timestamp;
+ if (rflag) {
+ if (tlast == -1)
+ tlast = tnow;
+ fprintf(out, "%16ju ", tlast - tnow);
+ tlast = tnow;
+ } else
+ fprintf(out, "%16ju ", tnow);
+ }
if (fflag) {
if (kvm_read(kd, (u_long)buf[i].ktr_file, fbuf,
sizeof(fbuf)) == -1)
OpenPOWER on IntegriCloud