From 48b0c6f93ad3ba41103e59e3008b8ac6247e8f28 Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Thu, 16 Apr 2009 21:55:40 +0000 Subject: [PATCH] debug_trap_cpu_in_kdl(): If the CPU running the kernel debugger exited and re-entered it fast enough, we wouldn't leave the loop and thus cause a deadlock, since we wouldn't process the ICI message telling us to halt. We do now call smp_intercpu_int_handler() in the loop and guard the function from being re-entered. This also has the advantage that we can execute code on all CPUs in the kernel debugger, if we have to. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30208 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/kernel/debug/debug.cpp | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/system/kernel/debug/debug.cpp b/src/system/kernel/debug/debug.cpp index 92ba0579a0..83bcafc0d5 100644 --- a/src/system/kernel/debug/debug.cpp +++ b/src/system/kernel/debug/debug.cpp @@ -26,6 +26,7 @@ #include #include +#include #include #include @@ -102,6 +103,8 @@ static vint32 sInDebugger = 0; static bool sPreviousDprintfState; static volatile bool sHandOverKDL = false; static vint32 sHandOverKDLToCPU = -1; +static bool sCPUTrapped[B_MAX_CPU_COUNT]; + #define distance(a, b) ((a) < (b) ? (b) - (a) : (a) - (b)) @@ -1307,19 +1310,28 @@ debug_get_page_fault_info() void debug_trap_cpu_in_kdl(bool returnIfHandedOver) { - cpu_status state = disable_interrupts(); + InterruptsLocker locker; + + int cpu = smp_get_current_cpu(); + + // return, if we've been called recursively (we call + // smp_intercpu_int_handler() below) + if (sCPUTrapped[cpu]) + return; + + sCPUTrapped[cpu] = true; while (sInDebugger != 0) { - if (sHandOverKDL && sHandOverKDLToCPU == smp_get_current_cpu()) { + if (sHandOverKDL && sHandOverKDLToCPU == cpu) { if (returnIfHandedOver) - return; + break; kernel_debugger(NULL); } else - PAUSE(); + smp_intercpu_int_handler(); } - restore_interrupts(state); + sCPUTrapped[cpu] = false; }