+2014-08-09 Yao Qi <yao@codesourcery.com>
+
+ * gdb.base/display.exp: Invoke is_address_zero_readable.
+ * gdb.guile/scm-value.exp (test_value_in_inferior): Likewise.
+ * gdb.python/py-value.exp (test_value_in_inferior): Likewise.
+ * gdb.base/hbreak-unmapped.exp: Return if
+ is_address_zero_readable returns true.
+ * gdb.base/signest.exp: Likewise.
+ * gdb.base/signull.exp: Likewise.
+ * gdb.base/sigbpt.exp: Likewise.
+ * gdb.guile/scm-disasm.exp: Do the test if
+ is_address_zero_readable returns false.
+ * gdb.guile/scm-pretty-print.exp (run_lang_tests): Likewise.
+ * gdb.python/py-arch.exp: Likewise.
+ * gdb.python/py-prettyprint.exp (run_lang_tests): Likewise.
+ * lib/gdb.exp (is_address_zero_readable): New proc.
+
2014-08-09 Yao Qi <yao@codesourcery.com>
PR testsuite/13443
# Test displaying a variable that is temporarily at a bad address.
# But if we can examine what's at memory address 0, then we'll also be
# able to display it without error. Don't run the test in that case.
-set can_read_0 0
-gdb_test_multiple "x 0" "memory at address 0" {
- -re "0x0:.*Cannot access memory at address 0x0.*$gdb_prompt $" { }
- -re "0x0:.*Error accessing memory address 0x0.*$gdb_prompt $" { }
- -re ".*$gdb_prompt $" {
- set can_read_0 1
- }
-}
+set can_read_0 [is_address_zero_readable]
if { !$can_read_0 } {
gdb_test "disp *p_i" ".*: \\*p_i = 0"
}
# If we can read the memory at address 0, skip the test.
-gdb_test_multiple "x 0" "memory at address 0" {
- -re "0x0:.*Cannot access memory at address 0x0.*$gdb_prompt $" { }
- -re "0x0:.*Error accessing memory address 0x0.*$gdb_prompt $" { }
- -re ".*$gdb_prompt $" {
- untested "Memory at address 0 is readable"
- return
- }
+if { [is_address_zero_readable] } {
+ untested "Memory at address 0 is readable"
+ return
}
delete_breakpoints
# especially on targets without an MMU. Don't run the tests in that
# case.
-gdb_test_multiple "x 0" "memory at address 0" {
- -re "0x0:.*Cannot access memory at address 0x0.*$gdb_prompt $" { }
- -re "0x0:.*Error accessing memory address 0x0.*$gdb_prompt $" { }
- -re ".*$gdb_prompt $" {
- untested "Memory at address 0 is possibly executable"
- return
- }
+if { [is_address_zero_readable] } {
+ untested "Memory at address 0 is possibly executable"
+ return
}
gdb_test "break keeper"
# especially on targets without an MMU. Don't run the tests in that
# case.
-gdb_test_multiple "x 0" "memory at address 0" {
- -re "0x0:.*Cannot access memory at address 0x0.*$gdb_prompt $" { }
- -re "0x0:.*Error accessing memory address 0x0.*$gdb_prompt $" { }
- -re ".*$gdb_prompt $" {
- untested "Memory at address 0 is possibly executable"
- return -1
- }
+if { [is_address_zero_readable] } {
+ untested "Memory at address 0 is possibly executable"
+ return -1
}
# Run until we hit the SIGSEGV (or SIGBUS on some platforms).
# especially on targets without an MMU. Don't run the tests in that
# case.
-gdb_test_multiple "x 0" "memory at address 0" {
- -re "0x0:.*Cannot access memory at address 0x0.*$gdb_prompt $" { }
- -re "0x0:.*Error accessing memory address 0x0.*$gdb_prompt $" { }
- -re ".*$gdb_prompt $" {
- untested "Memory at address 0 is possibly executable"
- return
- }
+if { [is_address_zero_readable] } {
+ untested "Memory at address 0 is possibly executable"
+ return
}
# If an attempt to call a NULL pointer leaves the inferior in main,
test_disassemble_1 "basic" "pc" ""
-# Negative test
-gdb_test "guile (arch-disassemble arch 0 #:size 1)" \
- "ERROR: Cannot access memory at address 0x.*" "test bad memory access"
+if { ![is_address_zero_readable] } {
+ # Negative test
+ gdb_test "guile (arch-disassemble arch 0 #:size 1)" \
+ "ERROR: Cannot access memory at address 0x.*" "test bad memory access"
+}
# Test disassembly through a port.
gdb_scm_test_silent_cmd "set print elements 200" "" 1
}
- gdb_test "print ns2" "<error reading variable: ERROR: Cannot access memory at address 0x0>"
+ if { ![is_address_zero_readable] } {
+ gdb_test "print ns2" "<error reading variable: ERROR: Cannot access memory at address 0x0>"
+ }
gdb_test "print x" " = \"this is x\""
gdb_test "print cstring" " = \"const string\""
# Test displaying a variable that is temporarily at a bad address.
# But if we can examine what's at memory address 0, then we'll also be
# able to display it without error. Don't run the test in that case.
- set can_read_0 0
- gdb_test_multiple "x 0" "memory at address 0" {
- -re "0x0:\[ \t\]*Cannot access memory at address 0x0\r\n$gdb_prompt $" { }
- -re "0x0:\[ \t\]*Error accessing memory address 0x0\r\n$gdb_prompt $" { }
- -re "\r\n$gdb_prompt $" {
- set can_read_0 1
- }
- }
+ set can_read_0 [is_address_zero_readable]
# Test memory error.
set test "parse_and_eval with memory error"
gdb_test "python print (\"asm\" in insn)" "True" "test key asm"
gdb_test "python print (\"length\" in insn)" "True" "test key length"
-# Negative test
-gdb_test "python arch.disassemble(0, 0)" ".*gdb\.MemoryError.*" \
- "test bad memory access"
+if { ![is_address_zero_readable] } {
+ # Negative test
+ gdb_test "python arch.disassemble(0, 0)" ".*gdb\.MemoryError.*" \
+ "test bad memory access"
+}
gdb_py_test_silent_cmd "set print elements 200" "" 1
}
- gdb_test "print ns2" ".error reading variable: Cannot access memory at address 0x0."
+ if { ![is_address_zero_readable] } {
+ gdb_test "print ns2" \
+ ".error reading variable: Cannot access memory at address 0x0."
+ }
gdb_test "print x" " = \"this is x\""
gdb_test "print cstring" " = \"const string\""
# Test displaying a variable that is temporarily at a bad address.
# But if we can examine what's at memory address 0, then we'll also be
# able to display it without error. Don't run the test in that case.
- set can_read_0 0
- gdb_test_multiple "x 0" "memory at address 0" {
- -re "0x0:\[ \t\]*Cannot access memory at address 0x0\r\n$gdb_prompt $" { }
- -re "0x0:\[ \t\]*Error accessing memory address 0x0\r\n$gdb_prompt $" { }
- -re "\r\n$gdb_prompt $" {
- set can_read_0 1
- }
- }
+ set can_read_0 [is_address_zero_readable]
# Test memory error.
set test "parse_and_eval with memory error"
return 1
}
+# Return 1 if the memory at address zero is readable.
+
+gdb_caching_proc is_address_zero_readable {
+ global gdb_prompt
+
+ set ret 0
+ gdb_test_multiple "x 0" "" {
+ -re "Cannot access memory at address 0x0.*$gdb_prompt $" {
+ set ret 0
+ }
+ -re ".*$gdb_prompt $" {
+ set ret 1
+ }
+ }
+
+ return $ret
+}
+
# Produce source file NAME and write SOURCES into it.
proc gdb_produce_source { name sources } {