Source-Changes-HG archive

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

[src/trunk]: src/sys/ddb Opt to print a backtrace on panic by default with th...



details:   https://anonhg.NetBSD.org/src/rev/a7b84581d1c4
branches:  trunk
changeset: 359603:a7b84581d1c4
user:      sevan <sevan%NetBSD.org@localhost>
date:      Sat Feb 17 00:41:09 2018 +0000

description:
Opt to print a backtrace on panic by default with the intention of improving bug reports.
Instead of relying on ddb.onpanic=2, introduce a new sysctl called dumpstack to handle this.
via <jmcneill> channeled through <mrg> on tech-kern[1]

[1] https://mail-index.netbsd.org/tech-kern/2018/02/15/msg023103.html

diffstat:

 sys/ddb/db_panic.c     |  12 ++++++------
 sys/ddb/db_variables.c |  20 ++++++++++++++++++--
 sys/ddb/ddbvar.h       |   3 ++-
 3 files changed, 26 insertions(+), 9 deletions(-)

diffs (108 lines):

diff -r 7b04781cd441 -r a7b84581d1c4 sys/ddb/db_panic.c
--- a/sys/ddb/db_panic.c        Sat Feb 17 00:28:47 2018 +0000
+++ b/sys/ddb/db_panic.c        Sat Feb 17 00:41:09 2018 +0000
@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: db_panic.c,v 1.6 2017/12/28 17:51:19 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_panic.c,v 1.7 2018/02/17 00:41:09 sevan Exp $");
 
 #include <sys/types.h>
 #include <sys/cpu.h>
@@ -41,9 +41,7 @@
 void db_panic(void)
 {
 
-       if (db_onpanic == 1)
-               Debugger();
-       else if (db_onpanic >= 0) {
+       if (db_dumpstack > 0) {
                static int intrace = 0;
 
                if (intrace == 0) {
@@ -58,8 +56,10 @@
                        intrace = 0;
                } else
                        printf("Faulted in mid-traceback; aborting...\n");
-               if (db_onpanic == 2)
-                       Debugger();
        }
+
+       if (db_onpanic > 0)
+               Debugger();
+
        return;
 }
diff -r 7b04781cd441 -r a7b84581d1c4 sys/ddb/db_variables.c
--- a/sys/ddb/db_variables.c    Sat Feb 17 00:28:47 2018 +0000
+++ b/sys/ddb/db_variables.c    Sat Feb 17 00:41:09 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: db_variables.c,v 1.45 2017/12/28 17:51:19 christos Exp $       */
+/*     $NetBSD: db_variables.c,v 1.46 2018/02/17 00:41:09 sevan Exp $  */
 
 /*
  * Mach Operating System
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: db_variables.c,v 1.45 2017/12/28 17:51:19 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_variables.c,v 1.46 2018/02/17 00:41:09 sevan Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddbparam.h"
@@ -71,6 +71,10 @@
 #endif
 int            db_panicstackframes = DDB_PANICSTACKFRAMES;
 
+#ifndef DDB_DUMPSTACK
+#define DDB_DUMPSTACK 1
+#endif
+int            db_dumpstack = DDB_DUMPSTACK;
 
 static int     db_rw_internal_variable(const struct db_variable *, db_expr_t *,
                    int);
@@ -115,6 +119,12 @@
                .modif = NULL,
        },
        {
+               .name = "dumpstack",
+               .valuep = &db_dumpstack,
+               .fcn = db_rw_internal_variable,
+               .modif = NULL,
+       },
+       {
                .name = "radix",
                .valuep = &db_radix,
                .fcn = db_rw_internal_variable,
@@ -217,6 +227,12 @@
                       SYSCTL_DESCR("Number of stack frames to print on panic"),
                       NULL, 0, &db_panicstackframes, 0,
                       CTL_DDB, CTL_CREATE, CTL_EOL);
+       sysctl_createv(clog, 0, NULL, NULL,
+                      CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
+                      CTLTYPE_INT, "dumpstack",
+                      SYSCTL_DESCR("On panic print stack trace"),
+                      NULL, 0, &db_dumpstack, 0,
+                      CTL_DDB, CTL_CREATE, CTL_EOL);
 }
 #endif /* _KERNEL */
 
diff -r 7b04781cd441 -r a7b84581d1c4 sys/ddb/ddbvar.h
--- a/sys/ddb/ddbvar.h  Sat Feb 17 00:28:47 2018 +0000
+++ b/sys/ddb/ddbvar.h  Sat Feb 17 00:41:09 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ddbvar.h,v 1.12 2017/12/28 17:51:19 christos Exp $     */
+/*     $NetBSD: ddbvar.h,v 1.13 2018/02/17 00:41:09 sevan Exp $        */
 
 /*-
  * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
@@ -40,6 +40,7 @@
 extern int db_fromconsole;
 extern int db_panicstackframes;
 extern int db_tee_msgbuf;
+extern int db_dumpstack;
 
 extern void db_panic(void);
 



Home | Main Index | Thread Index | Old Index