Report "No hardware breakpoint support" correctly

Message ID 1405349255-26782-1-git-send-email-emachado@linux.vnet.ibm.com
State Committed
Headers

Commit Message

Edjunior Barbosa Machado July 14, 2014, 2:47 p.m. UTC
  Hi,

when trying to set a hardware breakpoint on Power server processors, gdb
currently reports "Hardware breakpoints used exceeds limit." when in fact
hbreaks are not supported. With this patch, gdb will report "No hardware
breakpoint support in the target.", which seems to be more appropriate in this
case.
This also fixes the several unexpected failures in
gdb.base/watchpoint-reuse-slot.exp testcase, that didn't detect that hbreaks
are not supported in this target.
Ok?

Thanks and regards,
--
Edjunior

gdb/
2014-07-14  Edjunior Barbosa Machado  <emachado@linux.vnet.ibm.com>

	* gdb/ppc-linux-nat.c (ppc_linux_can_use_hw_breakpoint): Report no
	hardware breakpoint support correctly.

---
 gdb/ppc-linux-nat.c | 3 +++
 1 file changed, 3 insertions(+)
  

Comments

Joel Brobecker July 14, 2014, 4:13 p.m. UTC | #1
> gdb/
> 2014-07-14  Edjunior Barbosa Machado  <emachado@linux.vnet.ibm.com>
> 
> 	* gdb/ppc-linux-nat.c (ppc_linux_can_use_hw_breakpoint): Report no
> 	hardware breakpoint support correctly.

Just one itty bitty tiny little nit:

> ---
>  gdb/ppc-linux-nat.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/gdb/ppc-linux-nat.c b/gdb/ppc-linux-nat.c
> index fcfd452..4c5d878 100644
> --- a/gdb/ppc-linux-nat.c
> +++ b/gdb/ppc-linux-nat.c
> @@ -1473,6 +1473,9 @@ ppc_linux_can_use_hw_breakpoint (struct target_ops *self,
>      }
>    else if (type == bp_hardware_breakpoint)
>      {
> +      if (total_hw_bp == 0)
> +	/* No hardware breakpoint support. */
> +	return 0;

Can you nest the contents of the if block inside curly braces.
We've decided a while ago that a comment looks visually like
a statement, and thus that comment + statement looks the same
as 2 statements, and thus normally requires curly braces...

Thanks!
  

Patch

diff --git a/gdb/ppc-linux-nat.c b/gdb/ppc-linux-nat.c
index fcfd452..4c5d878 100644
--- a/gdb/ppc-linux-nat.c
+++ b/gdb/ppc-linux-nat.c
@@ -1473,6 +1473,9 @@  ppc_linux_can_use_hw_breakpoint (struct target_ops *self,
     }
   else if (type == bp_hardware_breakpoint)
     {
+      if (total_hw_bp == 0)
+	/* No hardware breakpoint support. */
+	return 0;
       if (cnt > total_hw_bp)
 	return -1;
     }