Allow the dmesg command to show the last N bytes of the kernel message

buffer.
This commit is contained in:
simonb 2003-07-02 07:05:29 +00:00
parent 1121191d31
commit c9bc6f3a9a

View File

@ -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 <sys/cdefs.h>
__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 <sys/param.h>
#include <sys/systm.h>
@ -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) {