Commit | Line | Data |
---|---|---|
7b6bb8da | 1 | # Copyright 2010, 2011 Free Software Foundation, Inc. |
2a20745c 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 | ||
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 | } | |
0c51be18 YQ |
71 | |
72 | ######################################### | |
73 | # Test ldrX literal | |
74 | proc test_ldr_literal {} { | |
75 | global srcfile | |
76 | global gdb_prompt | |
77 | ||
78 | gdb_test_multiple "break *test_ldr_literal" "break test_ldr_literal" { | |
79 | -re "Breakpoint.*at.* file .*$srcfile, line.*\r\n$gdb_prompt $" { | |
80 | pass "break test_ldr_literal" | |
81 | } | |
82 | -re "No symbol.*\r\n$gdb_prompt $" { | |
83 | return 0 | |
84 | } | |
85 | } | |
86 | ||
87 | gdb_test "break *test_ldrsb_literal" \ | |
88 | "Breakpoint.*at.* file .*$srcfile, line.*" \ | |
89 | "break test_ldrsb_literal" | |
90 | gdb_test "break *test_ldrsh_literal" \ | |
91 | "Breakpoint.*at.* file .*$srcfile, line.*" \ | |
92 | "break test_ldrsh_literal" | |
93 | gdb_test "break *test_ldr_literal_end" \ | |
94 | "Breakpoint.*at.* file .*$srcfile, line.*" \ | |
95 | "break test_test_ldr_literal_end" | |
96 | ||
97 | gdb_continue_to_breakpoint "continue to test_ldr_literal" \ | |
98 | ".*ldrh.*r0\,.*\[pc\].*" | |
99 | gdb_continue_to_breakpoint "continue to test_ldrsb_literal" \ | |
100 | ".*ldrsb.*r0\,.*\[pc\].*" | |
101 | gdb_continue_to_breakpoint "continue to test_ldrsh_literal" \ | |
102 | ".*ldrsh.*r0\,.*\[pc\].*" | |
103 | gdb_continue_to_breakpoint "continue to test_ldr_literal_ret" \ | |
104 | ".*bx lr.*" | |
105 | } | |
106 | ||
2a20745c YQ |
107 | ########################################## |
108 | # Test call/ret. | |
109 | proc test_call_ret {} { | |
110 | global srcfile | |
111 | gdb_test "break *test_call_end" \ | |
112 | "Breakpoint.*at.* file .*$srcfile, line.*" \ | |
113 | "break test_call_end" | |
114 | gdb_test "break *test_ret" \ | |
115 | "Breakpoint.*at.* file .*$srcfile, line.*" \ | |
116 | "break test_ret" | |
117 | gdb_test "break *test_ret_end" \ | |
118 | "Breakpoint.*at.* file .*$srcfile, line.*" \ | |
119 | "break test_ret_end" | |
120 | ||
121 | gdb_continue_to_breakpoint "continue to test_call_end" \ | |
122 | ".*@ Location test_call_end.*" | |
123 | gdb_continue_to_breakpoint "continue to test_ret" \ | |
124 | ".*bx lr.*" | |
125 | gdb_continue_to_breakpoint "continue to test_ret_end" \ | |
126 | ".*@ Location test_ret_end.*" | |
127 | } | |
128 | ||
129 | ||
130 | ######################################### | |
131 | # Test branch | |
132 | proc test_branch {} { | |
133 | global srcfile | |
134 | gdb_test "break *test_branch" \ | |
135 | "Breakpoint.*at.* file .*$srcfile, line.*" \ | |
136 | "break test_branch" | |
137 | gdb_test "break *L_branch" \ | |
138 | "Breakpoint.*at.* file .*$srcfile, line.*" \ | |
139 | "break Lbranch" | |
140 | ||
141 | gdb_continue_to_breakpoint "continue to test_branch" \ | |
142 | ".*b.*L_branch.*" | |
143 | gdb_continue_to_breakpoint "continue to Lbranch" \ | |
144 | ".*bx lr.*" | |
145 | } | |
146 | ||
147 | ######################################### | |
148 | ||
149 | # Test ldr from pc | |
150 | proc test_ldr_from_pc {} { | |
151 | global srcfile | |
152 | gdb_test "break *test_ldr_pc" \ | |
153 | "Breakpoint.*at.* file .*$srcfile, line.*" \ | |
154 | "break test_ldr_pc" | |
155 | gdb_test "break test_ldr_pc_ret" \ | |
156 | "Breakpoint.*at.* file .*$srcfile, line.*" \ | |
157 | "break test_ldr_pc_ret" | |
158 | ||
159 | gdb_continue_to_breakpoint "continue to test_ldr_pc" \ | |
160 | ".*ldr.*r1\,.*\[pc, #0\].*" | |
161 | gdb_continue_to_breakpoint "continue to Lbranch" \ | |
162 | ".*bx lr.*" | |
163 | } | |
164 | ||
0c51be18 YQ |
165 | proc test_adr_32bit {} { |
166 | global srcfile | |
167 | global gdb_prompt | |
168 | ||
169 | gdb_test_multiple "break *test_adr_32bit" "break test_adr_32bit" { | |
170 | -re "Breakpoint.*at.* file .*$srcfile, line.*\r\n$gdb_prompt $" { | |
171 | pass "break test_adr" | |
172 | } | |
173 | -re "No symbol.*\r\n$gdb_prompt $" { | |
174 | return 0 | |
175 | } | |
176 | } | |
177 | ||
178 | gdb_test "break *test_adr_32bit_after" \ | |
179 | "Breakpoint.*at.* file .*$srcfile, line.*" \ | |
180 | "break test_adr_32bit_after" | |
181 | ||
182 | gdb_test "break *test_adr_32bit_end" \ | |
183 | "Breakpoint.*at.* file .*$srcfile, line.*" \ | |
184 | "break test_adr_32bit_end" | |
185 | ||
186 | gdb_continue_to_breakpoint "test_adr_32bit" \ | |
187 | ".*adr.*r0\,.*\.L6.*" | |
188 | gdb_continue_to_breakpoint "test_adr_32bit_after" \ | |
189 | ".*adr.*r0\,.*\.L6.*" | |
190 | gdb_continue_to_breakpoint "test_adr_32bit_end" \ | |
191 | ".*bx lr.*" | |
192 | } | |
193 | ||
194 | ######################################### | |
195 | # Test pop to PC | |
196 | proc test_pop_pc {} { | |
197 | global srcfile | |
198 | gdb_test "break *test_pop_pc_1" \ | |
199 | "Breakpoint.*at.* file .*$srcfile, line.*" \ | |
200 | "break test_pop_pc" | |
201 | gdb_test "break *test_pop_pc_ret" \ | |
202 | "Breakpoint.*at.* file .*$srcfile, line.*" \ | |
203 | "break test_pop_pc_ret" | |
204 | ||
205 | gdb_continue_to_breakpoint "continue to test_pop_pc" \ | |
206 | ".*b.*\{r1\, pc\}.*" | |
207 | gdb_continue_to_breakpoint "continue to test_pop_pc_ret" \ | |
208 | ".*bx lr.*" | |
209 | } | |
210 | ||
494e194e YQ |
211 | ########################################### |
212 | ||
213 | proc test_str_pc {} { | |
214 | global srcfile | |
215 | gdb_test_multiple "break *test_str_pc" "break test_str_pc" { | |
216 | -re "Breakpoint.*at.* file .*$srcfile, line.*" { | |
217 | pass "break test_str_pc" | |
218 | } | |
219 | -re "No symbol.*" { | |
220 | pass "break test_str_pc" | |
221 | return | |
222 | } | |
223 | } | |
224 | gdb_test "break *test_str_pc_end" \ | |
225 | "Breakpoint.*at.* file .*$srcfile, line.*" \ | |
226 | "break test_str_pc_end" | |
227 | ||
228 | # Set breakpoint on both lables pc_offset_right and pc_offset_wrong | |
229 | gdb_test "break *pc_offset_right" \ | |
230 | "Breakpoint.*at.* file .*$srcfile, line.*" \ | |
231 | "break pc_offset_right" | |
232 | gdb_test "break *pc_offset_wrong" \ | |
233 | "Breakpoint.*at.* file .*$srcfile, line.*" \ | |
234 | "break pc_offset_wrong" | |
235 | ||
236 | gdb_continue_to_breakpoint "continue to test_str_pc" \ | |
237 | ".*str.*pc\,.*\[sp, #-4\].*" | |
238 | # If breakpoint on lable pc_offset_wrong is hit, that means the offset | |
239 | # computed in displaced stepping is different from offset computed | |
240 | # without displaced stepping. Report a failure. | |
241 | gdb_continue_to_breakpoint "continue to pc_offset_right" \ | |
242 | ".*b.*test_str_pc_end.*" | |
243 | gdb_continue_to_breakpoint "continue to test_str_pc_end" \ | |
244 | ".*bx lr.*" | |
245 | } | |
246 | ||
2a20745c YQ |
247 | # Get things started. |
248 | ||
249 | clean_restart ${testfile} | |
250 | ||
251 | # Turn displaced stepping off before runto main. When displaced stepping | |
252 | # is on, and we type 'run', GDB will first try to single step on _dl_debug_state, | |
253 | # which is in library might be compiled in Thumb. | |
254 | gdb_test_no_output "set displaced-stepping off" | |
255 | ||
256 | if ![runto_main] then { | |
257 | fail "Can't run to main" | |
258 | return 0 | |
259 | } | |
260 | ||
261 | gdb_test_no_output "set displaced-stepping on" | |
262 | gdb_test "show displaced-stepping" ".* displaced stepping .* is on.*" | |
263 | ||
264 | gdb_test "break *test_call" \ | |
265 | "Breakpoint.*at.* file .*$srcfile, line.*" \ | |
266 | "break test_call" | |
267 | ||
268 | gdb_test_multiple "continue" "continue to test_call" { | |
269 | -re ".*bl test_call_subr.*" { | |
270 | pass "continue to test_call" | |
271 | } | |
272 | -re "Displaced stepping is only supported in" { | |
273 | kfail "gdb/NNNN" $testfile | |
274 | return | |
275 | } | |
276 | } | |
277 | ||
278 | test_call_ret | |
279 | ||
280 | test_branch | |
281 | ||
282 | test_ldr_from_pc | |
283 | ||
284 | test_ldm_stm_pc | |
285 | ||
0c51be18 YQ |
286 | test_ldr_literal |
287 | ||
288 | test_adr_32bit | |
289 | ||
290 | test_pop_pc | |
291 | ||
494e194e | 292 | test_str_pc |
2a20745c YQ |
293 | ########################################## |
294 | ||
295 | # Done, run program to exit. | |
296 | ||
297 | gdb_continue_to_end "arm-disp-step" |