diff options
author | Luis Machado <lgustavo@codesourcery.com> | 2015-04-29 12:09:40 -0300 |
---|---|---|
committer | Luis Machado <lgustavo@codesourcery.com> | 2015-04-29 12:09:40 -0300 |
commit | ecbf2b3c4f5ee6c00cf058b87fa49708d4030d7f (patch) | |
tree | 088ad98a585552c4f7ef172cad7a919fe4df064c /gdb/testsuite/gdb.base/break-always.exp | |
parent | 0a13382c8e708fd9eb15dbc81cedc35e6670090c (diff) | |
download | gdb-ecbf2b3c4f5ee6c00cf058b87fa49708d4030d7f.zip gdb-ecbf2b3c4f5ee6c00cf058b87fa49708d4030d7f.tar.gz gdb-ecbf2b3c4f5ee6c00cf058b87fa49708d4030d7f.tar.bz2 |
Handle memory write errors on gdb.base/break-always.exp
This is another case of the testcase not handling memory write errors that
happen on some targets (QEMU) when GDB attempts to modify an address that
should contain a breakpoint, for example.
The following patch handles this and prevents spurious failures from
happening. It also adds a foreach loop to avoid duplication of code
and hardcoded patterns.
gdb/testsuite/ChangeLog:
2015-04-29 Luis Machado <lgustavo@codesourcery.com>
* gdb.base/break-always.exp: Abort testing if writing to memory
causes an error.
Diffstat (limited to 'gdb/testsuite/gdb.base/break-always.exp')
-rw-r--r-- | gdb/testsuite/gdb.base/break-always.exp | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/gdb/testsuite/gdb.base/break-always.exp b/gdb/testsuite/gdb.base/break-always.exp index 681be37..c45ce54 100644 --- a/gdb/testsuite/gdb.base/break-always.exp +++ b/gdb/testsuite/gdb.base/break-always.exp @@ -69,19 +69,25 @@ gdb_test "p /x \$shadow = *(char *) $bp_address" \ # and still leave the breakpoint insn planted. Try twice with # different values, in case we happen to be writting exactly what was # there already. -gdb_test "p /x *(char *) $bp_address = 0" \ - " = 0x0" \ - "write 0 to breakpoint's address" -gdb_test "p /x *(char *) $bp_address" \ - " = 0x0" \ - "read back 0 from the breakpoint's address" - -gdb_test "p /x *(char *) $bp_address = 1" \ - " = 0x1" \ - "write 1 to breakpoint's address" -gdb_test "p /x *(char *) $bp_address" \ - " = 0x1" \ - "read back 1 from the breakpoint's address" +foreach test_value {0 1} { + set write_test "write $test_value to breakpoint's address" + + gdb_test_multiple "p /x *(char *) $bp_address = $test_value" $write_test { + -re "Cannot access memory at address $hex.*$gdb_prompt $" { + + # Some targets do not allow manually writing a breakpoint to a + # certain memory address, like QEMU. In that case, just bail out. + unsupported "Cannot write to address $bp_address" + return -1 + } + -re " = .*$gdb_prompt $" { + pass $write_test + } + } + + set read_test "read back $test_value from the breakpoint's address" + gdb_test "p /x *(char *) $bp_address" " = 0x$test_value" $read_test +} # Restore the original contents. gdb_test "p /x *(char *) $bp_address = \$shadow" "" \ |