2012-08-27 Wei-cheng Wang <cole945@gmail.com>
authorPedro Alves <palves@redhat.com>
Mon, 27 Aug 2012 08:58:01 +0000 (08:58 +0000)
committerPedro Alves <palves@redhat.com>
Mon, 27 Aug 2012 08:58:01 +0000 (08:58 +0000)
* 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.

gdb/ChangeLog
gdb/memattr.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.base/memattr.exp

index 666a35fd1324a2d8c39d0093b250f1158ed18147..d17f5331c7d236db2f406cf2b5c22d4f537dde8f 100644 (file)
@@ -1,3 +1,8 @@
+2012-08-27  Wei-cheng Wang  <cole945@gmail.com>
+
+       * memattr.c (create_mem_region): Fix memory region overlapping
+       checking.
+
 2012-08-24  Siddhesh Poyarekar  <siddhesh@redhat.com>
 
        * h8300-tdep.c (h8300_push_dummy_call): Replace unsafe alloca
index ec7deb5f54f84942be853714280fd946cb3f0327..bd92f1d00882412473dc98fa56c87fceb5cd9f04 100644 (file)
@@ -207,7 +207,7 @@ create_mem_region (CORE_ADDR lo, CORE_ADDR hi,
 
       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 || hi == 0)))
+         || (lo <= n->lo && ((hi >= n->hi && n->hi != 0) || hi == 0)))
        {
          printf_unfiltered (_("overlapping memory region\n"));
          return;
index c78f4fb2be3f3812f9726ae26a1abdfe2f8445e9..153339be6791230ae572f062aa07466a26b35a04 100644 (file)
@@ -1,3 +1,11 @@
+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.
+
 2012-08-24  Tom Tromey  <tromey@redhat.com>
 
        * lib/gdb.exp (skip_unwinder_tests): Don't leave 'ok' set if
index 4065808997748868ba90e9e2d323569ea9033d29..0528dceb92804ecbbca9a6275663ae3efc1b8d19 100644 (file)
@@ -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"
+}
This page took 0.048015 seconds and 4 git commands to generate.