aboutsummaryrefslogtreecommitdiff
path: root/sys/i386/i386/db_interface.c
diff options
context:
space:
mode:
authorBruce Evans <bde@FreeBSD.org>2003-03-24 10:17:14 +0000
committerBruce Evans <bde@FreeBSD.org>2003-03-24 10:17:14 +0000
commitf261b1f35fdd5a279c377ca978f712d36584785d (patch)
tree4b95fc998041d683ead48a7c799ac1e529d0f525 /sys/i386/i386/db_interface.c
parent5efb531d6c5662c674990ccb5c891b01909913e7 (diff)
downloadsrc-f261b1f35fdd5a279c377ca978f712d36584785d.tar.gz
src-f261b1f35fdd5a279c377ca978f712d36584785d.zip
Disable interrupts while in kdb_trap() to handle cases where the caller
doesn't do it. This fixes all known causes of "Context switches not allowed in the debugger" in mi_switch(). The main cause was trap_fatal() calling kdb_trap() with interrupts enabled. Switching to ithreads for interrupt handling then made fatal traps more fatal and harder to debug. The problem was limited in -current because most interrupt handlers are blocked by Giant, but it occurred almost deterministically for me because my clock interrupt handlers are non-fast and not blocked by Giant.
Notes
Notes: svn path=/head/; revision=112526
Diffstat (limited to 'sys/i386/i386/db_interface.c')
-rw-r--r--sys/i386/i386/db_interface.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/sys/i386/i386/db_interface.c b/sys/i386/i386/db_interface.c
index f1ba48c28dae..e2b936bb1f0d 100644
--- a/sys/i386/i386/db_interface.c
+++ b/sys/i386/i386/db_interface.c
@@ -77,6 +77,7 @@ rss(void)
int
kdb_trap(int type, int code, struct i386_saved_state *regs)
{
+ u_int ef;
volatile int ddb_mode = !(boothowto & RB_GDB);
/*
@@ -96,6 +97,9 @@ kdb_trap(int type, int code, struct i386_saved_state *regs)
return (0);
}
+ ef = read_eflags();
+ disable_intr();
+
switch (type) {
case T_BPTFLT: /* breakpoint */
case T_TRCTRAP: /* debug exception */
@@ -216,6 +220,9 @@ kdb_trap(int type, int code, struct i386_saved_state *regs)
regs->tf_fs = ddb_regs.tf_fs & 0xffff;
regs->tf_cs = ddb_regs.tf_cs & 0xffff;
regs->tf_ds = ddb_regs.tf_ds & 0xffff;
+
+ write_eflags(ef);
+
return (1);
}