]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.arch/arm-single-step-kernel-helper.exp
update copyright year range in GDB files
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.arch / arm-single-step-kernel-helper.exp
1 # Copyright (C) 2016-2017 Free Software Foundation, Inc.
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 { ![is_aarch32_target] } {
17 verbose "Skipping ${gdb_test_file_name}."
18 return
19 }
20
21 standard_testfile
22
23 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
24 [list debug]] } {
25 return -1
26 }
27
28 if { ![runto_main] } {
29 return -1
30 }
31
32 # Check kernel helpers are supported or not.
33
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
40 }
41 }
42 }
43
44 if { !$kernel_helper_supported } {
45 unsupported "kernel doesn't have helpers"
46 return 0
47 }
48
49 # Get the instruction branching to kernel helper, they can be
50 # blx rN or bx rN.
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)
57 exp_continue
58 }
59 -re ".*$gdb_prompt $" {
60 }
61 }
62
63 if { ![gdb_assert $branch_to_kernel_helper \
64 "find instruction branch to kernel helper"] } {
65 return
66 }
67
68 with_test_prefix "single-step" {
69 gdb_breakpoint "*${branch_to_kernel_helper}"
70 gdb_continue_to_breakpoint "branch to kernel helper"
71 gdb_test "si"
72
73 set test "bt"
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
77 # somewhere else.
78 pass $test
79 }
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.
83 pass $test
84 }
85
86 }
87
88 delete_breakpoints
89 }
90
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"
94 gdb_test "p i" " = 6"
95
96 delete_breakpoints
97 }