]>
Commit | Line | Data |
---|---|---|
1d506c26 | 1 | # Copyright (C) 2016-2024 Free Software Foundation, Inc. |
01113bc1 YQ |
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 | ||
abdc86ca | 16 | require is_aarch32_target |
01113bc1 YQ |
17 | |
18 | standard_testfile | |
19 | ||
5b362f04 | 20 | if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \ |
01113bc1 YQ |
21 | [list debug]] } { |
22 | return -1 | |
23 | } | |
24 | ||
25 | if { ![runto_main] } { | |
26 | return -1 | |
27 | } | |
28 | ||
29 | # Check kernel helpers are supported or not. | |
30 | ||
31 | set kernel_helper_supported 0 | |
32 | gdb_test_multiple "p *kernel_user_helper_version" \ | |
33 | "check kernel helper version" { | |
34 | -re " = ($decimal)\r\n$gdb_prompt $" { | |
35 | if { $expect_out(1,string) >= 1 } { | |
36 | set kernel_helper_supported 1 | |
37 | } | |
38 | } | |
39 | } | |
40 | ||
41 | if { !$kernel_helper_supported } { | |
42 | unsupported "kernel doesn't have helpers" | |
43 | return 0 | |
44 | } | |
45 | ||
46 | # Get the instruction branching to kernel helper, they can be | |
47 | # blx rN or bx rN. | |
48 | set branch_to_kernel_helper 0 | |
49 | set branch_insn "bl?x\[ \t\]*r${decimal}" | |
50 | set test "disassemble main" | |
51 | gdb_test_multiple $test $test { | |
52 | -re ".*($hex) <\\+$decimal>:\[ \t\]+$branch_insn" { | |
53 | set branch_to_kernel_helper $expect_out(1,string) | |
54 | exp_continue | |
55 | } | |
56 | -re ".*$gdb_prompt $" { | |
57 | } | |
58 | } | |
59 | ||
60 | if { ![gdb_assert $branch_to_kernel_helper \ | |
61 | "find instruction branch to kernel helper"] } { | |
62 | return | |
63 | } | |
64 | ||
65 | with_test_prefix "single-step" { | |
66 | gdb_breakpoint "*${branch_to_kernel_helper}" | |
67 | gdb_continue_to_breakpoint "branch to kernel helper" | |
68 | gdb_test "si" | |
69 | ||
70 | set test "bt" | |
71 | gdb_test_multiple $test $test { | |
72 | -re "#0 \[^\\r\\n\]*main .*\r\n$gdb_prompt $" { | |
73 | # Test that the program still stops in main rather than | |
74 | # somewhere else. | |
75 | pass $test | |
76 | } | |
77 | -re "#0 0xffff0fe0 .*\r\n$gdb_prompt $" { | |
78 | # AArch64 linux kernel can do hardware single step, so | |
79 | # the program can stop at kernel helper. | |
80 | pass $test | |
81 | } | |
82 | ||
83 | } | |
84 | ||
85 | delete_breakpoints | |
86 | } | |
87 | ||
88 | with_test_prefix "cond-breakpoint" { | |
89 | gdb_breakpoint "*${branch_to_kernel_helper} if i > 5" | |
90 | gdb_continue_to_breakpoint "branch to kernel helper" | |
91 | gdb_test "p i" " = 6" | |
92 | ||
93 | delete_breakpoints | |
94 | } |