Subject: ddb dmesg change
To: None <tech-kern@netbsd.org>
From: Simon Burge <simonb@wasabisystems.com>
List: tech-kern
Date: 05/29/2003 12:28:33
The following patch adds support for the ddb "dmesg" command to only
print the last N bytes of the kernel message buffer.  I've found this
useful when debugging a system with a large message buffer, but was
interested in only the last few pages of dmesg output.

Any objections before I commit it?

Simon.
--
Simon Burge                                   <simonb@wasabisystems.com>
NetBSD Development, Support and Service:   http://www.wasabisystems.com/


Index: db_xxx.c
===================================================================
RCS file: /cvsroot/src/sys/ddb/db_xxx.c,v
retrieving revision 1.22
diff -d -p -u -r1.22 db_xxx.c
--- db_xxx.c	2003/05/15 13:18:18	1.22
+++ db_xxx.c	2003/05/28 17:35:54
@@ -234,6 +234,7 @@ void
 db_dmesg(db_expr_t addr, int haddr, db_expr_t count, char *modif)
 {
 	struct kern_msgbuf *mbp;
+	db_expr_t print;
 	int ch, newl, skip, i;
 	char *p, *bufdata;
 
@@ -245,10 +246,17 @@ db_dmesg(db_expr_t addr, int haddr, db_e
 	mbp = msgbufp;
 	bufdata = &mbp->msg_bufc[0];
 
+	if (haddr && addr <  mbp->msg_bufs)
+		print = addr;
+	else
+		print = mbp->msg_bufs;
+
 	for (newl = skip = i = 0, p = bufdata + mbp->msg_bufx;
 	    i < mbp->msg_bufs; i++, p++) {
 		if (p == bufdata + mbp->msg_bufs)
 			p = bufdata;
+		if (i < mbp->msg_bufs - print)
+			continue;
 		ch = *p;
 		/* Skip "\n<.*>" syslog sequences. */
 		if (skip) {