aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.base
diff options
context:
space:
mode:
authorLuis Machado <lgustavo@codesourcery.com>2017-01-26 13:51:09 -0600
committerLuis Machado <lgustavo@codesourcery.com>2017-01-26 13:51:09 -0600
commite309aa6524f8becadf6f1b75060a74be4c221899 (patch)
tree2fb9c2a3d7a73674cf999166fad7aa7c3a2e9073 /gdb/testsuite/gdb.base
parent7cf1de6cf421f52b145b88055cc89fc666343fba (diff)
downloadgdb-e309aa6524f8becadf6f1b75060a74be4c221899.zip
gdb-e309aa6524f8becadf6f1b75060a74be4c221899.tar.gz
gdb-e309aa6524f8becadf6f1b75060a74be4c221899.tar.bz2
Harden tests that deal with memory regions
Exercising aarch64-elf with a custom debug stub i noticed a few failures in both gdb.base/breakpoint-in-ro-region.exp and gdb.base/memattr.exp: FAIL: gdb.base/breakpoint-in-ro-region.exp: create read-only mem region covering main FAIL: gdb.base/breakpoint-in-ro-region.exp: writing to read-only memory fails FAIL: gdb.base/breakpoint-in-ro-region.exp: inserting software breakpoint in read-only memory fails FAIL: gdb.base/memattr.exp: create mem region 1 FAIL: gdb.base/memattr.exp: create mem region 2 FAIL: gdb.base/memattr.exp: create mem region 3 FAIL: gdb.base/memattr.exp: create mem region 4 FAIL: gdb.base/memattr.exp: create mem region 5 FAIL: gdb.base/memattr.exp: info mem (1) FAIL: gdb.base/memattr.exp: mem1 cannot be read FAIL: gdb.base/memattr.exp: mem2 cannot be written FAIL: gdb.base/memattr.exp: mem2 can be read FAIL: gdb.base/memattr.exp: disable mem 1 FAIL: gdb.base/memattr.exp: mem 1 was disabled FAIL: gdb.base/memattr.exp: enable mem 1 FAIL: gdb.base/memattr.exp: mem 1 was enabled FAIL: gdb.base/memattr.exp: disable mem 2 4 FAIL: gdb.base/memattr.exp: mem 2 and 4 were disabled FAIL: gdb.base/memattr.exp: enable mem 2-4 FAIL: gdb.base/memattr.exp: mem 2-4 were enabled FAIL: gdb.base/memattr.exp: mem 1 to 5 were disabled FAIL: gdb.base/memattr.exp: mem 1 to 5 were enabled FAIL: gdb.base/memattr.exp: delete mem 1 FAIL: gdb.base/memattr.exp: mem 1 was deleted FAIL: gdb.base/memattr.exp: delete mem 2 4 FAIL: gdb.base/memattr.exp: mem 2 and 4 were deleted FAIL: gdb.base/memattr.exp: mem 2-4 were deleted These failures don't show up with gdbserver or native gdb on Linux because they don't export any memory maps, therefore the vector of memory regions is empty. Outside of that scenario, we can't guarantee the absence of memory regions reported by the target upon a connection. In our particular target, we provide a memory map and the memory regions vector ceases to be empty. With a non-empty memory regions vector, manipulating memory regions will cause gdb to be more verbose and output text. For example: memattr.c:require_user_regions /* Otherwise, let the user know how to get back. */ if (from_tty) warning (_("Switching to manual control of memory regions; use " "\"mem auto\" to fetch regions from the target again.")); memattr.c:create_mem_region if ((lo >= n->lo && (lo < n->hi || n->hi == 0)) || (hi > n->lo && (hi <= n->hi || n->hi == 0)) || (lo <= n->lo && ((hi >= n->hi && n->hi != 0) || hi == 0))) { printf_unfiltered (_("overlapping memory region\n")); return; } In my particular case i got both of the above messages. In order to fix this, i've moved the delete_memory proc from gdb.base/memattr.exp to a new file lib/memory.exp and made lib/gdb.exp load that file. For both gdb.base/breakpoint-in-ro-region.exp and gdb.base/memattr.exp the patch clears all existing memory regions after running to main. That way we are guaranteed to have a clean state for memory regions so the tests can exercise whatever they want and have an expected output pattern. Regression checked on x86-64/Ubuntu 16.04. gdb/testsuite/ChangeLog: 2017-01-26 Luis Machado <lgustavo@codesourcery.com> * lib/memory.exp: New file. * lib/gdb.exp: Load memory.exp. * gdb.base/memattr.exp (delete_memory): Move proc to lib/memory.exp and rename to delete_memory_regions. Replace delete_memory with delete_memory_regions. Cleanup memory regions before tests. * gdb.base/breakpoint-in-ro-region.exp: Cleanup memory regions before tests.
Diffstat (limited to 'gdb/testsuite/gdb.base')
-rw-r--r--gdb/testsuite/gdb.base/breakpoint-in-ro-region.exp3
-rw-r--r--gdb/testsuite/gdb.base/memattr.exp21
2 files changed, 10 insertions, 14 deletions
diff --git a/gdb/testsuite/gdb.base/breakpoint-in-ro-region.exp b/gdb/testsuite/gdb.base/breakpoint-in-ro-region.exp
index 7c3bd46..122b04d 100644
--- a/gdb/testsuite/gdb.base/breakpoint-in-ro-region.exp
+++ b/gdb/testsuite/gdb.base/breakpoint-in-ro-region.exp
@@ -25,6 +25,9 @@ if ![runto main] {
return -1
}
+# Delete all target-supplied memory regions.
+delete_memory_regions
+
delete_breakpoints
# Probe for hardware stepping.
diff --git a/gdb/testsuite/gdb.base/memattr.exp b/gdb/testsuite/gdb.base/memattr.exp
index 5e37187..48f0496 100644
--- a/gdb/testsuite/gdb.base/memattr.exp
+++ b/gdb/testsuite/gdb.base/memattr.exp
@@ -25,6 +25,9 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile] } {
runto main
+# Delete all target-supplied memory regions.
+delete_memory_regions
+
set mem1start -1
set mem2start -1
set mem3start -1
@@ -487,18 +490,6 @@ gdb_test "delete mem 8" "No memory region number 8." \
# Test overlapping checking
#
-proc delete_memory {} {
- global gdb_prompt
-
- gdb_test_multiple "delete mem" "delete mem" {
- -re "Delete all memory regions.*y or n.*$" {
- send_gdb "y\n"
- exp_continue
- }
- -re "$gdb_prompt $" { }
- }
-}
-
# Create a region that doesn't overlap (a PASS in the table).
proc region_pass { region } {
@@ -530,7 +521,8 @@ proc region_fail { region } {
# |--| PASS
# |--- PASS
-delete_memory
+# Clear the memory regions list.
+delete_memory_regions
gdb_test_no_output "mem 0x30 0x60 ro"
with_test_prefix "0x30 0x60" {
region_fail "0x20 0x40"
@@ -562,7 +554,8 @@ with_test_prefix "0x30 0x60" {
# |--| PASS
# |--| PASS
-delete_memory
+# Clear the memory regions list.
+delete_memory_regions
gdb_test_no_output "mem 0x30 0x0 ro"
with_test_prefix "0x30 0x0" {
region_fail "0x20 0x50"