Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 27 Dec 1998 19:33:56 -0500 (EST)
From:      Brian Feldman <green@unixhelp.org>
To:        current@FreeBSD.ORG
Subject:   debugger_on_panic behavior changes (for the better)
Message-ID:  <Pine.BSF.4.05.9812271925350.20018-100000@janus.syracuse.net>

next in thread | raw e-mail | index | archive | help
  There's something that's been bugging me for a while, so I decided to fix it.
FreeBSD now will DTRT WRT DDB and DDB_UNATTENDED (!debugger_on_panic), at least
in my opinion. The behavior change is such that:

	1. Nothing changes when debugger_on_panic != 0.
	2. When DDB_UNATTENDED (!debugger_on_panic), if a panic occurs, the
		machine will reboot. Also, if a trap occurs, the machine will
		panic and reboot, unlike how it broke to DDB before. HOWEVER,
		a trap inside DDB will not cause a panic, allowing full use
		of DDB without having to worry about the machine being stuck
		at a DDB prompt if something goes wrong during the day.
		Patches for this behavior follow my signature, and it would
		be a boon to anyone (like me) who uses DDB_UNATTENDED, but
		actually wants the machine to panic on a trap (otherwise,
		what's the use, if the machine causes a fatal trap rather than
		a true panic, of debugger_on_panic?). The changes cause no
		adverse behavior, but do involve two symbols becoming global
		(shouldn't be that bad of pollution). Comments?

 Brian Feldman						  _ __  ___ ___ ___  
 green@unixhelp.org				      _ __ ___ | _ ) __|   \ 
		      http://www.freebsd.org/	 _ __ ___ ____ | _ \__ \ |) |
 FreeBSD: The Power to Serve!		   _ __ ___ ____ _____ |___/___/___/ 

--- src/sys/kern/kern_shutdown.c.orig	Sun Dec 27 15:00:08 1998
+++ src/sys/kern/kern_shutdown.c	Sun Dec 27 15:01:51 1998
@@ -80,9 +80,9 @@
 
 #ifdef DDB
 #ifdef DDB_UNATTENDED
-static int debugger_on_panic = 0;
+int debugger_on_panic = 0;
 #else
-static int debugger_on_panic = 1;
+int debugger_on_panic = 1;
 #endif
 SYSCTL_INT(_debug, OID_AUTO, debugger_on_panic, CTLFLAG_RW,
 	&debugger_on_panic, 0, "");
--- src/sys/i386/i386/trap.c.orig	Sun Dec 27 14:47:39 1998
+++ src/sys/i386/i386/trap.c	Sun Dec 27 15:01:01 1998
@@ -93,6 +93,10 @@
 #include <machine/vm86.h>
 #endif
 
+#ifdef DDB
+	extern int in_Debugger, debugger_on_panic;
+#endif
+
 #include "isa.h"
 #include "npx.h"
 
@@ -901,7 +905,7 @@
 		return;
 #endif
 #ifdef DDB
-	if (kdb_trap (type, 0, frame))
+	if ((debugger_on_panic || in_Debugger) && kdb_trap(type, 0, frame))
 		return;
 #endif
 	printf("trap number		= %d\n", type);
--- src/sys/i386/i386/db_interface.c.orig	Sun Dec 27 14:45:51 1998
+++ src/sys/i386/i386/db_interface.c	Sun Dec 27 14:56:54 1998
@@ -295,11 +295,12 @@
  * Move this to machdep.c and allow it to be called if any debugger is
  * installed.
  */
+volatile int in_Debugger = 0;
+
 void
 Debugger(msg)
 	const char *msg;
 {
-	static volatile u_char in_Debugger;
 
 	/*
 	 * XXX



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.05.9812271925350.20018-100000>