@@ -137,6 +137,8 @@ if ![get_function_bounds "main" main_lo main_hi] {
return -1
}
+delete_memory_regions
+
# Manually create a read-only memory region that covers 'main'.
gdb_test_no_output "mem $main_lo $main_hi ro" \
"create read-only mem region covering main"
@@ -25,6 +25,8 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile] } {
runto main
+delete_memory_regions
+
set mem1start -1
set mem2start -1
set mem3start -1
@@ -487,18 +489,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 +520,7 @@ proc region_fail { region } {
# |--| PASS
# |--- PASS
-delete_memory
+delete_memory_regions
gdb_test_no_output "mem 0x30 0x60 ro"
with_test_prefix "0x30 0x60" {
region_fail "0x20 0x40"
@@ -562,7 +552,7 @@ with_test_prefix "0x30 0x60" {
# |--| PASS
# |--| PASS
-delete_memory
+delete_memory_regions
gdb_test_no_output "mem 0x30 0x0 ro"
with_test_prefix "0x30 0x0" {
region_fail "0x20 0x50"
new file mode 100644
@@ -0,0 +1,33 @@
+# Copyright 2012 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# This file holds functions and data dealing with memory checks and other memory
+# manipulation routines.
+
+# Deletes all the target-supplied memory regions GDB currently knows about.
+
+proc delete_memory_regions {} {
+ 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 $" { }
+ }
+}
+
+
@@ -28,6 +28,7 @@ if {$tool == ""} {
load_lib libgloss.exp
load_lib cache.exp
load_lib gdb-utils.exp
+load_lib gdb-memory.exp
global GDB