From b447670286ce35b20725cc585c250f03a08d15aa Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Thu, 16 Apr 2009 19:56:11 +0000 Subject: [PATCH] * Removed most of the special-casing for kernel breakpoints in the kernel enter/exit code. There's no real reason not to keep kernel breakpoints enabled when in userland (unless there are breakpoints installed for the team, of course). * Enabled kernel breakpoints by default (check your kernel_debug_config.h, if you have overridden it!), since they don't really add any overhead anymore. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30206 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- build/config_headers/kernel_debug_config.h | 4 +-- src/system/kernel/arch/x86/arch_interrupts.S | 25 ++++--------------- .../kernel/arch/x86/arch_user_debugger.cpp | 20 +++++++-------- 3 files changed, 16 insertions(+), 33 deletions(-) diff --git a/build/config_headers/kernel_debug_config.h b/build/config_headers/kernel_debug_config.h index 1fae90e846..dd4d09d12c 100644 --- a/build/config_headers/kernel_debug_config.h +++ b/build/config_headers/kernel_debug_config.h @@ -18,8 +18,8 @@ // benaphore-style. #define KDEBUG KDEBUG_LEVEL_2 -// Enable this to get support for kernel breakpoints. -#define KERNEL_BREAKPOINTS 0 +// Set to 0 to disable support for kernel breakpoints. +#define KERNEL_BREAKPOINTS 1 // block/file cache diff --git a/src/system/kernel/arch/x86/arch_interrupts.S b/src/system/kernel/arch/x86/arch_interrupts.S index eda44b1819..d6e376dfb0 100644 --- a/src/system/kernel/arch/x86/arch_interrupts.S +++ b/src/system/kernel/arch/x86/arch_interrupts.S @@ -98,16 +98,11 @@ original eax/edx values */ \ iret -#if KERNEL_BREAKPOINTS -# define DISABLE_BREAKPOINTS() \ - call x86_exit_user_debug_at_kernel_entry; -#else -# define DISABLE_BREAKPOINTS() \ - testl $THREAD_FLAGS_BREAKPOINTS_INSTALLED, THREAD_flags(%edi); \ - jz 1f; \ - call x86_exit_user_debug_at_kernel_entry; \ - 1: -#endif // KERNEL_BREAKPOINTS +#define DISABLE_BREAKPOINTS() \ + testl $THREAD_FLAGS_BREAKPOINTS_INSTALLED, THREAD_flags(%edi); \ + jz 1f; \ + call x86_exit_user_debug_at_kernel_entry; \ + 1: #define COPY_SYSCALL_PARAMETERS() \ /* make room for the syscall params */ \ @@ -311,14 +306,10 @@ STATIC_FUNCTION(int_bottom_user): cmp $USER_CODE_SEG, IFRAME_cs(%ebp) jne 1f -#if KERNEL_BREAKPOINTS - jmp kernel_exit_work -#else testl $(THREAD_FLAGS_DEBUGGER_INSTALLED | THREAD_FLAGS_SIGNALS_PENDING \ | THREAD_FLAGS_DEBUG_THREAD | THREAD_FLAGS_BREAKPOINTS_DEFINED) \ , THREAD_flags(%edi) jnz kernel_exit_work -#endif 1: cli // disable interrupts @@ -422,16 +413,12 @@ STATIC_FUNCTION(handle_syscall): TRACE_POST_SYSCALL() -#if KERNEL_BREAKPOINTS - jmp post_syscall_work -#else testl $(THREAD_FLAGS_DEBUGGER_INSTALLED | THREAD_FLAGS_SIGNALS_PENDING \ | THREAD_FLAGS_DEBUG_THREAD | THREAD_FLAGS_BREAKPOINTS_DEFINED \ | THREAD_FLAGS_64_BIT_SYSCALL_RETURN \ | THREAD_FLAGS_RESTART_SYSCALL | THREAD_FLAGS_SYSCALL_RESTARTED) \ , THREAD_flags(%edi) jnz post_syscall_work -#endif cli // disable interrupts @@ -507,10 +494,8 @@ FUNCTION_END(handle_syscall) 1: // install breakpoints, if defined -#if !KERNEL_BREAKPOINTS testl $THREAD_FLAGS_BREAKPOINTS_DEFINED, THREAD_flags(%edi) jz 1f -#endif push %ebp call x86_init_user_debug_at_kernel_exit 1: diff --git a/src/system/kernel/arch/x86/arch_user_debugger.cpp b/src/system/kernel/arch/x86/arch_user_debugger.cpp index f534a0aa40..438786d3a0 100644 --- a/src/system/kernel/arch/x86/arch_user_debugger.cpp +++ b/src/system/kernel/arch/x86/arch_user_debugger.cpp @@ -516,7 +516,7 @@ arch_update_thread_single_step() { if (struct iframe* frame = i386_get_user_iframe()) { struct thread* thread = thread_get_current_thread(); - + // set/clear TF in EFLAGS depending on if single stepping is desired if (thread->debug_info.flags & B_THREAD_DEBUG_SINGLE_STEP) frame->flags |= (1 << X86_EFLAGS_TF); @@ -710,17 +710,18 @@ x86_init_user_debug_at_kernel_exit(struct iframe *frame) { struct thread *thread = thread_get_current_thread(); -#if !KERNEL_BREAKPOINTS if (!(thread->flags & THREAD_FLAGS_BREAKPOINTS_DEFINED)) return; -#endif + + // disable kernel breakpoints + disable_breakpoints(); GRAB_THREAD_LOCK(); GRAB_TEAM_DEBUG_INFO_LOCK(thread->team->debug_info); arch_team_debug_info &teamInfo = thread->team->debug_info.arch_info; - // install the breakpoints + // install the user breakpoints install_breakpoints(teamInfo); atomic_or(&thread->flags, THREAD_FLAGS_BREAKPOINTS_INSTALLED); @@ -738,22 +739,19 @@ x86_exit_user_debug_at_kernel_entry() { struct thread *thread = thread_get_current_thread(); -#if !KERNEL_BREAKPOINTS if (!(thread->flags & THREAD_FLAGS_BREAKPOINTS_INSTALLED)) return; -#endif GRAB_THREAD_LOCK(); - // disable breakpoints + // disable user breakpoints disable_breakpoints(); -#if KERNEL_BREAKPOINTS + // install kernel breakpoints struct team* kernelTeam = team_get_kernel_team(); GRAB_TEAM_DEBUG_INFO_LOCK(kernelTeam->debug_info); install_breakpoints(kernelTeam->debug_info.arch_info); RELEASE_TEAM_DEBUG_INFO_LOCK(kernelTeam->debug_info); -#endif atomic_and(&thread->flags, ~THREAD_FLAGS_BREAKPOINTS_INSTALLED); @@ -762,7 +760,7 @@ x86_exit_user_debug_at_kernel_entry() /** - * Interrupts are disabled and will be enabled by the function. + * Interrupts are disabled and will possibly be enabled by the function. */ void x86_handle_debug_exception(struct iframe *frame) @@ -839,7 +837,7 @@ x86_handle_debug_exception(struct iframe *frame) /** - * Interrupts are disabled and will be enabled by the function. + * Interrupts are disabled and will possibly be enabled by the function. */ void x86_handle_breakpoint_exception(struct iframe *frame)