Skip to contentSkip to conversation

Enable hardware breakpoint upon re-registering

PATCH In review Aravinda Prasad 2 participants 2 messages Nov 5, 2012 – Nov 6, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Enable hardware breakpoint upon re-registering

On powerpc, ptrace will disable hardware breakpoint request once the breakpoint is hit. It is the responsibility of the caller to set it again. However, when the caller sets the hardware breakpoint again using ptrace(PTRACE_SET_DEBUGREG, child_pid, 0, addr), the hardware breakpoint is not enabled.

While gdb's approach is to unregister and re-register the hardware breakpoint every time the breakpoint is hit - which is working fine, this could affect other programs trying to re-register hardware breakpoint without unregistering.

This patch enables hardware breakpoint if the caller is re-registering.

---
 arch/powerpc/kernel/ptrace.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
arch/powerpc/kernel/ptrace.c +4 -0
index 79d8e56..09371d0 100644
@@ -952,6 +952,10 @@ int ptrace_set_debugreg(struct task_struct *task, unsigned long addr,
 		arch_bp_generic_fields(data &
 					(DABR_DATA_WRITE | DABR_DATA_READ),
 							&attr.bp_type);
+
+		/* Enable breakpoint */
+		attr.disabled = false;
+
 		ret =  modify_user_hw_breakpoint(bp, &attr);
 		if (ret) {
 			ptrace_put_breakpoints(task);
Acked-by on v1 1/1
#1 lore raw
Quoted 6 lines · Aravinda Prasad

On powerpc, ptrace will disable hardware breakpoint request once the breakpoint is hit. It is the responsibility of the caller to set it again. However, when the caller sets the hardware breakpoint again using ptrace(PTRACE_SET_DEBUGREG, child_pid, 0, addr), the hardware breakpoint is not enabled.

Quoted 8 lines

While gdb's approach is to unregister and re-register the hardware breakpoint every time the breakpoint is hit - which is working fine, this could affect other programs trying to re-register hardware breakpoint without unregistering.

This patch enables hardware breakpoint if the caller is re-registering.

Passes my tests here and I don't think it'll break existing gdb. So FWIW

Thanks!

Quoted 25 lines
---
 arch/powerpc/kernel/ptrace.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
arch/powerpc/kernel/ptrace.c +4 -0
index 79d8e56..09371d0 100644
@@ -952,6 +952,10 @@ int ptrace_set_debugreg(struct task_struct *task, unsigned long addr,
 		arch_bp_generic_fields(data &
 					(DABR_DATA_WRITE | DABR_DATA_READ),
 							&attr.bp_type);
+
+		/* Enable breakpoint */
+		attr.disabled = false;
+
 		ret =  modify_user_hw_breakpoint(bp, &attr);
 		if (ret) {
 			ptrace_put_breakpoints(task);

_______________________________________________
Linuxppc-dev mailing list
[email protected]
https://lists.ozlabs.org/listinfo/linuxppc-dev