breakpoint-shadow.exp revision 1.8
1# Copyright 2008-2019 Free Software Foundation, Inc. 2 3# This program is free software; you can redistribute it and/or modify 4# it under the terms of the GNU General Public License as published by 5# the Free Software Foundation; either version 3 of the License, or 6# (at your option) any later version. 7# 8# This program is distributed in the hope that it will be useful, 9# but WITHOUT ANY WARRANTY; without even the implied warranty of 10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11# GNU General Public License for more details. 12# 13# You should have received a copy of the GNU General Public License 14# along with this program. If not, see <http://www.gnu.org/licenses/>. 15 16standard_testfile 17 18if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} { 19 return -1 20} 21 22# We need to start the inferior to place the breakpoints in the memory at all. 23if ![runto_main] { 24 untested start 25 return -1 26} 27 28# The default "auto" mode removes all the breakpoints when we stop (and not 29# running the nonstop mode). We would not be able to test the shadow. 30gdb_test_no_output "set breakpoint always-inserted on" 31gdb_test "show breakpoint always-inserted" "Always inserted breakpoint mode is on." 32 33set match "\nDump of assembler code for function main:\r\n(.*)End of assembler dump.\r\n$gdb_prompt $" 34 35set test "disassembly without breakpoints" 36gdb_test_multiple "disass main" $test { 37 -re $match { 38 set orig $expect_out(1,string) 39 pass $test 40 } 41} 42 43gdb_test "b [gdb_get_line_number "break-first"]" "Breakpoint \[0-9\] at .*" "first breakpoint placed" 44gdb_test "b [gdb_get_line_number "break-second"]" "Breakpoint \[0-9\] at .*" "second breakpoint placed" 45 46# Disassemble main, and compare the output to the original output 47# before breakpoints were inserted. TEST is used as test message. 48 49proc test_disassembly {test} { 50 global match orig 51 52 gdb_test_multiple "disass main" $test { 53 -re $match { 54 set got $expect_out(1,string) 55 if [string equal -nocase $orig $got] { 56 pass $test 57 } else { 58 fail $test 59 } 60 } 61 } 62} 63 64test_disassembly "disassembly with breakpoints" 65 66# Now check the interaction between the code cache and breakpoint 67# always-inserted mode. 68 69# Recreate the code cache when breakpoints are already inserted. 70gdb_test_no_output "set code-cache off" 71gdb_test_no_output "set code-cache on" 72 73test_disassembly "disassembly with breakpoints, fresh code cache" 74 75# Delete breakpoints. This should update the code cache as well. 76delete_breakpoints 77 78test_disassembly "disassembly without breakpoints, no stale breakpoints" 79