summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/ChangeLog6
-rw-r--r--gdb/ppc-linux-nat.c21
2 files changed, 18 insertions, 9 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 5fbc887cb11..5106b28523b 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,11 @@
2020-08-14 Pedro Franco de Carvalho <pedromfc@linux.ibm.com>
+ PR breakpoints/26385
+ * ppc-linux-nat.c (ppc_linux_nat_target::low_prepare_to_resume):
+ Always clear watchpoint with PTRACE_SET_DEBUGREG.
+
+2020-08-14 Pedro Franco de Carvalho <pedromfc@linux.ibm.com>
+
* ppc-linux-nat.c (ppc_linux_dreg_interface::detect)
(ppc_linux_nat_target::low_prepare_to_resume): Use ptrace () < 0
and >= to check return value instead of == -1 and != -1.
diff --git a/gdb/ppc-linux-nat.c b/gdb/ppc-linux-nat.c
index 89efdaebc0b..5f823d7eeb3 100644
--- a/gdb/ppc-linux-nat.c
+++ b/gdb/ppc-linux-nat.c
@@ -2909,20 +2909,23 @@ ppc_linux_nat_target::low_prepare_to_resume (struct lwp_info *lp)
{
gdb_assert (m_dreg_interface.debugreg_p ());
- /* Passing 0 to PTRACE_SET_DEBUGREG will clear the
- watchpoint. */
- long wp = 0;
+ /* Passing 0 to PTRACE_SET_DEBUGREG will clear the watchpoint. We
+ always clear the watchpoint instead of just overwriting it, in
+ case there is a request for a new watchpoint, because on some
+ older kernel versions and configurations simply overwriting the
+ watchpoint after it was hit would not re-enable it. */
+ if (ptrace (PTRACE_SET_DEBUGREG, lp->ptid.lwp (), 0, 0) < 0)
+ perror_with_name (_("Error clearing hardware watchpoint"));
/* GDB requested a watchpoint to be installed. */
if (process_it != m_process_info.end ()
&& process_it->second.requested_wp_val.has_value ())
- wp = *(process_it->second.requested_wp_val);
-
- long ret = ptrace (PTRACE_SET_DEBUGREG, lp->ptid.lwp (),
- 0, wp);
+ {
+ long wp = *(process_it->second.requested_wp_val);
- if (ret < 0)
- perror_with_name (_("Error setting hardware watchpoint"));
+ if (ptrace (PTRACE_SET_DEBUGREG, lp->ptid.lwp (), 0, wp) < 0)
+ perror_with_name (_("Error setting hardware watchpoint"));
+ }
}
lp_arch_info->debug_regs_stale = false;