Module Name: src
Committed By: mrg
Date: Wed May 11 09:22:55 UTC 2016
Added Files:
src/sys/gdbscripts: kernhist
Log Message:
add a gdb script to dump kernel histories. based upon a script by skrll,
updated by myself to run faster and more stupidly (but more workingly.)
normal gdb scripts don't seem to be able to call printf with the format
string as a variable, so we simply print the format itself as a string
and the (upto 4) arguments as unsigned long (how they're strored.)
To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/gdbscripts/kernhist
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Added files:
Index: src/sys/gdbscripts/kernhist
diff -u /dev/null src/sys/gdbscripts/kernhist:1.1
--- /dev/null Wed May 11 09:22:55 2016
+++ src/sys/gdbscripts/kernhist Wed May 11 09:22:55 2016
@@ -0,0 +1,42 @@
+# $NetBSD: kernhist,v 1.1 2016/05/11 09:22:55 mrg Exp $
+
+# by mrg and skrll
+
+define kernhist
+ dont-repeat
+
+ set $hist = (struct kern_history *)&$arg0
+ set $histf = $hist->f
+ set $histn = $hist->n
+ set $lcv = $histf
+
+ printf "Kernel history %s has %d entries (next free %d)\n", $hist->name, $histn, $histf
+ while (1)
+ set $e = &$hist->e[$lcv]
+ set $fmt = $e->fmt
+
+ if ($fmt)
+ printf "%06lx.%06d ", $e->tv.tv_sec, $e->tv.tv_usec
+ printf "%s#%ld@%d: ", $e->fn, $e->call, $e->cpunum
+ printf "%s: %lx %lx %lx %lx\n", $fmt, $e->v[0], $e->v[1], $e->v[2], $e->v[3]
+ set $lcv = ($lcv + 1) % $histn
+ else
+ if ($histf == 0)
+ printf "No entries\n"
+ loop_break
+ end
+ # if fmt is NULL and hist->f isn't zero, skip back to
+ # the start of the list since it hasn't looped yet.
+ set $lcv = 0
+ end
+
+ if ($lcv == $histf)
+ loop_break
+ end
+ end
+end
+document kernhist
+dump a kernel hist. eg, "kernhist usbhist". note that the format
+is not expanded due to there being now way to pass a variable format
+string to gdb's printf.
+end