From 45538a5e3173993560f2469efbf0e1da25de4d2e Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Sun, 18 Apr 2010 17:06:02 +0000 Subject: [PATCH] x86_handle_debug_exception(): The values of dr6 and dr7 are only stored in the CPU info, if x86_exit_user_debug_at_kernel_entry() was executed before, i.e. if the debug exception occurred in userlands. In all other cases we need to read the current register values. Fixes #5742, a regression introduced in r35951. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36340 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../kernel/arch/x86/arch_user_debugger.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/system/kernel/arch/x86/arch_user_debugger.cpp b/src/system/kernel/arch/x86/arch_user_debugger.cpp index b4861bc3bd..d0c967b498 100644 --- a/src/system/kernel/arch/x86/arch_user_debugger.cpp +++ b/src/system/kernel/arch/x86/arch_user_debugger.cpp @@ -835,11 +835,22 @@ x86_exit_user_debug_at_kernel_entry() void x86_handle_debug_exception(struct iframe *frame) { - // get debug status and control registers (saved earlier in - // x86_exit_user_debug_at_kernel_entry()) struct thread* thread = thread_get_current_thread(); - uint32 dr6 = thread->cpu->arch.dr6; - uint32 dr7 = thread->cpu->arch.dr7; + + // Get dr6 and dr7. If the given iframe is a userland frame, the exception + // obviously occurred in userland. In that case + // x86_exit_user_debug_at_kernel_entry() has already been invoked and dr6 + // and dr7 are stored in the cpu info. Otherwise we need to fetch the + // current values from the registers. + uint32 dr6; + uint32 dr7; + if (IFRAME_IS_USER(frame)) { + dr6 = thread->cpu->arch.dr6; + dr7 = thread->cpu->arch.dr7; + } else { + asm("movl %%dr6, %0" : "=r"(dr6)); + asm("movl %%dr7, %0" : "=r"(dr7)); + } TRACE(("i386_handle_debug_exception(): DR6: %lx, DR7: %lx\n", dr6, dr7));