Module Name:    src
Committed By:   christos
Date:           Tue Apr 14 13:58:12 UTC 2020

Added Files:
        src/sys/gdbscripts: dmesg

Log Message:
Add dmesg functionality.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/gdbscripts/dmesg

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/dmesg
diff -u /dev/null src/sys/gdbscripts/dmesg:1.1
--- /dev/null	Tue Apr 14 09:58:12 2020
+++ src/sys/gdbscripts/dmesg	Tue Apr 14 09:58:11 2020
@@ -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

Reply via email to