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] watchpoint-reuse-slot.exp: skip setting HW breakpoints on some address


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

commit ca5fd19bfb2a41fae7696d67d1f4dce5d5a9053a
Author: Yao Qi <yao.qi@linaro.org>
Date:   Fri Mar 13 10:56:01 2015 +0000

    watchpoint-reuse-slot.exp: skip setting HW breakpoints on some address
    
    We see some fails in watchpoint-reuse-slot.exp on aarch64-linux, because
    it sets some HW breakpoint on some address doesn't meet the alignment
    requirements by kernel, kernel will reject the
    ptrace (PTRACE_SETHBPREGS) call, and some fails are caused, for example:
    
    (gdb) PASS: gdb.base/watchpoint-reuse-slot.exp: always-inserted off: watch x hbreak: : width 1, iter 0: base + 0: delete $bpnum
    hbreak *(buf.byte + 0 + 1)^M
    Hardware assisted breakpoint 80 at 0x410a61^M
    (gdb) PASS: gdb.base/watchpoint-reuse-slot.exp: always-inserted off: watch x hbreak: : width 1, iter 0: base + 1: hbreak *(buf.byte + 0 + 1)
    stepi^M
    Warning:^M
    Cannot insert hardware breakpoint 80.^M
    Could not insert hardware breakpoints:^M
    You may have requested too many hardware breakpoints/watchpoints.^M
    ^M
    (gdb) FAIL: gdb.base/watchpoint-reuse-slot.exp: always-inserted off: watch x hbreak: : width 1, iter 0: base + 1: stepi advanced
    
    hbreak *(buf.byte + 0 + 1)^M
    Hardware assisted breakpoint 440 at 0x410a61^M
    Warning:^M
    Cannot insert hardware breakpoint 440.^M
    Could not insert hardware breakpoints:^M
    You may have requested too many hardware breakpoints/watchpoints.^M
    ^M
    (gdb) FAIL: gdb.base/watchpoint-reuse-slot.exp: always-inserted on: watch x hbreak: : width 1, iter 0: base + 1: hbreak *(buf.byte + 0 + 1)
    
    This patch is to skip some tests by checking proc valid_addr_p.
    We can handle other targets in valid_addr_p too.
    
    gdb/testsuite:
    
    2015-03-16  Yao Qi  <yao.qi@linaro.org>
    
    	* gdb.base/watchpoint-reuse-slot.exp (valid_addr_p): New proc.
    	(top level): Skip tests if valid_addr_p returns false for
    	$cmd1 or $cmd2.

Diff:
---
 gdb/testsuite/ChangeLog                          |  6 +++++
 gdb/testsuite/gdb.base/watchpoint-reuse-slot.exp | 31 ++++++++++++++++++++++++
 2 files changed, 37 insertions(+)

diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 76dcde5..c182e7c 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2015-03-16  Yao Qi  <yao.qi@linaro.org>
+
+	* gdb.base/watchpoint-reuse-slot.exp (valid_addr_p): New proc.
+	(top level): Skip tests if valid_addr_p returns false for
+	$cmd1 or $cmd2.
+
 2015-03-11  Andy Wingo  <wingo@igalia.com>
 
 	* gdb.guile/scm-objfile.exp: Add objfile-progspace test.
diff --git a/gdb/testsuite/gdb.base/watchpoint-reuse-slot.exp b/gdb/testsuite/gdb.base/watchpoint-reuse-slot.exp
index 844bf3a..6d2c867 100644
--- a/gdb/testsuite/gdb.base/watchpoint-reuse-slot.exp
+++ b/gdb/testsuite/gdb.base/watchpoint-reuse-slot.exp
@@ -133,6 +133,28 @@ delete_breakpoints
 
 set cur_addr [get_pc]
 
+# Return true if the memory range [buf.byte + OFFSET, +WIDTH] can be
+# monitored by CMD, otherwise return false.
+
+proc valid_addr_p {cmd offset width} {
+
+    if { [istarget "aarch64*-*-linux*"] } {
+	# The aarch64 Linux kernel port only accepts 4-byte aligned addresses
+	# for hardware breakpoints and 8-byte aligned addresses for hardware
+	# watchpoints.  However, both GDB and GDBserver support unaligned
+	# watchpoints by using more than one properly aligned watchpoint
+	# registers to represent the whole unaligned region.  Breakpoint
+	# addresses must still be aligned though.
+	if {$cmd == "hbreak" } {
+	    if { [expr ($offset) % 4] != 0 } {
+		return 0
+	    }
+	}
+    }
+
+    return 1
+}
+
 # Watch WIDTH bytes at BASE + OFFSET.  CMD specifices the specific
 # type of watchpoint to use.  If CMD is "hbreak", WIDTH is ignored.
 
@@ -172,6 +194,15 @@ foreach always_inserted {"off" "on" } {
 		}
 
 		for {set x 0} {$x < 4} {incr x} {
+
+		    if { ![valid_addr_p $cmd1 $x $width]
+			 || ![valid_addr_p $cmd2 $x+1 $width] } {
+			# Skip tests if requested address or length
+			# of breakpoint or watchpoint don't meet
+			# target or kernel requirements.
+			continue
+		    }
+
 		    set prefix "always-inserted $always_inserted: "
 		    append prefix "$cmd1 x $cmd2: "
 		    with_test_prefix "$prefix: width $width, iter $x" {


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