]>
Commit | Line | Data |
---|---|---|
42a4f53d | 1 | # Copyright 2018-2019 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 | ||
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"]] } { | |
21 | return -1 | |
22 | } | |
23 | ||
24 | if { ![runto_main] } { | |
25 | untested "failed to run to main" | |
26 | return -1 | |
27 | } | |
28 | ||
29 | # Do repeated instruction steps in order to reach TARGET from CURRENT | |
30 | # | |
31 | # CURRENT is a string matching the current location | |
32 | # TARGET is a string matching the target location | |
33 | # TEST is the test name | |
34 | # | |
35 | # The function issues repeated "stepi" commands as long as the location | |
36 | # matches CURRENT up to a maximum of 100 steps. | |
37 | # | |
38 | # TEST passes if the resulting location matches TARGET and fails | |
39 | # otherwise. | |
40 | # | |
41 | proc stepi_until { current target test } { | |
42 | global gdb_prompt | |
43 | ||
44 | set count 0 | |
45 | gdb_test_multiple "stepi" "$test" { | |
46 | -re "$current.*$gdb_prompt $" { | |
47 | incr count | |
48 | if { $count < 100 } { | |
49 | send_gdb "stepi\n" | |
50 | exp_continue | |
51 | } else { | |
52 | fail "$test" | |
53 | } | |
54 | } | |
55 | -re "$target.*$gdb_prompt $" { | |
56 | pass "$test" | |
57 | } | |
58 | } | |
59 | } | |
60 | ||
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" | |
67 | ||
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" |