Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 1 Nov 2018 21:34:18 +0000 (UTC)
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r340020 - in head/sys: amd64/amd64 arm/arm arm64/arm64 i386/i386 kern mips/mips powerpc/powerpc sys
Message-ID:  <201811012134.wA1LYIjm012800@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jhb
Date: Thu Nov  1 21:34:17 2018
New Revision: 340020
URL: https://svnweb.freebsd.org/changeset/base/340020

Log:
  Don't enter DDB for fatal traps before panic by default.
  
  Add a new 'debugger_on_trap' knob separate from 'debugger_on_panic'
  and make the calls to kdb_trap() in MD fatal trap handlers prior to
  calling panic() conditional on this new knob instead of
  'debugger_on_panic'.  Disable the new knob by default.  Developers who
  wish to recover from a fatal fault by adjusting saved register state
  and retrying the faulting instruction can still do so by enabling the
  new knob.  However, for the more common case this makes the user
  experience for panics due to a fatal fault match the user experience
  for other panics, e.g. 'c' in DDB will generate a crash dump and
  reboot the system rather than being stuck in an infinite loop of fatal
  fault messages and DDB prompts.
  
  Reviewed by:	kib, avg
  MFC after:	2 months
  Sponsored by:	Chelsio Communications
  Differential Revision:	https://reviews.freebsd.org/D17768

Modified:
  head/sys/amd64/amd64/trap.c
  head/sys/arm/arm/trap-v4.c
  head/sys/arm/arm/trap-v6.c
  head/sys/arm64/arm64/trap.c
  head/sys/i386/i386/trap.c
  head/sys/kern/kern_shutdown.c
  head/sys/mips/mips/trap.c
  head/sys/powerpc/powerpc/trap.c
  head/sys/sys/kdb.h

Modified: head/sys/amd64/amd64/trap.c
==============================================================================
--- head/sys/amd64/amd64/trap.c	Thu Nov  1 21:28:22 2018	(r340019)
+++ head/sys/amd64/amd64/trap.c	Thu Nov  1 21:34:17 2018	(r340020)
@@ -916,7 +916,7 @@ trap_fatal(frame, eva)
 	    curproc->p_pid, curthread->td_name);
 
 #ifdef KDB
-	if (debugger_on_panic) {
+	if (debugger_on_trap) {
 		kdb_why = KDB_WHY_TRAP;
 		handled = kdb_trap(type, 0, frame);
 		kdb_why = KDB_WHY_UNSET;

Modified: head/sys/arm/arm/trap-v4.c
==============================================================================
--- head/sys/arm/arm/trap-v4.c	Thu Nov  1 21:28:22 2018	(r340019)
+++ head/sys/arm/arm/trap-v4.c	Thu Nov  1 21:34:17 2018	(r340020)
@@ -456,7 +456,7 @@ dab_fatal(struct trapframe *tf, u_int fsr, u_int far, 
 	printf(", pc =%08x\n\n", tf->tf_pc);
 
 #ifdef KDB
-	if (debugger_on_panic) {
+	if (debugger_on_trap) {
 		kdb_why = KDB_WHY_TRAP;
 		handled = kdb_trap(fsr, 0, tf);
 		kdb_why = KDB_WHY_UNSET;

Modified: head/sys/arm/arm/trap-v6.c
==============================================================================
--- head/sys/arm/arm/trap-v6.c	Thu Nov  1 21:28:22 2018	(r340019)
+++ head/sys/arm/arm/trap-v6.c	Thu Nov  1 21:34:17 2018	(r340020)
@@ -599,7 +599,7 @@ abort_fatal(struct trapframe *tf, u_int idx, u_int fsr
 	printf(", pc =%08x\n\n", tf->tf_pc);
 
 #ifdef KDB
-	if (debugger_on_panic) {
+	if (debugger_on_trap) {
 		kdb_why = KDB_WHY_TRAP;
 		kdb_trap(fsr, 0, tf);
 		kdb_why = KDB_WHY_UNSET;

Modified: head/sys/arm64/arm64/trap.c
==============================================================================
--- head/sys/arm64/arm64/trap.c	Thu Nov  1 21:28:22 2018	(r340019)
+++ head/sys/arm64/arm64/trap.c	Thu Nov  1 21:34:17 2018	(r340020)
@@ -256,7 +256,7 @@ no_pmap_fault:
 			printf(" esr:         %.8lx\n", esr);
 
 #ifdef KDB
-			if (debugger_on_panic) {
+			if (debugger_on_trap) {
 				kdb_why = KDB_WHY_TRAP;
 				handled = kdb_trap(ESR_ELx_EXCEPTION(esr), 0,
 				    frame);

Modified: head/sys/i386/i386/trap.c
==============================================================================
--- head/sys/i386/i386/trap.c	Thu Nov  1 21:28:22 2018	(r340019)
+++ head/sys/i386/i386/trap.c	Thu Nov  1 21:34:17 2018	(r340020)
@@ -977,7 +977,7 @@ trap_fatal(frame, eva)
 	    curproc->p_pid, curthread->td_name);
 
 #ifdef KDB
-	if (debugger_on_panic) {
+	if (debugger_on_trap) {
 		kdb_why = KDB_WHY_TRAP;
 		frame->tf_err = eva;	/* smuggle fault address to ddb */
 		handled = kdb_trap(type, 0, frame);

Modified: head/sys/kern/kern_shutdown.c
==============================================================================
--- head/sys/kern/kern_shutdown.c	Thu Nov  1 21:28:22 2018	(r340019)
+++ head/sys/kern/kern_shutdown.c	Thu Nov  1 21:34:17 2018	(r340020)
@@ -115,13 +115,18 @@ SYSCTL_INT(_kern, OID_AUTO, panic_reboot_wait_time, CT
 
 #ifdef KDB
 #ifdef KDB_UNATTENDED
-int debugger_on_panic = 0;
+static int debugger_on_panic = 0;
 #else
-int debugger_on_panic = 1;
+static int debugger_on_panic = 1;
 #endif
 SYSCTL_INT(_debug, OID_AUTO, debugger_on_panic,
     CTLFLAG_RWTUN | CTLFLAG_SECURE,
     &debugger_on_panic, 0, "Run debugger on kernel panic");
+
+int debugger_on_trap = 0;
+SYSCTL_INT(_debug, OID_AUTO, debugger_on_trap,
+    CTLFLAG_RWTUN | CTLFLAG_SECURE,
+    &debugger_on_trap, 0, "Run debugger on kernel trap before panic");
 
 #ifdef KDB_TRACE
 static int trace_on_panic = 1;

Modified: head/sys/mips/mips/trap.c
==============================================================================
--- head/sys/mips/mips/trap.c	Thu Nov  1 21:28:22 2018	(r340019)
+++ head/sys/mips/mips/trap.c	Thu Nov  1 21:34:17 2018	(r340020)
@@ -1100,7 +1100,7 @@ err:
 #endif
 
 #ifdef KDB
-		if (debugger_on_panic) {
+		if (debugger_on_trap) {
 			kdb_why = KDB_WHY_TRAP;
 			kdb_trap(type, 0, trapframe);
 			kdb_why = KDB_WHY_UNSET;

Modified: head/sys/powerpc/powerpc/trap.c
==============================================================================
--- head/sys/powerpc/powerpc/trap.c	Thu Nov  1 21:28:22 2018	(r340019)
+++ head/sys/powerpc/powerpc/trap.c	Thu Nov  1 21:34:17 2018	(r340020)
@@ -455,7 +455,7 @@ trap_fatal(struct trapframe *frame)
 
 	printtrap(frame->exc, frame, 1, (frame->srr1 & PSL_PR));
 #ifdef KDB
-	if (debugger_on_panic) {
+	if (debugger_on_trap) {
 		kdb_why = KDB_WHY_TRAP;
 		handled = kdb_trap(frame->exc, 0, frame);
 		kdb_why = KDB_WHY_UNSET;

Modified: head/sys/sys/kdb.h
==============================================================================
--- head/sys/sys/kdb.h	Thu Nov  1 21:28:22 2018	(r340019)
+++ head/sys/sys/kdb.h	Thu Nov  1 21:34:17 2018	(r340020)
@@ -62,7 +62,7 @@ struct kdb_dbbe {
 	DATA_SET(kdb_dbbe_set, name##_dbbe)
 
 extern u_char kdb_active;		/* Non-zero while in debugger. */
-extern int debugger_on_panic;		/* enter the debugger on panic. */
+extern int debugger_on_trap;		/* enter the debugger on trap. */
 extern struct kdb_dbbe *kdb_dbbe;	/* Default debugger backend or NULL. */
 extern struct trapframe *kdb_frame;	/* Frame to kdb_trap(). */
 extern struct pcb *kdb_thrctx;		/* Current context. */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201811012134.wA1LYIjm012800>