diff mbox

[testsuite] Probe awatch/rwatch support

Message ID 1429011949-28215-1-git-send-email-qiyaoltc@gmail.com
State New
Headers show

Commit Message

Yao Qi April 14, 2015, 11:45 a.m. UTC
From: Yao Qi <yao.qi@linaro.org>

I see some awatch/rwatch related fails on one arm board which doesn't hw
watchpoint or it is not enabled in the kernel, like this,

  rwatch global^M
  Expression cannot be implemented with read/access watchpoint.^M
  (gdb) FAIL: gdb.base/break-idempotent.exp: always-inserted off: rwatch: once: rwatch global

Although we've had a proc skip_hw_watchpoint_access_tests to check
whether rwatch/awatch is supported according to target triplet, it
isn't accurate because HW watchpoint support varies on different
processor implementations and linux kernel of the same arch.

This patch is to probe the awatch/rwatch support in a new proc
gdb_read_access_watchpoint, and callers just bail out the test
if awatch/rwatch isn't supported or isn't successfully created.
This patch skips these tests on native arm-linux testing, so fails
go away.

-FAIL: gdb.base/break-idempotent.exp: always-inserted off: rwatch: once: rwatch global
-FAIL: gdb.base/break-idempotent.exp: always-inserted off: rwatch: twice: rwatch global
-FAIL: gdb.base/break-idempotent.exp: always-inserted off: awatch: once: awatch global
-FAIL: gdb.base/break-idempotent.exp: always-inserted off: awatch: twice: awatch global
-FAIL: gdb.base/break-idempotent.exp: always-inserted on: rwatch: once: rwatch global
-FAIL: gdb.base/break-idempotent.exp: always-inserted on: rwatch: twice: rwatch global
-FAIL: gdb.base/break-idempotent.exp: always-inserted on: awatch: once: awatch global
-FAIL: gdb.base/break-idempotent.exp: always-inserted on: awatch: twice: awatch global
-FAIL: gdb.base/watch-read.exp: set hardware read watchpoint on global variable
-FAIL: gdb.base/watch-read.exp: read watchpoint triggers on first read (timeout)
-FAIL: gdb.base/watch-read.exp: read watchpoint triggers on read after value changed (timeout)
-FAIL: gdb.base/watch-read.exp: set write watchpoint on global variable (timeout)
-FAIL: gdb.base/watch-read.exp: write watchpoint triggers (timeout)
-FAIL: gdb.base/watch-read.exp: only write watchpoint triggers when value changes (timeout)
-FAIL: gdb.base/watch-read.exp: read watchpoint triggers when value doesn't change, trapping reads and writes (timeout)
-FAIL: gdb.base/watch-read.exp: only read watchpoint triggers when value doesn't change (timeout)
-FAIL: gdb.base/watch_thread_num.exp: Watchpoint on shared variable
-FAIL: gdb.base/watch_thread_num.exp: info breakpoint shows watchpoint is thread-specific
-FAIL: gdb.base/watch_thread_num.exp: Watchpoint triggered iteration 1 (timeout)
-FAIL: gdb.base/watch_thread_num.exp: Check thread that triggered iteration 1 (timeout)
-FAIL: gdb.base/watch_thread_num.exp: Watchpoint triggered iteration 2 (timeout)
-FAIL: gdb.base/watch_thread_num.exp: Check thread that triggered iteration 2 (timeout)
-FAIL: gdb.base/watch_thread_num.exp: Watchpoint triggered iteration 3 (timeout)
-FAIL: gdb.base/watch_thread_num.exp: Check thread that triggered iteration 3 (timeout)
-FAIL: gdb.base/watch_thread_num.exp: Watchpoint triggered iteration 4 (timeout)
-FAIL: gdb.base/watch_thread_num.exp: Check thread that triggered iteration 4 (timeout)
-FAIL: gdb.base/watch_thread_num.exp: Watchpoint triggered iteration 5 (timeout)
-FAIL: gdb.base/watch_thread_num.exp: Check thread that triggered iteration 5 (timeout)
-FAIL: gdb.base/watchpoint-hw-hit-once.exp: continue
-FAIL: gdb.base/watchpoint-hw-hit-once.exp: continue to break-at-exit (the program exited)
-FAIL: gdb.multi/watchpoint-multi.exp: awatch c on inferior 2

this patch should also fix fails in gdb.base/watch_thread_num.exp on
s390x, which were reporeted here:

  https://www.sourceware.org/ml/gdb-testers/2015-q2/msg01663.html

gdb/testsuite:

2015-04-14  Yao Qi  <yao.qi@linaro.org>

	* gdb.base/break-idempotent.exp (set_breakpoint): Match the
	output for read/access watchpoint.
	* gdb.base/watch-read.exp: Invoke gdb_read_access_watchpoint
	and return if it returns false.
	* gdb.base/watch_thread_num.exp: Likewise.
	* gdb.base/watchpoint-hw-hit-once.exp: Likewise.
	* gdb.multi/watchpoint-multi.exp: Likewise.
	* gdb.base/watchpoint-reuse-slot.exp: Match the output
	for read/access watchpoint.
	* lib/gdb.exp (gdb_read_access_watchpoint): New proc.
---
 gdb/testsuite/gdb.base/break-idempotent.exp       |  7 +++++++
 gdb/testsuite/gdb.base/watch-read.exp             |  8 ++++----
 gdb/testsuite/gdb.base/watch_thread_num.exp       |  7 ++++---
 gdb/testsuite/gdb.base/watchpoint-hw-hit-once.exp |  4 +++-
 gdb/testsuite/gdb.base/watchpoint-reuse-slot.exp  |  3 +++
 gdb/testsuite/gdb.multi/watchpoint-multi.exp      |  6 +++---
 gdb/testsuite/lib/gdb.exp                         | 25 +++++++++++++++++++++++
 7 files changed, 49 insertions(+), 11 deletions(-)
diff mbox

Patch

diff --git a/gdb/testsuite/gdb.base/break-idempotent.exp b/gdb/testsuite/gdb.base/break-idempotent.exp
index c5dae96..ef7db22 100644
--- a/gdb/testsuite/gdb.base/break-idempotent.exp
+++ b/gdb/testsuite/gdb.base/break-idempotent.exp
@@ -107,6 +107,13 @@  proc set_breakpoint { break_command } {
 	    -re "Could not insert hardware watchpoint.*$gdb_prompt $" {
 		unsupported $test
 	    }
+	    -re "Expression cannot be implemented with read/access watchpoint..*$gdb_prompt $" {
+		if { $break_command == "watch" } {
+		    fail $test
+		} else {
+		    unsupported $test
+		}
+	    }
 	    -re "atchpoint \[0-9\]+: global\r\n$gdb_prompt $" {
 		pass $test
 	    }
diff --git a/gdb/testsuite/gdb.base/watch-read.exp b/gdb/testsuite/gdb.base/watch-read.exp
index ddba14e..4bf9a9e 100644
--- a/gdb/testsuite/gdb.base/watch-read.exp
+++ b/gdb/testsuite/gdb.base/watch-read.exp
@@ -42,10 +42,10 @@  set read_line [gdb_get_line_number "read line" $srcfile]
 
 # Test running to a read of `global', with a read watchpoint set
 # watching it.
-
-gdb_test "rwatch global" \
-    "Hardware read watchpoint .*: global" \
-    "set hardware read watchpoint on global variable"
+if { ![gdb_read_access_watchpoint "rwatch" "global" \
+	   "set hardware read watchpoint on global variable"] } {
+    return
+}
 
 # The first read is on entry to the loop.
 
diff --git a/gdb/testsuite/gdb.base/watch_thread_num.exp b/gdb/testsuite/gdb.base/watch_thread_num.exp
index d559f22..1995e5d 100644
--- a/gdb/testsuite/gdb.base/watch_thread_num.exp
+++ b/gdb/testsuite/gdb.base/watch_thread_num.exp
@@ -71,9 +71,10 @@  delete_breakpoints
 # simultaneously, on targets with continuable watchpoints, such as
 # x86.  See PR breakpoints/10116.
 
-gdb_test "awatch shared_var thread $thread_num" \
-    "Hardware access \\(read/write\\) watchpoint .*: shared_var.*" \
-    "Watchpoint on shared variable"
+if { ![gdb_read_access_watchpoint "awatch" "shared_var thread $thread_num" \
+	   "Watchpoint on shared variable"] } {
+    return
+}
 
 gdb_test "info breakpoint \$bpnum" \
     "stop only in thread $thread_num" \
diff --git a/gdb/testsuite/gdb.base/watchpoint-hw-hit-once.exp b/gdb/testsuite/gdb.base/watchpoint-hw-hit-once.exp
index 7ae76e0..d0aa2b9 100644
--- a/gdb/testsuite/gdb.base/watchpoint-hw-hit-once.exp
+++ b/gdb/testsuite/gdb.base/watchpoint-hw-hit-once.exp
@@ -27,7 +27,9 @@  if ![runto_main] {
     return -1
 }
 
-gdb_test "rwatch watchee"
+if { ![gdb_read_access_watchpoint "rwatch" "watchee" "rwatch watchee"] } {
+    return
+}
 
 gdb_breakpoint [gdb_get_line_number "dummy = 2"]
 
diff --git a/gdb/testsuite/gdb.base/watchpoint-reuse-slot.exp b/gdb/testsuite/gdb.base/watchpoint-reuse-slot.exp
index abe81d6..d9a7cee 100644
--- a/gdb/testsuite/gdb.base/watchpoint-reuse-slot.exp
+++ b/gdb/testsuite/gdb.base/watchpoint-reuse-slot.exp
@@ -106,6 +106,9 @@  foreach cmd {"watch" "awatch" "rwatch"} {
 	-re "Target does not support.*$gdb_prompt $" {
 	    unsupported $test
 	}
+	-re "Expression cannot be implemented with read/access watchpoint..*$gdb_prompt $" {
+	    unsupported $test
+	}
 	-re "$gdb_prompt $" {
 	    pass $test
 	    lappend cmds $cmd
diff --git a/gdb/testsuite/gdb.multi/watchpoint-multi.exp b/gdb/testsuite/gdb.multi/watchpoint-multi.exp
index dcf2f1b..7cd437f 100644
--- a/gdb/testsuite/gdb.multi/watchpoint-multi.exp
+++ b/gdb/testsuite/gdb.multi/watchpoint-multi.exp
@@ -60,9 +60,9 @@  gdb_load $binfile
 gdb_breakpoint main {temporary}
 gdb_test "run" "Temporary breakpoint.* main .*" "start to main inferior 2"
 
-gdb_test "awatch c" \
-    "Hardware access \\(read/write\\) watchpoint \[0-9\]+: c" \
-    "awatch c on inferior 2"
+if { ![gdb_read_access_watchpoint "awatch" "c" "awatch c on inferior 2"] } {
+    return
+}
 
 gdb_breakpoint "marker_exit"
 
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index f1616e3..1448fba 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -455,6 +455,31 @@  proc gdb_breakpoint { function args } {
     return 1
 }    
 
+# Insert read/access watchpoint on location LOC.  TYPE is either rwatch
+# or awatch.  Emit PASS, FAIL or UNSUPPORTED in test summary.  Return 1
+# for success, 0 for failure.
+
+proc gdb_read_access_watchpoint { type loc message } {
+    global gdb_prompt
+
+    gdb_test_multiple "$type $loc" $message {
+	-re "Target does not support this type of hardware watchpoint\\.\r\n$gdb_prompt $" {
+	    unsupported $message
+	}
+	-re "Could not insert hardware watchpoint.*$gdb_prompt $" {
+	    unsupported $message
+	}
+	-re "Expression cannot be implemented with read/access watchpoint..*$gdb_prompt $" {
+	    unsupported $message
+	}
+	-re "Hardware .* watchpoint .*: .*\r\n$gdb_prompt $" {
+	    pass $message
+	    return 1
+	}
+    }
+    return 0;
+}
+
 # Set breakpoint at function and run gdb until it breaks there.
 # Since this is the only breakpoint that will be set, if it stops
 # at a breakpoint, we will assume it is the one we want.  We can't