Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/gdbscripts add a gdb script to dump kernel histories. b...



details:   https://anonhg.NetBSD.org/src/rev/6c43d1c8c5e5
branches:  trunk
changeset: 345172:6c43d1c8c5e5
user:      mrg <mrg%NetBSD.org@localhost>
date:      Wed May 11 09:22:55 2016 +0000

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

diffstat:

 sys/gdbscripts/kernhist |  42 ++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 42 insertions(+), 0 deletions(-)

diffs (46 lines):

diff -r 362996824eed -r 6c43d1c8c5e5 sys/gdbscripts/kernhist
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/gdbscripts/kernhist   Wed May 11 09:22:55 2016 +0000
@@ -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



Home | Main Index | Thread Index | Old Index