Source-Changes-HG archive

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

[src/trunk]: src (1) Don't print the message buffer (via ddb's dmesg command)...



details:   https://anonhg.NetBSD.org/src/rev/10219013a6a0
branches:  trunk
changeset: 547223:10219013a6a0
user:      atatat <atatat%NetBSD.org@localhost>
date:      Thu May 15 13:18:18 2003 +0000

description:
(1) Don't print the message buffer (via ddb's dmesg command) if the
message buffer has not yet been set up, mimicking code from the top of
the sysctl routine for retrieving the message buffer.

(2) Add a /l modifier to the trace command.  This makes it print the
backtrace using printf() instead of db_printf(), which has the nice
side-effect of also putting it into the message buffer.  A kernel with
ddb in it but disabled (ie, ddb.onpanic set to zero) will print a
backtrace (which ends up in the message buffer) before dumping (or
not, depending on the value of kern.dump_on_panic) and rebooting, but
if ddb is not disabled, the backtrace is not printed, and there's no
way to get it to display a backtrace such that you can retrieve it
after the dump.  The backtrace printed by gdb is sometimes a little
different.

(3) Documentation for the above.

diffstat:

 share/man/man4/ddb.4 |  21 +++++++++++++++++----
 sys/ddb/db_command.c |  14 +++++++++++---
 sys/ddb/db_xxx.c     |   9 +++++++--
 3 files changed, 35 insertions(+), 9 deletions(-)

diffs (129 lines):

diff -r 912aba3fc76d -r 10219013a6a0 share/man/man4/ddb.4
--- a/share/man/man4/ddb.4      Thu May 15 13:18:05 2003 +0000
+++ b/share/man/man4/ddb.4      Thu May 15 13:18:18 2003 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: ddb.4,v 1.64 2003/05/08 05:38:10 wiz Exp $
+.\"    $NetBSD: ddb.4,v 1.65 2003/05/15 13:18:19 atatat Exp $
 .\"
 .\" Copyright (c) 1997 - 2003 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -357,6 +357,10 @@
 if it's prefixed with
 .Sq Cm \&# .
 .It Xo
+.Ic dmesg
+.Xc
+Prints the contents of the kernel message buffer.
+.It Xo
 .Ic dwatch
 .Ar address
 .Xc
@@ -730,7 +734,8 @@
 .It Ic sync
 Force a crash dump, and then reboot.
 .It Xo
-.Ic trace Ns Op Cm /u
+.Ic trace
+.Ic Ns Op Cm /u Ns Op Cm l
 .Sm off
 .Op Ar frame-address
 .Op Cm , Ar count
@@ -746,11 +751,15 @@
 If
 .Ar count
 is omitted, all frames are printed.
+If
+.Cm /l
+is specified, the trace is printed and also stored in the kernel
+message buffer.
 .Pp
 Warning: user-space stack trace is valid only if the machine dependent
 code supports it.
 .It Xo
-.Ic trace/t
+.Ic trace/t Ns Op Cm l
 .Sm off
 .Op Ar pid
 .Op Cm , Ar count
@@ -771,7 +780,11 @@
 .Sq 0t
 to force it to be interpreted as decimal (see
 .Sx VARIABLES
-section for radix)
+section for radix).
+If
+.Cm /l
+is specified, the trace is printed and also stored in the kernel
+message buffer.
 .Pp
 Warning: trace by pid is valid only if the machine dependent code
 supports it.
diff -r 912aba3fc76d -r 10219013a6a0 sys/ddb/db_command.c
--- a/sys/ddb/db_command.c      Thu May 15 13:18:05 2003 +0000
+++ b/sys/ddb/db_command.c      Thu May 15 13:18:18 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: db_command.c,v 1.69 2003/04/28 02:49:54 briggs Exp $   */
+/*     $NetBSD: db_command.c,v 1.70 2003/05/15 13:18:18 atatat Exp $   */
 
 /*
  * Mach Operating System
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: db_command.c,v 1.69 2003/04/28 02:49:54 briggs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_command.c,v 1.70 2003/05/15 13:18:18 atatat Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -707,11 +707,19 @@
 static void
 db_stack_trace_cmd(db_expr_t addr, int have_addr, db_expr_t count, char *modif)
 {
+       register char *cp = modif;
+       register char c;
+       void (*pr)(const char *, ...);
+
+       pr = db_printf;
+       while ((c = *cp++) != 0)
+               if (c == 'l')
+                       pr = printf;
 
        if (count == -1)
                count = 65535;
 
-       db_stack_trace_print(addr, have_addr, count, modif, db_printf);
+       db_stack_trace_print(addr, have_addr, count, modif, pr);
 }
 
 static void
diff -r 912aba3fc76d -r 10219013a6a0 sys/ddb/db_xxx.c
--- a/sys/ddb/db_xxx.c  Thu May 15 13:18:05 2003 +0000
+++ b/sys/ddb/db_xxx.c  Thu May 15 13:18:18 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: db_xxx.c,v 1.21 2003/04/28 02:49:55 briggs Exp $       */
+/*     $NetBSD: db_xxx.c,v 1.22 2003/05/15 13:18:18 atatat 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.21 2003/04/28 02:49:55 briggs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_xxx.c,v 1.22 2003/05/15 13:18:18 atatat Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -237,6 +237,11 @@
        int ch, newl, skip, i;
        char *p, *bufdata;
 
+        if (!msgbufenabled || msgbufp->msg_magic != MSG_MAGIC) {
+               db_printf("message buffer not available\n");
+               return;
+       }
+
        mbp = msgbufp;
        bufdata = &mbp->msg_bufc[0];
 



Home | Main Index | Thread Index | Old Index