Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 323849
b: refs/heads/master
c: 848e8f5
h: refs/heads/master
i:
  323847: 5715599
v: v3
  • Loading branch information
Oleg Nesterov committed Sep 15, 2012
1 parent 5a5089b commit 465a862
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 21 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: bdc1e47217315be14ba04881b0a4c8ecb3ff320c
refs/heads/master: 848e8f5f0ad3169560c516fff6471be65f76e69f
41 changes: 21 additions & 20 deletions trunk/arch/x86/kernel/step.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,21 @@ static int enable_single_step(struct task_struct *child)
return 1;
}

static void set_task_blockstep(struct task_struct *task, bool on)
{
unsigned long debugctl;

debugctl = get_debugctlmsr();
if (on) {
debugctl |= DEBUGCTLMSR_BTF;
set_tsk_thread_flag(task, TIF_BLOCKSTEP);
} else {
debugctl &= ~DEBUGCTLMSR_BTF;
clear_tsk_thread_flag(task, TIF_BLOCKSTEP);
}
update_debugctlmsr(debugctl);
}

/*
* Enable single or block step.
*/
Expand All @@ -169,19 +184,10 @@ static void enable_step(struct task_struct *child, bool block)
* So no one should try to use debugger block stepping in a program
* that uses user-mode single stepping itself.
*/
if (enable_single_step(child) && block) {
unsigned long debugctl = get_debugctlmsr();

debugctl |= DEBUGCTLMSR_BTF;
update_debugctlmsr(debugctl);
set_tsk_thread_flag(child, TIF_BLOCKSTEP);
} else if (test_tsk_thread_flag(child, TIF_BLOCKSTEP)) {
unsigned long debugctl = get_debugctlmsr();

debugctl &= ~DEBUGCTLMSR_BTF;
update_debugctlmsr(debugctl);
clear_tsk_thread_flag(child, TIF_BLOCKSTEP);
}
if (enable_single_step(child) && block)
set_task_blockstep(child, true);
else if (test_tsk_thread_flag(child, TIF_BLOCKSTEP))
set_task_blockstep(child, false);
}

void user_enable_single_step(struct task_struct *child)
Expand All @@ -199,13 +205,8 @@ void user_disable_single_step(struct task_struct *child)
/*
* Make sure block stepping (BTF) is disabled.
*/
if (test_tsk_thread_flag(child, TIF_BLOCKSTEP)) {
unsigned long debugctl = get_debugctlmsr();

debugctl &= ~DEBUGCTLMSR_BTF;
update_debugctlmsr(debugctl);
clear_tsk_thread_flag(child, TIF_BLOCKSTEP);
}
if (test_tsk_thread_flag(child, TIF_BLOCKSTEP))
set_task_blockstep(child, false);

/* Always clear TIF_SINGLESTEP... */
clear_tsk_thread_flag(child, TIF_SINGLESTEP);
Expand Down

0 comments on commit 465a862

Please sign in to comment.