This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] Fix memory-region overlapping checking
Hi Yao,
Thanks for your correction.
I wasn't aware of that rule and wondered what the message is used for.
After I reviewed the cases, I think the cases should be altered a little.
When testing against 0x30-0x0, 0x50-0x70 is no different than 0x40-0x50,
so I remove it and add various boundary cases.
Below is the altered one based on your fix.
--
Wei-cheng
2012-08-08 Wei-cheng Wang <cole945@gmail.com>
Yao Qi <yao@codesourcery.com>
* gdb.base/memattr.exp: Add cases for overlapping checking.
diff --git INDEX:/gdb/testsuite/gdb.base/memattr.exp
--- INDEX:/gdb/testsuite/gdb.base/memattr.exp
+++ WORKDIR:/gdb/testsuite/gdb.base/memattr.exp
@@ -448,3 +448,45 @@ 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
+#
+# lo' hi'
+# |---------|
+# 10 20 30 40 50 60 70 80
+# |----| FAIL
+# |--| FAIL
+# |---| FAIL
+# |--| FAIL
+# |----| FAIL
+# |---------| FAIL
+# |-------------| FAIL
+# |----------------- FAIL
+# |------------ FAIL
+# |--- FAIL
+# |----| PASS
+# |----| PASS
+
+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 $" { }
+ }
+}
+
+# Test normal case (upper != 0)
+delete_memory
+gdb_test_no_output "mem 0x30 0x60 ro"
+gdb_test "mem 0x20 0x40 ro" "overlapping memory region" "mem 0x20 0x40 1"
+gdb_test "mem 0x30 0x40 ro" "overlapping memory region" "mem 0x30 0x40 1"
+gdb_test "mem 0x40 0x50 ro" "overlapping memory region" "mem 0x40 0x50 1"
+gdb_test "mem 0x50 0x60 ro" "overlapping memory region" "mem 0x50 0x60 1"
+gdb_test "mem 0x30 0x60 ro" "overlapping memory region" "mem 0x30 0x60 1"
+gdb_test "mem 0x50 0x70 ro" "overlapping memory region" "mem 0x50 0x70 1"
+gdb_test "mem 0x20 0x0 ro" "overlapping memory region" "mem 0x20 0x0 1"
+gdb_test "mem 0x30 0x0 ro" "overlapping memory region" "mem 0x30 0x0 1"
+gdb_test_no_output "mem 0x10 0x30 ro" "mem 0x10 0x30 1"
+gdb_test_no_output "mem 0x60 0x80 ro" "mem 0x60 0x80 1"
+gdb_test_no_output "mem 0x80 0x0 ro" "mem 0x80 0x0 1"
+
+# Test special case (upper == 0)
+delete_memory
+gdb_test_no_output "mem 0x30 0x0 ro"
+gdb_test "mem 0x20 0x40 ro" "overlapping memory region" "mem 0x20 0x40 2"
+gdb_test "mem 0x30 0x40 ro" "overlapping memory region" "mem 0x30 0x40 2"
+gdb_test "mem 0x20 0x0 ro" "overlapping memory region" "mem 0x20 0x0 2"
+gdb_test "mem 0x30 0x0 ro" "overlapping memory region" "mem 0x30 0x0 2"
+gdb_test_no_output "mem 0x10 0x30 ro" "mem 0x10 0x30 2"