Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 22 Jun 2018 11:16:17 +0000 (UTC)
From:      Andriy Gapon <avg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r335557 - in stable/10/sys: arm/arm mips/mips
Message-ID:  <201806221116.w5MBGHjP090637@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: avg
Date: Fri Jun 22 11:16:17 2018
New Revision: 335557
URL: https://svnweb.freebsd.org/changeset/base/335557

Log:
  MFC r333667: followup to r332730/r332752: set kdb_why to "trap" for fatal traps
  
  This change updates arm, arm64 and mips achitectures.  Additionally, it
  removes redundant checks for kdb_active where it already results in
  kdb_reenter() and adds kdb_reenter() calls where they were missing.
  
  Some architectures check the return value of kdb_trap(), but some don't.
  I haven't changed any of that.
  
  Some trap handling routines have a return code.  I am not sure if I
  provided correct ones for returns after kdb_reenter().  kdb_reenter
  should never return unless kdb_jmpbufp is NULL for some reason.

Modified:
  stable/10/sys/arm/arm/trap-v6.c
  stable/10/sys/arm/arm/trap.c
  stable/10/sys/mips/mips/trap.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/arm/arm/trap-v6.c
==============================================================================
--- stable/10/sys/arm/arm/trap-v6.c	Fri Jun 22 10:49:21 2018	(r335556)
+++ stable/10/sys/arm/arm/trap-v6.c	Fri Jun 22 11:16:17 2018	(r335557)
@@ -592,8 +592,11 @@ 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 || kdb_active)
+	if (debugger_on_panic) {
+		kdb_why = KDB_WHY_TRAP;
 		kdb_trap(fsr, 0, tf);
+		kdb_why = KDB_WHY_UNSET;
+	}
 #endif
 	panic("Fatal abort");
 	/*NOTREACHED*/

Modified: stable/10/sys/arm/arm/trap.c
==============================================================================
--- stable/10/sys/arm/arm/trap.c	Fri Jun 22 10:49:21 2018	(r335556)
+++ stable/10/sys/arm/arm/trap.c	Fri Jun 22 11:16:17 2018	(r335557)
@@ -422,7 +422,16 @@ dab_fatal(struct trapframe *tf, u_int fsr, u_int far, 
     struct ksig *ksig)
 {
 	const char *mode;
+#ifdef KDB
+	bool handled;
+#endif
 
+#ifdef KDB
+	if (kdb_active) {
+		kdb_reenter();
+		return (0);
+	}
+#endif
 	mode = TRAP_USERMODE(tf) ? "user" : "kernel";
 
 	disable_interrupts(PSR_I|PSR_F);
@@ -458,9 +467,13 @@ 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 || kdb_active)
-		if (kdb_trap(fsr, 0, tf))
+	if (debugger_on_panic) {
+		kdb_why = KDB_WHY_TRAP;
+		handled = kdb_trap(fsr, 0, tf);
+		kdb_why = KDB_WHY_UNSET;
+		if (handled)
 			return (0);
+	}
 #endif
 	panic("Fatal abort");
 	/*NOTREACHED*/
@@ -749,4 +762,4 @@ badaddr_read(void *addr, size_t size, void *rptr)
 
 	/* Return EFAULT if the address was invalid, else zero */
 	return (rv);
-}
\ No newline at end of file
+}

Modified: stable/10/sys/mips/mips/trap.c
==============================================================================
--- stable/10/sys/mips/mips/trap.c	Fri Jun 22 10:49:21 2018	(r335556)
+++ stable/10/sys/mips/mips/trap.c	Fri Jun 22 11:16:17 2018	(r335557)
@@ -529,7 +529,12 @@ trap(struct trapframe *trapframe)
 	register_t *frame_regs;
 
 	trapdebug_enter(trapframe, 0);
-	
+#ifdef KDB
+	if (kdb_active) {
+		kdb_reenter();
+		return (0);
+	}
+#endif
 	type = (trapframe->cause & MIPS_CR_EXC_CODE) >> MIPS_CR_EXC_CODE_SHIFT;
 	if (TRAPF_USERMODE(trapframe)) {
 		type |= T_USER;
@@ -1104,8 +1109,10 @@ err:
 #endif
 
 #ifdef KDB
-		if (debugger_on_panic || kdb_active) {
+		if (debugger_on_panic) {
+			kdb_why = KDB_WHY_TRAP;
 			kdb_trap(type, 0, trapframe);
+			kdb_why = KDB_WHY_UNSET;
 		}
 #endif
 		panic("trap");



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