1 |
1181 |
sfurman |
# Copyright 1998 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 2 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, write to the Free Software
|
15 |
|
|
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
16 |
|
|
|
17 |
|
|
# Please email any bugs, comments, and/or additions to this file to:
|
18 |
|
|
# bug-gdb@prep.ai.mit.edu
|
19 |
|
|
|
20 |
|
|
# This file was written by Michael Snyder (msnyder@cygnus.com)
|
21 |
|
|
|
22 |
|
|
load_lib "trace-support.exp";
|
23 |
|
|
|
24 |
|
|
if $tracelevel then {
|
25 |
|
|
strace $tracelevel
|
26 |
|
|
}
|
27 |
|
|
|
28 |
|
|
set prms_id 0
|
29 |
|
|
set bug_id 0
|
30 |
|
|
|
31 |
|
|
gdb_exit
|
32 |
|
|
gdb_start
|
33 |
|
|
|
34 |
|
|
if [istarget "m68k-*-elf"] then {
|
35 |
|
|
load_lib "emc-support.exp";
|
36 |
|
|
set srcfile gdb_c_test.c
|
37 |
|
|
set binfile [board_info target d490_binfile];
|
38 |
|
|
gdb_test "set remotetimeout 6" "" ""
|
39 |
|
|
set timeout 500
|
40 |
|
|
gdb_target_monitor "$binfile"
|
41 |
|
|
# Give a TSTOP and ignore errors, to make sure any previous trace is off
|
42 |
|
|
gdb_test "tstop" "" ""
|
43 |
|
|
gdb_test "tfind none" "" ""
|
44 |
|
|
send_gdb "compare-sections CS\n"
|
45 |
|
|
gdb_expect {
|
46 |
|
|
-re "MIS-MATCHED.*$gdb_prompt $" {
|
47 |
|
|
gdb_suppress_entire_file "Symbol file does not match target!
|
48 |
|
|
all tests in this module will fail.";
|
49 |
|
|
}
|
50 |
|
|
-re ".*$gdb_prompt $" { }
|
51 |
|
|
}
|
52 |
|
|
} else {
|
53 |
|
|
set testfile "actions"
|
54 |
|
|
set srcfile ${testfile}.c
|
55 |
|
|
set binfile $objdir/$subdir/$testfile
|
56 |
|
|
if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
|
57 |
|
|
executable {debug additional_flags=-w}] != "" } {
|
58 |
|
|
gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
|
59 |
|
|
}
|
60 |
|
|
gdb_load $binfile
|
61 |
|
|
gdb_test "tstop" "" ""
|
62 |
|
|
gdb_test "tfind none" "" ""
|
63 |
|
|
runto_main
|
64 |
|
|
}
|
65 |
|
|
gdb_reinitialize_dir $srcdir/$subdir
|
66 |
|
|
|
67 |
|
|
# We generously give ourselves one "pass" if we successfully
|
68 |
|
|
# detect that this test cannot be run on this target!
|
69 |
|
|
if { ![gdb_target_supports_trace] } then {
|
70 |
|
|
pass "Current target does not supporst trace"
|
71 |
|
|
return 1;
|
72 |
|
|
|
73 |
|
|
}
|
74 |
|
|
|
75 |
|
|
#
|
76 |
|
|
# test backtraces in trace frames
|
77 |
|
|
#
|
78 |
|
|
|
79 |
|
|
set testline1 0
|
80 |
|
|
set testline2 0
|
81 |
|
|
set testline3 0
|
82 |
|
|
set testline4 0
|
83 |
|
|
set testline5 0
|
84 |
|
|
set testline6 0
|
85 |
|
|
|
86 |
|
|
set arg1 1
|
87 |
|
|
set arg2 2
|
88 |
|
|
set arg3 3
|
89 |
|
|
set arg4 4
|
90 |
|
|
set arg5 5
|
91 |
|
|
set arg6 6
|
92 |
|
|
|
93 |
|
|
set baseline [gdb_find_recursion_test_baseline $srcfile];
|
94 |
|
|
if { $baseline == -1 } {
|
95 |
|
|
fail "Could not find gdb_recursion_test function"
|
96 |
|
|
return;
|
97 |
|
|
}
|
98 |
|
|
|
99 |
|
|
send_gdb "list $baseline, +12\n"
|
100 |
|
|
gdb_expect {
|
101 |
|
|
-re "\[\r\n\](\[0-9\]+).*gdbtestline 1 " {
|
102 |
|
|
set testline1 $expect_out(1,string)
|
103 |
|
|
exp_continue
|
104 |
|
|
}
|
105 |
|
|
-re "\[\r\n\](\[0-9\]+).*gdbtestline 2 " {
|
106 |
|
|
set testline2 $expect_out(1,string)
|
107 |
|
|
exp_continue
|
108 |
|
|
}
|
109 |
|
|
-re "\[\r\n\](\[0-9\]+).*gdbtestline 3 " {
|
110 |
|
|
set testline3 $expect_out(1,string)
|
111 |
|
|
exp_continue
|
112 |
|
|
}
|
113 |
|
|
-re "\[\r\n\](\[0-9\]+).*gdbtestline 4 " {
|
114 |
|
|
set testline4 $expect_out(1,string)
|
115 |
|
|
exp_continue
|
116 |
|
|
}
|
117 |
|
|
-re "\[\r\n\](\[0-9\]+).*gdbtestline 5 " {
|
118 |
|
|
set testline5 $expect_out(1,string)
|
119 |
|
|
exp_continue
|
120 |
|
|
}
|
121 |
|
|
-re "\[\r\n\](\[0-9\]+).*gdbtestline 6 " {
|
122 |
|
|
set testline6 $expect_out(1,string)
|
123 |
|
|
exp_continue
|
124 |
|
|
}
|
125 |
|
|
-re ".*$gdb_prompt $" {
|
126 |
|
|
if { ($testline1 == 0) || ($testline2 == 0) || ($testline3 == 0) || ($testline4 == 0) || ($testline5 == 0) || ($testline6 == 0) } {
|
127 |
|
|
gdb_suppress_entire_file "failed to locate test source lines:
|
128 |
|
|
all tests in this module will fail."
|
129 |
|
|
}
|
130 |
|
|
}
|
131 |
|
|
default {
|
132 |
|
|
gdb_suppress_entire_file "failed to locate test source lines (def):
|
133 |
|
|
all tests in this module will fail."
|
134 |
|
|
}
|
135 |
|
|
}
|
136 |
|
|
|
137 |
|
|
#
|
138 |
|
|
# Setup backtrace experiment. This will involve:
|
139 |
|
|
# 1) a tracepoint where nothing is collected
|
140 |
|
|
# 2) a tracepoint where only regs are collected
|
141 |
|
|
# 3) a tracepoint where regs, locals and args are collected
|
142 |
|
|
# 4) a tracepoint where regs plus some amount of stack are collected.
|
143 |
|
|
#
|
144 |
|
|
|
145 |
|
|
gdb_delete_tracepoints
|
146 |
|
|
set tdp2 [gdb_gettpnum $testline2]
|
147 |
|
|
set tdp3 [gdb_gettpnum $testline3]
|
148 |
|
|
set tdp4 [gdb_gettpnum $testline4]
|
149 |
|
|
set tdp5 [gdb_gettpnum $testline5]
|
150 |
|
|
set tdp6 [gdb_gettpnum $testline6]
|
151 |
|
|
if { $tdp2 <= 0 || $tdp3 <= 0 || \
|
152 |
|
|
$tdp4 <= 0 || $tdp5 <= 0 || $tdp6 <= 0 } then {
|
153 |
|
|
fail "setting tracepoints failed"
|
154 |
|
|
return;
|
155 |
|
|
}
|
156 |
|
|
|
157 |
|
|
#gdb_trace_setactions "setup TP to collect FP" \
|
158 |
|
|
# "$tdp2" \
|
159 |
|
|
# "collect \$fp" ""
|
160 |
|
|
#
|
161 |
|
|
|
162 |
|
|
gdb_trace_setactions "8.6: setup TP to collect regs" \
|
163 |
|
|
"$tdp3" \
|
164 |
|
|
"collect \$regs" "^$"
|
165 |
|
|
|
166 |
|
|
gdb_trace_setactions "8.6: setup TP to collect regs, args, and locals" \
|
167 |
|
|
"$tdp4" \
|
168 |
|
|
"collect \$regs, \$args, \$locs" "^$"
|
169 |
|
|
|
170 |
|
|
gdb_trace_setactions "8.6: setup TP to collect stack mem cast expr" \
|
171 |
|
|
"$tdp6" \
|
172 |
|
|
"collect \$fp, \(\*\(void \*\*\) \(\$sp\)\) @ 64" "^$"
|
173 |
|
|
|
174 |
|
|
gdb_test "tstart" "" ""
|
175 |
|
|
|
176 |
|
|
if [istarget "m68k-*-elf"] then {
|
177 |
|
|
gdb_emclaptop_command "85,$arg1,$arg2,$arg3,$arg4,$arg5,$arg6"
|
178 |
|
|
sleep 5
|
179 |
|
|
} else {
|
180 |
|
|
gdb_test "break end" "" ""
|
181 |
|
|
gdb_test "continue" \
|
182 |
|
|
"Continuing.*Breakpoint $decimal, end.*" \
|
183 |
|
|
"run trace experiment"
|
184 |
|
|
}
|
185 |
|
|
|
186 |
|
|
gdb_test "tstop" "" ""
|
187 |
|
|
|
188 |
|
|
proc gdb_backtrace_tdp_1 { msg } {
|
189 |
|
|
global gdb_prompt
|
190 |
|
|
|
191 |
|
|
# We are in a trace frame at which we didn't collect anything
|
192 |
|
|
# except $PC. Therefore we expect to be able to identify stack
|
193 |
|
|
# frame #0, but that's about all. In particular we do not expect
|
194 |
|
|
# to be able to display the function's arguments or locals, and we
|
195 |
|
|
# do not expect to be able to identify the caller of this function.
|
196 |
|
|
|
197 |
|
|
send_gdb "backtrace\n"
|
198 |
|
|
gdb_expect {
|
199 |
|
|
-re "#0\[\t \]+gdb_recursion_test.*depth=.*$gdb_prompt $" {
|
200 |
|
|
pass "$msg"
|
201 |
|
|
}
|
202 |
|
|
-re ".*$gdb_prompt $" {
|
203 |
|
|
fail "$msg"
|
204 |
|
|
}
|
205 |
|
|
timeout { fail "$msg (timeout)" }
|
206 |
|
|
}
|
207 |
|
|
}
|
208 |
|
|
|
209 |
|
|
proc gdb_backtrace_tdp_2 { msg } {
|
210 |
|
|
global gdb_prompt
|
211 |
|
|
|
212 |
|
|
# We are in a trace frame at which we collected only the registers
|
213 |
|
|
# Therefore we expect to be able to identify stack frame #0, but
|
214 |
|
|
# we don't expect to be able to display its args unles they are
|
215 |
|
|
# passed in registers (which isn't the case for m68k), and we
|
216 |
|
|
# don't expect to be able to identify the caller's stack frame.
|
217 |
|
|
|
218 |
|
|
send_gdb "backtrace\n"
|
219 |
|
|
gdb_expect {
|
220 |
|
|
-re "#0\[\t \]+gdb_recursion_test.*depth=.*$gdb_prompt $" {
|
221 |
|
|
pass "$msg"
|
222 |
|
|
}
|
223 |
|
|
-re ".*$gdb_prompt $" {
|
224 |
|
|
fail "$msg"
|
225 |
|
|
}
|
226 |
|
|
timeout { fail "$msg (timeout)" }
|
227 |
|
|
}
|
228 |
|
|
}
|
229 |
|
|
|
230 |
|
|
proc gdb_backtrace_tdp_3 { msg } {
|
231 |
|
|
global gdb_prompt
|
232 |
|
|
|
233 |
|
|
# We are in a trace frame at which we collected all registers, all
|
234 |
|
|
# arguments and all locals. This means that the display of
|
235 |
|
|
# stack frame #0 should be complete (including argument values).
|
236 |
|
|
|
237 |
|
|
send_gdb "backtrace\n"
|
238 |
|
|
gdb_expect {
|
239 |
|
|
-re "#0\[\t \]+gdb_recursion_test.*depth=\[0-9\]+.*q1=\[0-9\]+.*q2=\[0-9\]+.*q3=\[0-9\]+.*q4=\[0-9\]+.*q5=\[0-9\]+.*q6=\[0-9\]+.*$gdb_prompt $" {
|
240 |
|
|
pass "$msg"
|
241 |
|
|
}
|
242 |
|
|
-re "#0\[\t \]+gdb_recursion_test.*depth=Cannot access.*$gdb_prompt $" {
|
243 |
|
|
fail "$msg (failed to collect arguments)"
|
244 |
|
|
}
|
245 |
|
|
-re ".*$gdb_prompt $" {
|
246 |
|
|
fail "$msg"
|
247 |
|
|
}
|
248 |
|
|
timeout { fail "$msg (timeout)" }
|
249 |
|
|
}
|
250 |
|
|
}
|
251 |
|
|
|
252 |
|
|
proc gdb_backtrace_tdp_4 { msg depth } {
|
253 |
|
|
global gdb_prompt
|
254 |
|
|
|
255 |
|
|
# We are in a trace frame at which we collected all registers,
|
256 |
|
|
# plus a sizeable hunk of stack memory. This should enable us to
|
257 |
|
|
# display at least several stack frames worth of backtrace. We'll
|
258 |
|
|
# assume that if we can't display at least "depth" levels (with
|
259 |
|
|
# args), it counts as an error.
|
260 |
|
|
|
261 |
|
|
send_gdb "backtrace\n"
|
262 |
|
|
gdb_expect {
|
263 |
|
|
-re "#$depth\[\t \].*gdb_recursion_test.*depth=\[0-9\]+.*q1=\[0-9\]+.*q2=\[0-9\]+.*q3=\[0-9\]+.*q4=\[0-9\]+.*q5=\[0-9\]+.*q6=\[0-9\]+.*$gdb_prompt $" {
|
264 |
|
|
pass "$msg"
|
265 |
|
|
}
|
266 |
|
|
-re "#$depth\[\t \].*gdb_recursion_test.*depth=.*$gdb_prompt $" {
|
267 |
|
|
fail "$msg (args missing from #$depth stack frame)"
|
268 |
|
|
}
|
269 |
|
|
-re "#\[0-9\]+\[\t \].*gdb_recursion_test.*depth=.*$gdb_prompt $" {
|
270 |
|
|
fail "$msg (fewer than $depth stack frames found)"
|
271 |
|
|
}
|
272 |
|
|
-re ".*$gdb_prompt $" {
|
273 |
|
|
fail "$msg"
|
274 |
|
|
}
|
275 |
|
|
timeout { fail "$msg (timeout)" }
|
276 |
|
|
}
|
277 |
|
|
}
|
278 |
|
|
|
279 |
|
|
#
|
280 |
|
|
# begin backtrace test
|
281 |
|
|
#
|
282 |
|
|
|
283 |
|
|
set timeout 60
|
284 |
|
|
|
285 |
|
|
gdb_tfind_test "init: make sure not debugging any trace frame" "none" "-1"
|
286 |
|
|
|
287 |
|
|
gdb_tfind_test "8.6: find start frame" "start" "0"
|
288 |
|
|
gdb_test "printf \"TDP \%d:\\n\", \$tracepoint" \
|
289 |
|
|
"TDP $tdp2:" ""
|
290 |
|
|
gdb_backtrace_tdp_1 "8.6: Backtrace, depth == 1, collect nothing"
|
291 |
|
|
|
292 |
|
|
gdb_tfind_test "8.6: find frame 1" "1" "1"
|
293 |
|
|
gdb_test "printf \"TDP \%d:\\n\", \$tracepoint" \
|
294 |
|
|
"TDP $tdp3:" ""
|
295 |
|
|
gdb_backtrace_tdp_2 "8.6: Backtrace, depth == 1, collect regs"
|
296 |
|
|
|
297 |
|
|
gdb_tfind_test "8.6: find frame 2" "2" "2"
|
298 |
|
|
gdb_test "printf \"TDP \%d:\\n\", \$tracepoint" \
|
299 |
|
|
"TDP $tdp4:" ""
|
300 |
|
|
gdb_backtrace_tdp_3 "8.6: Backtrace, depth == 1, collect args and locals"
|
301 |
|
|
|
302 |
|
|
|
303 |
|
|
gdb_tfind_test "8.6: find frame 4" "4" "4"
|
304 |
|
|
gdb_test "printf \"TDP \%d:\\n\", \$tracepoint" \
|
305 |
|
|
"TDP $tdp6:" ""
|
306 |
|
|
gdb_backtrace_tdp_4 "8.6: Backtrace, depth == 1, collect stack mem expr" "0"
|
307 |
|
|
|
308 |
|
|
gdb_tfind_test "8.6: find frame 5" "5" "5"
|
309 |
|
|
gdb_test "printf \"TDP \%d:\\n\", \$tracepoint" \
|
310 |
|
|
"TDP $tdp2:" ""
|
311 |
|
|
gdb_backtrace_tdp_1 "8.6: Backtrace, depth == 2, collect nothing"
|
312 |
|
|
|
313 |
|
|
gdb_tfind_test "8.6: find frame 6" "6" "6"
|
314 |
|
|
gdb_test "printf \"TDP \%d:\\n\", \$tracepoint" \
|
315 |
|
|
"TDP $tdp3:" ""
|
316 |
|
|
gdb_backtrace_tdp_2 "8.6: Backtrace, depth == 2, collect regs"
|
317 |
|
|
|
318 |
|
|
gdb_tfind_test "8.6: find frame 7" "7" "7"
|
319 |
|
|
gdb_test "printf \"TDP \%d:\\n\", \$tracepoint" \
|
320 |
|
|
"TDP $tdp4:" ""
|
321 |
|
|
gdb_backtrace_tdp_3 "8.6: Backtrace, depth == 2, collect args and locals"
|
322 |
|
|
|
323 |
|
|
|
324 |
|
|
gdb_tfind_test "8.6: find frame 9" "9" "9"
|
325 |
|
|
gdb_test "printf \"TDP \%d:\\n\", \$tracepoint" \
|
326 |
|
|
"TDP $tdp6:" ""
|
327 |
|
|
gdb_backtrace_tdp_4 "8.6: Backtrace, depth == 1, collect stack mem expr" "0"
|
328 |
|
|
|
329 |
|
|
gdb_tfind_test "8.6: find frame 10" "10" "10"
|
330 |
|
|
gdb_test "printf \"TDP \%d:\\n\", \$tracepoint" \
|
331 |
|
|
"TDP $tdp2:" ""
|
332 |
|
|
gdb_backtrace_tdp_1 "8.6: Backtrace, depth == 3, collect nothing"
|
333 |
|
|
|
334 |
|
|
gdb_tfind_test "8.6: find frame 11" "11" "11"
|
335 |
|
|
gdb_test "printf \"TDP \%d:\\n\", \$tracepoint" \
|
336 |
|
|
"TDP $tdp3:" ""
|
337 |
|
|
gdb_backtrace_tdp_2 "8.6: Backtrace, depth == 3, collect regs"
|
338 |
|
|
|
339 |
|
|
gdb_tfind_test "8.6: find frame 12" "12" "12"
|
340 |
|
|
gdb_test "printf \"TDP \%d:\\n\", \$tracepoint" \
|
341 |
|
|
"TDP $tdp4:" ""
|
342 |
|
|
gdb_backtrace_tdp_3 "8.6: Backtrace, depth == 3, collect args and locals"
|
343 |
|
|
|
344 |
|
|
|
345 |
|
|
gdb_tfind_test "8.6: find frame 14" "14" "14"
|
346 |
|
|
gdb_test "printf \"TDP \%d:\\n\", \$tracepoint" \
|
347 |
|
|
"TDP $tdp6:" ""
|
348 |
|
|
gdb_backtrace_tdp_4 "8.6: Backtrace, depth == 1, collect stack mem expr" "0"
|
349 |
|
|
|
350 |
|
|
gdb_tfind_test "8.6: find frame 15" "15" "15"
|
351 |
|
|
gdb_test "printf \"TDP \%d:\\n\", \$tracepoint" \
|
352 |
|
|
"TDP $tdp2:" ""
|
353 |
|
|
gdb_backtrace_tdp_1 "8.6: Backtrace, depth == 4, collect nothing"
|
354 |
|
|
|
355 |
|
|
gdb_tfind_test "8.6: find frame 16" "16" "16"
|
356 |
|
|
gdb_test "printf \"TDP \%d:\\n\", \$tracepoint" \
|
357 |
|
|
"TDP $tdp3:" ""
|
358 |
|
|
gdb_backtrace_tdp_2 "8.6: Backtrace, depth == 4, collect regs"
|
359 |
|
|
|
360 |
|
|
gdb_tfind_test "8.6: find frame 17" "17" "17"
|
361 |
|
|
gdb_test "printf \"TDP \%d:\\n\", \$tracepoint" \
|
362 |
|
|
"TDP $tdp4:" ""
|
363 |
|
|
gdb_backtrace_tdp_3 "8.6: Backtrace, depth == 4, collect args and locals"
|
364 |
|
|
|
365 |
|
|
|
366 |
|
|
gdb_tfind_test "8.6: find frame 19" "19" "19"
|
367 |
|
|
gdb_test "printf \"TDP \%d:\\n\", \$tracepoint" \
|
368 |
|
|
"TDP $tdp6:" ""
|
369 |
|
|
gdb_backtrace_tdp_4 "8.6: Backtrace, depth == 1, collect stack mem expr" "0"
|
370 |
|
|
|
371 |
|
|
gdb_test "printf \"x \%d x\\n\", depth == 3" \
|
372 |
|
|
"x 0 x" \
|
373 |
|
|
"1.13: trace in recursion: depth not equal to 3"
|
374 |
|
|
|
375 |
|
|
# Finished!
|
376 |
|
|
gdb_test "tfind none" "" ""
|