From c9bc6f3a9abaf17422a7cefaad26b3680094b5f6 Mon Sep 17 00:00:00 2001 From: simonb Date: Wed, 2 Jul 2003 07:05:29 +0000 Subject: [PATCH] Allow the dmesg command to show the last N bytes of the kernel message buffer. --- sys/ddb/db_xxx.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/sys/ddb/db_xxx.c b/sys/ddb/db_xxx.c index 81870d4fc79a..e5b6e7b370a5 100644 --- a/sys/ddb/db_xxx.c +++ b/sys/ddb/db_xxx.c @@ -1,4 +1,4 @@ -/* $NetBSD: db_xxx.c,v 1.24 2003/06/29 22:29:55 fvdl Exp $ */ +/* $NetBSD: db_xxx.c,v 1.25 2003/07/02 07:05:29 simonb Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1991, 1993 @@ -43,7 +43,7 @@ #include "opt_kgdb.h" #include -__KERNEL_RCSID(0, "$NetBSD: db_xxx.c,v 1.24 2003/06/29 22:29:55 fvdl Exp $"); +__KERNEL_RCSID(0, "$NetBSD: db_xxx.c,v 1.25 2003/07/02 07:05:29 simonb Exp $"); #include #include @@ -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_expr_t count, char *modif) 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) {