This is the mail archive of the gdb-cvs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] Return zero in aarch64_linux_can_use_hw_breakpoint if target doesn't support HW watchpoint/breakpoin


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=c2fbdc5901a9220d0953f14c27760c3d3ae13074

commit c2fbdc5901a9220d0953f14c27760c3d3ae13074
Author: Yao Qi <yao.qi@linaro.org>
Date:   Thu Jul 23 11:22:34 2015 +0100

    Return zero in aarch64_linux_can_use_hw_breakpoint if target doesn't support HW watchpoint/breakpoint
    
    Nowadays aarch64_linux_can_use_hw_breakpoint always return one, but it
    can be smarter, say, if GDB knows target doesn't support HW watchpoint
    or breakpoint because HW watchpoint/breakpoint is disabled in linux
    kernel, for example, it can safely return zero.
    
    gdb:
    
    2015-07-23  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.

Diff:
---
 gdb/ChangeLog           |  6 ++++++
 gdb/aarch64-linux-nat.c | 29 +++++++++++++++++++++--------
 2 files changed, 27 insertions(+), 8 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 69a086b..8f390a4 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,9 @@
+2015-07-23  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.
+
 2015-07-21  Yao Qi  <yao.qi@linaro.org>
 
 	* aarch64-linux-nat.c (aarch64_linux_get_debug_reg_capacity):
diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c
index 1c962b6..dae0c15 100644
--- a/gdb/aarch64-linux-nat.c
+++ b/gdb/aarch64-linux-nat.c
@@ -707,19 +707,32 @@ aarch64_linux_read_description (struct target_ops *ops)
    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;
 }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]