Add dmesg functionality.

This commit is contained in:
christos 2020-04-14 13:58:11 +00:00
parent 43dafa4757
commit b2032fd53a
1 changed files with 47 additions and 0 deletions

47
sys/gdbscripts/dmesg Normal file
View File

@ -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