Home | History | Annotate | Line # | Download | only in gdbscripts
      1 #	$NetBSD: dmesg,v 1.1 2020/04/14 13:58:11 christos Exp $
      2 
      3 define dmesg
      4 	set $mbp = msgbufp
      5 	set $bufdata = &$mbp->msg_bufc[0]
      6 	set $print = $mbp->msg_bufs
      7 	set $newl = 0
      8 	set $skip = 0
      9 	set $i = -1 
     10 	set $p = $bufdata + $mbp->msg_bufx - 1
     11 
     12 	while ($i < $mbp->msg_bufs)
     13 		set $i = $i + 1
     14 		set $p = $p + 1
     15 		if ($p == $bufdata + $mbp->msg_bufs)
     16 			set $p = $bufdata
     17 		end
     18 		if ($i < $mbp->msg_bufs - $print)
     19 			loop_continue
     20 		end
     21 		set $c = $p[0]
     22 		# Skip syslog sequences
     23 		if ($skip)
     24 			if ($c == '>')
     25 				set $newl = 0
     26 				set $skip = 0
     27 			end
     28 			loop_continue
     29 		end
     30 		if ($newl && $c == '<')
     31 			set $skip = 1
     32 			loop_continue
     33 		end
     34 		if ($c == '\0')
     35 			loop_continue
     36 		end
     37 		set $newl = $c == '\n'
     38 		printf "%c", $c
     39 	end
     40 	if (!$newl)
     41 		printf "\n"
     42 	end
     43 end
     44 
     45 document dmesg
     46 print the message buffer
     47 end
     48