]>
Commit | Line | Data |
---|---|---|
1d506c26 | 1 | # Copyright 2018-2024 Free Software Foundation, Inc. |
1d509aa6 MM |
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 | standard_testfile | |
17 | ||
24d59b55 | 18 | require {istarget "x86*"} |
43127ae5 | 19 | |
9d9dd861 TV |
20 | set cflags "-mindirect-branch=thunk -mfunction-return=thunk" |
21 | ||
22 | if { [gcc_major_version] >= 8 } { | |
23 | append cflags " -fcf-protection=none" | |
24 | } | |
1d509aa6 MM |
25 | if { [prepare_for_testing "failed to prepare" $testfile $srcfile \ |
26 | [list debug "additional_flags=$cflags"]] } { | |
27 | return -1 | |
28 | } | |
29 | ||
30 | if { ![runto_main] } { | |
1d509aa6 MM |
31 | return -1 |
32 | } | |
33 | ||
34 | # Do repeated instruction steps in order to reach TARGET from CURRENT | |
35 | # | |
36 | # CURRENT is a string matching the current location | |
37 | # TARGET is a string matching the target location | |
38 | # TEST is the test name | |
39 | # | |
40 | # The function issues repeated "stepi" commands as long as the location | |
41 | # matches CURRENT up to a maximum of 100 steps. | |
42 | # | |
43 | # TEST passes if the resulting location matches TARGET and fails | |
44 | # otherwise. | |
45 | # | |
46 | proc stepi_until { current target test } { | |
47 | global gdb_prompt | |
48 | ||
49 | set count 0 | |
50 | gdb_test_multiple "stepi" "$test" { | |
51 | -re "$current.*$gdb_prompt $" { | |
52 | incr count | |
53 | if { $count < 100 } { | |
54 | send_gdb "stepi\n" | |
55 | exp_continue | |
56 | } else { | |
57 | fail "$test" | |
58 | } | |
59 | } | |
60 | -re "$target.*$gdb_prompt $" { | |
61 | pass "$test" | |
62 | } | |
63 | } | |
64 | } | |
65 | ||
66 | # Normal stepping steps through all thunks. | |
67 | gdb_test "step" "thrice\.2.*" "step into thrice" | |
68 | gdb_test "next" "thrice\.3.*" "step through thunks and over inc" | |
69 | gdb_test "step" "inc\.2.*" "step through call thunk into inc" | |
70 | gdb_test "step" "inc\.3.*" "step inside inc" | |
71 | gdb_test "step" "thrice\.4.*" "step through return thunk back into thrice" | |
72 | ||
c47860a4 TV |
73 | set alphanum_re "\[a-zA-Z0-9\]" |
74 | set pic_thunk_re "__$alphanum_re*\\.get_pc_thunk\\.$alphanum_re* \\(\\)" | |
75 | ||
1d509aa6 MM |
76 | # We can use instruction stepping to step into thunks. |
77 | stepi_until "thrice" "indirect_thunk" "stepi into call thunk" | |
78 | stepi_until "indirect_thunk" "inc." "stepi out of call thunk into inc" | |
c47860a4 | 79 | stepi_until "(inc|$pic_thunk_re)" "return_thunk" "stepi into return thunk" |
1d509aa6 MM |
80 | stepi_until "return_thunk" "thrice" \ |
81 | "stepi out of return thunk back into thrice" |