svn commit: r281970 - head/usr.bin/kdump

Maxim Sobolev sobomax at FreeBSD.org
Sat Apr 25 04:58:09 UTC 2015


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);
 		}
 	}


More information about the svn-src-all mailing list