public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Return zero in aarch64_linux_can_use_hw_breakpoint if target doesn't support HW watchpoint/breakpoint
@ 2015-07-07 16:30 Yao Qi
  2015-07-07 16:36 ` Joel Brobecker
  0 siblings, 1 reply; 4+ messages in thread
From: Yao Qi @ 2015-07-07 16:30 UTC (permalink / raw)
  To: gdb-patches

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-07  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.
---
 gdb/aarch64-linux-nat.c | 29 +++++++++++++++++++++--------
 1 file changed, 21 insertions(+), 8 deletions(-)

diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c
index cafd824..2cd20d1 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 (FALSE);
+
+  /* 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;
 }
 
-- 
1.9.1

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Return zero in aarch64_linux_can_use_hw_breakpoint if target doesn't support HW watchpoint/breakpoint
  2015-07-07 16:30 [PATCH] Return zero in aarch64_linux_can_use_hw_breakpoint if target doesn't support HW watchpoint/breakpoint Yao Qi
@ 2015-07-07 16:36 ` Joel Brobecker
  2015-07-08  8:10   ` Yao Qi
  0 siblings, 1 reply; 4+ messages in thread
From: Joel Brobecker @ 2015-07-07 16:36 UTC (permalink / raw)
  To: Yao Qi; +Cc: gdb-patches

> +  else
> +    gdb_assert (FALSE);

Use gdb_assert_not_reached instead?

-- 
Joel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Return zero in aarch64_linux_can_use_hw_breakpoint if target doesn't support HW watchpoint/breakpoint
  2015-07-07 16:36 ` Joel Brobecker
@ 2015-07-08  8:10   ` Yao Qi
  2015-07-23 10:23     ` Yao Qi
  0 siblings, 1 reply; 4+ messages in thread
From: Yao Qi @ 2015-07-08  8:10 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: Yao Qi, gdb-patches

Joel Brobecker <brobecker@adacore.com> writes:

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

Good point.  Patch is updated to fix this.

-- 
Yao (齐尧)

From 79122a045b43a844de70612bf45ad8dee7f218b1 Mon Sep 17 00:00:00 2001
From: Yao Qi <yao.qi@linaro.org>
Date: Fri, 19 Jun 2015 12:21:27 +0100
Subject: [PATCH] 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-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.

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;
 }

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Return zero in aarch64_linux_can_use_hw_breakpoint if target doesn't support HW watchpoint/breakpoint
  2015-07-08  8:10   ` Yao Qi
@ 2015-07-23 10:23     ` Yao Qi
  0 siblings, 0 replies; 4+ messages in thread
From: Yao Qi @ 2015-07-23 10:23 UTC (permalink / raw)
  To: Yao Qi; +Cc: gdb-patches

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.

-- 
Yao (齐尧)

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-07-23 10:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-07 16:30 [PATCH] Return zero in aarch64_linux_can_use_hw_breakpoint if target doesn't support HW watchpoint/breakpoint Yao Qi
2015-07-07 16:36 ` Joel Brobecker
2015-07-08  8:10   ` Yao Qi
2015-07-23 10:23     ` Yao Qi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).