Commit | Line | Data |
---|---|---|
c5a57081 | 1 | # Copyright 1998, 2005, 2007-2012 Free Software Foundation, Inc. |
06d72e16 PA |
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 | load_lib "trace-support.exp" | |
17 | ||
18 | set testfile "unavailable" | |
19 | set srcfile ${testfile}.cc | |
20 | set executable $testfile | |
21 | set binfile $objdir/$subdir/$executable | |
22 | ||
23 | if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \ | |
24 | executable {debug nowarnings c++}] != "" } { | |
25 | untested unavailable.exp | |
26 | return -1 | |
27 | } | |
28 | ||
29 | set ws "\[\r\n\t \]+" | |
30 | set cr "\[\r\n\]+" | |
31 | ||
7f062217 | 32 | if [is_amd64_regs_target] { |
0fdb4f18 PA |
33 | set fpreg "rbp" |
34 | set spreg "rsp" | |
35 | set pcreg "rip" | |
7f062217 | 36 | } elseif [is_x86_like_target] { |
0fdb4f18 PA |
37 | set fpreg "ebp" |
38 | set spreg "esp" | |
39 | set pcreg "eip" | |
40 | } else { | |
41 | set fpreg "fp" | |
42 | set spreg "sp" | |
43 | set pcreg "pc" | |
44 | } | |
45 | ||
06d72e16 PA |
46 | # |
47 | # Utility procs | |
48 | # | |
49 | ||
0fdb4f18 PA |
50 | proc test_register { reg } { |
51 | global gdb_prompt | |
52 | global hex | |
53 | global cr | |
54 | ||
55 | gdb_test_multiple "print /x $reg" "collected $reg" { | |
56 | -re "\\$\[0-9\]+ = \[x0\]+$cr$gdb_prompt $" { | |
57 | fail "collected $reg (zero)" | |
58 | } | |
59 | -re "\\$\[0-9\]+ = $hex$cr$gdb_prompt $" { | |
60 | pass "collected $reg" | |
61 | } | |
62 | -re "\[Ee\]rror.*$gdb_prompt $" { | |
63 | fail "collected $reg (error)" | |
64 | } | |
65 | } | |
66 | } | |
67 | ||
68 | proc test_register_unavailable { reg } { | |
69 | gdb_test "print /x $reg" \ | |
70 | "<unavailable>" \ | |
71 | "correctly report $reg as unavailable" | |
72 | } | |
73 | ||
06d72e16 PA |
74 | proc prepare_for_trace_test {} { |
75 | global executable | |
76 | ||
77 | clean_restart $executable | |
78 | ||
79 | runto_main | |
80 | ||
81 | gdb_test "break begin" ".*" "" | |
82 | gdb_test "break end" ".*" "" | |
83 | } | |
84 | ||
85 | proc run_trace_experiment { test_func } { | |
86 | global gdb_prompt | |
87 | ||
88 | gdb_test "continue" \ | |
89 | ".*Breakpoint \[0-9\]+, begin .*" \ | |
90 | "advance to begin" | |
91 | ||
92 | gdb_test_no_output "tstart" "start trace experiment" | |
93 | ||
94 | gdb_test "continue" \ | |
95 | "Continuing.*Breakpoint \[0-9\]+, end.*" \ | |
96 | "run trace experiment" | |
97 | gdb_test "tstop" \ | |
98 | "\[\r\n\]+" \ | |
99 | "stop trace experiment" | |
100 | gdb_test "tfind start" \ | |
101 | "#0 $test_func .*" \ | |
102 | "tfind test frame" | |
103 | } | |
104 | ||
af6e93b2 PA |
105 | # Test that "display VAR" works as expected, assuming VAR is wholly |
106 | # unavailable. | |
107 | ||
108 | proc test_maybe_regvar_display { var } { | |
109 | global gdb_prompt | |
110 | ||
111 | # Evaluating VAR's location description may throw an internal | |
112 | # "unavailable" exception, if for example, the value of a register | |
113 | # necessary for computing VAR's location is unavailable. Such an | |
114 | # exception is caught, and should not cause automatic disablement | |
115 | # of the current display being printed. (GDB used to disable the | |
116 | # current display whenever any exception was thrown.) | |
117 | set test "display $var" | |
118 | gdb_test_multiple "$test" "$test" { | |
119 | -re "Disabling display ? to avoid infinite recursion.*$gdb_prompt $" { | |
120 | fail "$test" | |
121 | } | |
122 | -re "display ${var}\r\n1: ${var} = <unavailable>\r\n$gdb_prompt $" { | |
123 | pass "$test" | |
124 | } | |
125 | } | |
126 | gdb_test "info display" ".*1:\[ \t\]+y\[ \t\]+${var}" "display ${var} is enabled" | |
127 | ||
128 | gdb_test "undisp" \ | |
129 | "" \ | |
130 | "delete $var display" \ | |
131 | ".*Delete all auto-display expressions.*y or n. $" \ | |
132 | "y" | |
133 | } | |
134 | ||
06d72e16 PA |
135 | # |
136 | # Test procs | |
137 | # | |
138 | ||
0f4d39d5 | 139 | proc gdb_collect_args_test {} { with_test_prefix "unavailable arguments" { |
8661b11b PA |
140 | global cr |
141 | global gdb_prompt | |
8661b11b PA |
142 | |
143 | prepare_for_trace_test | |
144 | ||
145 | gdb_test "trace args_test_func" \ | |
146 | "Tracepoint \[0-9\]+ at .*" \ | |
147 | "set tracepoint" | |
148 | ||
149 | # Begin the test. | |
150 | run_trace_experiment args_test_func | |
151 | ||
152 | # Test printing the variables, and also their addresses. We | |
153 | # haven't collected any stack, so there's no way GDB can figure | |
154 | # out the latter. | |
155 | ||
156 | gdb_test "print argc" " = <unavailable>" | |
157 | gdb_test "print &argc" \ | |
158 | "Can't take address of \"argc\" which isn't an lvalue\." | |
159 | ||
160 | gdb_test "print argi" " = <unavailable>" | |
161 | gdb_test "print &argi" \ | |
162 | "Can't take address of \"argi\" which isn't an lvalue\." | |
163 | ||
164 | gdb_test "print argf" " = <unavailable>" | |
165 | gdb_test "print &argf" \ | |
166 | "Can't take address of \"argf\" which isn't an lvalue\." | |
167 | ||
168 | gdb_test "print argd" " = <unavailable>" | |
169 | gdb_test "print &argd" \ | |
170 | "Can't take address of \"argd\" which isn't an lvalue\." | |
171 | ||
172 | # struct arg as one of several args (near end of list) | |
173 | ||
174 | gdb_test "print argstruct" \ | |
175 | " = \{memberc = <unavailable>, memberi = <unavailable>, memberf = <unavailable>, memberd = <unavailable>\}" | |
176 | ||
177 | gdb_test "print argstruct.memberc" " = <unavailable>" | |
178 | gdb_test "print argstruct.memberi" " = <unavailable>" | |
179 | gdb_test "print argstruct.memberf" " = <unavailable>" | |
180 | gdb_test "print argstruct.memberd" " = <unavailable>" | |
181 | ||
182 | gdb_test "print argarray" " = \\(int \\*\\) <unavailable>" | |
183 | ||
184 | gdb_test "print &argarray" \ | |
185 | "Can't take address of \"argarray\" which isn't an lvalue\." | |
186 | ||
187 | gdb_test "print argarray\[0\]" "value is not available" | |
188 | ||
189 | # Test "info args" | |
190 | set r "" | |
191 | set r "${r}argc = <unavailable>${cr}" | |
192 | set r "${r}argi = <unavailable>${cr}" | |
193 | set r "${r}argf = <unavailable>${cr}" | |
194 | set r "${r}argd = <unavailable>${cr}" | |
195 | set r "${r}argstruct = {memberc = <unavailable>, memberi = <unavailable>, memberf = <unavailable>, memberd = <unavailable>}${cr}" | |
196 | set r "${r}argarray = <unavailable>${cr}" | |
197 | gdb_test "info args" "$r" "info args" | |
198 | ||
af6e93b2 PA |
199 | test_maybe_regvar_display "argc" |
200 | ||
8661b11b PA |
201 | gdb_test "tfind none" \ |
202 | "#0 end .*" \ | |
203 | "cease trace debugging" | |
6a5870ce | 204 | }} |
8661b11b | 205 | |
0f4d39d5 | 206 | proc gdb_collect_locals_test { func msg } { with_test_prefix "unavailable locals: $msg" { |
8661b11b PA |
207 | global cr |
208 | global gdb_prompt | |
8661b11b PA |
209 | |
210 | prepare_for_trace_test | |
211 | ||
212 | set testline [gdb_get_line_number "set $func tracepoint here"] | |
213 | ||
214 | gdb_test "trace $testline" \ | |
215 | "Tracepoint \[0-9\]+ at .*" \ | |
216 | "set tracepoint" | |
217 | ||
218 | # Begin the test. | |
219 | run_trace_experiment $func | |
220 | ||
221 | gdb_test "print locc" " = <unavailable>" | |
222 | gdb_test "print loci" " = <unavailable>" | |
223 | gdb_test "print locf" " = <unavailable>" | |
224 | gdb_test "print locd" " = <unavailable>" | |
225 | ||
226 | gdb_test "print locst.memberc" " = <unavailable>" | |
227 | gdb_test "print locst.memberi" " = <unavailable>" | |
228 | gdb_test "print locst.memberf" " = <unavailable>" | |
229 | gdb_test "print locst.memberd" " = <unavailable>" | |
230 | ||
231 | gdb_test "print locar\[0\]" " = <unavailable>" | |
232 | gdb_test "print locar\[1\]" " = <unavailable>" | |
233 | gdb_test "print locar\[2\]" " = <unavailable>" | |
234 | gdb_test "print locar\[3\]" " = <unavailable>" | |
235 | ||
236 | # Test "info locals" | |
237 | set r "" | |
238 | set r "${r}locf = <unavailable>${cr}" | |
239 | set r "${r}locd = <unavailable>${cr}" | |
240 | set r "${r}locst = {memberc = <unavailable>, memberi = <unavailable>, memberf = <unavailable>, memberd = <unavailable>}${cr}" | |
241 | set r "${r}locar = {<unavailable>, <unavailable>, <unavailable>, <unavailable>}${cr}" | |
242 | set r "${r}i = <unavailable>${cr}" | |
243 | if { $func == "local_test_func" } { | |
244 | set r "${r}locdefst = {<No data fields>}${cr}" | |
245 | } | |
246 | set r "${r}locc = <unavailable>${cr}" | |
247 | set r "${r}loci = <unavailable>${cr}" | |
248 | gdb_test "info locals" "$r" "info locals" | |
249 | ||
af6e93b2 PA |
250 | test_maybe_regvar_display "loci" |
251 | ||
8661b11b PA |
252 | gdb_test "tfind none" \ |
253 | "#0 end .*" \ | |
254 | "cease trace debugging" | |
6a5870ce | 255 | }} |
8661b11b | 256 | |
0f4d39d5 | 257 | proc gdb_unavailable_registers_test { } { with_test_prefix "unavailable registers" { |
0fdb4f18 PA |
258 | global gdb_prompt |
259 | global spreg | |
260 | global pcreg | |
0fdb4f18 PA |
261 | |
262 | prepare_for_trace_test | |
263 | ||
264 | # We'll simply re-use the globals_test_function for this test | |
265 | gdb_test "trace globals_test_func" \ | |
266 | "Tracepoint \[0-9\]+ at .*" \ | |
267 | "set tracepoint" | |
268 | ||
269 | # Collect nothing. | |
270 | ||
271 | # Begin the test. | |
272 | run_trace_experiment globals_test_func | |
273 | ||
274 | # On some archs, the $sp/$pc are a real raw registers. On others, | |
275 | # like x86, they're user registers. Test both variants. | |
276 | test_register_unavailable "\$$spreg" | |
277 | test_register_unavailable "\$sp" | |
278 | ||
279 | # Test reading uncollected pseudo-registers. The set of which | |
280 | # depends on target. | |
7f062217 | 281 | if [is_amd64_regs_target] { |
0fdb4f18 PA |
282 | # Check the raw register first. |
283 | test_register_unavailable "\$rax" | |
284 | test_register_unavailable "\$eax" | |
285 | test_register_unavailable "\$ax" | |
7f062217 | 286 | } elseif [is_x86_like_target] { |
0fdb4f18 PA |
287 | # Check the raw register first. |
288 | test_register_unavailable "\$eax" | |
289 | test_register_unavailable "\$ax" | |
290 | } | |
291 | ||
292 | # GDBserver always provides the PC value of regular tracepoint | |
293 | # hits, since it's the same as the tracepoint's address. | |
294 | test_register "\$$pcreg" | |
295 | test_register "\$pc" | |
296 | ||
297 | gdb_test "info registers" \ | |
298 | "\\*value not available\\*.*\\*value not available\\*" \ | |
299 | "info registers, multiple registers not available" | |
300 | ||
301 | gdb_test "info registers \$$spreg" \ | |
302 | "\\*value not available\\*" \ | |
303 | "info registers \$$spreg reports not available" | |
304 | ||
305 | gdb_test "tfind none" "#0 end .*" "cease trace debugging" | |
6a5870ce | 306 | }} |
0fdb4f18 | 307 | |
ad5f7d6e PA |
308 | proc gdb_unavailable_floats { } { |
309 | global gdb_prompt | |
310 | ||
311 | with_test_prefix "unavailable floats" { | |
312 | prepare_for_trace_test | |
313 | ||
314 | # We'll simply re-use the globals_test_function for this test | |
315 | gdb_test "trace globals_test_func" \ | |
316 | "Tracepoint \[0-9\]+ at .*" \ | |
317 | "set tracepoint" | |
318 | ||
319 | # Collect nothing. | |
320 | ||
321 | # Begin the test. | |
322 | run_trace_experiment globals_test_func | |
323 | ||
324 | # Necessarily target specific. | |
325 | if {[istarget "x86_64-*-*"] || [istarget i?86-*]} { | |
326 | send_gdb "info float\n" | |
327 | gdb_expect_list "info float" ".*$gdb_prompt $" { | |
328 | "Status Word: <unavailable>" | |
329 | "Control Word: <unavailable>" | |
330 | "Tag Word: <unavailable>" | |
331 | "Instruction Pointer: <unavailable>:<unavailable>" | |
332 | "Operand Pointer: <unavailable>:<unavailable>" | |
333 | "Opcode: <unavailable>" | |
334 | } | |
335 | } | |
336 | ||
337 | gdb_test "tfind none" "#0 end .*" "cease trace debugging" | |
338 | } | |
339 | } | |
340 | ||
0f4d39d5 | 341 | proc gdb_collect_globals_test { } { with_test_prefix "collect globals" { |
06d72e16 PA |
342 | global ws |
343 | global cr | |
344 | global gdb_prompt | |
345 | global hex | |
06d72e16 PA |
346 | |
347 | prepare_for_trace_test | |
348 | ||
349 | set testline [gdb_get_line_number "set globals_test_func tracepoint here"] | |
350 | ||
351 | gdb_test "trace $testline" \ | |
352 | "Tracepoint \[0-9\]+ at .*" \ | |
353 | "set tracepoint" | |
354 | ||
8af8e3bc PA |
355 | # We collect the initial sizeof(pointer) bytes of derived_partial |
356 | # in an attempt of collecting the vptr. Not portable, but should | |
357 | # work everywhere we need to care. | |
06d72e16 PA |
358 | gdb_trace_setactions "define actions" \ |
359 | "" \ | |
360 | "collect struct_b.struct_a.array\[2\]" "^$" \ | |
361 | "collect struct_b.struct_a.array\[100\]" "^$" \ | |
362 | \ | |
1b28d0b3 PA |
363 | "collect a" "^$" \ |
364 | "collect c" "^$" \ | |
365 | \ | |
06d72e16 PA |
366 | "collect tarray\[0\].a" "^$" \ |
367 | "collect tarray\[1\].a" "^$" \ | |
368 | "collect tarray\[3\].a" "^$" \ | |
369 | "collect tarray\[3\].b" "^$" \ | |
370 | "collect tarray\[4\].b" "^$" \ | |
371 | "collect tarray\[5\].b" "^$" \ | |
372 | \ | |
373 | "collect g_string_p" "^$" \ | |
374 | "collect g_string_partial\[1\]" "^$" \ | |
375 | "collect g_string_partial\[2\]" "^$" \ | |
376 | \ | |
8af8e3bc PA |
377 | "collect g_structref_p" "^$" \ |
378 | \ | |
379 | "collect *((char *)&derived_partial)@sizeof\(void *\)" "^$" \ | |
380 | "collect derived_whole" "^$" \ | |
381 | \ | |
382 | "collect virtual_partial.z" "^$" | |
06d72e16 PA |
383 | |
384 | # Begin the test. | |
385 | run_trace_experiment globals_test_func | |
386 | ||
387 | gdb_test "print globalc" " = <unavailable>" | |
388 | gdb_test "print globali" " = <unavailable>" | |
389 | gdb_test "print globalf" " = <unavailable>" | |
390 | gdb_test "print globald" " = <unavailable>" | |
391 | ||
392 | gdb_test "print globalstruct.memberc" " = <unavailable>" | |
393 | gdb_test "print globalstruct.memberi" " = <unavailable>" | |
394 | gdb_test "print globalstruct.memberf" " = <unavailable>" | |
395 | gdb_test "print globalstruct.memberd" " = <unavailable>" | |
396 | ||
397 | gdb_test "print globalstruct" \ | |
398 | " = {memberc = <unavailable>, memberi = <unavailable>, memberf = <unavailable>, memberd = <unavailable>}" | |
399 | ||
400 | gdb_test "print globalp == &globalstruct" \ | |
401 | "value is not available" \ | |
402 | "can't compare using non collected global pointer" | |
403 | ||
404 | gdb_test "print globalarr\[1\]" " = <unavailable>" | |
405 | gdb_test "print globalarr\[2\]" " = <unavailable>" | |
406 | gdb_test "print globalarr\[3\]" " = <unavailable>" | |
407 | ||
408 | gdb_test "print struct_b" \ | |
409 | " = {d = <unavailable>, ef = <unavailable>, struct_a = {a = <unavailable>, b = <unavailable>, array = {<unavailable>, <unavailable>, -1431655766, <unavailable> <repeats 97 times>, -1431655766, <unavailable> <repeats 9899 times>}, ptr = <unavailable>, bitfield = <unavailable>}, s = <unavailable>, static static_struct_a = {a = <unavailable>, b = <unavailable>, array = {<unavailable> <repeats 10000 times>}, ptr = <unavailable>, bitfield = <unavailable>}, string = <unavailable>}" | |
410 | ||
411 | gdb_test "print /x struct_b" \ | |
412 | " = {d = <unavailable>, ef = <unavailable>, struct_a = {a = <unavailable>, b = <unavailable>, array = {<unavailable>, <unavailable>, 0xaaaaaaaa, <unavailable> <repeats 97 times>, 0xaaaaaaaa, <unavailable> <repeats 9899 times>}, ptr = <unavailable>, bitfield = <unavailable>}, s = <unavailable>, static static_struct_a = {a = <unavailable>, b = <unavailable>, array = {<unavailable> <repeats 10000 times>}, ptr = <unavailable>, bitfield = <unavailable>}, string = <unavailable>}" | |
413 | ||
414 | gdb_test "print /x struct_b.struct_a" \ | |
415 | " = {a = <unavailable>, b = <unavailable>, array = {<unavailable>, <unavailable>, 0xaaaaaaaa, <unavailable> <repeats 97 times>, 0xaaaaaaaa, <unavailable> <repeats 9899 times>}, ptr = <unavailable>, bitfield = <unavailable>}" | |
416 | ||
417 | gdb_test "print /x struct_b.struct_a.array" \ | |
418 | " = {<unavailable>, <unavailable>, 0xaaaaaaaa, <unavailable> <repeats 97 times>, 0xaaaaaaaa, <unavailable> <repeats 9899 times>}" | |
419 | ||
420 | gdb_test "print /x struct_b.struct_a.array\[0\]" " = <unavailable>" | |
421 | ||
422 | gdb_test "print /x struct_b.struct_a.array\[2\]" " = 0xaaaaaaaa" | |
423 | ||
1b28d0b3 PA |
424 | # Check the target doesn't overcollect. GDB used to merge memory |
425 | # ranges to collect if they were close enough (collecting the hole | |
426 | # as well), but does not do that anymore. It's plausible that a | |
427 | # target may do this on its end, but as of this writing, no known | |
428 | # target does it. | |
429 | gdb_test "print {a, b, c}" \ | |
430 | " = \\{1, <unavailable>, 3\\}" \ | |
431 | "No overcollect of almost but not quite adjacent memory ranges" | |
432 | ||
06d72e16 PA |
433 | # Check <unavailable> isn't confused with 0 in array element repetitions |
434 | ||
435 | gdb_test_no_output "set print repeat 1" | |
436 | ||
437 | gdb_test "print /x tarray" \ | |
438 | " = \{\{a = 0x0, b = <unavailable>\} <repeats 2 times>, \{a = <unavailable>, b = <unavailable>\}, \{a = 0x0, b = 0x0\}, \{a = <unavailable>, b = 0x0\} <repeats 2 times>, \{a = <unavailable>, b = <unavailable>\} <repeats 2 times>\}" \ | |
439 | "<unavailable> is not the same as 0 in array element repetitions" | |
440 | ||
441 | gdb_test_no_output "set print repeat 10" | |
442 | ||
24e6bcee PA |
443 | # Check that value repeat handles unavailable-ness. |
444 | gdb_test "print *tarray@3" " = \\{\\{a = 0, b = <unavailable>\\}, \\{a = 0, b = <unavailable>\\}, \\{a = <unavailable>, b = <unavailable>\\}\\}" | |
445 | ||
06d72e16 PA |
446 | # Static fields |
447 | ||
448 | gdb_test "print struct_b.static_struct_a" \ | |
449 | " = {a = <unavailable>, b = <unavailable>, array = {<unavailable> <repeats 10000 times>}, ptr = <unavailable>, bitfield = <unavailable>}" | |
450 | ||
451 | # Bitfields | |
452 | ||
453 | gdb_test "print struct_b.struct_a.bitfield" " = <unavailable>" | |
454 | ||
455 | # References | |
456 | ||
457 | gdb_test "print g_int" " = <unavailable>" | |
458 | ||
459 | gdb_test "print g_ref" \ | |
460 | "\\(int &\\) @$hex: <unavailable>" \ | |
461 | "global reference shows address but not value" | |
462 | ||
463 | gdb_test "print *&g_ref" \ | |
464 | "\\$\[0-9\]+ = <unavailable>$cr" \ | |
465 | "referenced integer was not collected (taking address of reference)" | |
466 | ||
467 | gdb_test "print *g_structref_p" \ | |
468 | " = {d = <unavailable>, ref = <unavailable>}" | |
469 | ||
470 | # Strings | |
471 | ||
472 | # Const string is always available, even when not collected. | |
473 | gdb_test "print g_const_string" \ | |
474 | " = \"hello world\"$cr" \ | |
475 | "non collected const string is still printable" | |
476 | ||
477 | gdb_test "print g_string_p" \ | |
478 | " = $hex \"hello world\"" \ | |
479 | "printing constant string through collected pointer" | |
480 | ||
481 | gdb_test "print g_string_unavail" \ | |
482 | " = \{<unavailable> <repeats 12 times>\}" \ | |
483 | "printing non collected string" | |
484 | ||
485 | # Incomplete strings print as an array. | |
486 | gdb_test "print g_string_partial" \ | |
487 | "\\$\[0-9\]+ = \{<unavailable>, 101 'e', 108 'l', <unavailable>, <unavailable>, <unavailable>, <unavailable>, <unavailable>, <unavailable>, <unavailable>, <unavailable>, <unavailable>\}" \ | |
488 | "printing partially collected string" | |
489 | ||
490 | # It is important for this test that the last examined value is | |
491 | # <unavailable>, to exercise the case of the $__ convenience | |
492 | # variable being set to <unavailable> without error. | |
493 | set msg "examining partially collected object" | |
494 | gdb_test_multiple "x /10x &struct_b" "$msg" { | |
495 | -re "$hex <struct_b>:${ws}<unavailable>${ws}<unavailable>${ws}<unavailable>${ws}<unavailable>$cr$hex <struct_b\\+16>:${ws}<unavailable>${ws}<unavailable>${ws}0xaaaaaaaa${ws}<unavailable>$cr$hex <struct_b\\+32>:${ws}<unavailable>${ws}<unavailable>$cr$gdb_prompt $" { | |
496 | pass "$msg" | |
497 | } | |
498 | -re "value is not available" { | |
499 | fail "$msg" | |
500 | } | |
501 | } | |
502 | ||
503 | gdb_test "p \$__" " = <unavailable>" "last examined value was <unavailable>" | |
504 | ||
39d37385 PA |
505 | # This tests that building the array does not require accessing |
506 | # g_int's contents. | |
507 | gdb_test "print { 1, g_int, 3 }" \ | |
508 | " = \\{1, <unavailable>, 3\\}" \ | |
509 | "build array from unavailable value" | |
510 | ||
511 | # Note, depends on previous test. | |
512 | gdb_test "print \$\[1\]" \ | |
513 | " = <unavailable>" \ | |
514 | "subscript a non-memory rvalue array, accessing an unvailable element" | |
515 | ||
516 | # Access a field of a non-lazy value, making sure the | |
517 | # unavailable-ness is propagated. History values are easy | |
518 | # non-lazy values, so use those. The first test just sets up for | |
519 | # the second. | |
520 | gdb_test "print g_smallstruct" " = \\{member = <unavailable>\\}" | |
521 | gdb_test "print \$.member" " = <unavailable>" | |
522 | ||
523 | # Cast to baseclass, checking the unavailable-ness is propagated. | |
524 | gdb_test "print (small_struct) g_smallstruct_b" " = \\{member = <unavailable>\\}" | |
525 | ||
526 | # Same cast, but starting from a non-lazy, value. | |
527 | gdb_test "print g_smallstruct_b" " = \\{<small_struct> = \\{member = <unavailable>\\}, <No data fields>\\}" | |
528 | gdb_test "print (small_struct) \$" " = \\{member = <unavailable>\\}" | |
529 | ||
ec0a52e1 PA |
530 | gdb_test_no_output "set print object on" |
531 | ||
fdcfef12 PA |
532 | with_test_prefix "print object on" { |
533 | # With print object on, printing a pointer may need to fetch | |
534 | # the pointed-to object, to check its run-time type. Make | |
535 | # sure that fails gracefully and transparently when the | |
536 | # pointer itself is unavailable. | |
537 | gdb_test "print virtualp" " = \\(Virtual \\*\\) <unavailable>" | |
538 | ||
539 | # no vtable pointer available | |
540 | gdb_test "print derived_unavail" \ | |
541 | " = {<Middle> = <unavailable>, _vptr.Derived = <unavailable>, z = <unavailable>}" | |
542 | ||
543 | # vtable pointer available, but nothing else | |
544 | gdb_test "print derived_partial" \ | |
545 | " = \\(Derived\\) {<Middle> = {<Base> = <unavailable>, _vptr.Middle = <unavailable>, y = <unavailable>}, _vptr.Derived = $hex, z = <unavailable>}" | |
546 | ||
547 | # whole object available | |
548 | gdb_test "print derived_whole" \ | |
549 | " = \\(Derived\\) {<Middle> = {<Base> = {x = 2}, _vptr.Middle = $hex, y = 3}, _vptr.Derived = $hex, z = 4}" | |
550 | } | |
8af8e3bc | 551 | |
ec0a52e1 PA |
552 | gdb_test_no_output "set print object off" |
553 | ||
fdcfef12 PA |
554 | with_test_prefix "print object off" { |
555 | gdb_test "print virtualp" " = \\(Virtual \\*\\) <unavailable>" | |
8af8e3bc | 556 | |
fdcfef12 PA |
557 | # no vtable pointer available |
558 | gdb_test "print derived_unavail" \ | |
559 | " = {<Middle> = <unavailable>, _vptr.Derived = <unavailable>, z = <unavailable>}" | |
8af8e3bc | 560 | |
fdcfef12 PA |
561 | # vtable pointer available, but nothing else |
562 | gdb_test "print derived_partial" \ | |
563 | " = {<Middle> = {<Base> = <unavailable>, _vptr.Middle = <unavailable>, y = <unavailable>}, _vptr.Derived = $hex, z = <unavailable>}" | |
8af8e3bc | 564 | |
fdcfef12 PA |
565 | # whole object available |
566 | gdb_test "print derived_whole" \ | |
567 | " = {<Middle> = {<Base> = {x = 2}, _vptr.Middle = $hex, y = 3}, _vptr.Derived = $hex, z = 4}" | |
568 | } | |
8af8e3bc PA |
569 | |
570 | # An instance of a virtual class where we collected everything but | |
571 | # the vptr. | |
572 | gdb_test "print virtual_partial" \ | |
573 | " = {_vptr.Virtual = <unavailable>, z = 0}" | |
574 | ||
06d72e16 PA |
575 | gdb_test "tfind none" \ |
576 | "#0 end .*" \ | |
577 | "cease trace debugging" | |
6a5870ce | 578 | }} |
06d72e16 PA |
579 | |
580 | proc gdb_trace_collection_test {} { | |
581 | gdb_collect_globals_test | |
0fdb4f18 | 582 | gdb_unavailable_registers_test |
ad5f7d6e | 583 | gdb_unavailable_floats |
8661b11b PA |
584 | |
585 | gdb_collect_args_test | |
586 | gdb_collect_locals_test local_test_func "auto locals" | |
587 | gdb_collect_locals_test reglocal_test_func "register locals" | |
588 | gdb_collect_locals_test statlocal_test_func "static locals" | |
06d72e16 PA |
589 | } |
590 | ||
591 | clean_restart $executable | |
592 | runto_main | |
593 | ||
06d72e16 | 594 | if { ![gdb_target_supports_trace] } then { |
10010058 | 595 | unsupported "Current target does not support trace" |
06d72e16 PA |
596 | return 1; |
597 | } | |
598 | ||
599 | # Body of test encased in a proc so we can return prematurely. | |
600 | gdb_trace_collection_test | |
601 | ||
602 | # Finished! | |
603 | gdb_test "tfind none" ".*" "" |