Patchwork return zero in arm_linux_can_use_hw_breakpoint if HW point isn't supported

login
register
mail settings
Submitter Yao Qi
Date April 17, 2015, 9:40 a.m.
Message ID <1429263600-4098-1-git-send-email-qiyaoltc@gmail.com>
Download mbox | patch
Permalink /patch/6278/
State New
Headers show

Comments

Yao Qi - April 17, 2015, 9:40 a.m.
From: Yao Qi <yao.qi@linaro.org>

This patch is to cherry-pick part of Pedro's patch here
https://sourceware.org/ml/gdb-patches/2015-04/msg00527.html in which
zero is returned if the HW point isn't supported.

In arm-linux native gdb testing on a board doesn't support HW breakpoint,
without this patch, the output in gdb.base/breakpoint-in-ro-region.exp is like:

(gdb) hbreak *0x83bc^M
Hardware breakpoints used exceeds limit.^M
(gdb) PASS: gdb.base/breakpoint-in-ro-region.exp: probe hbreak support (support)

with this patch, the output becomes:

(gdb) hbreak *0x83bc^M
No hardware breakpoint support in the target.^M
(gdb) PASS: gdb.base/breakpoint-in-ro-region.exp: probe hbreak support (no support)

As a result, the following fails are fixed.

-FAIL: gdb.base/breakpoint-in-ro-region.exp: always-inserted off: auto-hw on: step in ro region (cannot insert hw break)
-FAIL: gdb.base/breakpoint-in-ro-region.exp: always-inserted off: auto-hw on: thread advanced
-FAIL: gdb.base/breakpoint-in-ro-region.exp: always-inserted on: auto-hw on: step in ro region (cannot insert hw break)
-FAIL: gdb.base/breakpoint-in-ro-region.exp: always-inserted on: auto-hw on: thread advanced

gdb:

2015-04-17  Pedro Alves  <palves@redhat.com>

	* arm-linux-nat.c (arm_linux_can_use_hw_breakpoint): Return zero
	if HW point of TYPE isn't supported.
---
 gdb/arm-linux-nat.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
Pedro Alves - April 17, 2015, 11:12 a.m.
On 04/17/2015 10:40 AM, Yao Qi wrote:
> From: Yao Qi <yao.qi@linaro.org>
> 
> This patch is to cherry-pick part of Pedro's patch here
> https://sourceware.org/ml/gdb-patches/2015-04/msg00527.html in which
> zero is returned if the HW point isn't supported.
> 
> In arm-linux native gdb testing on a board doesn't support HW breakpoint,
> without this patch, the output in gdb.base/breakpoint-in-ro-region.exp is like:
> 
> (gdb) hbreak *0x83bc^M
> Hardware breakpoints used exceeds limit.^M
> (gdb) PASS: gdb.base/breakpoint-in-ro-region.exp: probe hbreak support (support)
> 
> with this patch, the output becomes:
> 
> (gdb) hbreak *0x83bc^M
> No hardware breakpoint support in the target.^M
> (gdb) PASS: gdb.base/breakpoint-in-ro-region.exp: probe hbreak support (no support)
> 
> As a result, the following fails are fixed.
> 
> -FAIL: gdb.base/breakpoint-in-ro-region.exp: always-inserted off: auto-hw on: step in ro region (cannot insert hw break)
> -FAIL: gdb.base/breakpoint-in-ro-region.exp: always-inserted off: auto-hw on: thread advanced
> -FAIL: gdb.base/breakpoint-in-ro-region.exp: always-inserted on: auto-hw on: step in ro region (cannot insert hw break)
> -FAIL: gdb.base/breakpoint-in-ro-region.exp: always-inserted on: auto-hw on: thread advanced
> 

Great, thanks for doing this.  Looks good to me, FWIW.  :-)

Thanks,
Pedro Alves
Yao Qi - April 17, 2015, 1:01 p.m.
Pedro Alves <palves@redhat.com> writes:

> Great, thanks for doing this.  Looks good to me, FWIW.  :-)

Thanks, patch is pushed in.

Patch

diff --git a/gdb/arm-linux-nat.c b/gdb/arm-linux-nat.c
index bb8358c..afc5817 100644
--- a/gdb/arm-linux-nat.c
+++ b/gdb/arm-linux-nat.c
@@ -771,12 +771,20 @@  arm_linux_can_use_hw_breakpoint (struct target_ops *self,
   if (type == bp_hardware_watchpoint || type == bp_read_watchpoint
       || type == bp_access_watchpoint || type == bp_watchpoint)
     {
-      if (cnt + ot > arm_linux_get_hw_watchpoint_count ())
+      int count = arm_linux_get_hw_watchpoint_count ();
+
+      if (count == 0)
+	return 0;
+      else if (cnt + ot > count)
 	return -1;
     }
   else if (type == bp_hardware_breakpoint)
     {
-      if (cnt > arm_linux_get_hw_breakpoint_count ())
+      int count = arm_linux_get_hw_breakpoint_count ();
+
+      if (count == 0)
+	return 0;
+      else if (cnt > count)
 	return -1;
     }
   else