aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.base/memattr.exp
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2012-08-27 08:58:01 +0000
committerPedro Alves <palves@redhat.com>2012-08-27 08:58:01 +0000
commit1591a1e8523aff54250fd7376b0ceeb83e5f2b15 (patch)
treef13bdd89527a676bbd1afe716bf354a71cabab3e /gdb/testsuite/gdb.base/memattr.exp
parentf4b8daea2addae0f9bc702040c2381d69fb35fb8 (diff)
downloadgdb-1591a1e8523aff54250fd7376b0ceeb83e5f2b15.zip
gdb-1591a1e8523aff54250fd7376b0ceeb83e5f2b15.tar.gz
gdb-1591a1e8523aff54250fd7376b0ceeb83e5f2b15.tar.bz2
2012-08-27 Wei-cheng Wang <cole945@gmail.com>
* memattr.c (create_mem_region): Fix memory region overlapping checking. 2012-08-27 Wei-cheng Wang <cole945@gmail.com> Yao Qi <yao@codesourcery.com> Pedro Alves <palves@redhat.com> * gdb.base/memattr.exp (delete_memory, region_pass, region_fail): New procedures. (top level): Add overlap checking tests.
Diffstat (limited to 'gdb/testsuite/gdb.base/memattr.exp')
-rw-r--r--gdb/testsuite/gdb.base/memattr.exp92
1 files changed, 92 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.base/memattr.exp b/gdb/testsuite/gdb.base/memattr.exp
index 4065808..0528dce 100644
--- a/gdb/testsuite/gdb.base/memattr.exp
+++ b/gdb/testsuite/gdb.base/memattr.exp
@@ -448,3 +448,95 @@ gdb_test_multiple "info mem" "mem 2-4 were deleted" {
gdb_test "delete mem 8" "No memory region number 8." \
"delete non-existant region"
+
+#
+# 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 } {
+ gdb_test_no_output "mem $region ro" "$region: no-overlap"
+}
+
+# Try to create a region that overlaps (a FAIL in the table).
+
+proc region_fail { region } {
+ gdb_test "mem $region ro" "overlapping memory region" "$region: overlap"
+}
+
+# Test normal case (upper != 0)
+#
+# lo' hi'
+# |--------|
+# 10 20 30 40 50 60 70 80 90
+# |-----| FAIL
+# |--| FAIL
+# |--| FAIL
+# |--| FAIL
+# |-----| FAIL
+# |--------| FAIL
+# |--------------| FAIL
+# |--------------------- FAIL
+# |------------------ FAIL
+# |--------------- FAIL
+# |--| PASS
+# |--| PASS
+# |--- PASS
+
+delete_memory
+gdb_test_no_output "mem 0x30 0x60 ro"
+with_test_prefix "0x30 0x60" {
+ region_fail "0x20 0x40"
+ region_fail "0x30 0x40"
+ region_fail "0x40 0x50"
+ region_fail "0x50 0x60"
+ region_fail "0x50 0x70"
+ region_fail "0x30 0x60"
+ region_fail "0x20 0x70"
+ region_fail "0x20 0x0"
+ region_fail "0x30 0x0"
+ region_fail "0x40 0x0"
+ region_pass "0x20 0x30"
+ region_pass "0x60 0x70"
+ region_pass "0x80 0x0"
+}
+
+# Test special case (upper == 0)
+#
+# lo' hi'
+# |---------------
+# 00 10 20 30 40 50 60 70 80
+# |--------| FAIL
+# |-----| FAIL
+# |--| FAIL
+# |------------------ FAIL
+# |--------------- FAIL
+# |------------ FAIL
+# |--| PASS
+# |--| PASS
+
+delete_memory
+gdb_test_no_output "mem 0x30 0x0 ro"
+with_test_prefix "0x30 0x0" {
+ region_fail "0x20 0x50"
+ region_fail "0x30 0x50"
+ region_fail "0x40 0x50"
+ region_fail "0x20 0x0"
+ region_fail "0x30 0x0"
+ region_fail "0x40 0x0"
+ region_pass "0x20 0x30"
+ region_pass "0x00 0x10"
+}