1 # Copyright 2018-2019 Free Software Foundation, Inc.
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.
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.
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/>.
18 set cflags "-mindirect-branch=thunk -mfunction-return=thunk"
19 if { [prepare_for_testing "failed to prepare" $testfile $srcfile \
20 [list debug "additional_flags=$cflags"]] } {
24 if { ![runto_main] } {
25 untested "failed to run to main"
29 # Do repeated instruction steps in order to reach TARGET from CURRENT
31 # CURRENT is a string matching the current location
32 # TARGET is a string matching the target location
33 # TEST is the test name
35 # The function issues repeated "stepi" commands as long as the location
36 # matches CURRENT up to a maximum of 100 steps.
38 # TEST passes if the resulting location matches TARGET and fails
41 proc stepi_until { current target test } {
45 gdb_test_multiple "stepi" "$test" {
46 -re "$current.*$gdb_prompt $" {
55 -re "$target.*$gdb_prompt $" {
61 # Normal stepping steps through all thunks.
62 gdb_test "step" "thrice\.2.*" "step into thrice"
63 gdb_test "next" "thrice\.3.*" "step through thunks and over inc"
64 gdb_test "step" "inc\.2.*" "step through call thunk into inc"
65 gdb_test "step" "inc\.3.*" "step inside inc"
66 gdb_test "step" "thrice\.4.*" "step through return thunk back into thrice"
68 # We can use instruction stepping to step into thunks.
69 stepi_until "thrice" "indirect_thunk" "stepi into call thunk"
70 stepi_until "indirect_thunk" "inc." "stepi out of call thunk into inc"
71 stepi_until "inc" "return_thunk" "stepi into return thunk"
72 stepi_until "return_thunk" "thrice" \
73 "stepi out of return thunk back into thrice"