OLD | NEW |
1 # Copyright 1998, 2005, 2007-2012 Free Software Foundation, Inc. | 1 # Copyright 1998, 2005, 2007-2012 Free Software Foundation, Inc. |
2 | 2 |
3 # This program is free software; you can redistribute it and/or modify | 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 | 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 | 5 # the Free Software Foundation; either version 3 of the License, or |
6 # (at your option) any later version. | 6 # (at your option) any later version. |
7 # | 7 # |
8 # This program is distributed in the hope that it will be useful, | 8 # This program is distributed in the hope that it will be useful, |
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of | 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
11 # GNU General Public License for more details. | 11 # GNU General Public License for more details. |
12 # | 12 # |
13 # You should have received a copy of the GNU General Public License | 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/>. | 14 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
15 | 15 |
16 load_lib "trace-support.exp" | 16 load_lib "trace-support.exp" |
17 | 17 |
18 set testfile "unavailable" | 18 standard_testfile unavailable.cc |
19 set srcfile ${testfile}.cc | |
20 set executable $testfile | 19 set executable $testfile |
21 set binfile $objdir/$subdir/$executable | |
22 | 20 |
23 if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \ | 21 if {[prepare_for_testing $testfile.exp $testfile $srcfile \ |
24 » executable {debug nowarnings c++}] != "" } { | 22 » {debug nowarnings c++}]} { |
25 untested unavailable.exp | |
26 return -1 | 23 return -1 |
27 } | 24 } |
28 | 25 |
29 set ws "\[\r\n\t \]+" | 26 set ws "\[\r\n\t \]+" |
30 set cr "\[\r\n\]+" | 27 set cr "\[\r\n\]+" |
31 | 28 |
32 if [is_amd64_regs_target] { | 29 if [is_amd64_regs_target] { |
33 set fpreg "rbp" | 30 set fpreg "rbp" |
34 set spreg "rsp" | 31 set spreg "rsp" |
35 set pcreg "rip" | 32 set pcreg "rip" |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 "" \ | 126 "" \ |
130 "delete $var display" \ | 127 "delete $var display" \ |
131 ".*Delete all auto-display expressions.*y or n. $" \ | 128 ".*Delete all auto-display expressions.*y or n. $" \ |
132 "y" | 129 "y" |
133 } | 130 } |
134 | 131 |
135 # | 132 # |
136 # Test procs | 133 # Test procs |
137 # | 134 # |
138 | 135 |
139 proc gdb_collect_args_test {} { | 136 proc gdb_collect_args_test {} { with_test_prefix "unavailable arguments" { |
140 global cr | 137 global cr |
141 global gdb_prompt | 138 global gdb_prompt |
142 global pf_prefix | |
143 | |
144 set old_pf_prefix $pf_prefix | |
145 set pf_prefix "$pf_prefix unavailable arguments:" | |
146 | 139 |
147 prepare_for_trace_test | 140 prepare_for_trace_test |
148 | 141 |
149 gdb_test "trace args_test_func" \ | 142 gdb_test "trace args_test_func" \ |
150 "Tracepoint \[0-9\]+ at .*" \ | 143 "Tracepoint \[0-9\]+ at .*" \ |
151 "set tracepoint" | 144 "set tracepoint" |
152 | 145 |
153 # Begin the test. | 146 # Begin the test. |
154 run_trace_experiment args_test_func | 147 run_trace_experiment args_test_func |
155 | 148 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 set r "${r}argd = <unavailable>${cr}" | 191 set r "${r}argd = <unavailable>${cr}" |
199 set r "${r}argstruct = {memberc = <unavailable>, memberi = <unavailable>, me
mberf = <unavailable>, memberd = <unavailable>}${cr}" | 192 set r "${r}argstruct = {memberc = <unavailable>, memberi = <unavailable>, me
mberf = <unavailable>, memberd = <unavailable>}${cr}" |
200 set r "${r}argarray = <unavailable>${cr}" | 193 set r "${r}argarray = <unavailable>${cr}" |
201 gdb_test "info args" "$r" "info args" | 194 gdb_test "info args" "$r" "info args" |
202 | 195 |
203 test_maybe_regvar_display "argc" | 196 test_maybe_regvar_display "argc" |
204 | 197 |
205 gdb_test "tfind none" \ | 198 gdb_test "tfind none" \ |
206 "#0 end .*" \ | 199 "#0 end .*" \ |
207 "cease trace debugging" | 200 "cease trace debugging" |
| 201 }} |
208 | 202 |
209 set pf_prefix $old_pf_prefix | 203 proc gdb_collect_locals_test { func msg } { with_test_prefix "unavailable locals
: $msg" { |
210 } | |
211 | |
212 proc gdb_collect_locals_test { func msg } { | |
213 global cr | 204 global cr |
214 global gdb_prompt | 205 global gdb_prompt |
215 global pf_prefix | |
216 | |
217 set old_pf_prefix $pf_prefix | |
218 set pf_prefix "$pf_prefix unavailable locals: $msg:" | |
219 | 206 |
220 prepare_for_trace_test | 207 prepare_for_trace_test |
221 | 208 |
222 set testline [gdb_get_line_number "set $func tracepoint here"] | 209 set testline [gdb_get_line_number "set $func tracepoint here"] |
223 | 210 |
224 gdb_test "trace $testline" \ | 211 gdb_test "trace $testline" \ |
225 "Tracepoint \[0-9\]+ at .*" \ | 212 "Tracepoint \[0-9\]+ at .*" \ |
226 "set tracepoint" | 213 "set tracepoint" |
227 | 214 |
228 # Begin the test. | 215 # Begin the test. |
(...skipping 26 matching lines...) Expand all Loading... |
255 } | 242 } |
256 set r "${r}locc = <unavailable>${cr}" | 243 set r "${r}locc = <unavailable>${cr}" |
257 set r "${r}loci = <unavailable>${cr}" | 244 set r "${r}loci = <unavailable>${cr}" |
258 gdb_test "info locals" "$r" "info locals" | 245 gdb_test "info locals" "$r" "info locals" |
259 | 246 |
260 test_maybe_regvar_display "loci" | 247 test_maybe_regvar_display "loci" |
261 | 248 |
262 gdb_test "tfind none" \ | 249 gdb_test "tfind none" \ |
263 "#0 end .*" \ | 250 "#0 end .*" \ |
264 "cease trace debugging" | 251 "cease trace debugging" |
| 252 }} |
265 | 253 |
266 set pf_prefix $old_pf_prefix | 254 proc gdb_unavailable_registers_test { } { with_test_prefix "unavailable register
s" { |
267 } | |
268 | |
269 proc gdb_unavailable_registers_test { } { | |
270 global gdb_prompt | 255 global gdb_prompt |
271 global spreg | 256 global spreg |
272 global pcreg | 257 global pcreg |
273 global pf_prefix | |
274 | |
275 set old_pf_prefix $pf_prefix | |
276 set pf_prefix "$pf_prefix unavailable registers:" | |
277 | 258 |
278 prepare_for_trace_test | 259 prepare_for_trace_test |
279 | 260 |
280 # We'll simply re-use the globals_test_function for this test | 261 # We'll simply re-use the globals_test_function for this test |
281 gdb_test "trace globals_test_func" \ | 262 gdb_test "trace globals_test_func" \ |
282 "Tracepoint \[0-9\]+ at .*" \ | 263 "Tracepoint \[0-9\]+ at .*" \ |
283 "set tracepoint" | 264 "set tracepoint" |
284 | 265 |
285 # Collect nothing. | 266 # Collect nothing. |
286 | 267 |
(...skipping 25 matching lines...) Expand all Loading... |
312 | 293 |
313 gdb_test "info registers" \ | 294 gdb_test "info registers" \ |
314 "\\*value not available\\*.*\\*value not available\\*" \ | 295 "\\*value not available\\*.*\\*value not available\\*" \ |
315 "info registers, multiple registers not available" | 296 "info registers, multiple registers not available" |
316 | 297 |
317 gdb_test "info registers \$$spreg" \ | 298 gdb_test "info registers \$$spreg" \ |
318 "\\*value not available\\*" \ | 299 "\\*value not available\\*" \ |
319 "info registers \$$spreg reports not available" | 300 "info registers \$$spreg reports not available" |
320 | 301 |
321 gdb_test "tfind none" "#0 end .*" "cease trace debugging" | 302 gdb_test "tfind none" "#0 end .*" "cease trace debugging" |
| 303 }} |
322 | 304 |
323 set pf_prefix $old_pf_prefix | 305 proc gdb_unavailable_floats { } { |
| 306 global gdb_prompt |
| 307 |
| 308 with_test_prefix "unavailable floats" { |
| 309 » prepare_for_trace_test |
| 310 |
| 311 » # We'll simply re-use the globals_test_function for this test |
| 312 » gdb_test "trace globals_test_func" \ |
| 313 » "Tracepoint \[0-9\]+ at .*" \ |
| 314 » "set tracepoint" |
| 315 |
| 316 » # Collect nothing. |
| 317 |
| 318 » # Begin the test. |
| 319 » run_trace_experiment globals_test_func |
| 320 |
| 321 » # Necessarily target specific. |
| 322 » if {[istarget "x86_64-*-*"] || [istarget i?86-*]} { |
| 323 » send_gdb "info float\n" |
| 324 » gdb_expect_list "info float" ".*$gdb_prompt $" { |
| 325 » » "Status Word: <unavailable>" |
| 326 » » "Control Word: <unavailable>" |
| 327 » » "Tag Word: <unavailable>" |
| 328 » » "Instruction Pointer: <unavailable>:<unavailable>" |
| 329 » » "Operand Pointer: <unavailable>:<unavailable>" |
| 330 » » "Opcode: <unavailable>" |
| 331 » } |
| 332 » } |
| 333 |
| 334 » gdb_test "tfind none" "#0 end .*" "cease trace debugging" |
| 335 } |
324 } | 336 } |
325 | 337 |
326 proc gdb_collect_globals_test { } { | 338 proc gdb_collect_globals_test { } { with_test_prefix "collect globals" { |
327 global ws | 339 global ws |
328 global cr | 340 global cr |
329 global gdb_prompt | 341 global gdb_prompt |
330 global hex | 342 global hex |
331 global pf_prefix | |
332 | |
333 set old_pf_prefix $pf_prefix | |
334 set pf_prefix "$pf_prefix collect globals:" | |
335 | 343 |
336 prepare_for_trace_test | 344 prepare_for_trace_test |
337 | 345 |
338 set testline [gdb_get_line_number "set globals_test_func tracepoint here"] | 346 set testline [gdb_get_line_number "set globals_test_func tracepoint here"] |
339 | 347 |
340 gdb_test "trace $testline" \ | 348 gdb_test "trace $testline" \ |
341 "Tracepoint \[0-9\]+ at .*" \ | 349 "Tracepoint \[0-9\]+ at .*" \ |
342 "set tracepoint" | 350 "set tracepoint" |
343 | 351 |
344 # We collect the initial sizeof(pointer) bytes of derived_partial | 352 # We collect the initial sizeof(pointer) bytes of derived_partial |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
457 " = {d = <unavailable>, ref = <unavailable>}" | 465 " = {d = <unavailable>, ref = <unavailable>}" |
458 | 466 |
459 # Strings | 467 # Strings |
460 | 468 |
461 # Const string is always available, even when not collected. | 469 # Const string is always available, even when not collected. |
462 gdb_test "print g_const_string" \ | 470 gdb_test "print g_const_string" \ |
463 " = \"hello world\"$cr" \ | 471 " = \"hello world\"$cr" \ |
464 "non collected const string is still printable" | 472 "non collected const string is still printable" |
465 | 473 |
466 gdb_test "print g_string_p" \ | 474 gdb_test "print g_string_p" \ |
467 » " = $hex \"hello world\"" \ | 475 » " = $hex <g_const_string> \"hello world\"" \ |
468 "printing constant string through collected pointer" | 476 "printing constant string through collected pointer" |
469 | 477 |
470 gdb_test "print g_string_unavail" \ | 478 gdb_test "print g_string_unavail" \ |
471 " = \{<unavailable> <repeats 12 times>\}" \ | 479 " = \{<unavailable> <repeats 12 times>\}" \ |
472 "printing non collected string" | 480 "printing non collected string" |
473 | 481 |
474 # Incomplete strings print as an array. | 482 # Incomplete strings print as an array. |
475 gdb_test "print g_string_partial" \ | 483 gdb_test "print g_string_partial" \ |
476 "\\$\[0-9\]+ = \{<unavailable>, 101 'e', 108 'l', <unavailable>, <unavai
lable>, <unavailable>, <unavailable>, <unavailable>, <unavailable>, <unavailable
>, <unavailable>, <unavailable>\}" \ | 484 "\\$\[0-9\]+ = \{<unavailable>, 101 'e', 108 'l', <unavailable>, <unavai
lable>, <unavailable>, <unavailable>, <unavailable>, <unavailable>, <unavailable
>, <unavailable>, <unavailable>\}" \ |
477 "printing partially collected string" | 485 "printing partially collected string" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
511 | 519 |
512 # Cast to baseclass, checking the unavailable-ness is propagated. | 520 # Cast to baseclass, checking the unavailable-ness is propagated. |
513 gdb_test "print (small_struct) g_smallstruct_b" " = \\{member = <unavailable
>\\}" | 521 gdb_test "print (small_struct) g_smallstruct_b" " = \\{member = <unavailable
>\\}" |
514 | 522 |
515 # Same cast, but starting from a non-lazy, value. | 523 # Same cast, but starting from a non-lazy, value. |
516 gdb_test "print g_smallstruct_b" " = \\{<small_struct> = \\{member = <unavai
lable>\\}, <No data fields>\\}" | 524 gdb_test "print g_smallstruct_b" " = \\{<small_struct> = \\{member = <unavai
lable>\\}, <No data fields>\\}" |
517 gdb_test "print (small_struct) \$" " = \\{member = <unavailable>\\}" | 525 gdb_test "print (small_struct) \$" " = \\{member = <unavailable>\\}" |
518 | 526 |
519 gdb_test_no_output "set print object on" | 527 gdb_test_no_output "set print object on" |
520 | 528 |
521 set old_pf_prefix_2 $pf_prefix | 529 with_test_prefix "print object on" { |
522 set pf_prefix "$pf_prefix print object on:" | 530 » # With print object on, printing a pointer may need to fetch |
| 531 » # the pointed-to object, to check its run-time type. Make |
| 532 » # sure that fails gracefully and transparently when the |
| 533 » # pointer itself is unavailable. |
| 534 » gdb_test "print virtualp" " = \\(Virtual \\*\\) <unavailable>" |
523 | 535 |
524 # With print object on, printing a pointer may need to fetch the | 536 » # no vtable pointer available |
525 # pointed-to object, to check its run-time type. Make sure that | 537 » gdb_test "print derived_unavail" \ |
526 # fails gracefully and transparently when the pointer itself is | 538 » " = {<Middle> = <unavailable>, _vptr.Derived = <unavailable>, z = <u
navailable>}" |
527 # unavailable. | |
528 gdb_test "print virtualp" " = \\(Virtual \\*\\) <unavailable>" | |
529 | 539 |
530 # no vtable pointer available | 540 » # vtable pointer available, but nothing else |
531 gdb_test "print derived_unavail" \ | 541 » gdb_test "print derived_partial" \ |
532 » " = {<Middle> = <unavailable>, _vptr.Derived = <unavailable>, z = <unava
ilable>}" | 542 » " = \\(Derived\\) {<Middle> = {<Base> = <unavailable>, _vptr.Middle
= <unavailable>, y = <unavailable>}, _vptr.Derived = $hex <vtable for Derived.*>
, z = <unavailable>}" |
533 | 543 |
534 # vtable pointer available, but nothing else | 544 » # whole object available |
535 gdb_test "print derived_partial" \ | 545 » gdb_test "print derived_whole" \ |
536 » " = \\(Derived\\) {<Middle> = {<Base> = <unavailable>, _vptr.Middle = <u
navailable>, y = <unavailable>}, _vptr.Derived = $hex, z = <unavailable>}" | 546 » " = \\(Derived\\) {<Middle> = {<Base> = {x = 2}, _vptr.Middle = $hex
, y = 3}, _vptr.Derived = $hex <vtable for Derived.*>, z = 4}" |
537 | 547 } |
538 # whole object available | |
539 gdb_test "print derived_whole" \ | |
540 » " = \\(Derived\\) {<Middle> = {<Base> = {x = 2}, _vptr.Middle = $hex, y
= 3}, _vptr.Derived = $hex, z = 4}" | |
541 | |
542 set pf_prefix $old_pf_prefix_2 | |
543 | 548 |
544 gdb_test_no_output "set print object off" | 549 gdb_test_no_output "set print object off" |
545 | 550 |
546 set pf_prefix "$pf_prefix print object off:" | 551 with_test_prefix "print object off" { |
| 552 » gdb_test "print virtualp" " = \\(Virtual \\*\\) <unavailable>" |
547 | 553 |
548 gdb_test "print virtualp" " = \\(Virtual \\*\\) <unavailable>" | 554 » # no vtable pointer available |
| 555 » gdb_test "print derived_unavail" \ |
| 556 » " = {<Middle> = <unavailable>, _vptr.Derived = <unavailable>, z = <u
navailable>}" |
549 | 557 |
550 # no vtable pointer available | 558 » # vtable pointer available, but nothing else |
551 gdb_test "print derived_unavail" \ | 559 » gdb_test "print derived_partial" \ |
552 » " = {<Middle> = <unavailable>, _vptr.Derived = <unavailable>, z = <unava
ilable>}" | 560 » " = {<Middle> = {<Base> = <unavailable>, _vptr.Middle = <unavailable
>, y = <unavailable>}, _vptr.Derived = $hex <vtable for Derived.*>, z = <unavail
able>}" |
553 | 561 |
554 # vtable pointer available, but nothing else | 562 » # whole object available |
555 gdb_test "print derived_partial" \ | 563 » gdb_test "print derived_whole" \ |
556 » " = {<Middle> = {<Base> = <unavailable>, _vptr.Middle = <unavailable>, y
= <unavailable>}, _vptr.Derived = $hex, z = <unavailable>}" | 564 » " = {<Middle> = {<Base> = {x = 2}, _vptr.Middle = $hex, y = 3}, _vpt
r.Derived = $hex <vtable for Derived.*>, z = 4}" |
557 | 565 } |
558 # whole object available | |
559 gdb_test "print derived_whole" \ | |
560 » " = {<Middle> = {<Base> = {x = 2}, _vptr.Middle = $hex, y = 3}, _vptr.De
rived = $hex, z = 4}" | |
561 | |
562 set pf_prefix $old_pf_prefix_2 | |
563 | 566 |
564 # An instance of a virtual class where we collected everything but | 567 # An instance of a virtual class where we collected everything but |
565 # the vptr. | 568 # the vptr. |
566 gdb_test "print virtual_partial" \ | 569 gdb_test "print virtual_partial" \ |
567 " = {_vptr.Virtual = <unavailable>, z = 0}" | 570 " = {_vptr.Virtual = <unavailable>, z = 0}" |
568 | 571 |
569 gdb_test "tfind none" \ | 572 gdb_test "tfind none" \ |
570 "#0 end .*" \ | 573 "#0 end .*" \ |
571 "cease trace debugging" | 574 "cease trace debugging" |
572 | 575 }} |
573 set pf_prefix $old_pf_prefix | |
574 } | |
575 | 576 |
576 proc gdb_trace_collection_test {} { | 577 proc gdb_trace_collection_test {} { |
577 gdb_collect_globals_test | 578 gdb_collect_globals_test |
578 gdb_unavailable_registers_test | 579 gdb_unavailable_registers_test |
| 580 gdb_unavailable_floats |
579 | 581 |
580 gdb_collect_args_test | 582 gdb_collect_args_test |
581 gdb_collect_locals_test local_test_func "auto locals" | 583 gdb_collect_locals_test local_test_func "auto locals" |
582 gdb_collect_locals_test reglocal_test_func "register locals" | 584 gdb_collect_locals_test reglocal_test_func "register locals" |
583 gdb_collect_locals_test statlocal_test_func "static locals" | 585 gdb_collect_locals_test statlocal_test_func "static locals" |
584 } | 586 } |
585 | 587 |
586 clean_restart $executable | |
587 runto_main | 588 runto_main |
588 | 589 |
589 # We generously give ourselves one "pass" if we successfully | |
590 # detect that this test cannot be run on this target! | |
591 if { ![gdb_target_supports_trace] } then { | 590 if { ![gdb_target_supports_trace] } then { |
592 pass "Current target does not support trace" | 591 unsupported "Current target does not support trace" |
593 return 1; | 592 return 1; |
594 } | 593 } |
595 | 594 |
596 # Body of test encased in a proc so we can return prematurely. | 595 # Body of test encased in a proc so we can return prematurely. |
597 gdb_trace_collection_test | 596 gdb_trace_collection_test |
598 | 597 |
599 # Finished! | 598 # Finished! |
600 gdb_test "tfind none" ".*" "" | 599 gdb_test "tfind none" ".*" "" |
OLD | NEW |