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.
This commit is contained in:
parent
4be14af9cf
commit
7d8c7fe102
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=129574
@ -33,7 +33,7 @@
|
|||||||
.Nd print kernel ktr trace buffer
|
.Nd print kernel ktr trace buffer
|
||||||
.Sh SYNOPSIS
|
.Sh SYNOPSIS
|
||||||
.Nm
|
.Nm
|
||||||
.Op Fl cfqt
|
.Op Fl cfqrt
|
||||||
.Op Fl e Ar execfile
|
.Op Fl e Ar execfile
|
||||||
.Op Fl m Ar corefile
|
.Op Fl m Ar corefile
|
||||||
.Op Fl o Ar outfile
|
.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.
|
Print the file and line number that each entry was logged from.
|
||||||
.It Fl q
|
.It Fl q
|
||||||
Quiet mode; don't print the column header.
|
Quiet mode; don't print the column header.
|
||||||
|
.It Fl r
|
||||||
|
Print relative timestamps rather than absolute timestamps.
|
||||||
.It Fl t
|
.It Fl t
|
||||||
Print the timestamp for each entry.
|
Print the timestamp for each entry.
|
||||||
.It Fl e Ar execfile
|
.It Fl e Ar execfile
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
/*-
|
/*-
|
||||||
* Copyright (c) 2002 Jake Burkholder
|
* Copyright (c) 2002 Jake Burkholder
|
||||||
|
* Copyright (c) 2004 Robert Watson
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@ -45,7 +46,7 @@ __FBSDID("$FreeBSD$");
|
|||||||
|
|
||||||
#define SBUFLEN 128
|
#define SBUFLEN 128
|
||||||
#define USAGE \
|
#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 char *optarg;
|
||||||
extern int optind;
|
extern int optind;
|
||||||
@ -65,6 +66,7 @@ static int eflag;
|
|||||||
static int fflag;
|
static int fflag;
|
||||||
static int mflag;
|
static int mflag;
|
||||||
static int qflag;
|
static int qflag;
|
||||||
|
static int rflag;
|
||||||
static int tflag;
|
static int tflag;
|
||||||
static int iflag;
|
static int iflag;
|
||||||
|
|
||||||
@ -85,6 +87,7 @@ main(int ac, char **av)
|
|||||||
{
|
{
|
||||||
u_long parms[KTR_PARMS];
|
u_long parms[KTR_PARMS];
|
||||||
struct ktr_entry *buf;
|
struct ktr_entry *buf;
|
||||||
|
uintmax_t tlast, tnow;
|
||||||
struct stat sb;
|
struct stat sb;
|
||||||
kvm_t *kd;
|
kvm_t *kd;
|
||||||
FILE *out;
|
FILE *out;
|
||||||
@ -101,7 +104,7 @@ main(int ac, char **av)
|
|||||||
* Parse commandline arguments.
|
* Parse commandline arguments.
|
||||||
*/
|
*/
|
||||||
out = stdout;
|
out = stdout;
|
||||||
while ((c = getopt(ac, av, "cfqte:i:m:o:")) != -1)
|
while ((c = getopt(ac, av, "cfqrte:i:m:o:")) != -1)
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'c':
|
case 'c':
|
||||||
cflag = 1;
|
cflag = 1;
|
||||||
@ -133,6 +136,9 @@ main(int ac, char **av)
|
|||||||
case 'q':
|
case 'q':
|
||||||
qflag++;
|
qflag++;
|
||||||
break;
|
break;
|
||||||
|
case 'r':
|
||||||
|
rflag = 1;
|
||||||
|
break;
|
||||||
case 't':
|
case 't':
|
||||||
tflag = 1;
|
tflag = 1;
|
||||||
break;
|
break;
|
||||||
@ -208,6 +214,7 @@ main(int ac, char **av)
|
|||||||
*/
|
*/
|
||||||
if (!iflag)
|
if (!iflag)
|
||||||
i = (index - 1) & (entries - 1);
|
i = (index - 1) & (entries - 1);
|
||||||
|
tlast = -1;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (buf[i].ktr_desc == NULL)
|
if (buf[i].ktr_desc == NULL)
|
||||||
break;
|
break;
|
||||||
@ -241,9 +248,16 @@ main(int ac, char **av)
|
|||||||
fprintf(out, "%6d ", i);
|
fprintf(out, "%6d ", i);
|
||||||
if (cflag)
|
if (cflag)
|
||||||
fprintf(out, "%3d ", buf[i].ktr_cpu);
|
fprintf(out, "%3d ", buf[i].ktr_cpu);
|
||||||
if (tflag)
|
if (tflag) {
|
||||||
fprintf(out, "%16ju ",
|
tnow = (uintmax_t)buf[i].ktr_timestamp;
|
||||||
(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 (fflag) {
|
||||||
if (kvm_read(kd, (u_long)buf[i].ktr_file, fbuf,
|
if (kvm_read(kd, (u_long)buf[i].ktr_file, fbuf,
|
||||||
sizeof(fbuf)) == -1)
|
sizeof(fbuf)) == -1)
|
||||||
|
Loading…
Reference in New Issue
Block a user