* 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
This commit is contained in:
Ingo Weinhold
2009-04-16 19:56:11 +00:00
parent 5e71c7b1e5
commit b447670286
3 changed files with 16 additions and 33 deletions
+2 -2
View File
@@ -18,8 +18,8 @@
// benaphore-style. // benaphore-style.
#define KDEBUG KDEBUG_LEVEL_2 #define KDEBUG KDEBUG_LEVEL_2
// Enable this to get support for kernel breakpoints. // Set to 0 to disable support for kernel breakpoints.
#define KERNEL_BREAKPOINTS 0 #define KERNEL_BREAKPOINTS 1
// block/file cache // block/file cache
+5 -20
View File
@@ -98,16 +98,11 @@
original eax/edx values */ \ original eax/edx values */ \
iret iret
#if KERNEL_BREAKPOINTS #define DISABLE_BREAKPOINTS() \
# define DISABLE_BREAKPOINTS() \ testl $THREAD_FLAGS_BREAKPOINTS_INSTALLED, THREAD_flags(%edi); \
call x86_exit_user_debug_at_kernel_entry; jz 1f; \
#else call x86_exit_user_debug_at_kernel_entry; \
# define DISABLE_BREAKPOINTS() \ 1:
testl $THREAD_FLAGS_BREAKPOINTS_INSTALLED, THREAD_flags(%edi); \
jz 1f; \
call x86_exit_user_debug_at_kernel_entry; \
1:
#endif // KERNEL_BREAKPOINTS
#define COPY_SYSCALL_PARAMETERS() \ #define COPY_SYSCALL_PARAMETERS() \
/* make room for the syscall params */ \ /* make room for the syscall params */ \
@@ -311,14 +306,10 @@ STATIC_FUNCTION(int_bottom_user):
cmp $USER_CODE_SEG, IFRAME_cs(%ebp) cmp $USER_CODE_SEG, IFRAME_cs(%ebp)
jne 1f jne 1f
#if KERNEL_BREAKPOINTS
jmp kernel_exit_work
#else
testl $(THREAD_FLAGS_DEBUGGER_INSTALLED | THREAD_FLAGS_SIGNALS_PENDING \ testl $(THREAD_FLAGS_DEBUGGER_INSTALLED | THREAD_FLAGS_SIGNALS_PENDING \
| THREAD_FLAGS_DEBUG_THREAD | THREAD_FLAGS_BREAKPOINTS_DEFINED) \ | THREAD_FLAGS_DEBUG_THREAD | THREAD_FLAGS_BREAKPOINTS_DEFINED) \
, THREAD_flags(%edi) , THREAD_flags(%edi)
jnz kernel_exit_work jnz kernel_exit_work
#endif
1: 1:
cli // disable interrupts cli // disable interrupts
@@ -422,16 +413,12 @@ STATIC_FUNCTION(handle_syscall):
TRACE_POST_SYSCALL() TRACE_POST_SYSCALL()
#if KERNEL_BREAKPOINTS
jmp post_syscall_work
#else
testl $(THREAD_FLAGS_DEBUGGER_INSTALLED | THREAD_FLAGS_SIGNALS_PENDING \ testl $(THREAD_FLAGS_DEBUGGER_INSTALLED | THREAD_FLAGS_SIGNALS_PENDING \
| THREAD_FLAGS_DEBUG_THREAD | THREAD_FLAGS_BREAKPOINTS_DEFINED \ | THREAD_FLAGS_DEBUG_THREAD | THREAD_FLAGS_BREAKPOINTS_DEFINED \
| THREAD_FLAGS_64_BIT_SYSCALL_RETURN \ | THREAD_FLAGS_64_BIT_SYSCALL_RETURN \
| THREAD_FLAGS_RESTART_SYSCALL | THREAD_FLAGS_SYSCALL_RESTARTED) \ | THREAD_FLAGS_RESTART_SYSCALL | THREAD_FLAGS_SYSCALL_RESTARTED) \
, THREAD_flags(%edi) , THREAD_flags(%edi)
jnz post_syscall_work jnz post_syscall_work
#endif
cli // disable interrupts cli // disable interrupts
@@ -507,10 +494,8 @@ FUNCTION_END(handle_syscall)
1: 1:
// install breakpoints, if defined // install breakpoints, if defined
#if !KERNEL_BREAKPOINTS
testl $THREAD_FLAGS_BREAKPOINTS_DEFINED, THREAD_flags(%edi) testl $THREAD_FLAGS_BREAKPOINTS_DEFINED, THREAD_flags(%edi)
jz 1f jz 1f
#endif
push %ebp push %ebp
call x86_init_user_debug_at_kernel_exit call x86_init_user_debug_at_kernel_exit
1: 1:
@@ -516,7 +516,7 @@ arch_update_thread_single_step()
{ {
if (struct iframe* frame = i386_get_user_iframe()) { if (struct iframe* frame = i386_get_user_iframe()) {
struct thread* thread = thread_get_current_thread(); struct thread* thread = thread_get_current_thread();
// set/clear TF in EFLAGS depending on if single stepping is desired // set/clear TF in EFLAGS depending on if single stepping is desired
if (thread->debug_info.flags & B_THREAD_DEBUG_SINGLE_STEP) if (thread->debug_info.flags & B_THREAD_DEBUG_SINGLE_STEP)
frame->flags |= (1 << X86_EFLAGS_TF); 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(); struct thread *thread = thread_get_current_thread();
#if !KERNEL_BREAKPOINTS
if (!(thread->flags & THREAD_FLAGS_BREAKPOINTS_DEFINED)) if (!(thread->flags & THREAD_FLAGS_BREAKPOINTS_DEFINED))
return; return;
#endif
// disable kernel breakpoints
disable_breakpoints();
GRAB_THREAD_LOCK(); GRAB_THREAD_LOCK();
GRAB_TEAM_DEBUG_INFO_LOCK(thread->team->debug_info); GRAB_TEAM_DEBUG_INFO_LOCK(thread->team->debug_info);
arch_team_debug_info &teamInfo = thread->team->debug_info.arch_info; arch_team_debug_info &teamInfo = thread->team->debug_info.arch_info;
// install the breakpoints // install the user breakpoints
install_breakpoints(teamInfo); install_breakpoints(teamInfo);
atomic_or(&thread->flags, THREAD_FLAGS_BREAKPOINTS_INSTALLED); 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(); struct thread *thread = thread_get_current_thread();
#if !KERNEL_BREAKPOINTS
if (!(thread->flags & THREAD_FLAGS_BREAKPOINTS_INSTALLED)) if (!(thread->flags & THREAD_FLAGS_BREAKPOINTS_INSTALLED))
return; return;
#endif
GRAB_THREAD_LOCK(); GRAB_THREAD_LOCK();
// disable breakpoints // disable user breakpoints
disable_breakpoints(); disable_breakpoints();
#if KERNEL_BREAKPOINTS // install kernel breakpoints
struct team* kernelTeam = team_get_kernel_team(); struct team* kernelTeam = team_get_kernel_team();
GRAB_TEAM_DEBUG_INFO_LOCK(kernelTeam->debug_info); GRAB_TEAM_DEBUG_INFO_LOCK(kernelTeam->debug_info);
install_breakpoints(kernelTeam->debug_info.arch_info); install_breakpoints(kernelTeam->debug_info.arch_info);
RELEASE_TEAM_DEBUG_INFO_LOCK(kernelTeam->debug_info); RELEASE_TEAM_DEBUG_INFO_LOCK(kernelTeam->debug_info);
#endif
atomic_and(&thread->flags, ~THREAD_FLAGS_BREAKPOINTS_INSTALLED); 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 void
x86_handle_debug_exception(struct iframe *frame) 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 void
x86_handle_breakpoint_exception(struct iframe *frame) x86_handle_breakpoint_exception(struct iframe *frame)