Commit | Line | Data |
---|---|---|
88b9d363 | 1 | # Copyright 2018-2022 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 | if { ![supports_reverse] } { | |
17 | untested "target does not support record" | |
18 | return -1 | |
19 | } | |
20 | ||
21 | standard_testfile | |
22 | ||
23 | set cflags "-mindirect-branch=thunk -mfunction-return=thunk" | |
24 | if { [prepare_for_testing "failed to prepare" $testfile $srcfile \ | |
25 | [list debug "additional_flags=$cflags"]] } { | |
26 | return -1 | |
27 | } | |
28 | ||
29 | if { ![runto_main] } { | |
30 | untested "failed to run to main" | |
31 | return -1 | |
32 | } | |
33 | ||
34 | # Do repeated stepping COMMANDs in order to reach TARGET from CURRENT | |
35 | # | |
36 | # COMMAND is a stepping command | |
37 | # CURRENT is a string matching the current location | |
38 | # TARGET is a string matching the target location | |
39 | # TEST is the test name | |
40 | # | |
41 | # The function issues repeated COMMANDs as long as the location matches | |
42 | # CURRENT up to a maximum of 100 steps. | |
43 | # | |
44 | # TEST passes if the resulting location matches TARGET and fails | |
45 | # otherwise. | |
46 | # | |
47 | proc step_until { command current target test } { | |
48 | global gdb_prompt | |
49 | ||
50 | set count 0 | |
51 | gdb_test_multiple "$command" "$test" { | |
52 | -re "$current.*$gdb_prompt $" { | |
53 | incr count | |
54 | if { $count < 100 } { | |
55 | send_gdb "$command\n" | |
56 | exp_continue | |
57 | } else { | |
58 | fail "$test" | |
59 | } | |
60 | } | |
61 | -re "$target.*$gdb_prompt $" { | |
62 | pass "$test" | |
63 | } | |
64 | } | |
65 | } | |
66 | ||
67 | gdb_test_no_output "record" | |
68 | gdb_test "next" ".*" "record trace" | |
69 | ||
70 | # Normal stepping steps through all thunks. | |
71 | gdb_test "reverse-step" "apply\.3.*" "reverse-step into apply" | |
72 | gdb_test "reverse-step" "inc\.3.*" "reverse-step into inc" | |
73 | gdb_test "reverse-step" "inc\.2.*" "reverse-step inside inc" | |
74 | gdb_test "reverse-step" "apply\.2.*" \ | |
4d421147 | 75 | "reverse-step through call thunk into apply, first time" |
1d509aa6 MM |
76 | gdb_test "reverse-step" "main\.2.*" "reverse-step into main" |
77 | gdb_test "step" "apply\.2.*" "step into apply" | |
78 | gdb_test "step" "inc\.2.*" "step through call thunk into inc" | |
79 | gdb_test "reverse-step" "apply\.2.*" \ | |
4d421147 | 80 | "reverse-step through call thunk into apply, second time" |
1d509aa6 MM |
81 | gdb_test "next" "apply\.3.*" "step through thunks and over inc" |
82 | gdb_test "reverse-next" "apply\.2.*" \ | |
83 | "reverse-step through thunks and over inc" | |
84 | ||
85 | # We can use instruction stepping to step into thunks. | |
86 | step_until "stepi" "apply\.2" "indirect_thunk" "stepi into call thunk" | |
87 | step_until "stepi" "indirect_thunk" "inc" \ | |
88 | "stepi out of call thunk into inc" | |
89 | step_until "stepi" "inc" "return_thunk" "stepi into return thunk" | |
90 | step_until "stepi" "return_thunk" "apply" \ | |
91 | "stepi out of return thunk back into apply" | |
92 | ||
93 | step_until "reverse-stepi" "apply" "return_thunk" \ | |
94 | "reverse-stepi into return thunk" | |
95 | step_until "reverse-stepi" "return_thunk" "inc" \ | |
96 | "reverse-stepi out of return thunk into inc" | |
97 | step_until "reverse-stepi" "inc" "indirect_thunk" \ | |
98 | "reverse-stepi into call thunk" | |
99 | step_until "reverse-stepi" "indirect_thunk" "apply" \ | |
100 | "reverse-stepi out of call thunk into apply" |