Source-Changes-HG archive

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

[src/trunk]: src/sys/ddb - add ddb.panicstackframes to avoid scrolling the in...



details:   https://anonhg.NetBSD.org/src/rev/27b43a5d9752
branches:  trunk
changeset: 828719:27b43a5d9752
user:      christos <christos%NetBSD.org@localhost>
date:      Thu Dec 28 17:51:19 2017 +0000

description:
- add ddb.panicstackframes to avoid scrolling the interesting parts of panic
  stacktraces off.
- change valuep to void * to avoid casts
- sort and use c99 initializers in variables array

diffstat:

 sys/ddb/db_panic.c     |   4 +-
 sys/ddb/db_variables.c |  84 +++++++++++++++++++++++++++++++++++++++++--------
 sys/ddb/db_variables.h |   4 +-
 sys/ddb/ddbvar.h       |   3 +-
 sys/ddb/files.ddb      |   4 +-
 5 files changed, 78 insertions(+), 21 deletions(-)

diffs (213 lines):

diff -r 93ac49638f90 -r 27b43a5d9752 sys/ddb/db_panic.c
--- a/sys/ddb/db_panic.c        Thu Dec 28 15:12:15 2017 +0000
+++ b/sys/ddb/db_panic.c        Thu Dec 28 17:51:19 2017 +0000
@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: db_panic.c,v 1.5 2017/10/27 12:25:15 joerg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_panic.c,v 1.6 2017/12/28 17:51:19 christos Exp $");
 
 #include <sys/types.h>
 #include <sys/cpu.h>
@@ -52,7 +52,7 @@
                            cpu_index(curcpu()));
                        db_stack_trace_print(
                            (db_expr_t)(intptr_t)__builtin_frame_address(0),
-                           true, 65535, "", printf);
+                           true, db_panicstackframes, "", printf);
                        printf("cpu%u: End traceback...\n",
                            cpu_index(curcpu()));
                        intrace = 0;
diff -r 93ac49638f90 -r 27b43a5d9752 sys/ddb/db_variables.c
--- a/sys/ddb/db_variables.c    Thu Dec 28 15:12:15 2017 +0000
+++ b/sys/ddb/db_variables.c    Thu Dec 28 17:51:19 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: db_variables.c,v 1.44 2014/02/25 18:30:09 pooka Exp $  */
+/*     $NetBSD: db_variables.c,v 1.45 2017/12/28 17:51:19 christos Exp $       */
 
 /*
  * Mach Operating System
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: db_variables.c,v 1.44 2014/02/25 18:30:09 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_variables.c,v 1.45 2017/12/28 17:51:19 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddbparam.h"
@@ -66,6 +66,11 @@
 #endif
 int            db_tee_msgbuf = DDB_TEE_MSGBUF;
 
+#ifndef DDB_PANICSTACKFRAMES
+#define DDB_PANICSTACKFRAMES 65535
+#endif
+int            db_panicstackframes = DDB_PANICSTACKFRAMES;
+
 
 static int     db_rw_internal_variable(const struct db_variable *, db_expr_t *,
                    int);
@@ -73,16 +78,62 @@
 
 /* XXX must all be ints for sysctl. */
 const struct db_variable db_vars[] = {
-       { "radix",      (void *)&db_radix,      db_rw_internal_variable, NULL },
-       { "maxoff",     (void *)&db_maxoff,     db_rw_internal_variable, NULL },
-       { "maxwidth",   (void *)&db_max_width,  db_rw_internal_variable, NULL },
-       { "tabstops",   (void *)&db_tab_stop_width, db_rw_internal_variable, NULL },
-       { "lines",      (void *)&db_max_line,   db_rw_internal_variable, NULL },
-       { "onpanic",    (void *)&db_onpanic,    db_rw_internal_variable, NULL },
-       { "fromconsole", (void *)&db_fromconsole, db_rw_internal_variable, NULL },
-       { "tee_msgbuf", (void *)&db_tee_msgbuf, db_rw_internal_variable, NULL },
+       {
+               .name = "fromconsole",
+               .valuep = &db_fromconsole,
+               .fcn = db_rw_internal_variable,
+               .modif = NULL,
+       },
+       {
+               .name = "maxoff",
+               .valuep = &db_maxoff,
+               .fcn = db_rw_internal_variable,
+               .modif = NULL,
+       },
+       {
+               .name = "maxwidth",
+               .valuep = &db_max_width,
+               .fcn = db_rw_internal_variable,
+               .modif = NULL,
+       },
+       {
+               .name = "lines",
+               .valuep = &db_max_line,
+               .fcn = db_rw_internal_variable,
+               .modif = NULL,
+       },
+       {
+               .name = "onpanic",
+               .valuep = &db_onpanic,
+               .fcn = db_rw_internal_variable,
+               .modif = NULL,
+       },
+       {
+               .name = "panicstackframes",
+               .valuep = &db_panicstackframes,
+               .fcn = db_rw_internal_variable,
+               .modif = NULL,
+       },
+       {
+               .name = "radix",
+               .valuep = &db_radix,
+               .fcn = db_rw_internal_variable,
+               .modif = NULL,
+       },
+       {
+               .name = "tabstops",
+               .valuep = &db_tab_stop_width,
+               .fcn = db_rw_internal_variable,
+               .modif = NULL,
+       },
+       {
+               .name = "tee_msgbuf",
+               .valuep = &db_tee_msgbuf,
+               .fcn = db_rw_internal_variable,
+               .modif = NULL,
+       },
 };
-const struct db_variable * const db_evars = db_vars + sizeof(db_vars)/sizeof(db_vars[0]);
+const struct db_variable * const db_evars = db_vars + __arraycount(db_vars);
 
 /*
  * ddb command line access to the DDB variables defined above.
@@ -154,13 +205,18 @@
                       SYSCTL_DESCR("Whether to tee ddb output to the msgbuf"),
                       NULL, 0, &db_tee_msgbuf, 0,
                       CTL_DDB, CTL_CREATE, CTL_EOL);
-
        sysctl_createv(clog, 0, NULL, NULL,
                       CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
                       CTLTYPE_STRING, "commandonenter",
                       SYSCTL_DESCR("Command to be executed on each ddb enter"),
                       NULL, 0, db_cmd_on_enter, DB_LINE_MAXLEN,
                       CTL_DDB, CTL_CREATE, CTL_EOL);
+       sysctl_createv(clog, 0, NULL, NULL,
+                      CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
+                      CTLTYPE_INT, "panicstackframes",
+                      SYSCTL_DESCR("Number of stack frames to print on panic"),
+                      NULL, 0, &db_panicstackframes, 0,
+                      CTL_DDB, CTL_CREATE, CTL_EOL);
 }
 #endif /* _KERNEL */
 
@@ -223,7 +279,7 @@
        int (*func)(const struct db_variable *, db_expr_t *, int) = vp->fcn;
 
        if (func == FCN_NULL)
-               *valuep = *(vp->valuep);
+               *valuep = *(db_expr_t *)vp->valuep;
        else
                (*func)(vp, valuep, DB_VAR_GET);
 }
@@ -234,7 +290,7 @@
        int (*func)(const struct db_variable *, db_expr_t *, int) = vp->fcn;
 
        if (func == FCN_NULL)
-               *(vp->valuep) = *valuep;
+               *(db_expr_t *)vp->valuep = *valuep;
        else
                (*func)(vp, valuep, DB_VAR_SET);
 }
diff -r 93ac49638f90 -r 27b43a5d9752 sys/ddb/db_variables.h
--- a/sys/ddb/db_variables.h    Thu Dec 28 15:12:15 2017 +0000
+++ b/sys/ddb/db_variables.h    Thu Dec 28 17:51:19 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: db_variables.h,v 1.15 2007/02/22 04:38:06 matt Exp $   */
+/*     $NetBSD: db_variables.h,v 1.16 2017/12/28 17:51:19 christos Exp $       */
 
 /*
  * Mach Operating System
@@ -37,7 +37,7 @@
  */
 struct db_variable {
        const char *name;       /* Name of variable */
-       long    *valuep;        /* value of variable */
+       void    *valuep;        /* value of variable */
                                /* function to call when reading/writing */
        int     (*fcn)(const struct db_variable *, db_expr_t *, int);
        const char      *modif;
diff -r 93ac49638f90 -r 27b43a5d9752 sys/ddb/ddbvar.h
--- a/sys/ddb/ddbvar.h  Thu Dec 28 15:12:15 2017 +0000
+++ b/sys/ddb/ddbvar.h  Thu Dec 28 17:51:19 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ddbvar.h,v 1.11 2013/02/10 11:04:20 apb Exp $  */
+/*     $NetBSD: ddbvar.h,v 1.12 2017/12/28 17:51:19 christos Exp $     */
 
 /*-
  * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
@@ -38,6 +38,7 @@
 
 extern int db_onpanic;
 extern int db_fromconsole;
+extern int db_panicstackframes;
 extern int db_tee_msgbuf;
 
 extern void db_panic(void);
diff -r 93ac49638f90 -r 27b43a5d9752 sys/ddb/files.ddb
--- a/sys/ddb/files.ddb Thu Dec 28 15:12:15 2017 +0000
+++ b/sys/ddb/files.ddb Thu Dec 28 17:51:19 2017 +0000
@@ -1,11 +1,11 @@
-#      $NetBSD: files.ddb,v 1.10 2014/11/16 05:46:27 uebayasi Exp $
+#      $NetBSD: files.ddb,v 1.11 2017/12/28 17:51:19 christos Exp $
 
 #
 # DDB options
 #
 defflag opt_ddb.h              DDB DDB_VERBOSE_HELP
 defparam opt_ddbparam.h                DDB_FROMCONSOLE DDB_ONPANIC DDB_HISTORY_SIZE
-                               DDB_BREAK_CHAR DDB_KEYCODE
+                               DDB_BREAK_CHAR DDB_KEYCODE DDB_PANICSTACKFRAMES
                                DDB_COMMANDONENTER DB_MAX_LINE
 
 define ddb



Home | Main Index | Thread Index | Old Index