1 # Copyright (C) 2016-2019 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 if { ![is_aarch32_target] } {
17 verbose "Skipping ${gdb_test_file_name}."
23 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
28 if { ![runto_main] } {
32 # Check kernel helpers are supported or not.
34 set kernel_helper_supported 0
35 gdb_test_multiple "p *kernel_user_helper_version" \
36 "check kernel helper version" {
37 -re " = ($decimal)\r\n$gdb_prompt $" {
38 if { $expect_out(1,string) >= 1 } {
39 set kernel_helper_supported 1
44 if { !$kernel_helper_supported } {
45 unsupported "kernel doesn't have helpers"
49 # Get the instruction branching to kernel helper, they can be
51 set branch_to_kernel_helper 0
52 set branch_insn "bl?x\[ \t\]*r${decimal}"
53 set test "disassemble main"
54 gdb_test_multiple $test $test {
55 -re ".*($hex) <\\+$decimal>:\[ \t\]+$branch_insn" {
56 set branch_to_kernel_helper $expect_out(1,string)
59 -re ".*$gdb_prompt $" {
63 if { ![gdb_assert $branch_to_kernel_helper \
64 "find instruction branch to kernel helper"] } {
68 with_test_prefix "single-step" {
69 gdb_breakpoint "*${branch_to_kernel_helper}"
70 gdb_continue_to_breakpoint "branch to kernel helper"
74 gdb_test_multiple $test $test {
75 -re "#0 \[^\\r\\n\]*main .*\r\n$gdb_prompt $" {
76 # Test that the program still stops in main rather than
80 -re "#0 0xffff0fe0 .*\r\n$gdb_prompt $" {
81 # AArch64 linux kernel can do hardware single step, so
82 # the program can stop at kernel helper.
91 with_test_prefix "cond-breakpoint" {
92 gdb_breakpoint "*${branch_to_kernel_helper} if i > 5"
93 gdb_continue_to_breakpoint "branch to kernel helper"