[PATCH 3/6] x86, ptrace: Ifdef HW_BREAKPOINTS code in ptrace

From: Andi Kleen
Date: Fri Oct 04 2013 - 17:40:27 EST


From: Andi Kleen <ak@xxxxxxxxxxxxxxx>

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@xxxxxxxxx
Signed-off-by: Andi Kleen <ak@xxxxxxxxxxxxxxx>
---
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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/