Messages in this thread Patch in this message | | | From | Andi Kleen <> | Subject | [PATCH 3/6] x86, ptrace: Ifdef HW_BREAKPOINTS code in ptrace | Date | Fri, 4 Oct 2013 14:39:45 -0700 |
| |
From: Andi Kleen <ak@linux.intel.com>
Add ifdefs on CONFIG_HW_BREAKPOINTS to the hardware break point code in x86 ptrace.c. This prepares this file for being able to disable HW_BREAKPOINTS.
The only debug register that needs to be handled without break points is DR6, so do that in a simple separate function without breakpoints.
Cc: fweisbec@gmail.com Signed-off-by: Andi Kleen <ak@linux.intel.com> --- arch/x86/kernel/ptrace.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+)
diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c index 7461f50..dda433f 100644 --- a/arch/x86/kernel/ptrace.c +++ b/arch/x86/kernel/ptrace.c @@ -561,6 +561,8 @@ static int genregs_set(struct task_struct *target, return ret; } +#ifdef CONFIG_HW_BREAKPOINTS + static void ptrace_triggered(struct perf_event *bp, struct perf_sample_data *data, struct pt_regs *regs) @@ -778,6 +780,34 @@ static int ptrace_set_debugreg(struct task_struct *tsk, int n, return rc; } +#else + +/* Without breakpoints only handle DR6 */ +static unsigned long ptrace_get_debugreg(struct task_struct *tsk, int n) +{ + struct thread_struct *thread = &tsk->thread; + + if (n == 6) + return thread->debugreg6; + return 0; +} + +/* Without breakpoints only handle DR6 */ +static int ptrace_set_debugreg(struct task_struct *tsk, int n, + unsigned long val) +{ + struct thread_struct *thread = &tsk->thread; + int rc = -EIO; + + if (n == 6) { + thread->debugreg6 = val; + rc = 0; + } + return rc; +} + +#endif + /* * These access the current or another (stopped) task's io permission * bitmap for debugging or core dump. -- 1.8.3.1
| |