diff options
author | Yao Qi <yao@codesourcery.com> | 2014-08-07 16:09:38 +0800 |
---|---|---|
committer | Yao Qi <yao@codesourcery.com> | 2014-08-09 08:46:32 +0800 |
commit | 20c6f1e176f4139ed1e76d4256e70149e38c0820 (patch) | |
tree | 8b75b294fe07e0e89650e997f9594a14897454e5 /gdb/testsuite/gdb.python | |
parent | 5792e8e37be2f848152115fd4783b0e28b5253ad (diff) | |
download | binutils-20c6f1e176f4139ed1e76d4256e70149e38c0820.zip binutils-20c6f1e176f4139ed1e76d4256e70149e38c0820.tar.gz binutils-20c6f1e176f4139ed1e76d4256e70149e38c0820.tar.bz2 |
Remove duplicated code on checking address 0x0 is accessiable
I find some gdb.python tests fail on arm-none-eabi target, because the
tests assume that memory on address 0x is inaccessible. Some tests
(in gdb.base) are aware of this, so do a "x 0" check first. However,
the code is copy-n-paste.
This patch is to move the "x 0" check to a procedure in lib/gdb.exp,
and get needed tests call it. The original code matches pattern
"0x0:\[ \t\]*Error accessing memory address 0x0\r\n$gdb_prompt $", but
I remove it from the new proc is_address_zero_readable, because GDB
doesn't emit such message any more.
gdb/testsuite:
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.
Diffstat (limited to 'gdb/testsuite/gdb.python')
-rw-r--r-- | gdb/testsuite/gdb.python/py-arch.exp | 8 | ||||
-rw-r--r-- | gdb/testsuite/gdb.python/py-prettyprint.exp | 5 | ||||
-rw-r--r-- | gdb/testsuite/gdb.python/py-value.exp | 9 |
3 files changed, 10 insertions, 12 deletions
diff --git a/gdb/testsuite/gdb.python/py-arch.exp b/gdb/testsuite/gdb.python/py-arch.exp index a49d50a..554f05f 100644 --- a/gdb/testsuite/gdb.python/py-arch.exp +++ b/gdb/testsuite/gdb.python/py-arch.exp @@ -57,6 +57,8 @@ gdb_test "python print (\"addr\" in insn)" "True" "test key addr" 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" +} diff --git a/gdb/testsuite/gdb.python/py-prettyprint.exp b/gdb/testsuite/gdb.python/py-prettyprint.exp index 491b52d..1096389 100644 --- a/gdb/testsuite/gdb.python/py-prettyprint.exp +++ b/gdb/testsuite/gdb.python/py-prettyprint.exp @@ -83,7 +83,10 @@ proc run_lang_tests {exefile lang} { 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\"" diff --git a/gdb/testsuite/gdb.python/py-value.exp b/gdb/testsuite/gdb.python/py-value.exp index 13433fd..0728266 100644 --- a/gdb/testsuite/gdb.python/py-value.exp +++ b/gdb/testsuite/gdb.python/py-value.exp @@ -234,14 +234,7 @@ proc test_value_in_inferior {} { # 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" |