1# Copyright 2012-2024 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 16# Step over breakpoints with displaced stepping on, against Valgrind. 17# We can't really use displaced stepping with Valgrind, so what this 18# really tests is that GDB falls back to in-line stepping 19# automatically instead of getting stuck or crashing. 20 21# Valgrind gdbserver requires gdb with xml support. 22require allow_xml_test 23 24load_lib valgrind.exp 25 26require {!is_remote target} 27 28standard_testfile .c 29if {[build_executable "failed to build" $testfile $srcfile {debug}] == -1} { 30 return -1 31} 32 33if { [vgdb_start] == -1 } { 34 return -1 35} 36 37gdb_test_no_output "set displaced-stepping off" 38gdb_breakpoint "main" "breakpoint at main" 39gdb_test "continue" " stop 0 .*" "continue to main" 40delete_breakpoints 41 42set curr_stop 0 43foreach displaced { "off" "on" } { 44 with_test_prefix "displaced $displaced" { 45 46 gdb_test_no_output "set displaced-stepping $displaced" 47 48 foreach go { "once" "twice" } { 49 with_test_prefix $go { 50 gdb_test "break" "Breakpoint .* at .*" "set breakpoint" 51 52 # Whether we should see a warning. 53 set should_warn [expr {$go == "once" && $displaced == "on"}] 54 55 incr curr_stop 56 57 set msg "step over breakpoint" 58 set pattern " stop $curr_stop .*$gdb_prompt $" 59 gdb_test_multiple "next" $msg { 60 -re "warning: disabling displaced stepping.*$pattern" { 61 gdb_assert $should_warn $msg 62 } 63 -re "$pattern" { 64 gdb_assert !$should_warn $msg 65 } 66 } 67 } 68 } 69 } 70} 71 72vgdb_stop 73