Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 25 Apr 2015 04:58:09 +0000 (UTC)
From:      Maxim Sobolev <sobomax@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r281970 - head/usr.bin/kdump
Message-ID:  <201504250458.t3P4w9Rw059237@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: sobomax
Date: Sat Apr 25 04:58:08 2015
New Revision: 281970
URL: https://svnweb.freebsd.org/changeset/base/281970

Log:
  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).

Modified:
  head/usr.bin/kdump/kdump.c

Modified: head/usr.bin/kdump/kdump.c
==============================================================================
--- head/usr.bin/kdump/kdump.c	Sat Apr 25 04:49:45 2015	(r281969)
+++ head/usr.bin/kdump/kdump.c	Sat Apr 25 04:58:08 2015	(r281970)
@@ -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);
 		}
 	}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201504250458.t3P4w9Rw059237>