summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYao Qi <yao@codesourcery.com>2014-05-28 12:38:52 +0800
committerYao Qi <yao@codesourcery.com>2014-06-01 11:46:39 +0800
commitc72b2e7b2fbadd94f67a922e1a7f9d834dd45d38 (patch)
treef4067420d5e9b21d642a65385fb73051a4424917
parent11b28b91b2c51898e1347e62909811cc7dd720ea (diff)
downloadbinutils-gdb-c72b2e7b2fbadd94f67a922e1a7f9d834dd45d38.tar.gz
Skip test 'watch -location nullptr->p->x' if null pointer can be dereferenced
gdb.base/watchpoint.exp has a test below which expects to see "Cannot access memory at address 0x0" when a null pointer is dereferenced. gdb_test "watch -location nullptr->p->x" \ "Cannot access memory at address 0x0" This assumption is not true when the target is no-mmu, so we get watch -location nullptr->p->x Hardware watchpoint 28: -location nullptr->p->x (gdb) FAIL: gdb.base/watchpoint.exp: watch -location nullptr->p->x This patch is to check whether null pointer can be dereferenced first and then do the test. gdb/testsuite: 2014-06-01 Yao Qi <yao@codesourcery.com> * gdb.base/watchpoint.exp (test_watch_location): Check null pointer can be dereferenced. If not, do the test, otherwise skip it.
-rw-r--r--gdb/testsuite/ChangeLog6
-rw-r--r--gdb/testsuite/gdb.base/watchpoint.exp14
2 files changed, 18 insertions, 2 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index a931862ad56..06818af9e8e 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2014-06-01 Yao Qi <yao@codesourcery.com>
+
+ * gdb.base/watchpoint.exp (test_watch_location): Check null
+ pointer can be dereferenced. If not, do the test, otherwise
+ skip it.
+
2014-05-30 Andrew Burgess <aburgess@broadcom.com>
* gdb.arch/amd64-invalid-stack-middle.exp: Update expected
diff --git a/gdb/testsuite/gdb.base/watchpoint.exp b/gdb/testsuite/gdb.base/watchpoint.exp
index 1123824e0e5..c41b4fd91f7 100644
--- a/gdb/testsuite/gdb.base/watchpoint.exp
+++ b/gdb/testsuite/gdb.base/watchpoint.exp
@@ -595,11 +595,21 @@ proc test_disable_enable_software_watchpoint {} {
}
proc test_watch_location {} {
+ global gdb_prompt
+
gdb_breakpoint [gdb_get_line_number "func5 breakpoint here"]
gdb_continue_to_breakpoint "func5 breakpoint here"
- gdb_test "watch -location nullptr->p->x" \
- "Cannot access memory at address 0x0"
+ # Check first if a null pointer can be dereferenced on the target.
+ gdb_test_multiple "p *nullptr" "" {
+ -re "Cannot access memory at address 0x0.*$gdb_prompt $" {
+ gdb_test "watch -location nullptr->p->x" \
+ "Cannot access memory at address 0x0"
+ }
+ -re ".*$gdb_prompt $" {
+ # Null pointer dereference is legitimate.
+ }
+ }
gdb_test "watch -location *x" "atchpoint .*: .*" "watch -location .x"