Add translations for various sub-directories
[binutils-gdb.git] / gdb / testsuite / gdb.trace / unavailable.exp
blob83a327b4bcbc7259d7ee41e3ee81aaac1e6b13e5
1 # Copyright 1998-2024 Free Software Foundation, Inc.
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.
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.
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/>.
16 load_lib "trace-support.exp"
18 standard_testfile unavailable.cc
19 set executable $testfile
21 if {[prepare_for_testing "failed to prepare" $testfile $srcfile \
22          {debug nowarnings c++ nopie}]} {
23     return -1
26 set ws "\[\r\n\t \]+"
29 # Utility procs
32 proc test_register { reg } {
33     global gdb_prompt
34     global hex
36     gdb_test_multiple "print /x $reg" "collected $reg" {
37         -re "\\$\[0-9\]+ = \[x0\]+\r\n$gdb_prompt $" {
38             fail "collected $reg (zero)"
39         }
40         -re "\\$\[0-9\]+ = $hex\r\n$gdb_prompt $" {
41             pass "collected $reg"
42         }
43         -re "\[Ee\]rror.*$gdb_prompt $" {
44             fail "collected $reg (error)"
45         }
46     }
49 proc test_register_unavailable { reg } {
50     gdb_test "print /x $reg" \
51         "<unavailable>" \
52         "correctly report $reg as unavailable"
55 proc prepare_for_trace_test {} {
56     global executable
58     clean_restart $executable
60     runto_main
62     gdb_breakpoint "begin" qualified
63     gdb_breakpoint "end" qualified
66 proc run_trace_experiment { test_func } {
67     global gdb_prompt
69     gdb_test "continue" \
70         ".*Breakpoint \[0-9\]+, begin .*" \
71         "advance to begin"
73     gdb_test_no_output "tstart" "start trace experiment"
75     gdb_test "continue" \
76             "Continuing.*Breakpoint \[0-9\]+, end.*" \
77             "run trace experiment"
78     gdb_test_no_output "tstop" \
79             "stop trace experiment"
80     gdb_test "tfind start" \
81             "#0  $test_func .*" \
82             "tfind test frame"
85 # Test that "display VAR" works as expected, assuming VAR is wholly
86 # unavailable.
88 proc test_maybe_regvar_display { var } {
89     global gdb_prompt
91     # Evaluating VAR's location description may throw an internal
92     # "unavailable" exception, if for example, the value of a register
93     # necessary for computing VAR's location is unavailable.  Such an
94     # exception is caught, and should not cause automatic disablement
95     # of the current display being printed.  (GDB used to disable the
96     # current display whenever any exception was thrown.)
97     set test "display $var"
98     gdb_test_multiple "$test" "$test" {
99         -re "Disabling display ? to avoid infinite recursion.*$gdb_prompt $" {
100             fail "$test"
101         }
102         -re "display ${var}\r\n1: ${var} = <unavailable>\r\n$gdb_prompt $" {
103             pass "$test"
104         }
105     }
106     gdb_test "info display" ".*1:\[ \t\]+y\[ \t\]+${var}" "display ${var} is enabled"
108     gdb_test "undisp" \
109         "" \
110         "delete $var display" \
111         ".*Delete all auto-display expressions.*y or n. $" \
112         "y"
116 # Test procs
119 proc gdb_collect_args_test_1 {} {
120     # Test printing the variables, and also their addresses.  We
121     # haven't collected any stack, so there's no way GDB can figure
122     # out the latter.
124     gdb_test "print argc" " = <unavailable>"
125     gdb_test "print &argc" \
126         "Can't take address of \"argc\" which isn't an lvalue\."
128     gdb_test "print argi" " = <unavailable>"
129     gdb_test "print &argi" \
130         "Can't take address of \"argi\" which isn't an lvalue\."
132     gdb_test "print argf" " = <unavailable>"
133     gdb_test "print &argf" \
134         "Can't take address of \"argf\" which isn't an lvalue\."
136     gdb_test "print argd" " = <unavailable>"
137     gdb_test "print &argd" \
138         "Can't take address of \"argd\" which isn't an lvalue\."
140     # struct arg as one of several args (near end of list)
142     gdb_test "print argstruct" " = <unavailable>"
144     gdb_test "print argstruct.memberc" " = <unavailable>"
145     gdb_test "print argstruct.memberi" " = <unavailable>"
146     gdb_test "print argstruct.memberf" " = <unavailable>"
147     gdb_test "print argstruct.memberd" " = <unavailable>"
149     gdb_test "print argarray" " = <unavailable>"
151     gdb_test "print &argarray" \
152         "Can't take address of \"argarray\" which isn't an lvalue\."
154     gdb_test "print argarray\[0\]" "value is not available"
156     # Test "info args"
157     set r [multi_line \
158                "argc = <unavailable>" \
159                "argi = <unavailable>" \
160                "argf = <unavailable>" \
161                "argd = <unavailable>" \
162                "argstruct = <unavailable>" \
163                "argarray = <unavailable>"]
164     gdb_test "info args" "$r" "info args"
166     test_maybe_regvar_display "argc"
169 proc gdb_collect_args_test {} {
170     with_test_prefix "unavailable arguments" {
171         global gdb_prompt
172         global testfile srcdir subdir binfile
173         global trace_file_targets
175         prepare_for_trace_test
177         gdb_test "trace args_test_func" \
178             "Tracepoint \[0-9\]+ at .*" \
179             "set tracepoint"
181         # Begin the test.
182         run_trace_experiment args_test_func
184         gdb_collect_args_test_1
186         gdb_test "tfind none" \
187             "#0  end .*" \
188             "cease trace debugging"
190         set tracefile [standard_output_file ${testfile}]
191         gdb_test "tsave ${tracefile}.args.tfile" \
192             "Trace data saved to file '${tracefile}.args.tfile'\\." \
193             "tsave ${testfile}.args.tfile"
194         gdb_test "tsave -ctf ${tracefile}.args.ctf" \
195             "Trace data saved to directory '${tracefile}.args.ctf'\\." \
196             "save ctf trace file"
198         foreach target_name ${trace_file_targets} {
199             # Restart GDB and read the trace data in ${TARGET_NAME} target.
200             clean_restart
201             gdb_file_cmd $binfile
202             gdb_test "target ${target_name} ${tracefile}.args.${target_name}" ".*" \
203                 "change to ${target_name} target"
205             with_test_prefix "${target_name}" {
206                 gdb_test "tfind start" "#0  args_test_func .*" \
207                     "tfind test frame"
208                 gdb_collect_args_test_1
209             }
210         }
211     }
214 proc gdb_collect_locals_test_1 { func } {
215     gdb_test "print locc" " = <unavailable>"
216     gdb_test "print loci" " = <unavailable>"
217     gdb_test "print locf" " = <unavailable>"
218     gdb_test "print locd" " = <unavailable>"
220     gdb_test "print locst.memberc" " = <unavailable>"
221     gdb_test "print locst.memberi" " = <unavailable>"
222     gdb_test "print locst.memberf" " = <unavailable>"
223     gdb_test "print locst.memberd" " = <unavailable>"
225     gdb_test "print locar\[0\]" " = <unavailable>"
226     gdb_test "print locar\[1\]" " = <unavailable>"
227     gdb_test "print locar\[2\]" " = <unavailable>"
228     gdb_test "print locar\[3\]" " = <unavailable>"
230     # Test "info locals"
231     set r ""
232     set r "${r}locf = <unavailable>"
233     set r "${r}locd = <unavailable>"
234     set r "${r}locst = <unavailable>"
235     set r "${r}locar = <unavailable>"
236     set r "${r}i = <unavailable>"
237     if { $func == "local_test_func" } {
238         set r "${r}locdefst = <unavailable>"
239     }
240     set r "${r}locc = <unavailable>"
241     set r "${r}loci = <unavailable>"
242     gdb_test "info locals" "$r" "info locals"
244     test_maybe_regvar_display "loci"
247 proc gdb_collect_locals_test { func msg } {
248     with_test_prefix "unavailable locals: $msg" {
249         global gdb_prompt
250         global testfile srcdir subdir binfile
251         global trace_file_targets
253         prepare_for_trace_test
255         set testline [gdb_get_line_number "set $func tracepoint here"]
257         gdb_test "trace $testline" \
258             "Tracepoint \[0-9\]+ at .*" \
259             "set tracepoint"
261         # Begin the test.
262         run_trace_experiment $func
264         gdb_collect_locals_test_1 $func
266         gdb_test "tfind none" \
267             "#0  end .*" \
268             "cease trace debugging"
270         set tracefile [standard_output_file ${testfile}]
271         gdb_test "tsave ${tracefile}.locals.tfile" \
272             "Trace data saved to file '${tracefile}.locals.tfile'\\." \
273             "tsave ${testfile}.locals.tfile"
274         gdb_test "tsave -ctf ${tracefile}.locals.ctf" \
275             "Trace data saved to directory '${tracefile}.locals.ctf'\\." \
276             "save ctf trace file"
278         foreach target_name ${trace_file_targets} {
279             # Restart GDB and read the trace data in ${TARGET_NAME} target.
280             clean_restart
281             gdb_file_cmd $binfile
282             gdb_test "target ${target_name} ${tracefile}.locals.${target_name}" ".*" \
283                 "change to ${target_name} target"
285             with_test_prefix "${target_name}" {
286                 gdb_test "tfind start" "#0  $func .*" \
287                     "tfind test frame"
288                 gdb_collect_locals_test_1 $func
289             }
290         }
291     }
294 proc gdb_unavailable_registers_test_1 { } {
295     global spreg
296     global pcreg
298     # On some archs, the $sp/$pc are a real raw registers.  On others,
299     # like x86, they're user registers.  Test both variants.
300     test_register_unavailable "\$$spreg"
301     test_register_unavailable "\$sp"
303     # Test reading uncollected pseudo-registers.  The set of which
304     # depends on target.
305     if [is_amd64_regs_target] {
306         # Check the raw register first.
307         test_register_unavailable "\$rax"
308         test_register_unavailable "\$eax"
309         test_register_unavailable "\$ax"
310     } elseif [is_x86_like_target] {
311         # Check the raw register first.
312         test_register_unavailable "\$eax"
313         test_register_unavailable "\$ax"
314     }
316     # GDBserver always provides the PC value of regular tracepoint
317     # hits, since it's the same as the tracepoint's address.
318     test_register "\$$pcreg"
319     test_register "\$pc"
321     gdb_test "info registers" \
322         ".*<unavailable>.*<unavailable>.*" \
323         "info registers, multiple registers not available"
325     gdb_test "info registers \$$spreg" \
326         "<unavailable>" \
327         "info registers \$$spreg reports not available"
330 proc gdb_unavailable_registers_test { } {
331     with_test_prefix "unavailable registers" {
332         global testfile srcdir subdir binfile
333         global trace_file_targets
335         prepare_for_trace_test
337         # We'll simply re-use the globals_test_function for this test
338         gdb_test "trace globals_test_func" \
339             "Tracepoint \[0-9\]+ at .*" \
340             "set tracepoint"
342         # Collect nothing.
344         # Begin the test.
345         run_trace_experiment globals_test_func
347         gdb_unavailable_registers_test_1
349         gdb_test "tfind none" "#0  end .*" "cease trace debugging"
351         set tracefile [standard_output_file ${testfile}]
352         gdb_test "tsave ${tracefile}.registers.tfile" \
353             "Trace data saved to file '${tracefile}.registers.tfile'\\." \
354             "tsave ${testfile}.registers.tfile"
355         gdb_test "tsave -ctf ${tracefile}.registers.ctf" \
356             "Trace data saved to directory '${tracefile}.registers.ctf'\\." \
357             "save ctf trace file"
359         foreach target_name ${trace_file_targets} {
360             # Restart GDB and read the trace data in ${TARGET_NAME} target.
361             clean_restart
362             gdb_file_cmd $binfile
363             gdb_test "target ${target_name} ${tracefile}.registers.${target_name}" ".*" \
364                 "change to ${target_name} target"
366             with_test_prefix "${target_name}" {
367                 gdb_test "tfind start" "#0  globals_test_func .*" \
368                     "tfind test frame"
369                 gdb_unavailable_registers_test_1
370             }
371         }
372     }
375 proc gdb_unavailable_floats_1 { } {
376     global gdb_prompt
378     # Necessarily target specific.
379     if {[istarget "x86_64-*-*"] || [istarget i?86-*]} {
380         send_gdb "info float\n"
381         gdb_expect_list "info float" ".*$gdb_prompt $" {
382             "Status Word:         <unavailable>"
383             "Control Word:        <unavailable>"
384             "Tag Word:            <unavailable>"
385             "Instruction Pointer: <unavailable>:<unavailable>"
386             "Operand Pointer:     <unavailable>:<unavailable>"
387             "Opcode:              <unavailable>"
388         }
389     }
392 proc gdb_unavailable_floats { } {
393     with_test_prefix "unavailable floats" {
394         global testfile srcdir subdir binfile
395         global trace_file_targets
397         prepare_for_trace_test
399         # We'll simply re-use the globals_test_function for this test
400         gdb_test "trace globals_test_func" \
401             "Tracepoint \[0-9\]+ at .*" \
402             "set tracepoint"
404         # Collect nothing.
406         # Begin the test.
407         run_trace_experiment globals_test_func
409         gdb_unavailable_floats_1
411         gdb_test "tfind none" "#0  end .*" "cease trace debugging"
413         set tracefile [standard_output_file ${testfile}]
414         gdb_test "tsave ${tracefile}.floats.tfile" \
415             "Trace data saved to file '${tracefile}.floats.tfile'\\." \
416             "tsave ${testfile}.floats.tfile"
417         gdb_test "tsave -ctf ${tracefile}.floats.ctf" \
418             "Trace data saved to directory '${tracefile}.floats.ctf'\\." \
419             "save ctf trace file"
421         foreach target_name ${trace_file_targets} {
422             # Restart GDB and read the trace data in ${TARGET_NAME} target.
423             clean_restart
424             gdb_file_cmd $binfile
425             gdb_test "target ${target_name} ${tracefile}.floats.${target_name}" ".*" \
426                 "change to ${target_name} target"
428             with_test_prefix "${target_name}" {
429                 gdb_test "tfind start" "#0  globals_test_func .*" \
430                     "tfind test frame"
431                 gdb_unavailable_floats_1
432             }
433         }
434     }
437 proc gdb_collect_globals_test_1 { } {
438     global ws
439     global gdb_prompt
440     global hex
442     gdb_test "print globalc" " = <unavailable>"
443     gdb_test "print globali" " = <unavailable>"
444     gdb_test "print globalf" " = <unavailable>"
445     gdb_test "print globald" " = <unavailable>"
447     gdb_test "print globalstruct.memberc" " = <unavailable>"
448     gdb_test "print globalstruct.memberi" " = <unavailable>"
449     gdb_test "print globalstruct.memberf" " = <unavailable>"
450     gdb_test "print globalstruct.memberd" " = <unavailable>"
452     gdb_test "print globalstruct" " = <unavailable>"
454     gdb_test "print globalp == &globalstruct" \
455         "value is not available" \
456         "can't compare using non collected global pointer"
458     gdb_test "print globalarr\[1\]" " = <unavailable>"
459     gdb_test "print globalarr\[2\]" " = <unavailable>"
460     gdb_test "print globalarr\[3\]" " = <unavailable>"
462     gdb_test "print struct_b" \
463         " = {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>}"
465     gdb_test "print /x struct_b" \
466         " = {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>}"
468     gdb_test "print /x struct_b.struct_a" \
469         " = {a = <unavailable>, b = <unavailable>, array = {<unavailable>, <unavailable>, 0xaaaaaaaa, <unavailable> <repeats 97 times>, 0xaaaaaaaa, <unavailable> <repeats 9899 times>}, ptr = <unavailable>, bitfield = <unavailable>}"
471     gdb_test "print /x struct_b.struct_a.array" \
472         " = {<unavailable>, <unavailable>, 0xaaaaaaaa, <unavailable> <repeats 97 times>, 0xaaaaaaaa, <unavailable> <repeats 9899 times>}"
474     gdb_test "print /x struct_b.struct_a.array\[0\]" " = <unavailable>"
476     gdb_test "print /x struct_b.struct_a.array\[2\]" " = 0xaaaaaaaa"
478     # Check the target doesn't overcollect.  GDB used to merge memory
479     # ranges to collect if they were close enough (collecting the hole
480     # as well), but does not do that anymore.  It's plausible that a
481     # target may do this on its end, but as of this writing, no known
482     # target does it.
483     gdb_test "print {a, b, c}" \
484         " = \\{1, <unavailable>, 3\\}" \
485         "No overcollect of almost but not quite adjacent memory ranges"
487     # Check <unavailable> isn't confused with 0 in array element repetitions
489     gdb_test_no_output "set print repeat 1"
491     gdb_test "print /x tarray" \
492         " = \{\{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>\}" \
493         "<unavailable> is not the same as 0 in array element repetitions"
495     gdb_test_no_output "set print repeat 10"
497     # Check that value repeat handles unavailable-ness.
498     gdb_test "print *tarray@3" " = \\{\\{a = 0, b = <unavailable>\\}, \\{a = 0, b = <unavailable>\\}, \\{a = <unavailable>, b = <unavailable>\\}\\}"
500     # Static fields
502     gdb_test "print struct_b.static_struct_a" " = <unavailable>"
504     # Bitfields
506     gdb_test "print struct_b.struct_a.bitfield" " = <unavailable>"
508     # References
510     gdb_test "print g_int" " = <unavailable>"
512     gdb_test "print g_ref" \
513         "\\(int &\\) @$hex: <unavailable>" \
514         "global reference shows address but not value"
516     gdb_test "print *&g_ref" \
517         "\\$\[0-9\]+ = <unavailable>" \
518         "referenced integer was not collected (taking address of reference)"
520     gdb_test "print *g_structref_p" " = <unavailable>"
522     # Strings
524     # Const string is always available, even when not collected.
525     gdb_test "print g_const_string" \
526         " = \"hello world\"" \
527         "non collected const string is still printable"
529     gdb_test "print g_string_p" \
530         " = $hex <g_const_string> \"hello world\"" \
531         "printing constant string through collected pointer"
533     gdb_test "print g_string_unavail" \
534         " = <unavailable>" \
535         "printing non collected string"
537     # Incomplete strings print as an array.
538     gdb_test "print g_string_partial" \
539         "\\$\[0-9\]+ = \{<unavailable>, 101 'e', 108 'l', <unavailable>, <unavailable>, <unavailable>, <unavailable>, <unavailable>, <unavailable>, <unavailable>, <unavailable>, <unavailable>\}" \
540         "printing partially collected string"
542     # It is important for this test that the last examined value is
543     # <unavailable>, to exercise the case of the $__ convenience
544     # variable being set to <unavailable> without error.
545     set msg "examining partially collected object"
546     gdb_test_multiple "x /10x &struct_b" "$msg" {
547         -re "$hex <struct_b>:${ws}<unavailable>${ws}<unavailable>${ws}<unavailable>${ws}<unavailable>\r\n$hex <struct_b\\+16>:${ws}<unavailable>${ws}<unavailable>${ws}0xaaaaaaaa${ws}<unavailable>\r\n$hex <struct_b\\+32>:${ws}<unavailable>${ws}<unavailable>\r\n$gdb_prompt $" {
548             pass "$msg"
549         }
550         -re "value is not available" {
551             fail "$msg"
552         }
553     }
555     gdb_test "p \$__" " = <unavailable>" "last examined value was <unavailable>"
557     # This tests that building the array does not require accessing
558     # g_int's contents.
559     gdb_test "print { 1, g_int, 3 }" \
560         " = \\{1, <unavailable>, 3\\}" \
561         "build array from unavailable value"
563     # Note, depends on previous test.
564     gdb_test "print \$\[1\]" \
565         " = <unavailable>" \
566         "subscript a non-memory rvalue array, accessing an unvailable element"
568     # Access a field of a non-lazy value, making sure the
569     # unavailable-ness is propagated.  History values are easy
570     # non-lazy values, so use those.  The first test just sets up for
571     # the second.
572     gdb_test "print g_smallstruct" " = <unavailable>"
573     gdb_test "print \$.member" " = <unavailable>"
575     # Cast to baseclass, checking the unavailable-ness is propagated.
576     gdb_test "print (small_struct) g_smallstruct_b" " = <unavailable>"
578     # Same cast, but starting from a non-lazy, value.
579     gdb_test "print g_smallstruct_b" " = <unavailable>"
580     gdb_test "print (small_struct) \$" " = <unavailable>"
582     gdb_test_no_output "set print object on"
584     with_test_prefix "print object on" {
585         # With print object on, printing a pointer may need to fetch
586         # the pointed-to object, to check its run-time type.  Make
587         # sure that fails gracefully and transparently when the
588         # pointer itself is unavailable.
589         gdb_test "print virtualp" " = <unavailable>"
591         # no vtable pointer available
592         gdb_test "print derived_unavail" " = <unavailable>"
594         # vtable pointer available, but nothing else
595         gdb_test "print derived_partial" \
596             " = \\(Derived\\) {<Middle> = {<Base> = <unavailable>, _vptr.Middle = <unavailable>, y = <unavailable>}, _vptr.Derived = $hex <vtable for Derived.*>, z = <unavailable>}"
598         # whole object available
599         gdb_test "print derived_whole" \
600             " = \\(Derived\\) {<Middle> = {<Base> = {x = 2}, _vptr.Middle = ${hex}( <\[^>]*>)?, y = 3}, _vptr.Derived = $hex <vtable for Derived.*>, z = 4}"
601     }
603     gdb_test_no_output "set print object off"
605     with_test_prefix "print object off" {
606         gdb_test "print virtualp" " = <unavailable>"
608         # no vtable pointer available
609         gdb_test "print derived_unavail" \
610             " = <unavailable>"
612         # vtable pointer available, but nothing else
613         gdb_test "print derived_partial" \
614             " = {<Middle> = {<Base> = <unavailable>, _vptr.Middle = <unavailable>, y = <unavailable>}, _vptr.Derived = $hex <vtable for Derived.*>, z = <unavailable>}"
616         # whole object available
617         gdb_test "print derived_whole" \
618             " = {<Middle> = {<Base> = {x = 2}, _vptr.Middle = ${hex}( <\[^>]*>)?, y = 3}, _vptr.Derived = $hex <vtable for Derived.*>, z = 4}"
619     }
621     # An instance of a virtual class where we collected everything but
622     # the vptr.
623     gdb_test "print virtual_partial" \
624         " = {_vptr.Virtual = <unavailable>, z = 0}"
627 proc gdb_collect_globals_test { } {
628     with_test_prefix "collect globals" {
629         global testfile binfile srcdir subdir
630         global trace_file_targets
632         prepare_for_trace_test
634         set testline [gdb_get_line_number "set globals_test_func tracepoint here"]
636         gdb_test "trace $testline" \
637             "Tracepoint \[0-9\]+ at .*" \
638             "set tracepoint"
640         # We collect the initial sizeof(pointer) bytes of derived_partial
641         # in an attempt of collecting the vptr.  Not portable, but should
642         # work everywhere we need to care.
643         gdb_trace_setactions "define actions" \
644             "" \
645             "collect struct_b.struct_a.array\[2\]" "^$" \
646             "collect struct_b.struct_a.array\[100\]" "^$" \
647             \
648             "collect a" "^$" \
649             "collect c" "^$" \
650             \
651             "collect tarray\[0\].a" "^$" \
652             "collect tarray\[1\].a" "^$" \
653             "collect tarray\[3\].a" "^$" \
654             "collect tarray\[3\].b" "^$" \
655             "collect tarray\[4\].b" "^$" \
656             "collect tarray\[5\].b" "^$" \
657             \
658             "collect g_string_p" "^$" \
659             "collect g_string_partial\[1\]" "^$" \
660             "collect g_string_partial\[2\]" "^$" \
661             \
662             "collect g_structref_p" "^$" \
663             \
664             "collect *((char *)&derived_partial)@sizeof\(void *\)" "^$" \
665             "collect derived_whole" "^$" \
666             \
667             "collect virtual_partial.z" "^$"
669         # Begin the test.
670         run_trace_experiment globals_test_func
672         gdb_collect_globals_test_1
674         gdb_test "tfind none" \
675             "#0  end .*" \
676             "cease trace debugging"
678         set tracefile [standard_output_file ${testfile}]
679         gdb_test "tsave ${tracefile}.globals.tfile" \
680             "Trace data saved to file '${tracefile}.globals.tfile'\\." \
681             "tsave ${testfile}.globals.tfile"
682         gdb_test "tsave -ctf ${tracefile}.globals.ctf" \
683             "Trace data saved to directory '${tracefile}.globals.ctf'\\." \
684             "save ctf trace file"
686         foreach target_name ${trace_file_targets} {
687             # Restart GDB and read the trace data in ${TARGET_NAME} target.
688             clean_restart
689             gdb_file_cmd $binfile
690             gdb_test "target ${target_name} ${tracefile}.globals.${target_name}" ".*" \
691                 "change to ${target_name} target"
693             with_test_prefix "${target_name}" {
694                 gdb_test "tfind start" "#0  globals_test_func .*" \
695                     "tfind test frame"
696                 gdb_collect_globals_test_1
697             }
698         }
700     }
703 proc gdb_trace_collection_test {} {
704     gdb_collect_globals_test
705     gdb_unavailable_registers_test
706     gdb_unavailable_floats
708     gdb_collect_args_test
709     gdb_collect_locals_test local_test_func "auto locals"
710     gdb_collect_locals_test reglocal_test_func "register locals"
711     gdb_collect_locals_test statlocal_test_func "static locals"
714 runto_main
716 if {![gdb_target_supports_trace]} {
717     unsupported "current target does not support trace"
718     return 1
721 set trace_file_targets [list "tfile"]
722 gdb_test_multiple "target ctf" "" {
723     -re "Undefined target command: \"ctf\"\.  Try \"help target\"\.\r\n$gdb_prompt $" {
724     }
725     -re "No CTF directory specified.*\r\n$gdb_prompt $" {
726         lappend trace_file_targets "ctf"
727     }
730 # Body of test encased in a proc so we can return prematurely.
731 gdb_trace_collection_test
733 # Finished!
734 gdb_test "tfind none" ".*" ""