1# Copyright 2015-2023 Free Software Foundation, Inc. 2# This program is free software; you can redistribute it and/or modify 3# it under the terms of the GNU General Public License as published by 4# the Free Software Foundation; either version 3 of the License, or 5# (at your option) any later version. 6# 7# This program is distributed in the hope that it will be useful, 8# but WITHOUT ANY WARRANTY; without even the implied warranty of 9# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10# GNU General Public License for more details. 11# 12# You should have received a copy of the GNU General Public License 13# along with this program. If not, see <http://www.gnu.org/licenses/>. 14 15standard_testfile insn-reloc.c 16set executable $testfile 17set expfile $testfile.exp 18 19if { ![support_displaced_stepping] } { 20 unsupported "displaced stepping" 21 return -1 22} 23 24# Some targets have leading underscores on assembly symbols. 25set additional_flags [gdb_target_symbol_prefix_flags] 26 27if [prepare_for_testing "failed to prepare" $executable $srcfile \ 28 [list debug $additional_flags]] { 29 return -1 30} 31 32if ![runto_main] { 33 return -1 34} 35 36# Read function name from testcases[N]. 37 38proc read_testcase { n } { 39 global gdb_prompt 40 41 set result -1 42 gdb_test_multiple "print testcases\[${n}\]" "read name of test case ${n}" { 43 -re "\[$\].*= .*<(.*)>.*$gdb_prompt $" { 44 set result $expect_out(1,string) 45 } 46 -re "$gdb_prompt $" { } 47 } 48 49 return $result 50} 51 52set n_testcases [get_integer_valueof "n_testcases" 0] 53if { ${n_testcases} == 0 } { 54 untested "no instruction relocation to test" 55 return 1 56} 57 58# Set a fast tracepoint on each set_point${i} symbol. There is one for 59# each testcase. 60for { set i 0 } { ${i} < ${n_testcases} } { incr i } { 61 set testcase [read_testcase $i] 62 63 gdb_test "break *set_point$i" "Breakpoint .*" "breakpoint on ${testcase}" 64} 65 66gdb_test "break pass" ".*" "" 67gdb_test "break fail" ".*" "" 68 69gdb_test_no_output "set displaced-stepping on" 70 71# Make sure we have hit the pass breakpoint for each testcase. 72for { set i 0 } { ${i} < ${n_testcases} } { incr i } { 73 set testcase [read_testcase $i] 74 75 with_test_prefix "${testcase}" { 76 gdb_test "continue" ".*Breakpoint \[0-9\]+, .*" \ 77 "go to breakpoint $i" 78 79 gdb_test "continue" ".*Breakpoint \[0-9\]+, pass \(\).*" \ 80 "relocated instruction" 81 } 82} 83