svn commit: r332959 - head/sys/kern

Conrad Meyer cem at FreeBSD.org
Tue Apr 24 18:54:21 UTC 2018


Author: cem
Date: Tue Apr 24 18:54:20 2018
New Revision: 332959
URL: https://svnweb.freebsd.org/changeset/base/332959

Log:
  panic: Optionally, trace secondary panics
  
  To diagnose and fix secondary panics, it is useful to have a stack trace.
  When panic tracing is enabled, optionally trace secondary panics as well.
  
  The option is configured with the tunable/sysctl debug.trace_all_panics.
  
  (The original concern that inspired only tracing the primary panic was
  likely that the secondary trace may scroll the original panic message or trace
  off the screen.  This is less of a concern for serial consoles with logging.
  Not everything has a serial console, though, so the behavior is optional.)
  
  Discussed with:	jhb
  Sponsored by:	Dell EMC Isilon

Modified:
  head/sys/kern/kern_shutdown.c

Modified: head/sys/kern/kern_shutdown.c
==============================================================================
--- head/sys/kern/kern_shutdown.c	Tue Apr 24 18:47:35 2018	(r332958)
+++ head/sys/kern/kern_shutdown.c	Tue Apr 24 18:54:20 2018	(r332959)
@@ -124,12 +124,16 @@ SYSCTL_INT(_debug, OID_AUTO, debugger_on_panic,
 
 #ifdef KDB_TRACE
 static int trace_on_panic = 1;
+static bool trace_all_panics = true;
 #else
 static int trace_on_panic = 0;
+static bool trace_all_panics = false;
 #endif
 SYSCTL_INT(_debug, OID_AUTO, trace_on_panic,
     CTLFLAG_RWTUN | CTLFLAG_SECURE,
     &trace_on_panic, 0, "Print stack trace on kernel panic");
+SYSCTL_BOOL(_debug, OID_AUTO, trace_all_panics, CTLFLAG_RWTUN,
+    &trace_all_panics, 0, "Print stack traces on secondary kernel panics");
 #endif /* KDB */
 
 static int sync_on_panic = 0;
@@ -829,7 +833,7 @@ vpanic(const char *fmt, va_list ap)
 #endif
 	printf("time = %jd\n", (intmax_t )time_second);
 #ifdef KDB
-	if (newpanic && trace_on_panic)
+	if ((newpanic || trace_all_panics) && trace_on_panic)
 		kdb_backtrace();
 	if (debugger_on_panic)
 		kdb_enter(KDB_WHY_PANIC, "panic");


More information about the svn-src-head mailing list