Return zero in aarch64_linux_can_use_hw_breakpoint if target doesn't support HW watchpoint/breakpoint

Message ID 867fqbnk8f.fsf@gmail.com
State New, archived
Headers

Commit Message

Yao Qi July 8, 2015, 8:09 a.m. UTC
  Joel Brobecker <brobecker@adacore.com> writes:

>> +  else
>> +    gdb_assert (FALSE);
>
> Use gdb_assert_not_reached instead?

Good point.  Patch is updated to fix this.
  

Comments

Yao Qi July 23, 2015, 10:23 a.m. UTC | #1
Yao Qi <qiyaoltc@gmail.com> writes:

> gdb:
>
> 2015-07-08  Yao Qi  <yao.qi@linaro.org>
>
> 	* aarch64-linux-nat.c (aarch64_linux_can_use_hw_breakpoint): If
> 	TYPE is watchpoint, return zero if aarch64_num_wp_regs is zero.
> 	If TYPE is breakpoint, return zero if arch64_num_bp_regs is zero.

I've pushed it in.
  

Patch

diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c
index cafd824..d5d0038 100644
--- a/gdb/aarch64-linux-nat.c
+++ b/gdb/aarch64-linux-nat.c
@@ -1051,19 +1051,32 @@  aarch64_align_watchpoint (CORE_ADDR addr, int len, CORE_ADDR *aligned_addr_p,
    bp_read_watchpoint, bp_write_watchpoint, or bp_hardware_breakpoint.
    CNT is the number of such watchpoints used so far (including this
    one).  OTHERTYPE is non-zero if other types of watchpoints are
-   currently enabled.
-
-   We always return 1 here because we don't have enough information
-   about possible overlap of addresses that they want to watch.  As an
-   extreme example, consider the case where all the watchpoints watch
-   the same address and the same region length: then we can handle a
-   virtually unlimited number of watchpoints, due to debug register
-   sharing implemented via reference counts.  */
+   currently enabled.  */
 
 static int
 aarch64_linux_can_use_hw_breakpoint (struct target_ops *self,
 				     int type, int cnt, int othertype)
 {
+  if (type == bp_hardware_watchpoint || type == bp_read_watchpoint
+      || type == bp_access_watchpoint || type == bp_watchpoint)
+    {
+      if (aarch64_num_wp_regs == 0)
+	return 0;
+    }
+  else if (type == bp_hardware_breakpoint)
+    {
+      if (aarch64_num_bp_regs == 0)
+	return 0;
+    }
+  else
+    gdb_assert_not_reached ("unexpected breakpoint type");
+
+  /* We always return 1 here because we don't have enough information
+     about possible overlap of addresses that they want to watch.  As an
+     extreme example, consider the case where all the watchpoints watch
+     the same address and the same region length: then we can handle a
+     virtually unlimited number of watchpoints, due to debug register
+     sharing implemented via reference counts.  */
   return 1;
 }