Commit | Line | Data |
---|---|---|
2a20745c YQ |
1 | # Copyright 2010 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 | # This file is part of the gdb testsuite. | |
17 | ||
18 | # Test arm displaced stepping. | |
19 | ||
20 | if $tracelevel { | |
21 | strace $tracelevel | |
22 | } | |
23 | ||
24 | if {![istarget "arm*-*-*"]} then { | |
25 | verbose "Skipping arm displaced stepping tests." | |
26 | return | |
27 | } | |
28 | ||
29 | set testfile "arm-disp-step" | |
30 | set srcfile ${testfile}.S | |
31 | set binfile ${objdir}/${subdir}/${testfile} | |
32 | ||
33 | set additional_flags "-Wa,-g" | |
34 | ||
35 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug $additional_flags]] != "" } { | |
36 | untested arm-disp-step.exp | |
37 | return -1 | |
38 | } | |
39 | ||
40 | ||
41 | ######################################### | |
42 | # Test ldm/stm related to PC. | |
43 | proc test_ldm_stm_pc {} { | |
44 | global srcfile | |
45 | # Try to set breakpoint on test_ldm_stm_pc. If symbol 'test_ldm_stm_pc' | |
46 | # can't be resolved, test case is compiled in Thumb mode, skip it. | |
47 | gdb_test_multiple "break *test_ldm_stm_pc" "break test_ldm_stm_pc" { | |
48 | -re "Breakpoint.*at.* file .*$srcfile, line.*" { | |
49 | pass "break test_ldm_stm_pc" | |
50 | } | |
51 | -re "Function \"test_ldm_stm_pc\" not defined\..*Make breakpoint pending on future shared library load.*y or .n.. $" { | |
52 | gdb_test "n" "" "Test case is compiled in Thumb mode" | |
53 | return | |
54 | } | |
55 | } | |
56 | ||
57 | gdb_test "break *test_ldm_pc" \ | |
58 | "Breakpoint.*at.* file .*$srcfile, line.*" \ | |
59 | "break test_ldm_pc" | |
60 | gdb_test "break *test_ldm_stm_pc_ret" \ | |
61 | "Breakpoint.*at.* file .*$srcfile, line.*" \ | |
62 | "break test_ldm_stm_pc_ret" | |
63 | ||
64 | gdb_continue_to_breakpoint "continue to test_ldm_stm_pc" \ | |
65 | ".*stmdb.*sp\!\,.*\{lr\, pc\}.*" | |
66 | gdb_continue_to_breakpoint "continue to test_ldm_pc" \ | |
67 | ".*ldmia.*sp\!\,.*\{pc\}.*" | |
68 | gdb_continue_to_breakpoint "continue to test_ldm_stm_pc_ret" \ | |
69 | ".*bx lr.*" | |
70 | } | |
71 | ########################################## | |
72 | # Test call/ret. | |
73 | proc test_call_ret {} { | |
74 | global srcfile | |
75 | gdb_test "break *test_call_end" \ | |
76 | "Breakpoint.*at.* file .*$srcfile, line.*" \ | |
77 | "break test_call_end" | |
78 | gdb_test "break *test_ret" \ | |
79 | "Breakpoint.*at.* file .*$srcfile, line.*" \ | |
80 | "break test_ret" | |
81 | gdb_test "break *test_ret_end" \ | |
82 | "Breakpoint.*at.* file .*$srcfile, line.*" \ | |
83 | "break test_ret_end" | |
84 | ||
85 | gdb_continue_to_breakpoint "continue to test_call_end" \ | |
86 | ".*@ Location test_call_end.*" | |
87 | gdb_continue_to_breakpoint "continue to test_ret" \ | |
88 | ".*bx lr.*" | |
89 | gdb_continue_to_breakpoint "continue to test_ret_end" \ | |
90 | ".*@ Location test_ret_end.*" | |
91 | } | |
92 | ||
93 | ||
94 | ######################################### | |
95 | # Test branch | |
96 | proc test_branch {} { | |
97 | global srcfile | |
98 | gdb_test "break *test_branch" \ | |
99 | "Breakpoint.*at.* file .*$srcfile, line.*" \ | |
100 | "break test_branch" | |
101 | gdb_test "break *L_branch" \ | |
102 | "Breakpoint.*at.* file .*$srcfile, line.*" \ | |
103 | "break Lbranch" | |
104 | ||
105 | gdb_continue_to_breakpoint "continue to test_branch" \ | |
106 | ".*b.*L_branch.*" | |
107 | gdb_continue_to_breakpoint "continue to Lbranch" \ | |
108 | ".*bx lr.*" | |
109 | } | |
110 | ||
111 | ######################################### | |
112 | ||
113 | # Test ldr from pc | |
114 | proc test_ldr_from_pc {} { | |
115 | global srcfile | |
116 | gdb_test "break *test_ldr_pc" \ | |
117 | "Breakpoint.*at.* file .*$srcfile, line.*" \ | |
118 | "break test_ldr_pc" | |
119 | gdb_test "break test_ldr_pc_ret" \ | |
120 | "Breakpoint.*at.* file .*$srcfile, line.*" \ | |
121 | "break test_ldr_pc_ret" | |
122 | ||
123 | gdb_continue_to_breakpoint "continue to test_ldr_pc" \ | |
124 | ".*ldr.*r1\,.*\[pc, #0\].*" | |
125 | gdb_continue_to_breakpoint "continue to Lbranch" \ | |
126 | ".*bx lr.*" | |
127 | } | |
128 | ||
129 | # Get things started. | |
130 | ||
131 | clean_restart ${testfile} | |
132 | ||
133 | # Turn displaced stepping off before runto main. When displaced stepping | |
134 | # is on, and we type 'run', GDB will first try to single step on _dl_debug_state, | |
135 | # which is in library might be compiled in Thumb. | |
136 | gdb_test_no_output "set displaced-stepping off" | |
137 | ||
138 | if ![runto_main] then { | |
139 | fail "Can't run to main" | |
140 | return 0 | |
141 | } | |
142 | ||
143 | gdb_test_no_output "set displaced-stepping on" | |
144 | gdb_test "show displaced-stepping" ".* displaced stepping .* is on.*" | |
145 | ||
146 | gdb_test "break *test_call" \ | |
147 | "Breakpoint.*at.* file .*$srcfile, line.*" \ | |
148 | "break test_call" | |
149 | ||
150 | gdb_test_multiple "continue" "continue to test_call" { | |
151 | -re ".*bl test_call_subr.*" { | |
152 | pass "continue to test_call" | |
153 | } | |
154 | -re "Displaced stepping is only supported in" { | |
155 | kfail "gdb/NNNN" $testfile | |
156 | return | |
157 | } | |
158 | } | |
159 | ||
160 | test_call_ret | |
161 | ||
162 | test_branch | |
163 | ||
164 | test_ldr_from_pc | |
165 | ||
166 | test_ldm_stm_pc | |
167 | ||
168 | ########################################## | |
169 | ||
170 | # Done, run program to exit. | |
171 | ||
172 | gdb_continue_to_end "arm-disp-step" |