Module Name:    src
Committed By:   christos
Date:           Thu Dec 28 17:51:19 UTC 2017

Modified Files:
        src/sys/ddb: db_panic.c db_variables.c db_variables.h ddbvar.h
            files.ddb

Log Message:
- 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


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/ddb/db_panic.c
cvs rdiff -u -r1.44 -r1.45 src/sys/ddb/db_variables.c
cvs rdiff -u -r1.15 -r1.16 src/sys/ddb/db_variables.h
cvs rdiff -u -r1.11 -r1.12 src/sys/ddb/ddbvar.h
cvs rdiff -u -r1.10 -r1.11 src/sys/ddb/files.ddb

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/ddb/db_panic.c
diff -u src/sys/ddb/db_panic.c:1.5 src/sys/ddb/db_panic.c:1.6
--- src/sys/ddb/db_panic.c:1.5	Fri Oct 27 08:25:15 2017
+++ src/sys/ddb/db_panic.c	Thu Dec 28 12:51:19 2017
@@ -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;

Index: src/sys/ddb/db_variables.c
diff -u src/sys/ddb/db_variables.c:1.44 src/sys/ddb/db_variables.c:1.45
--- src/sys/ddb/db_variables.c:1.44	Tue Feb 25 13:30:09 2014
+++ src/sys/ddb/db_variables.c	Thu Dec 28 12:51:19 2017
@@ -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
 
 /* 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 d
 		       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_variabl
 	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_variab
 	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);
 }

Index: src/sys/ddb/db_variables.h
diff -u src/sys/ddb/db_variables.h:1.15 src/sys/ddb/db_variables.h:1.16
--- src/sys/ddb/db_variables.h:1.15	Wed Feb 21 23:38:06 2007
+++ src/sys/ddb/db_variables.h	Thu Dec 28 12:51:19 2017
@@ -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;

Index: src/sys/ddb/ddbvar.h
diff -u src/sys/ddb/ddbvar.h:1.11 src/sys/ddb/ddbvar.h:1.12
--- src/sys/ddb/ddbvar.h:1.11	Sun Feb 10 06:04:20 2013
+++ src/sys/ddb/ddbvar.h	Thu Dec 28 12:51:19 2017
@@ -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);

Index: src/sys/ddb/files.ddb
diff -u src/sys/ddb/files.ddb:1.10 src/sys/ddb/files.ddb:1.11
--- src/sys/ddb/files.ddb:1.10	Sun Nov 16 00:46:27 2014
+++ src/sys/ddb/files.ddb	Thu Dec 28 12:51:19 2017
@@ -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

Reply via email to