1 # Copyright (C) 2016-2024 Free Software Foundation, Inc.
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.
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.
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/>.
16 require is_aarch32_target
20 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
25 if { ![runto_main] } {
29 # Check kernel helpers are supported or not.
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
41 if { !$kernel_helper_supported } {
42 unsupported "kernel doesn't have helpers"
46 # Get the instruction branching to kernel helper, they can be
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)
56 -re ".*$gdb_prompt $" {
60 if { ![gdb_assert $branch_to_kernel_helper \
61 "find instruction branch to kernel helper"] } {
65 with_test_prefix "single-step" {
66 gdb_breakpoint "*${branch_to_kernel_helper}"
67 gdb_continue_to_breakpoint "branch to kernel helper"
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
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.
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"