Source-Changes-HG archive

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

[src/trunk]: src/sys/gdbscripts Add dmesg functionality.



details:   https://anonhg.NetBSD.org/src/rev/b32d724b0179
branches:  trunk
changeset: 1009167:b32d724b0179
user:      christos <christos%NetBSD.org@localhost>
date:      Tue Apr 14 13:58:11 2020 +0000

description:
Add dmesg functionality.

diffstat:

 sys/gdbscripts/dmesg |  47 +++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 47 insertions(+), 0 deletions(-)

diffs (51 lines):

diff -r 6bee228faf04 -r b32d724b0179 sys/gdbscripts/dmesg
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/gdbscripts/dmesg      Tue Apr 14 13:58:11 2020 +0000
@@ -0,0 +1,47 @@
+#      $NetBSD: dmesg,v 1.1 2020/04/14 13:58:11 christos Exp $
+
+define dmesg
+       set $mbp = msgbufp
+       set $bufdata = &$mbp->msg_bufc[0]
+       set $print = $mbp->msg_bufs
+       set $newl = 0
+       set $skip = 0
+       set $i = -1 
+       set $p = $bufdata + $mbp->msg_bufx - 1
+
+       while ($i < $mbp->msg_bufs)
+               set $i = $i + 1
+               set $p = $p + 1
+               if ($p == $bufdata + $mbp->msg_bufs)
+                       set $p = $bufdata
+               end
+               if ($i < $mbp->msg_bufs - $print)
+                       loop_continue
+               end
+               set $c = $p[0]
+               # Skip syslog sequences
+               if ($skip)
+                       if ($c == '>')
+                               set $newl = 0
+                               set $skip = 0
+                       end
+                       loop_continue
+               end
+               if ($newl && $c == '<')
+                       set $skip = 1
+                       loop_continue
+               end
+               if ($c == '\0')
+                       loop_continue
+               end
+               set $newl = $c == '\n'
+               printf "%c", $c
+       end
+       if (!$newl)
+               printf "\n"
+       end
+end
+
+document dmesg
+print the message buffer
+end



Home | Main Index | Thread Index | Old Index