Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/ddb Add "show dmesg" that prints the contents of the mes...



details:   https://anonhg.NetBSD.org/src/rev/b68cfa14c496
branches:  trunk
changeset: 783730:b68cfa14c496
user:      christos <christos%NetBSD.org@localhost>
date:      Sun Jan 06 03:23:55 2013 +0000

description:
Add "show dmesg" that prints the contents of the message buffer.

diffstat:

 sys/ddb/db_command.c   |   6 ++++--
 sys/ddb/db_interface.h |   3 ++-
 sys/ddb/db_xxx.c       |  34 ++++++++++++++++++++++++++++++++--
 3 files changed, 38 insertions(+), 5 deletions(-)

diffs (96 lines):

diff -r 8770411cfe51 -r b68cfa14c496 sys/ddb/db_command.c
--- a/sys/ddb/db_command.c      Sun Jan 06 02:22:50 2013 +0000
+++ b/sys/ddb/db_command.c      Sun Jan 06 03:23:55 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: db_command.c,v 1.139 2013/01/05 15:23:27 christos Exp $        */
+/*     $NetBSD: db_command.c,v 1.140 2013/01/06 03:23:55 christos Exp $        */
 
 /*
  * Copyright (c) 1996, 1997, 1998, 1999, 2002, 2009 The NetBSD Foundation, Inc.
@@ -60,7 +60,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: db_command.c,v 1.139 2013/01/05 15:23:27 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_command.c,v 1.140 2013/01/06 03:23:55 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_aio.h"
@@ -240,6 +240,8 @@
 #endif
        { DDB_ADD_CMD("buf",    db_buf_print_cmd,       0,
            "Print the struct buf at address.", "[/f] address",NULL) },
+       { DDB_ADD_CMD("dmesg",  db_show_dmesg,  0,
+           "Print the current message buffer",NULL,NULL) },
        { DDB_ADD_CMD("event",  db_event_print_cmd,     0,
            "Print all the non-zero evcnt(9) event counters.", "[/fitm]",NULL) },
        { DDB_ADD_CMD("files", db_show_files_cmd,       0,
diff -r 8770411cfe51 -r b68cfa14c496 sys/ddb/db_interface.h
--- a/sys/ddb/db_interface.h    Sun Jan 06 02:22:50 2013 +0000
+++ b/sys/ddb/db_interface.h    Sun Jan 06 03:23:55 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: db_interface.h,v 1.29 2013/01/05 15:23:27 christos Exp $       */
+/*     $NetBSD: db_interface.h,v 1.30 2013/01/06 03:23:55 christos Exp $       */
 
 /*-
  * Copyright (c) 1995 The NetBSD Foundation, Inc.
@@ -44,6 +44,7 @@
 void           db_kgdb_cmd(db_expr_t, bool, db_expr_t, const char *);
 void           db_show_files_cmd(db_expr_t, bool, db_expr_t, const char *);
 void           db_show_panic(db_expr_t, bool, db_expr_t, const char *);
+void           db_show_dmesg(db_expr_t, bool, db_expr_t, const char *);
 
 /* kern/kern_proc.c */
 void           db_kill_proc(db_expr_t, bool, db_expr_t, const char *);
diff -r 8770411cfe51 -r b68cfa14c496 sys/ddb/db_xxx.c
--- a/sys/ddb/db_xxx.c  Sun Jan 06 02:22:50 2013 +0000
+++ b/sys/ddb/db_xxx.c  Sun Jan 06 03:23:55 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: db_xxx.c,v 1.67 2013/01/05 15:23:27 christos Exp $     */
+/*     $NetBSD: db_xxx.c,v 1.68 2013/01/06 03:23:55 christos Exp $     */
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1991, 1993
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: db_xxx.c,v 1.67 2013/01/05 15:23:27 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_xxx.c,v 1.68 2013/01/06 03:23:55 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_kgdb.h"
@@ -320,3 +320,33 @@
        (void)splx(s);
 #endif
 }
+
+extern kmutex_t log_lock;
+
+void
+db_show_dmesg(db_expr_t addr, bool haddr, db_expr_t count, const char *modif)
+{
+#ifdef _KERNEL /* XXX CRASH(8) */
+       long maxlen, beg, end, len;
+
+       mutex_spin_enter(&log_lock);
+       maxlen = msgbufp->msg_bufs;
+       beg = msgbufp->msg_bufx;
+       end = msgbufp->msg_bufs;
+       mutex_spin_exit(&log_lock);
+
+       while (maxlen > 0) {
+               len = MIN(end - beg, maxlen);
+               if (len == 0)
+                       break;
+               db_printf("%.*s", (int)len, (const char *)&msgbufp->msg_bufc[beg]);
+               maxlen -= len;
+               /*
+                * ... then, copy from the beginning of message buffer to
+                * the write pointer.
+                */
+               beg = 0;
+               end = msgbufp->msg_bufx;
+       }
+#endif
+}



Home | Main Index | Thread Index | Old Index