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 | } | |
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 | ||
494e194e YQ |
129 | ########################################### |
130 | ||
131 | proc test_str_pc {} { | |
132 | global srcfile | |
133 | gdb_test_multiple "break *test_str_pc" "break test_str_pc" { | |
134 | -re "Breakpoint.*at.* file .*$srcfile, line.*" { | |
135 | pass "break test_str_pc" | |
136 | } | |
137 | -re "No symbol.*" { | |
138 | pass "break test_str_pc" | |
139 | return | |
140 | } | |
141 | } | |
142 | gdb_test "break *test_str_pc_end" \ | |
143 | "Breakpoint.*at.* file .*$srcfile, line.*" \ | |
144 | "break test_str_pc_end" | |
145 | ||
146 | # Set breakpoint on both lables pc_offset_right and pc_offset_wrong | |
147 | gdb_test "break *pc_offset_right" \ | |
148 | "Breakpoint.*at.* file .*$srcfile, line.*" \ | |
149 | "break pc_offset_right" | |
150 | gdb_test "break *pc_offset_wrong" \ | |
151 | "Breakpoint.*at.* file .*$srcfile, line.*" \ | |
152 | "break pc_offset_wrong" | |
153 | ||
154 | gdb_continue_to_breakpoint "continue to test_str_pc" \ | |
155 | ".*str.*pc\,.*\[sp, #-4\].*" | |
156 | # If breakpoint on lable pc_offset_wrong is hit, that means the offset | |
157 | # computed in displaced stepping is different from offset computed | |
158 | # without displaced stepping. Report a failure. | |
159 | gdb_continue_to_breakpoint "continue to pc_offset_right" \ | |
160 | ".*b.*test_str_pc_end.*" | |
161 | gdb_continue_to_breakpoint "continue to test_str_pc_end" \ | |
162 | ".*bx lr.*" | |
163 | } | |
164 | ||
2a20745c YQ |
165 | # Get things started. |
166 | ||
167 | clean_restart ${testfile} | |
168 | ||
169 | # Turn displaced stepping off before runto main. When displaced stepping | |
170 | # is on, and we type 'run', GDB will first try to single step on _dl_debug_state, | |
171 | # which is in library might be compiled in Thumb. | |
172 | gdb_test_no_output "set displaced-stepping off" | |
173 | ||
174 | if ![runto_main] then { | |
175 | fail "Can't run to main" | |
176 | return 0 | |
177 | } | |
178 | ||
179 | gdb_test_no_output "set displaced-stepping on" | |
180 | gdb_test "show displaced-stepping" ".* displaced stepping .* is on.*" | |
181 | ||
182 | gdb_test "break *test_call" \ | |
183 | "Breakpoint.*at.* file .*$srcfile, line.*" \ | |
184 | "break test_call" | |
185 | ||
186 | gdb_test_multiple "continue" "continue to test_call" { | |
187 | -re ".*bl test_call_subr.*" { | |
188 | pass "continue to test_call" | |
189 | } | |
190 | -re "Displaced stepping is only supported in" { | |
191 | kfail "gdb/NNNN" $testfile | |
192 | return | |
193 | } | |
194 | } | |
195 | ||
196 | test_call_ret | |
197 | ||
198 | test_branch | |
199 | ||
200 | test_ldr_from_pc | |
201 | ||
202 | test_ldm_stm_pc | |
203 | ||
494e194e | 204 | test_str_pc |
2a20745c YQ |
205 | ########################################## |
206 | ||
207 | # Done, run program to exit. | |
208 | ||
209 | gdb_continue_to_end "arm-disp-step" |