diff options
author | sobomax <sobomax@FreeBSD.org> | 2015-04-25 04:58:08 +0000 |
---|---|---|
committer | sobomax <sobomax@FreeBSD.org> | 2015-04-25 04:58:08 +0000 |
commit | 09e002d8cf136fba3639fbfa1d9c683b55f700a1 (patch) | |
tree | 322e60994010d5c114df032de21e5308e2a2af70 /usr.bin/kdump | |
parent | 2d0e3fb27f61c7dc8543323c706844554d32642f (diff) | |
download | FreeBSD-src-09e002d8cf136fba3639fbfa1d9c683b55f700a1.zip FreeBSD-src-09e002d8cf136fba3639fbfa1d9c683b55f700a1.tar.gz |
o Properly init prevtime, so that we don't print bogus value in the
first entry reported by the relative mode (-R).
o Properly print negative offsets, which I guess may happen if
records get re-ordered somehow, possibly due to the locking. Right
now we report huge bogus diff (i.e. 2 seconds or so).
Diffstat (limited to 'usr.bin/kdump')
-rw-r--r-- | usr.bin/kdump/kdump.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/usr.bin/kdump/kdump.c b/usr.bin/kdump/kdump.c index fe7bcd2..3b5a847 100644 --- a/usr.bin/kdump/kdump.c +++ b/usr.bin/kdump/kdump.c @@ -586,6 +586,7 @@ dumpheader(struct ktr_header *kth) static char unknown[64]; static struct timeval prevtime, prevtime_e, temp; const char *type; + const char *sign; switch (kth->ktr_type) { case KTR_SYSCALL: @@ -662,10 +663,20 @@ dumpheader(struct ktr_header *kth) timevaladd(&kth->ktr_time, &prevtime_e); } if (timestamp & TIMESTAMP_RELATIVE) { + if (prevtime.tv_sec == 0) + prevtime = kth->ktr_time; temp = kth->ktr_time; timevalsub(&kth->ktr_time, &prevtime); - prevtime = temp; - printf("%jd.%06ld ", (intmax_t)kth->ktr_time.tv_sec, + if ((intmax_t)kth->ktr_time.tv_sec < 0) { + kth->ktr_time = prevtime; + prevtime = temp; + timevalsub(&kth->ktr_time, &prevtime); + sign = "-"; + } else { + prevtime = temp; + sign = ""; + } + printf("%s%jd.%06ld ", sign, (intmax_t)kth->ktr_time.tv_sec, kth->ktr_time.tv_usec); } } |