diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 16c549c85b..3427db896e 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,14 @@ +2017-01-26 Luis Machado + + * 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. + 2017-01-26 Luis Machado * gdb.reverse/insn-reverse.c: Move arm and aarch64 code to their own diff --git a/gdb/testsuite/gdb.base/breakpoint-in-ro-region.exp b/gdb/testsuite/gdb.base/breakpoint-in-ro-region.exp index 7c3bd46737..122b04d284 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 5e37187a07..48f0496c04 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" diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 2ff5c22a1d..48bd7eefbd 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -28,6 +28,7 @@ if {$tool == ""} { load_lib libgloss.exp load_lib cache.exp load_lib gdb-utils.exp +load_lib memory.exp global GDB diff --git a/gdb/testsuite/lib/memory.exp b/gdb/testsuite/lib/memory.exp new file mode 100644 index 0000000000..62dd8ada77 --- /dev/null +++ b/gdb/testsuite/lib/memory.exp @@ -0,0 +1,33 @@ +# Copyright 2012-2017 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 . + +# This file holds functions and data dealing with memory checks and other memory +# manipulation routines. + +# Deletes all 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 $" { } + } +} + +