]>
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 | ||
5954db83 | 16 | require supports_reverse |
1d509aa6 | 17 | |
2ef339e3 TV |
18 | require {istarget "x86*"} |
19 | ||
1d509aa6 MM |
20 | standard_testfile |
21 | ||
d6246a87 TV |
22 | set cflags {} |
23 | lappend cflags debug | |
24 | lappend cflags additional_flags=-mindirect-branch=thunk | |
25 | lappend cflags additional_flags=-mfunction-return=thunk | |
26 | ||
27 | set fcf_protection_none additional_flags=-fcf-protection=none | |
28 | if { [gdb_can_simple_compile fcf-protection-none {int main () { return 0; }} \ | |
29 | executable $fcf_protection_none] } { | |
30 | lappend cflags $fcf_protection_none | |
31 | } | |
32 | ||
33 | if { [prepare_for_testing "failed to prepare" $testfile $srcfile $cflags] } { | |
1d509aa6 MM |
34 | return -1 |
35 | } | |
36 | ||
37 | if { ![runto_main] } { | |
1d509aa6 MM |
38 | return -1 |
39 | } | |
40 | ||
1d509aa6 MM |
41 | gdb_test_no_output "record" |
42 | gdb_test "next" ".*" "record trace" | |
43 | ||
44 | # Normal stepping steps through all thunks. | |
45 | gdb_test "reverse-step" "apply\.3.*" "reverse-step into apply" | |
46 | gdb_test "reverse-step" "inc\.3.*" "reverse-step into inc" | |
47 | gdb_test "reverse-step" "inc\.2.*" "reverse-step inside inc" | |
48 | gdb_test "reverse-step" "apply\.2.*" \ | |
4d421147 | 49 | "reverse-step through call thunk into apply, first time" |
1d509aa6 MM |
50 | gdb_test "reverse-step" "main\.2.*" "reverse-step into main" |
51 | gdb_test "step" "apply\.2.*" "step into apply" | |
52 | gdb_test "step" "inc\.2.*" "step through call thunk into inc" | |
53 | gdb_test "reverse-step" "apply\.2.*" \ | |
4d421147 | 54 | "reverse-step through call thunk into apply, second time" |
1d509aa6 MM |
55 | gdb_test "next" "apply\.3.*" "step through thunks and over inc" |
56 | gdb_test "reverse-next" "apply\.2.*" \ | |
57 | "reverse-step through thunks and over inc" | |
58 | ||
59 | # We can use instruction stepping to step into thunks. | |
334d405c CL |
60 | repeat_cmd_until "stepi" "apply\.2" "indirect_thunk" "stepi into call thunk" |
61 | repeat_cmd_until "stepi" "indirect_thunk" "inc" \ | |
1d509aa6 | 62 | "stepi out of call thunk into inc" |
c47860a4 TV |
63 | set alphanum_re "\[a-zA-Z0-9\]" |
64 | set pic_thunk_re "__$alphanum_re*\\.get_pc_thunk\\.$alphanum_re* \\(\\)" | |
334d405c CL |
65 | repeat_cmd_until "stepi" "(inc|$pic_thunk_re)" "return_thunk" "stepi into return thunk" |
66 | repeat_cmd_until "stepi" "return_thunk" "apply" \ | |
1d509aa6 MM |
67 | "stepi out of return thunk back into apply" |
68 | ||
334d405c | 69 | repeat_cmd_until "reverse-stepi" "apply" "return_thunk" \ |
1d509aa6 | 70 | "reverse-stepi into return thunk" |
334d405c | 71 | repeat_cmd_until "reverse-stepi" "return_thunk" "inc" \ |
1d509aa6 | 72 | "reverse-stepi out of return thunk into inc" |
334d405c | 73 | repeat_cmd_until "reverse-stepi" "(inc|$pic_thunk_re)" "indirect_thunk" \ |
1d509aa6 | 74 | "reverse-stepi into call thunk" |
334d405c | 75 | repeat_cmd_until "reverse-stepi" "indirect_thunk" "apply" \ |
1d509aa6 | 76 | "reverse-stepi out of call thunk into apply" |