2013-01-01 06:41:43 +00:00
|
|
|
# Copyright 1998-2013 Free Software Foundation, Inc.
|
2011-02-14 11:29:04 +00:00
|
|
|
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
load_lib "trace-support.exp"
|
|
|
|
|
2012-06-26 18:25:19 +00:00
|
|
|
standard_testfile unavailable.cc
|
2011-02-14 11:29:04 +00:00
|
|
|
set executable $testfile
|
|
|
|
|
2012-06-26 18:25:19 +00:00
|
|
|
if {[prepare_for_testing $testfile.exp $testfile $srcfile \
|
|
|
|
{debug nowarnings c++}]} {
|
2011-02-14 11:29:04 +00:00
|
|
|
return -1
|
|
|
|
}
|
|
|
|
|
|
|
|
set ws "\[\r\n\t \]+"
|
|
|
|
set cr "\[\r\n\]+"
|
|
|
|
|
2011-09-08 17:40:54 +00:00
|
|
|
if [is_amd64_regs_target] {
|
2011-03-18 18:41:36 +00:00
|
|
|
set fpreg "rbp"
|
|
|
|
set spreg "rsp"
|
|
|
|
set pcreg "rip"
|
2011-09-08 17:40:54 +00:00
|
|
|
} elseif [is_x86_like_target] {
|
2011-03-18 18:41:36 +00:00
|
|
|
set fpreg "ebp"
|
|
|
|
set spreg "esp"
|
|
|
|
set pcreg "eip"
|
|
|
|
} else {
|
|
|
|
set fpreg "fp"
|
|
|
|
set spreg "sp"
|
|
|
|
set pcreg "pc"
|
|
|
|
}
|
|
|
|
|
2011-02-14 11:29:04 +00:00
|
|
|
#
|
|
|
|
# Utility procs
|
|
|
|
#
|
|
|
|
|
2011-03-18 18:41:36 +00:00
|
|
|
proc test_register { reg } {
|
|
|
|
global gdb_prompt
|
|
|
|
global hex
|
|
|
|
global cr
|
|
|
|
|
|
|
|
gdb_test_multiple "print /x $reg" "collected $reg" {
|
|
|
|
-re "\\$\[0-9\]+ = \[x0\]+$cr$gdb_prompt $" {
|
|
|
|
fail "collected $reg (zero)"
|
|
|
|
}
|
|
|
|
-re "\\$\[0-9\]+ = $hex$cr$gdb_prompt $" {
|
|
|
|
pass "collected $reg"
|
|
|
|
}
|
|
|
|
-re "\[Ee\]rror.*$gdb_prompt $" {
|
|
|
|
fail "collected $reg (error)"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
proc test_register_unavailable { reg } {
|
|
|
|
gdb_test "print /x $reg" \
|
|
|
|
"<unavailable>" \
|
|
|
|
"correctly report $reg as unavailable"
|
|
|
|
}
|
|
|
|
|
2011-02-14 11:29:04 +00:00
|
|
|
proc prepare_for_trace_test {} {
|
|
|
|
global executable
|
|
|
|
|
|
|
|
clean_restart $executable
|
|
|
|
|
|
|
|
runto_main
|
|
|
|
|
|
|
|
gdb_test "break begin" ".*" ""
|
|
|
|
gdb_test "break end" ".*" ""
|
|
|
|
}
|
|
|
|
|
|
|
|
proc run_trace_experiment { test_func } {
|
|
|
|
global gdb_prompt
|
|
|
|
|
|
|
|
gdb_test "continue" \
|
|
|
|
".*Breakpoint \[0-9\]+, begin .*" \
|
|
|
|
"advance to begin"
|
|
|
|
|
|
|
|
gdb_test_no_output "tstart" "start trace experiment"
|
|
|
|
|
|
|
|
gdb_test "continue" \
|
|
|
|
"Continuing.*Breakpoint \[0-9\]+, end.*" \
|
|
|
|
"run trace experiment"
|
|
|
|
gdb_test "tstop" \
|
|
|
|
"\[\r\n\]+" \
|
|
|
|
"stop trace experiment"
|
|
|
|
gdb_test "tfind start" \
|
|
|
|
"#0 $test_func .*" \
|
|
|
|
"tfind test frame"
|
|
|
|
}
|
|
|
|
|
2011-08-05 15:17:59 +00:00
|
|
|
# Test that "display VAR" works as expected, assuming VAR is wholly
|
|
|
|
# unavailable.
|
|
|
|
|
|
|
|
proc test_maybe_regvar_display { var } {
|
|
|
|
global gdb_prompt
|
|
|
|
|
|
|
|
# Evaluating VAR's location description may throw an internal
|
|
|
|
# "unavailable" exception, if for example, the value of a register
|
|
|
|
# necessary for computing VAR's location is unavailable. Such an
|
|
|
|
# exception is caught, and should not cause automatic disablement
|
|
|
|
# of the current display being printed. (GDB used to disable the
|
|
|
|
# current display whenever any exception was thrown.)
|
|
|
|
set test "display $var"
|
|
|
|
gdb_test_multiple "$test" "$test" {
|
|
|
|
-re "Disabling display ? to avoid infinite recursion.*$gdb_prompt $" {
|
|
|
|
fail "$test"
|
|
|
|
}
|
|
|
|
-re "display ${var}\r\n1: ${var} = <unavailable>\r\n$gdb_prompt $" {
|
|
|
|
pass "$test"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
gdb_test "info display" ".*1:\[ \t\]+y\[ \t\]+${var}" "display ${var} is enabled"
|
|
|
|
|
|
|
|
gdb_test "undisp" \
|
|
|
|
"" \
|
|
|
|
"delete $var display" \
|
|
|
|
".*Delete all auto-display expressions.*y or n. $" \
|
|
|
|
"y"
|
|
|
|
}
|
|
|
|
|
2011-02-14 11:29:04 +00:00
|
|
|
#
|
|
|
|
# Test procs
|
|
|
|
#
|
|
|
|
|
2013-03-15 01:41:29 +00:00
|
|
|
proc gdb_collect_args_test {} {
|
|
|
|
with_test_prefix "unavailable arguments" {
|
|
|
|
global cr
|
|
|
|
global gdb_prompt
|
2011-03-18 18:51:08 +00:00
|
|
|
|
2013-03-15 01:41:29 +00:00
|
|
|
prepare_for_trace_test
|
2011-03-18 18:51:08 +00:00
|
|
|
|
2013-03-15 01:41:29 +00:00
|
|
|
gdb_test "trace args_test_func" \
|
|
|
|
"Tracepoint \[0-9\]+ at .*" \
|
|
|
|
"set tracepoint"
|
2011-03-18 18:51:08 +00:00
|
|
|
|
2013-03-15 01:41:29 +00:00
|
|
|
# Begin the test.
|
|
|
|
run_trace_experiment args_test_func
|
2011-03-18 18:51:08 +00:00
|
|
|
|
2013-03-15 01:41:29 +00:00
|
|
|
# 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.
|
2011-03-18 18:51:08 +00:00
|
|
|
|
2013-03-15 01:41:29 +00:00
|
|
|
gdb_test "print argc" " = <unavailable>"
|
|
|
|
gdb_test "print &argc" \
|
|
|
|
"Can't take address of \"argc\" which isn't an lvalue\."
|
2011-03-18 18:51:08 +00:00
|
|
|
|
2013-03-15 01:41:29 +00:00
|
|
|
gdb_test "print argi" " = <unavailable>"
|
|
|
|
gdb_test "print &argi" \
|
|
|
|
"Can't take address of \"argi\" which isn't an lvalue\."
|
2011-03-18 18:51:08 +00:00
|
|
|
|
2013-03-15 01:41:29 +00:00
|
|
|
gdb_test "print argf" " = <unavailable>"
|
|
|
|
gdb_test "print &argf" \
|
|
|
|
"Can't take address of \"argf\" which isn't an lvalue\."
|
2011-03-18 18:51:08 +00:00
|
|
|
|
2013-03-15 01:41:29 +00:00
|
|
|
gdb_test "print argd" " = <unavailable>"
|
|
|
|
gdb_test "print &argd" \
|
|
|
|
"Can't take address of \"argd\" which isn't an lvalue\."
|
2011-03-18 18:51:08 +00:00
|
|
|
|
2013-03-15 01:41:29 +00:00
|
|
|
# struct arg as one of several args (near end of list)
|
2011-03-18 18:51:08 +00:00
|
|
|
|
2013-03-15 01:41:29 +00:00
|
|
|
gdb_test "print argstruct" \
|
|
|
|
" = \{memberc = <unavailable>, memberi = <unavailable>, memberf = <unavailable>, memberd = <unavailable>\}"
|
2011-03-18 18:51:08 +00:00
|
|
|
|
2013-03-15 01:41:29 +00:00
|
|
|
gdb_test "print argstruct.memberc" " = <unavailable>"
|
|
|
|
gdb_test "print argstruct.memberi" " = <unavailable>"
|
|
|
|
gdb_test "print argstruct.memberf" " = <unavailable>"
|
|
|
|
gdb_test "print argstruct.memberd" " = <unavailable>"
|
2011-03-18 18:51:08 +00:00
|
|
|
|
2013-03-15 01:41:29 +00:00
|
|
|
gdb_test "print argarray" " = \\(int \\*\\) <unavailable>"
|
2011-03-18 18:51:08 +00:00
|
|
|
|
2013-03-15 01:41:29 +00:00
|
|
|
gdb_test "print &argarray" \
|
|
|
|
"Can't take address of \"argarray\" which isn't an lvalue\."
|
2011-03-18 18:51:08 +00:00
|
|
|
|
2013-03-15 01:41:29 +00:00
|
|
|
gdb_test "print argarray\[0\]" "value is not available"
|
2011-03-18 18:51:08 +00:00
|
|
|
|
2013-03-15 01:41:29 +00:00
|
|
|
# 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 = {memberc = <unavailable>, memberi = <unavailable>, memberf = <unavailable>, memberd = <unavailable>}${cr}"
|
|
|
|
set r "${r}argarray = <unavailable>${cr}"
|
|
|
|
gdb_test "info args" "$r" "info args"
|
2011-03-18 18:51:08 +00:00
|
|
|
|
2013-03-15 01:41:29 +00:00
|
|
|
test_maybe_regvar_display "argc"
|
2011-08-05 15:17:59 +00:00
|
|
|
|
2013-03-15 01:41:29 +00:00
|
|
|
gdb_test "tfind none" \
|
|
|
|
"#0 end .*" \
|
|
|
|
"cease trace debugging"
|
|
|
|
}
|
|
|
|
}
|
2011-03-18 18:51:08 +00:00
|
|
|
|
2013-03-15 01:41:29 +00:00
|
|
|
proc gdb_collect_locals_test { func msg } {
|
|
|
|
with_test_prefix "unavailable locals: $msg" {
|
|
|
|
global cr
|
|
|
|
global gdb_prompt
|
2011-03-18 18:51:08 +00:00
|
|
|
|
2013-03-15 01:41:29 +00:00
|
|
|
prepare_for_trace_test
|
2011-03-18 18:51:08 +00:00
|
|
|
|
2013-03-15 01:41:29 +00:00
|
|
|
set testline [gdb_get_line_number "set $func tracepoint here"]
|
2011-03-18 18:51:08 +00:00
|
|
|
|
2013-03-15 01:41:29 +00:00
|
|
|
gdb_test "trace $testline" \
|
2011-03-18 18:51:08 +00:00
|
|
|
"Tracepoint \[0-9\]+ at .*" \
|
|
|
|
"set tracepoint"
|
|
|
|
|
2013-03-15 01:41:29 +00:00
|
|
|
# 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 = {memberc = <unavailable>, memberi = <unavailable>, memberf = <unavailable>, memberd = <unavailable>}${cr}"
|
|
|
|
set r "${r}locar = {<unavailable>, <unavailable>, <unavailable>, <unavailable>}${cr}"
|
|
|
|
set r "${r}i = <unavailable>${cr}"
|
|
|
|
if { $func == "local_test_func" } {
|
|
|
|
set r "${r}locdefst = {<No data fields>}${cr}"
|
|
|
|
}
|
|
|
|
set r "${r}locc = <unavailable>${cr}"
|
|
|
|
set r "${r}loci = <unavailable>${cr}"
|
|
|
|
gdb_test "info locals" "$r" "info locals"
|
2011-03-18 18:51:08 +00:00
|
|
|
|
2013-03-15 01:41:29 +00:00
|
|
|
test_maybe_regvar_display "loci"
|
2011-08-05 15:17:59 +00:00
|
|
|
|
2013-03-15 01:41:29 +00:00
|
|
|
gdb_test "tfind none" \
|
|
|
|
"#0 end .*" \
|
|
|
|
"cease trace debugging"
|
|
|
|
}
|
|
|
|
}
|
2011-03-18 18:51:08 +00:00
|
|
|
|
2013-03-15 01:41:29 +00:00
|
|
|
proc gdb_unavailable_registers_test { } {
|
|
|
|
with_test_prefix "unavailable registers" {
|
|
|
|
global gdb_prompt
|
|
|
|
global spreg
|
|
|
|
global pcreg
|
2011-03-18 18:41:36 +00:00
|
|
|
|
2013-03-15 01:41:29 +00:00
|
|
|
prepare_for_trace_test
|
2011-03-18 18:41:36 +00:00
|
|
|
|
2013-03-15 01:41:29 +00:00
|
|
|
# We'll simply re-use the globals_test_function for this test
|
|
|
|
gdb_test "trace globals_test_func" \
|
2011-03-18 18:41:36 +00:00
|
|
|
"Tracepoint \[0-9\]+ at .*" \
|
|
|
|
"set tracepoint"
|
|
|
|
|
2013-03-15 01:41:29 +00:00
|
|
|
# Collect nothing.
|
|
|
|
|
|
|
|
# Begin the test.
|
|
|
|
run_trace_experiment globals_test_func
|
2011-03-18 18:41:36 +00:00
|
|
|
|
2013-03-15 01:41:29 +00:00
|
|
|
# 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"
|
|
|
|
}
|
2011-03-18 18:41:36 +00:00
|
|
|
|
2013-03-15 01:41:29 +00:00
|
|
|
# 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"
|
2011-03-18 18:41:36 +00:00
|
|
|
|
2013-03-15 01:41:29 +00:00
|
|
|
gdb_test "info registers" \
|
|
|
|
"\\*value not available\\*.*\\*value not available\\*" \
|
|
|
|
"info registers, multiple registers not available"
|
2011-03-18 18:41:36 +00:00
|
|
|
|
2013-03-15 01:41:29 +00:00
|
|
|
gdb_test "info registers \$$spreg" \
|
|
|
|
"\\*value not available\\*" \
|
|
|
|
"info registers \$$spreg reports not available"
|
|
|
|
|
|
|
|
gdb_test "tfind none" "#0 end .*" "cease trace debugging"
|
|
|
|
}
|
|
|
|
}
|
2011-03-18 18:41:36 +00:00
|
|
|
|
2012-03-01 20:49:02 +00:00
|
|
|
proc gdb_unavailable_floats { } {
|
|
|
|
global gdb_prompt
|
|
|
|
|
|
|
|
with_test_prefix "unavailable floats" {
|
|
|
|
prepare_for_trace_test
|
|
|
|
|
|
|
|
# We'll simply re-use the globals_test_function for this test
|
|
|
|
gdb_test "trace globals_test_func" \
|
|
|
|
"Tracepoint \[0-9\]+ at .*" \
|
|
|
|
"set tracepoint"
|
|
|
|
|
|
|
|
# Collect nothing.
|
|
|
|
|
|
|
|
# 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_test "tfind none" "#0 end .*" "cease trace debugging"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-15 01:41:29 +00:00
|
|
|
proc gdb_collect_globals_test { } {
|
|
|
|
with_test_prefix "collect globals" {
|
|
|
|
global ws
|
|
|
|
global cr
|
|
|
|
global gdb_prompt
|
|
|
|
global hex
|
2011-02-14 11:29:04 +00:00
|
|
|
|
2013-03-15 01:41:29 +00:00
|
|
|
prepare_for_trace_test
|
2011-02-14 11:29:04 +00:00
|
|
|
|
2013-03-15 01:41:29 +00:00
|
|
|
set testline [gdb_get_line_number "set globals_test_func tracepoint here"]
|
2011-02-14 11:29:04 +00:00
|
|
|
|
2013-03-15 01:41:29 +00:00
|
|
|
gdb_test "trace $testline" \
|
2011-02-14 11:29:04 +00:00
|
|
|
"Tracepoint \[0-9\]+ at .*" \
|
|
|
|
"set tracepoint"
|
|
|
|
|
2013-03-15 01:41:29 +00:00
|
|
|
# We collect the initial sizeof(pointer) bytes of derived_partial
|
|
|
|
# in an attempt of collecting the vptr. Not portable, but should
|
|
|
|
# work everywhere we need to care.
|
|
|
|
gdb_trace_setactions "define actions" \
|
|
|
|
"" \
|
|
|
|
"collect struct_b.struct_a.array\[2\]" "^$" \
|
|
|
|
"collect struct_b.struct_a.array\[100\]" "^$" \
|
|
|
|
\
|
|
|
|
"collect a" "^$" \
|
|
|
|
"collect c" "^$" \
|
|
|
|
\
|
|
|
|
"collect tarray\[0\].a" "^$" \
|
|
|
|
"collect tarray\[1\].a" "^$" \
|
|
|
|
"collect tarray\[3\].a" "^$" \
|
|
|
|
"collect tarray\[3\].b" "^$" \
|
|
|
|
"collect tarray\[4\].b" "^$" \
|
|
|
|
"collect tarray\[5\].b" "^$" \
|
|
|
|
\
|
|
|
|
"collect g_string_p" "^$" \
|
|
|
|
"collect g_string_partial\[1\]" "^$" \
|
|
|
|
"collect g_string_partial\[2\]" "^$" \
|
|
|
|
\
|
|
|
|
"collect g_structref_p" "^$" \
|
|
|
|
\
|
|
|
|
"collect *((char *)&derived_partial)@sizeof\(void *\)" "^$" \
|
|
|
|
"collect derived_whole" "^$" \
|
|
|
|
\
|
|
|
|
"collect virtual_partial.z" "^$"
|
|
|
|
|
|
|
|
# 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" \
|
2011-02-14 11:29:04 +00:00
|
|
|
" = {memberc = <unavailable>, memberi = <unavailable>, memberf = <unavailable>, memberd = <unavailable>}"
|
|
|
|
|
2013-03-15 01:41:29 +00:00
|
|
|
gdb_test "print globalp == &globalstruct" \
|
2011-02-14 11:29:04 +00:00
|
|
|
"value is not available" \
|
|
|
|
"can't compare using non collected global pointer"
|
|
|
|
|
2013-03-15 01:41:29 +00:00
|
|
|
gdb_test "print globalarr\[1\]" " = <unavailable>"
|
|
|
|
gdb_test "print globalarr\[2\]" " = <unavailable>"
|
|
|
|
gdb_test "print globalarr\[3\]" " = <unavailable>"
|
2011-02-14 11:29:04 +00:00
|
|
|
|
2013-03-15 01:41:29 +00:00
|
|
|
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>}"
|
2011-02-14 11:29:04 +00:00
|
|
|
|
2013-03-15 01:41:29 +00:00
|
|
|
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>}"
|
2011-02-14 11:29:04 +00:00
|
|
|
|
2013-03-15 01:41:29 +00:00
|
|
|
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>}"
|
2011-02-14 11:29:04 +00:00
|
|
|
|
2013-03-15 01:41:29 +00:00
|
|
|
gdb_test "print /x struct_b.struct_a.array" \
|
|
|
|
" = {<unavailable>, <unavailable>, 0xaaaaaaaa, <unavailable> <repeats 97 times>, 0xaaaaaaaa, <unavailable> <repeats 9899 times>}"
|
2011-02-14 11:29:04 +00:00
|
|
|
|
2013-03-15 01:41:29 +00:00
|
|
|
gdb_test "print /x struct_b.struct_a.array\[0\]" " = <unavailable>"
|
2011-02-14 11:29:04 +00:00
|
|
|
|
2013-03-15 01:41:29 +00:00
|
|
|
gdb_test "print /x struct_b.struct_a.array\[2\]" " = 0xaaaaaaaa"
|
2011-02-14 11:29:04 +00:00
|
|
|
|
2013-03-15 01:41:29 +00:00
|
|
|
# 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"
|
2011-02-14 11:34:31 +00:00
|
|
|
|
2013-03-15 01:41:29 +00:00
|
|
|
# Check <unavailable> isn't confused with 0 in array element repetitions
|
2011-02-14 11:29:04 +00:00
|
|
|
|
2013-03-15 01:41:29 +00:00
|
|
|
gdb_test_no_output "set print repeat 1"
|
2011-02-14 11:29:04 +00:00
|
|
|
|
2013-03-15 01:41:29 +00:00
|
|
|
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"
|
2011-02-14 11:29:04 +00:00
|
|
|
|
2013-03-15 01:41:29 +00:00
|
|
|
gdb_test_no_output "set print repeat 10"
|
2011-02-14 11:29:04 +00:00
|
|
|
|
2013-03-15 01:41:29 +00:00
|
|
|
# Check that value repeat handles unavailable-ness.
|
|
|
|
gdb_test "print *tarray@3" " = \\{\\{a = 0, b = <unavailable>\\}, \\{a = 0, b = <unavailable>\\}, \\{a = <unavailable>, b = <unavailable>\\}\\}"
|
2011-02-14 11:32:17 +00:00
|
|
|
|
2013-03-15 01:41:29 +00:00
|
|
|
# Static fields
|
2011-02-14 11:29:04 +00:00
|
|
|
|
2013-03-15 01:41:29 +00:00
|
|
|
gdb_test "print struct_b.static_struct_a" \
|
|
|
|
" = {a = <unavailable>, b = <unavailable>, array = {<unavailable> <repeats 10000 times>}, ptr = <unavailable>, bitfield = <unavailable>}"
|
2011-02-14 11:29:04 +00:00
|
|
|
|
2013-03-15 01:41:29 +00:00
|
|
|
# Bitfields
|
2011-02-14 11:29:04 +00:00
|
|
|
|
2013-03-15 01:41:29 +00:00
|
|
|
gdb_test "print struct_b.struct_a.bitfield" " = <unavailable>"
|
2011-02-14 11:29:04 +00:00
|
|
|
|
2013-03-15 01:41:29 +00:00
|
|
|
# References
|
2011-02-14 11:29:04 +00:00
|
|
|
|
2013-03-15 01:41:29 +00:00
|
|
|
gdb_test "print g_int" " = <unavailable>"
|
2011-02-14 11:29:04 +00:00
|
|
|
|
2013-03-15 01:41:29 +00:00
|
|
|
gdb_test "print g_ref" \
|
|
|
|
"\\(int &\\) @$hex: <unavailable>" \
|
|
|
|
"global reference shows address but not value"
|
2011-02-14 11:29:04 +00:00
|
|
|
|
2013-03-15 01:41:29 +00:00
|
|
|
gdb_test "print *&g_ref" \
|
|
|
|
"\\$\[0-9\]+ = <unavailable>$cr" \
|
|
|
|
"referenced integer was not collected (taking address of reference)"
|
2011-02-14 11:29:04 +00:00
|
|
|
|
2013-03-15 01:41:29 +00:00
|
|
|
gdb_test "print *g_structref_p" \
|
|
|
|
" = {d = <unavailable>, ref = <unavailable>}"
|
2011-02-14 11:29:04 +00:00
|
|
|
|
2013-03-15 01:41:29 +00:00
|
|
|
# Strings
|
2011-02-14 11:29:04 +00:00
|
|
|
|
2013-03-15 01:41:29 +00:00
|
|
|
# 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"
|
2011-02-14 11:29:04 +00:00
|
|
|
|
2013-03-15 01:41:29 +00:00
|
|
|
gdb_test "print g_string_p" \
|
|
|
|
" = $hex <g_const_string> \"hello world\"" \
|
|
|
|
"printing constant string through collected pointer"
|
2011-02-14 11:29:04 +00:00
|
|
|
|
2013-03-15 01:41:29 +00:00
|
|
|
gdb_test "print g_string_unavail" \
|
|
|
|
" = \{<unavailable> <repeats 12 times>\}" \
|
|
|
|
"printing non collected string"
|
2011-02-14 11:29:04 +00:00
|
|
|
|
2013-03-15 01:41:29 +00:00
|
|
|
# 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"
|
2011-02-14 11:29:04 +00:00
|
|
|
|
2013-03-15 01:41:29 +00:00
|
|
|
# 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"
|
|
|
|
}
|
2011-02-14 11:29:04 +00:00
|
|
|
}
|
|
|
|
|
2013-03-15 01:41:29 +00:00
|
|
|
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" " = \\{member = <unavailable>\\}"
|
|
|
|
gdb_test "print \$.member" " = <unavailable>"
|
|
|
|
|
|
|
|
# Cast to baseclass, checking the unavailable-ness is propagated.
|
|
|
|
gdb_test "print (small_struct) g_smallstruct_b" " = \\{member = <unavailable>\\}"
|
|
|
|
|
|
|
|
# Same cast, but starting from a non-lazy, value.
|
|
|
|
gdb_test "print g_smallstruct_b" " = \\{<small_struct> = \\{member = <unavailable>\\}, <No data fields>\\}"
|
|
|
|
gdb_test "print (small_struct) \$" " = \\{member = <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" " = \\(Virtual \\*\\) <unavailable>"
|
|
|
|
|
|
|
|
# no vtable pointer available
|
|
|
|
gdb_test "print derived_unavail" \
|
|
|
|
" = {<Middle> = <unavailable>, _vptr.Derived = <unavailable>, z = <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}"
|
|
|
|
}
|
2011-02-14 11:35:45 +00:00
|
|
|
|
2013-03-15 01:41:29 +00:00
|
|
|
gdb_test_no_output "set print object off"
|
2011-02-14 11:33:24 +00:00
|
|
|
|
2013-03-15 01:41:29 +00:00
|
|
|
with_test_prefix "print object off" {
|
|
|
|
gdb_test "print virtualp" " = \\(Virtual \\*\\) <unavailable>"
|
2011-02-14 11:35:45 +00:00
|
|
|
|
2013-03-15 01:41:29 +00:00
|
|
|
# no vtable pointer available
|
|
|
|
gdb_test "print derived_unavail" \
|
|
|
|
" = {<Middle> = <unavailable>, _vptr.Derived = <unavailable>, z = <unavailable>}"
|
2011-02-14 11:35:45 +00:00
|
|
|
|
2013-03-15 01:41:29 +00:00
|
|
|
# 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>}"
|
2011-02-14 11:35:45 +00:00
|
|
|
|
2013-03-15 01:41:29 +00:00
|
|
|
# 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}"
|
|
|
|
}
|
2011-02-14 11:35:45 +00:00
|
|
|
|
2013-03-15 01:41:29 +00:00
|
|
|
# An instance of a virtual class where we collected everything but
|
|
|
|
# the vptr.
|
|
|
|
gdb_test "print virtual_partial" \
|
|
|
|
" = {_vptr.Virtual = <unavailable>, z = 0}"
|
2011-02-14 11:35:45 +00:00
|
|
|
|
2013-03-15 01:41:29 +00:00
|
|
|
gdb_test "tfind none" \
|
|
|
|
"#0 end .*" \
|
|
|
|
"cease trace debugging"
|
|
|
|
}
|
|
|
|
}
|
2011-02-14 11:29:04 +00:00
|
|
|
|
|
|
|
proc gdb_trace_collection_test {} {
|
|
|
|
gdb_collect_globals_test
|
2011-03-18 18:41:36 +00:00
|
|
|
gdb_unavailable_registers_test
|
2012-03-01 20:49:02 +00:00
|
|
|
gdb_unavailable_floats
|
2011-03-18 18:51:08 +00:00
|
|
|
|
|
|
|
gdb_collect_args_test
|
|
|
|
gdb_collect_locals_test local_test_func "auto locals"
|
|
|
|
gdb_collect_locals_test reglocal_test_func "register locals"
|
|
|
|
gdb_collect_locals_test statlocal_test_func "static locals"
|
2011-02-14 11:29:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
runto_main
|
|
|
|
|
|
|
|
if { ![gdb_target_supports_trace] } then {
|
2012-02-15 18:09:20 +00:00
|
|
|
unsupported "Current target does not support trace"
|
gdb/testsuite/
* config/monitor.exp (gdb_target_cmd): Remove semicolon after
'return'.
(gdb_target_monitor, gdb_load): Likewise.
* config/sid.exp (gdb_load): Likewise.
* config/slite.exp (gdb_load): Likewise.
* config/vx.exp (gdb_start, spawn_vxgdb): Likewise.
* gdb.ada/arrayidx.exp, gdb.ada/null_array.exp: Likewise.
* gdb.arch/mips-octeon-bbit.exp (single_step): Likewise.
(single_step_until): Likewise.
* gdb.arch/powerpc-d128-regs.exp: Likewise.
* gdb.arch/system-gcore.exp: Likewise.
* gdb.base/bigcore.exp (extract_heap): Likewise.
* gdb.base/break-on-linker-gcd-function.exp: Likewise.
* gdb.base/call-ar-st.exp: Likewise.
* gdb.base/call-rt-st.exp: Likewise.
* gdb.base/call-sc.exp, gdb.base/call-strs.exp: Likewise.
* gdb.base/callfuncs.exp, gdb.base/completion.exp: Likewise.
* gdb.base/condbreak.exp, gdb.base/constvars.exp: Likewise.
* gdb.base/corefile.exp: Likewise.
* gdb.base/dbx.exp (gdb_file_cmd): Likewise.
* gdb.base/exprs.exp, gdb.base/fileio.exp: Likewise.
* gdb.base/fixsection.exp: Likewise.
* gdb.base/funcargs.exp: Likewise.
* gdb.base/gcore-buffer-overflow.exp: Likewise.
* gdb.base/gcore-relro.exp: Likewise.
* gdb.base/gcore.exp, gdb.base/gdb11530.exp: Likewise.
* gdb.base/gdb11531.exp, gdb.base/gnu-ifunc.exp: Likewise.
* gdb.base/info-os.exp, gdb.base/info-proc.exp: Likewise.
* gdb.base/interp.exp, gdb.base/langs.exp:: Likewise.
* gdb.base/list.exp: Likewise.
(set_listsize): Likewise.
* gdb.base/logical.exp, gdb.base/mips_pro.exp: Likewise.
* gdb.base/miscexprs.exp, gdb.base/nodebug.exp: Likewise.
* gdb.base/opaque.exp, gdb.base/pointers.exp: Likewise.
* gdb.base/psymtab.exp, gdb.base/ptype.exp: Likewise.
* gdb.base/relational.exp, gdb.base/scope.exp: Likewise.
* gdb.base/setvar.exp: Likewise.
(test_set): Likewise.
* gdb.base/signals.exp, gdb.base/sizeof.exp: Likewise.
* gdb.base/solib-overlap.exp: Likewise.
* gdb.base/store.exp, gdb.base/structs.exp: Likewise.
* gdb.base/structs2.exp, gdb.base/volatile.exp: Likewise.
* gdb.base/watchpoint.exp (initialize): Likewise.
(test_simple_watchpoint): Likewise.
(test_disabling_watchpoints): Likewise.
(test_watchpoint_triggered_in_syscall): Likewise.
* gdb.base/whatis.exp, gdb.cp/ambiguous.exp: Likewise.
* gdb.cp/casts.exp, gdb.cp/ctti.exp: Likewise.
* gdb.cp/namespace.exp, gdb.cp/nsdecl.exp: Likewise.
* gdb.cp/psmang.exp, gdb.dwarf2/dw2-ranges.exp: Likewise.
* gdb.hp/gdb.aCC/optimize.exp: Likewise.
* gdb.hp/gdb.aCC/watch-cmd.exp: Likewise.
* gdb.hp/gdb.base-hp/callfwmall.exp: Likewise.
* gdb.hp/gdb.base-hp/pxdb.exp: Likewise.
* gdb.hp/gdb.compat/xdb1.exp: Likewise.
* gdb.hp/gdb.compat/xdb2.exp: Likewise.
* gdb.hp/gdb.compat/xdb3.exp: Likewise.
* gdb.hp/gdb.defects/bs14602.exp: Likewise.
* gdb.hp/gdb.defects/solib-d.exp: Likewise.
* gdb.mi/gdb792.exp: Likewise.
* gdb.mi/mi-inheritance-syntax-error.exp: Likewise.
* gdb.mi/mi-logging.exp, gdb.mi/mi-var-cp.exp : Likewise.
* gdb.mi/mi-var-rtti.exp, gdb.python/py-type.exp: Likewise.
* gdb.threads/gcore-thread.exp: Likewise.
(load_core): Likewise.
* gdb.threads/pthreads.exp (all_threads_running): Likewise.
(test_startup, check_control_c): Likewise.
* gdb.threads/sigstep-threads.exp: Likewise.
* gdb.threads/thread_check.exp: Likewise.
* gdb.trace/backtrace.exp, gdb.trace/change-loc.exp: Likewise.
* gdb.trace/circ.exp (run_trace_experiment): Likewise.
(set_a_tracepoint, trace_buffer_normal): Likewise.
(gdb_trace_circular_tests): Likewise.
* gdb.trace/collection.exp: Likewise.
* gdb.trace/disconnected-tracing.exp: Likewise.
* gdb.trace/infotrace.exp: Likewise.
* gdb.trace/mi-traceframe-changed.exp: Likewise.
* gdb.trace/mi-tracepoint-changed.exp: Likewise.
* gdb.trace/mi-tsv-changed.exp (test_create_delete_modify_tsv): Likewise.
* gdb.trace/packetlen.exp, gdb.trace/passc-dyn.exp: Likewise.
* gdb.trace/pending.exp, gdb.trace/report.exp: Likewise.
* gdb.trace/stap-trace.exp: Likewise.
* gdb.trace/status-stop.exp,gdb.trace/strace.exp: Likewise.
* gdb.trace/tfind.exp, gdb.trace/trace-break.exp: Likewise.
* gdb.trace/trace-buffer-size.exp: Likewise.
* gdb.trace/tspeed.exp, gdb.trace/tsv.exp: Likewise.
* gdb.trace/unavailable.exp: Likewise.
* gdb.trace/while-dyn.exp: Likewise.
* lib/fortran.exp (set_lang_fortran): Likewise.
* lib/gdb.exp (default_gdb_version, gdb_start_cmd): Likewise.
(gdb_breakpoint, gdb_reinitialize_dir): Likewise.
(default_gdb_start, get_compiler_info): Likewise.
(gdb_compile, gdb_compile_objc, gdb_reload, gdb_init): Likewise.
(get_debug_format, setup_xfail_format): Likewise.
(rerun_to_main, gdb_skip_float_test): Likewise.
(build_id_debug_filename_get, get_remotetimeout): Likewise.
* lib/java.exp (set_lang_java): Likewise.
* lib/mi-support.exp (default_mi_gdb_start): Likewise.
(mi_gdb_reinitialize_dir, mi_gdb_target_cmd): Likewise.
(mi_gdb_file_cmd, mi_gdb_test): Likewise.
(mi_run_cmd_full, mi_expect_interrupt): Likewise.
* lib/objc.exp (set_lang_objc): Likewise.
* lib/pascal.exp (set_lang_pascal): Likewise.
* lib/prompt.exp (default_prompt_gdb_start): Likewise.
* lib/trace-support.exp (gdb_trace_setactions, gdb_tfind_test): Likewise.
(gdb_readexpr, gdb_gettpnum, gdb_find_recursion_test_baseline): Likewise.
2013-03-14 13:34:06 +00:00
|
|
|
return 1
|
2011-02-14 11:29:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# Body of test encased in a proc so we can return prematurely.
|
|
|
|
gdb_trace_collection_test
|
|
|
|
|
|
|
|
# Finished!
|
|
|
|
gdb_test "tfind none" ".*" ""
|