- 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
This commit is contained in:
christos 2017-12-28 17:51:19 +00:00
parent 6964f5bd48
commit bba310736c
5 changed files with 78 additions and 21 deletions

View File

@ -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 @@ void db_panic(void)
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;

View File

@ -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 @@ int db_fromconsole = DDB_FROMCONSOLE;
#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 @@ static int db_find_variable(const struct db_variable **);
/* 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_SETUP(sysctl_ddb_setup, "sysctl ddb subtree setup")
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 @@ db_read_variable(const struct db_variable *vp, db_expr_t *valuep)
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 @@ db_write_variable(const struct db_variable *vp, db_expr_t *valuep)
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);
}

View File

@ -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;

View File

@ -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);

View File

@ -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