mirror of
https://github.com/darlinghq/darling-gdb.git
synced 2024-12-11 06:04:12 +00:00
Move traceframe checking out of traceframe generation
This patch moves traceframe checking code out of traceframe generation, so that we can generation traceframe once, and do the checking in multiple times (with target remote, tfile and ctf respectively). This is a pure refactor, not functional changes in unavailable.exp. gdb/testsuite: 2014-05-05 Yao Qi <yao@codesourcery.com> * gdb.trace/unavailable.exp (gdb_collect_args_test): Move some code to ... (gdb_collect_args_test_1): ... it. New proc. (gdb_collect_locals_test): Move some code to ... (gdb_collect_locals_test_1): ... it. New proc. (gdb_unavailable_registers_test): Move some code to ... (gdb_unavailable_registers_test_1): ... it. New proc. (gdb_unavailable_floats): Move some code to ... (gdb_unavailable_floats_1): ... it. New proc.
This commit is contained in:
parent
74183dabc3
commit
b5262cd094
@ -1,3 +1,15 @@
|
||||
2014-05-05 Yao Qi <yao@codesourcery.com>
|
||||
|
||||
* gdb.trace/unavailable.exp (gdb_collect_args_test): Move some
|
||||
code to ...
|
||||
(gdb_collect_args_test_1): ... it. New proc.
|
||||
(gdb_collect_locals_test): Move some code to ...
|
||||
(gdb_collect_locals_test_1): ... it. New proc.
|
||||
(gdb_unavailable_registers_test): Move some code to ...
|
||||
(gdb_unavailable_registers_test_1): ... it. New proc.
|
||||
(gdb_unavailable_floats): Move some code to ...
|
||||
(gdb_unavailable_floats_1): ... it. New proc.
|
||||
|
||||
2014-05-02 Sergio Durigan Junior <sergiodj@redhat.com>
|
||||
|
||||
* gdb.arch/amd64-stap-optional-prefix.S (main): Add several
|
||||
|
@ -133,9 +133,60 @@ proc test_maybe_regvar_display { var } {
|
||||
# Test procs
|
||||
#
|
||||
|
||||
proc gdb_collect_args_test_1 {} {
|
||||
global cr
|
||||
|
||||
# Test printing the variables, and also their addresses. We
|
||||
# haven't collected any stack, so there's no way GDB can figure
|
||||
# out the latter.
|
||||
|
||||
gdb_test "print argc" " = <unavailable>"
|
||||
gdb_test "print &argc" \
|
||||
"Can't take address of \"argc\" which isn't an lvalue\."
|
||||
|
||||
gdb_test "print argi" " = <unavailable>"
|
||||
gdb_test "print &argi" \
|
||||
"Can't take address of \"argi\" which isn't an lvalue\."
|
||||
|
||||
gdb_test "print argf" " = <unavailable>"
|
||||
gdb_test "print &argf" \
|
||||
"Can't take address of \"argf\" which isn't an lvalue\."
|
||||
|
||||
gdb_test "print argd" " = <unavailable>"
|
||||
gdb_test "print &argd" \
|
||||
"Can't take address of \"argd\" which isn't an lvalue\."
|
||||
|
||||
# struct arg as one of several args (near end of list)
|
||||
|
||||
gdb_test "print argstruct" " = <unavailable>"
|
||||
|
||||
gdb_test "print argstruct.memberc" " = <unavailable>"
|
||||
gdb_test "print argstruct.memberi" " = <unavailable>"
|
||||
gdb_test "print argstruct.memberf" " = <unavailable>"
|
||||
gdb_test "print argstruct.memberd" " = <unavailable>"
|
||||
|
||||
gdb_test "print argarray" " = <unavailable>"
|
||||
|
||||
gdb_test "print &argarray" \
|
||||
"Can't take address of \"argarray\" which isn't an lvalue\."
|
||||
|
||||
gdb_test "print argarray\[0\]" "value is not available"
|
||||
|
||||
# Test "info args"
|
||||
set r ""
|
||||
set r "${r}argc = <unavailable>${cr}"
|
||||
set r "${r}argi = <unavailable>${cr}"
|
||||
set r "${r}argf = <unavailable>${cr}"
|
||||
set r "${r}argd = <unavailable>${cr}"
|
||||
set r "${r}argstruct = <unavailable>${cr}"
|
||||
set r "${r}argarray = <unavailable>${cr}"
|
||||
gdb_test "info args" "$r" "info args"
|
||||
|
||||
test_maybe_regvar_display "argc"
|
||||
}
|
||||
|
||||
proc gdb_collect_args_test {} {
|
||||
with_test_prefix "unavailable arguments" {
|
||||
global cr
|
||||
global gdb_prompt
|
||||
|
||||
prepare_for_trace_test
|
||||
@ -147,53 +198,7 @@ proc gdb_collect_args_test {} {
|
||||
# Begin the test.
|
||||
run_trace_experiment args_test_func
|
||||
|
||||
# Test printing the variables, and also their addresses. We
|
||||
# haven't collected any stack, so there's no way GDB can figure
|
||||
# out the latter.
|
||||
|
||||
gdb_test "print argc" " = <unavailable>"
|
||||
gdb_test "print &argc" \
|
||||
"Can't take address of \"argc\" which isn't an lvalue\."
|
||||
|
||||
gdb_test "print argi" " = <unavailable>"
|
||||
gdb_test "print &argi" \
|
||||
"Can't take address of \"argi\" which isn't an lvalue\."
|
||||
|
||||
gdb_test "print argf" " = <unavailable>"
|
||||
gdb_test "print &argf" \
|
||||
"Can't take address of \"argf\" which isn't an lvalue\."
|
||||
|
||||
gdb_test "print argd" " = <unavailable>"
|
||||
gdb_test "print &argd" \
|
||||
"Can't take address of \"argd\" which isn't an lvalue\."
|
||||
|
||||
# struct arg as one of several args (near end of list)
|
||||
|
||||
gdb_test "print argstruct" " = <unavailable>"
|
||||
|
||||
gdb_test "print argstruct.memberc" " = <unavailable>"
|
||||
gdb_test "print argstruct.memberi" " = <unavailable>"
|
||||
gdb_test "print argstruct.memberf" " = <unavailable>"
|
||||
gdb_test "print argstruct.memberd" " = <unavailable>"
|
||||
|
||||
gdb_test "print argarray" " = <unavailable>"
|
||||
|
||||
gdb_test "print &argarray" \
|
||||
"Can't take address of \"argarray\" which isn't an lvalue\."
|
||||
|
||||
gdb_test "print argarray\[0\]" "value is not available"
|
||||
|
||||
# Test "info args"
|
||||
set r ""
|
||||
set r "${r}argc = <unavailable>${cr}"
|
||||
set r "${r}argi = <unavailable>${cr}"
|
||||
set r "${r}argf = <unavailable>${cr}"
|
||||
set r "${r}argd = <unavailable>${cr}"
|
||||
set r "${r}argstruct = <unavailable>${cr}"
|
||||
set r "${r}argarray = <unavailable>${cr}"
|
||||
gdb_test "info args" "$r" "info args"
|
||||
|
||||
test_maybe_regvar_display "argc"
|
||||
gdb_collect_args_test_1
|
||||
|
||||
gdb_test "tfind none" \
|
||||
"#0 end .*" \
|
||||
@ -201,9 +206,43 @@ proc gdb_collect_args_test {} {
|
||||
}
|
||||
}
|
||||
|
||||
proc gdb_collect_locals_test_1 { func } {
|
||||
global cr
|
||||
|
||||
gdb_test "print locc" " = <unavailable>"
|
||||
gdb_test "print loci" " = <unavailable>"
|
||||
gdb_test "print locf" " = <unavailable>"
|
||||
gdb_test "print locd" " = <unavailable>"
|
||||
|
||||
gdb_test "print locst.memberc" " = <unavailable>"
|
||||
gdb_test "print locst.memberi" " = <unavailable>"
|
||||
gdb_test "print locst.memberf" " = <unavailable>"
|
||||
gdb_test "print locst.memberd" " = <unavailable>"
|
||||
|
||||
gdb_test "print locar\[0\]" " = <unavailable>"
|
||||
gdb_test "print locar\[1\]" " = <unavailable>"
|
||||
gdb_test "print locar\[2\]" " = <unavailable>"
|
||||
gdb_test "print locar\[3\]" " = <unavailable>"
|
||||
|
||||
# Test "info locals"
|
||||
set r ""
|
||||
set r "${r}locf = <unavailable>${cr}"
|
||||
set r "${r}locd = <unavailable>${cr}"
|
||||
set r "${r}locst = <unavailable>${cr}"
|
||||
set r "${r}locar = <unavailable>${cr}"
|
||||
set r "${r}i = <unavailable>${cr}"
|
||||
if { $func == "local_test_func" } {
|
||||
set r "${r}locdefst = <unavailable>${cr}"
|
||||
}
|
||||
set r "${r}locc = <unavailable>${cr}"
|
||||
set r "${r}loci = <unavailable>${cr}"
|
||||
gdb_test "info locals" "$r" "info locals"
|
||||
|
||||
test_maybe_regvar_display "loci"
|
||||
}
|
||||
|
||||
proc gdb_collect_locals_test { func msg } {
|
||||
with_test_prefix "unavailable locals: $msg" {
|
||||
global cr
|
||||
global gdb_prompt
|
||||
|
||||
prepare_for_trace_test
|
||||
@ -217,36 +256,7 @@ proc gdb_collect_locals_test { func msg } {
|
||||
# Begin the test.
|
||||
run_trace_experiment $func
|
||||
|
||||
gdb_test "print locc" " = <unavailable>"
|
||||
gdb_test "print loci" " = <unavailable>"
|
||||
gdb_test "print locf" " = <unavailable>"
|
||||
gdb_test "print locd" " = <unavailable>"
|
||||
|
||||
gdb_test "print locst.memberc" " = <unavailable>"
|
||||
gdb_test "print locst.memberi" " = <unavailable>"
|
||||
gdb_test "print locst.memberf" " = <unavailable>"
|
||||
gdb_test "print locst.memberd" " = <unavailable>"
|
||||
|
||||
gdb_test "print locar\[0\]" " = <unavailable>"
|
||||
gdb_test "print locar\[1\]" " = <unavailable>"
|
||||
gdb_test "print locar\[2\]" " = <unavailable>"
|
||||
gdb_test "print locar\[3\]" " = <unavailable>"
|
||||
|
||||
# Test "info locals"
|
||||
set r ""
|
||||
set r "${r}locf = <unavailable>${cr}"
|
||||
set r "${r}locd = <unavailable>${cr}"
|
||||
set r "${r}locst = <unavailable>${cr}"
|
||||
set r "${r}locar = <unavailable>${cr}"
|
||||
set r "${r}i = <unavailable>${cr}"
|
||||
if { $func == "local_test_func" } {
|
||||
set r "${r}locdefst = <unavailable>${cr}"
|
||||
}
|
||||
set r "${r}locc = <unavailable>${cr}"
|
||||
set r "${r}loci = <unavailable>${cr}"
|
||||
gdb_test "info locals" "$r" "info locals"
|
||||
|
||||
test_maybe_regvar_display "loci"
|
||||
gdb_collect_locals_test_1 $func
|
||||
|
||||
gdb_test "tfind none" \
|
||||
"#0 end .*" \
|
||||
@ -254,11 +264,44 @@ proc gdb_collect_locals_test { func msg } {
|
||||
}
|
||||
}
|
||||
|
||||
proc gdb_unavailable_registers_test_1 { } {
|
||||
global spreg
|
||||
global pcreg
|
||||
|
||||
# On some archs, the $sp/$pc are a real raw registers. On others,
|
||||
# like x86, they're user registers. Test both variants.
|
||||
test_register_unavailable "\$$spreg"
|
||||
test_register_unavailable "\$sp"
|
||||
|
||||
# Test reading uncollected pseudo-registers. The set of which
|
||||
# depends on target.
|
||||
if [is_amd64_regs_target] {
|
||||
# Check the raw register first.
|
||||
test_register_unavailable "\$rax"
|
||||
test_register_unavailable "\$eax"
|
||||
test_register_unavailable "\$ax"
|
||||
} elseif [is_x86_like_target] {
|
||||
# Check the raw register first.
|
||||
test_register_unavailable "\$eax"
|
||||
test_register_unavailable "\$ax"
|
||||
}
|
||||
|
||||
# GDBserver always provides the PC value of regular tracepoint
|
||||
# hits, since it's the same as the tracepoint's address.
|
||||
test_register "\$$pcreg"
|
||||
test_register "\$pc"
|
||||
|
||||
gdb_test "info registers" \
|
||||
"<unavailable>.*<unavailable>" \
|
||||
"info registers, multiple registers not available"
|
||||
|
||||
gdb_test "info registers \$$spreg" \
|
||||
"<unavailable>" \
|
||||
"info registers \$$spreg reports not available"
|
||||
}
|
||||
|
||||
proc gdb_unavailable_registers_test { } {
|
||||
with_test_prefix "unavailable registers" {
|
||||
global gdb_prompt
|
||||
global spreg
|
||||
global pcreg
|
||||
|
||||
prepare_for_trace_test
|
||||
|
||||
@ -272,44 +315,30 @@ proc gdb_unavailable_registers_test { } {
|
||||
# Begin the test.
|
||||
run_trace_experiment globals_test_func
|
||||
|
||||
# On some archs, the $sp/$pc are a real raw registers. On others,
|
||||
# like x86, they're user registers. Test both variants.
|
||||
test_register_unavailable "\$$spreg"
|
||||
test_register_unavailable "\$sp"
|
||||
|
||||
# Test reading uncollected pseudo-registers. The set of which
|
||||
# depends on target.
|
||||
if [is_amd64_regs_target] {
|
||||
# Check the raw register first.
|
||||
test_register_unavailable "\$rax"
|
||||
test_register_unavailable "\$eax"
|
||||
test_register_unavailable "\$ax"
|
||||
} elseif [is_x86_like_target] {
|
||||
# Check the raw register first.
|
||||
test_register_unavailable "\$eax"
|
||||
test_register_unavailable "\$ax"
|
||||
}
|
||||
|
||||
# GDBserver always provides the PC value of regular tracepoint
|
||||
# hits, since it's the same as the tracepoint's address.
|
||||
test_register "\$$pcreg"
|
||||
test_register "\$pc"
|
||||
|
||||
gdb_test "info registers" \
|
||||
"<unavailable>.*<unavailable>" \
|
||||
"info registers, multiple registers not available"
|
||||
|
||||
gdb_test "info registers \$$spreg" \
|
||||
"<unavailable>" \
|
||||
"info registers \$$spreg reports not available"
|
||||
gdb_unavailable_registers_test_1
|
||||
|
||||
gdb_test "tfind none" "#0 end .*" "cease trace debugging"
|
||||
}
|
||||
}
|
||||
|
||||
proc gdb_unavailable_floats { } {
|
||||
proc gdb_unavailable_floats_1 { } {
|
||||
global gdb_prompt
|
||||
|
||||
# Necessarily target specific.
|
||||
if {[istarget "x86_64-*-*"] || [istarget i?86-*]} {
|
||||
send_gdb "info float\n"
|
||||
gdb_expect_list "info float" ".*$gdb_prompt $" {
|
||||
"Status Word: <unavailable>"
|
||||
"Control Word: <unavailable>"
|
||||
"Tag Word: <unavailable>"
|
||||
"Instruction Pointer: <unavailable>:<unavailable>"
|
||||
"Operand Pointer: <unavailable>:<unavailable>"
|
||||
"Opcode: <unavailable>"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
proc gdb_unavailable_floats { } {
|
||||
with_test_prefix "unavailable floats" {
|
||||
prepare_for_trace_test
|
||||
|
||||
@ -323,30 +352,205 @@ proc gdb_unavailable_floats { } {
|
||||
# Begin the test.
|
||||
run_trace_experiment globals_test_func
|
||||
|
||||
# Necessarily target specific.
|
||||
if {[istarget "x86_64-*-*"] || [istarget i?86-*]} {
|
||||
send_gdb "info float\n"
|
||||
gdb_expect_list "info float" ".*$gdb_prompt $" {
|
||||
"Status Word: <unavailable>"
|
||||
"Control Word: <unavailable>"
|
||||
"Tag Word: <unavailable>"
|
||||
"Instruction Pointer: <unavailable>:<unavailable>"
|
||||
"Operand Pointer: <unavailable>:<unavailable>"
|
||||
"Opcode: <unavailable>"
|
||||
}
|
||||
}
|
||||
gdb_unavailable_floats_1
|
||||
|
||||
gdb_test "tfind none" "#0 end .*" "cease trace debugging"
|
||||
}
|
||||
}
|
||||
|
||||
proc gdb_collect_globals_test_1 { } {
|
||||
global ws
|
||||
global cr
|
||||
global gdb_prompt
|
||||
global hex
|
||||
|
||||
gdb_test "print globalc" " = <unavailable>"
|
||||
gdb_test "print globali" " = <unavailable>"
|
||||
gdb_test "print globalf" " = <unavailable>"
|
||||
gdb_test "print globald" " = <unavailable>"
|
||||
|
||||
gdb_test "print globalstruct.memberc" " = <unavailable>"
|
||||
gdb_test "print globalstruct.memberi" " = <unavailable>"
|
||||
gdb_test "print globalstruct.memberf" " = <unavailable>"
|
||||
gdb_test "print globalstruct.memberd" " = <unavailable>"
|
||||
|
||||
gdb_test "print globalstruct" " = <unavailable>"
|
||||
|
||||
gdb_test "print globalp == &globalstruct" \
|
||||
"value is not available" \
|
||||
"can't compare using non collected global pointer"
|
||||
|
||||
gdb_test "print globalarr\[1\]" " = <unavailable>"
|
||||
gdb_test "print globalarr\[2\]" " = <unavailable>"
|
||||
gdb_test "print globalarr\[3\]" " = <unavailable>"
|
||||
|
||||
gdb_test "print struct_b" \
|
||||
" = {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>}"
|
||||
|
||||
gdb_test "print /x struct_b" \
|
||||
" = {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>}"
|
||||
|
||||
gdb_test "print /x struct_b.struct_a" \
|
||||
" = {a = <unavailable>, b = <unavailable>, array = {<unavailable>, <unavailable>, 0xaaaaaaaa, <unavailable> <repeats 97 times>, 0xaaaaaaaa, <unavailable> <repeats 9899 times>}, ptr = <unavailable>, bitfield = <unavailable>}"
|
||||
|
||||
gdb_test "print /x struct_b.struct_a.array" \
|
||||
" = {<unavailable>, <unavailable>, 0xaaaaaaaa, <unavailable> <repeats 97 times>, 0xaaaaaaaa, <unavailable> <repeats 9899 times>}"
|
||||
|
||||
gdb_test "print /x struct_b.struct_a.array\[0\]" " = <unavailable>"
|
||||
|
||||
gdb_test "print /x struct_b.struct_a.array\[2\]" " = 0xaaaaaaaa"
|
||||
|
||||
# Check the target doesn't overcollect. GDB used to merge memory
|
||||
# ranges to collect if they were close enough (collecting the hole
|
||||
# as well), but does not do that anymore. It's plausible that a
|
||||
# target may do this on its end, but as of this writing, no known
|
||||
# target does it.
|
||||
gdb_test "print {a, b, c}" \
|
||||
" = \\{1, <unavailable>, 3\\}" \
|
||||
"No overcollect of almost but not quite adjacent memory ranges"
|
||||
|
||||
# Check <unavailable> isn't confused with 0 in array element repetitions
|
||||
|
||||
gdb_test_no_output "set print repeat 1"
|
||||
|
||||
gdb_test "print /x tarray" \
|
||||
" = \{\{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>\}" \
|
||||
"<unavailable> is not the same as 0 in array element repetitions"
|
||||
|
||||
gdb_test_no_output "set print repeat 10"
|
||||
|
||||
# Check that value repeat handles unavailable-ness.
|
||||
gdb_test "print *tarray@3" " = \\{\\{a = 0, b = <unavailable>\\}, \\{a = 0, b = <unavailable>\\}, \\{a = <unavailable>, b = <unavailable>\\}\\}"
|
||||
|
||||
# Static fields
|
||||
|
||||
gdb_test "print struct_b.static_struct_a" " = <unavailable>"
|
||||
|
||||
# Bitfields
|
||||
|
||||
gdb_test "print struct_b.struct_a.bitfield" " = <unavailable>"
|
||||
|
||||
# References
|
||||
|
||||
gdb_test "print g_int" " = <unavailable>"
|
||||
|
||||
gdb_test "print g_ref" \
|
||||
"\\(int &\\) @$hex: <unavailable>" \
|
||||
"global reference shows address but not value"
|
||||
|
||||
gdb_test "print *&g_ref" \
|
||||
"\\$\[0-9\]+ = <unavailable>$cr" \
|
||||
"referenced integer was not collected (taking address of reference)"
|
||||
|
||||
gdb_test "print *g_structref_p" " = <unavailable>"
|
||||
|
||||
# Strings
|
||||
|
||||
# Const string is always available, even when not collected.
|
||||
gdb_test "print g_const_string" \
|
||||
" = \"hello world\"$cr" \
|
||||
"non collected const string is still printable"
|
||||
|
||||
gdb_test "print g_string_p" \
|
||||
" = $hex <g_const_string> \"hello world\"" \
|
||||
"printing constant string through collected pointer"
|
||||
|
||||
gdb_test "print g_string_unavail" \
|
||||
" = <unavailable>" \
|
||||
"printing non collected string"
|
||||
|
||||
# Incomplete strings print as an array.
|
||||
gdb_test "print g_string_partial" \
|
||||
"\\$\[0-9\]+ = \{<unavailable>, 101 'e', 108 'l', <unavailable>, <unavailable>, <unavailable>, <unavailable>, <unavailable>, <unavailable>, <unavailable>, <unavailable>, <unavailable>\}" \
|
||||
"printing partially collected string"
|
||||
|
||||
# It is important for this test that the last examined value is
|
||||
# <unavailable>, to exercise the case of the $__ convenience
|
||||
# variable being set to <unavailable> without error.
|
||||
set msg "examining partially collected object"
|
||||
gdb_test_multiple "x /10x &struct_b" "$msg" {
|
||||
-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 $" {
|
||||
pass "$msg"
|
||||
}
|
||||
-re "value is not available" {
|
||||
fail "$msg"
|
||||
}
|
||||
}
|
||||
|
||||
gdb_test "p \$__" " = <unavailable>" "last examined value was <unavailable>"
|
||||
|
||||
# This tests that building the array does not require accessing
|
||||
# g_int's contents.
|
||||
gdb_test "print { 1, g_int, 3 }" \
|
||||
" = \\{1, <unavailable>, 3\\}" \
|
||||
"build array from unavailable value"
|
||||
|
||||
# Note, depends on previous test.
|
||||
gdb_test "print \$\[1\]" \
|
||||
" = <unavailable>" \
|
||||
"subscript a non-memory rvalue array, accessing an unvailable element"
|
||||
|
||||
# Access a field of a non-lazy value, making sure the
|
||||
# unavailable-ness is propagated. History values are easy
|
||||
# non-lazy values, so use those. The first test just sets up for
|
||||
# the second.
|
||||
gdb_test "print g_smallstruct" " = <unavailable>"
|
||||
gdb_test "print \$.member" " = <unavailable>"
|
||||
|
||||
# Cast to baseclass, checking the unavailable-ness is propagated.
|
||||
gdb_test "print (small_struct) g_smallstruct_b" " = <unavailable>"
|
||||
|
||||
# Same cast, but starting from a non-lazy, value.
|
||||
gdb_test "print g_smallstruct_b" " = <unavailable>"
|
||||
gdb_test "print (small_struct) \$" " = <unavailable>"
|
||||
|
||||
gdb_test_no_output "set print object on"
|
||||
|
||||
with_test_prefix "print object on" {
|
||||
# With print object on, printing a pointer may need to fetch
|
||||
# the pointed-to object, to check its run-time type. Make
|
||||
# sure that fails gracefully and transparently when the
|
||||
# pointer itself is unavailable.
|
||||
gdb_test "print virtualp" " = <unavailable>"
|
||||
|
||||
# no vtable pointer available
|
||||
gdb_test "print derived_unavail" " = <unavailable>"
|
||||
|
||||
# vtable pointer available, but nothing else
|
||||
gdb_test "print derived_partial" \
|
||||
" = \\(Derived\\) {<Middle> = {<Base> = <unavailable>, _vptr.Middle = <unavailable>, y = <unavailable>}, _vptr.Derived = $hex <vtable for Derived.*>, z = <unavailable>}"
|
||||
|
||||
# whole object available
|
||||
gdb_test "print derived_whole" \
|
||||
" = \\(Derived\\) {<Middle> = {<Base> = {x = 2}, _vptr.Middle = $hex, y = 3}, _vptr.Derived = $hex <vtable for Derived.*>, z = 4}"
|
||||
}
|
||||
|
||||
gdb_test_no_output "set print object off"
|
||||
|
||||
with_test_prefix "print object off" {
|
||||
gdb_test "print virtualp" " = <unavailable>"
|
||||
|
||||
# no vtable pointer available
|
||||
gdb_test "print derived_unavail" \
|
||||
" = <unavailable>"
|
||||
|
||||
# vtable pointer available, but nothing else
|
||||
gdb_test "print derived_partial" \
|
||||
" = {<Middle> = {<Base> = <unavailable>, _vptr.Middle = <unavailable>, y = <unavailable>}, _vptr.Derived = $hex <vtable for Derived.*>, z = <unavailable>}"
|
||||
|
||||
# whole object available
|
||||
gdb_test "print derived_whole" \
|
||||
" = {<Middle> = {<Base> = {x = 2}, _vptr.Middle = $hex, y = 3}, _vptr.Derived = $hex <vtable for Derived.*>, z = 4}"
|
||||
}
|
||||
|
||||
# An instance of a virtual class where we collected everything but
|
||||
# the vptr.
|
||||
gdb_test "print virtual_partial" \
|
||||
" = {_vptr.Virtual = <unavailable>, z = 0}"
|
||||
}
|
||||
|
||||
proc gdb_collect_globals_test { } {
|
||||
with_test_prefix "collect globals" {
|
||||
global ws
|
||||
global cr
|
||||
global gdb_prompt
|
||||
global hex
|
||||
|
||||
prepare_for_trace_test
|
||||
|
||||
set testline [gdb_get_line_number "set globals_test_func tracepoint here"]
|
||||
@ -387,189 +591,7 @@ proc gdb_collect_globals_test { } {
|
||||
# Begin the test.
|
||||
run_trace_experiment globals_test_func
|
||||
|
||||
gdb_test "print globalc" " = <unavailable>"
|
||||
gdb_test "print globali" " = <unavailable>"
|
||||
gdb_test "print globalf" " = <unavailable>"
|
||||
gdb_test "print globald" " = <unavailable>"
|
||||
|
||||
gdb_test "print globalstruct.memberc" " = <unavailable>"
|
||||
gdb_test "print globalstruct.memberi" " = <unavailable>"
|
||||
gdb_test "print globalstruct.memberf" " = <unavailable>"
|
||||
gdb_test "print globalstruct.memberd" " = <unavailable>"
|
||||
|
||||
gdb_test "print globalstruct" " = <unavailable>"
|
||||
|
||||
gdb_test "print globalp == &globalstruct" \
|
||||
"value is not available" \
|
||||
"can't compare using non collected global pointer"
|
||||
|
||||
gdb_test "print globalarr\[1\]" " = <unavailable>"
|
||||
gdb_test "print globalarr\[2\]" " = <unavailable>"
|
||||
gdb_test "print globalarr\[3\]" " = <unavailable>"
|
||||
|
||||
gdb_test "print struct_b" \
|
||||
" = {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>}"
|
||||
|
||||
gdb_test "print /x struct_b" \
|
||||
" = {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>}"
|
||||
|
||||
gdb_test "print /x struct_b.struct_a" \
|
||||
" = {a = <unavailable>, b = <unavailable>, array = {<unavailable>, <unavailable>, 0xaaaaaaaa, <unavailable> <repeats 97 times>, 0xaaaaaaaa, <unavailable> <repeats 9899 times>}, ptr = <unavailable>, bitfield = <unavailable>}"
|
||||
|
||||
gdb_test "print /x struct_b.struct_a.array" \
|
||||
" = {<unavailable>, <unavailable>, 0xaaaaaaaa, <unavailable> <repeats 97 times>, 0xaaaaaaaa, <unavailable> <repeats 9899 times>}"
|
||||
|
||||
gdb_test "print /x struct_b.struct_a.array\[0\]" " = <unavailable>"
|
||||
|
||||
gdb_test "print /x struct_b.struct_a.array\[2\]" " = 0xaaaaaaaa"
|
||||
|
||||
# Check the target doesn't overcollect. GDB used to merge memory
|
||||
# ranges to collect if they were close enough (collecting the hole
|
||||
# as well), but does not do that anymore. It's plausible that a
|
||||
# target may do this on its end, but as of this writing, no known
|
||||
# target does it.
|
||||
gdb_test "print {a, b, c}" \
|
||||
" = \\{1, <unavailable>, 3\\}" \
|
||||
"No overcollect of almost but not quite adjacent memory ranges"
|
||||
|
||||
# Check <unavailable> isn't confused with 0 in array element repetitions
|
||||
|
||||
gdb_test_no_output "set print repeat 1"
|
||||
|
||||
gdb_test "print /x tarray" \
|
||||
" = \{\{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>\}" \
|
||||
"<unavailable> is not the same as 0 in array element repetitions"
|
||||
|
||||
gdb_test_no_output "set print repeat 10"
|
||||
|
||||
# Check that value repeat handles unavailable-ness.
|
||||
gdb_test "print *tarray@3" " = \\{\\{a = 0, b = <unavailable>\\}, \\{a = 0, b = <unavailable>\\}, \\{a = <unavailable>, b = <unavailable>\\}\\}"
|
||||
|
||||
# Static fields
|
||||
|
||||
gdb_test "print struct_b.static_struct_a" " = <unavailable>"
|
||||
|
||||
# Bitfields
|
||||
|
||||
gdb_test "print struct_b.struct_a.bitfield" " = <unavailable>"
|
||||
|
||||
# References
|
||||
|
||||
gdb_test "print g_int" " = <unavailable>"
|
||||
|
||||
gdb_test "print g_ref" \
|
||||
"\\(int &\\) @$hex: <unavailable>" \
|
||||
"global reference shows address but not value"
|
||||
|
||||
gdb_test "print *&g_ref" \
|
||||
"\\$\[0-9\]+ = <unavailable>$cr" \
|
||||
"referenced integer was not collected (taking address of reference)"
|
||||
|
||||
gdb_test "print *g_structref_p" " = <unavailable>"
|
||||
|
||||
# Strings
|
||||
|
||||
# Const string is always available, even when not collected.
|
||||
gdb_test "print g_const_string" \
|
||||
" = \"hello world\"$cr" \
|
||||
"non collected const string is still printable"
|
||||
|
||||
gdb_test "print g_string_p" \
|
||||
" = $hex <g_const_string> \"hello world\"" \
|
||||
"printing constant string through collected pointer"
|
||||
|
||||
gdb_test "print g_string_unavail" \
|
||||
" = <unavailable>" \
|
||||
"printing non collected string"
|
||||
|
||||
# Incomplete strings print as an array.
|
||||
gdb_test "print g_string_partial" \
|
||||
"\\$\[0-9\]+ = \{<unavailable>, 101 'e', 108 'l', <unavailable>, <unavailable>, <unavailable>, <unavailable>, <unavailable>, <unavailable>, <unavailable>, <unavailable>, <unavailable>\}" \
|
||||
"printing partially collected string"
|
||||
|
||||
# It is important for this test that the last examined value is
|
||||
# <unavailable>, to exercise the case of the $__ convenience
|
||||
# variable being set to <unavailable> without error.
|
||||
set msg "examining partially collected object"
|
||||
gdb_test_multiple "x /10x &struct_b" "$msg" {
|
||||
-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 $" {
|
||||
pass "$msg"
|
||||
}
|
||||
-re "value is not available" {
|
||||
fail "$msg"
|
||||
}
|
||||
}
|
||||
|
||||
gdb_test "p \$__" " = <unavailable>" "last examined value was <unavailable>"
|
||||
|
||||
# This tests that building the array does not require accessing
|
||||
# g_int's contents.
|
||||
gdb_test "print { 1, g_int, 3 }" \
|
||||
" = \\{1, <unavailable>, 3\\}" \
|
||||
"build array from unavailable value"
|
||||
|
||||
# Note, depends on previous test.
|
||||
gdb_test "print \$\[1\]" \
|
||||
" = <unavailable>" \
|
||||
"subscript a non-memory rvalue array, accessing an unvailable element"
|
||||
|
||||
# Access a field of a non-lazy value, making sure the
|
||||
# unavailable-ness is propagated. History values are easy
|
||||
# non-lazy values, so use those. The first test just sets up for
|
||||
# the second.
|
||||
gdb_test "print g_smallstruct" " = <unavailable>"
|
||||
gdb_test "print \$.member" " = <unavailable>"
|
||||
|
||||
# Cast to baseclass, checking the unavailable-ness is propagated.
|
||||
gdb_test "print (small_struct) g_smallstruct_b" " = <unavailable>"
|
||||
|
||||
# Same cast, but starting from a non-lazy, value.
|
||||
gdb_test "print g_smallstruct_b" " = <unavailable>"
|
||||
gdb_test "print (small_struct) \$" " = <unavailable>"
|
||||
|
||||
gdb_test_no_output "set print object on"
|
||||
|
||||
with_test_prefix "print object on" {
|
||||
# With print object on, printing a pointer may need to fetch
|
||||
# the pointed-to object, to check its run-time type. Make
|
||||
# sure that fails gracefully and transparently when the
|
||||
# pointer itself is unavailable.
|
||||
gdb_test "print virtualp" " = <unavailable>"
|
||||
|
||||
# no vtable pointer available
|
||||
gdb_test "print derived_unavail" " = <unavailable>"
|
||||
|
||||
# vtable pointer available, but nothing else
|
||||
gdb_test "print derived_partial" \
|
||||
" = \\(Derived\\) {<Middle> = {<Base> = <unavailable>, _vptr.Middle = <unavailable>, y = <unavailable>}, _vptr.Derived = $hex <vtable for Derived.*>, z = <unavailable>}"
|
||||
|
||||
# whole object available
|
||||
gdb_test "print derived_whole" \
|
||||
" = \\(Derived\\) {<Middle> = {<Base> = {x = 2}, _vptr.Middle = $hex, y = 3}, _vptr.Derived = $hex <vtable for Derived.*>, z = 4}"
|
||||
}
|
||||
|
||||
gdb_test_no_output "set print object off"
|
||||
|
||||
with_test_prefix "print object off" {
|
||||
gdb_test "print virtualp" " = <unavailable>"
|
||||
|
||||
# no vtable pointer available
|
||||
gdb_test "print derived_unavail" \
|
||||
" = <unavailable>"
|
||||
|
||||
# vtable pointer available, but nothing else
|
||||
gdb_test "print derived_partial" \
|
||||
" = {<Middle> = {<Base> = <unavailable>, _vptr.Middle = <unavailable>, y = <unavailable>}, _vptr.Derived = $hex <vtable for Derived.*>, z = <unavailable>}"
|
||||
|
||||
# whole object available
|
||||
gdb_test "print derived_whole" \
|
||||
" = {<Middle> = {<Base> = {x = 2}, _vptr.Middle = $hex, y = 3}, _vptr.Derived = $hex <vtable for Derived.*>, z = 4}"
|
||||
}
|
||||
|
||||
# An instance of a virtual class where we collected everything but
|
||||
# the vptr.
|
||||
gdb_test "print virtual_partial" \
|
||||
" = {_vptr.Virtual = <unavailable>, z = 0}"
|
||||
gdb_collect_globals_test_1
|
||||
|
||||
gdb_test "tfind none" \
|
||||
"#0 end .*" \
|
||||
|
Loading…
Reference in New Issue
Block a user