1 # Copyright
1998-2022 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 # This test helps making sure QTro support doesn
't regress. If the
17 # stub supports the newer qXfer:traceframe-info:read, then the QTro
18 # paths in the stub are never exercised. PR remote/15455 is an
19 # example of a regression that unfortunately went unnoticed for long.
21 load_lib trace-support.exp
25 if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug nopie}]} {
33 # Check whether we're testing with the remote or extended
-remote
34 # targets
, and whether the target supports tracepoints.
36 if ![gdb_is_target_remote
] {
40 if ![gdb_target_supports_trace
] {
41 unsupported
"current target does not support trace"
45 # Run a
trace session
, stop it
, and
then inspect the resulting
trace
46 # frame
(IOW
, returns
while tfind
mode is active
).
47 proc prepare_for_trace_disassembly
{ } {
49 gdb_breakpoint
"end" qualified
51 gdb_test
"trace subr" "Tracepoint .*" \
54 gdb_trace_setactions
"define action" \
58 gdb_test_no_output
"tstart"
60 gdb_test
"continue" ".*Breakpoint \[0-9\]+, end .*" \
61 "advance through tracing"
63 gdb_test
"tstatus" ".*Collected 1 trace frame.*" \
64 "collected 1 trace frame"
66 gdb_test_no_output
"tstop"
68 gdb_tfind_test
"tfind start" "start" "0"
71 clean_restart $testfile
74 #
Trace once
, issuing a tstatus
, so that GDB tries
75 # qXfer
:trace-frame
-info:read.
76 prepare_for_trace_disassembly
78 # Now check whether the packet is supported.
79 set traceframe_info_supported
-1
80 set test
"probe for traceframe-info support"
81 gdb_test_multiple
"show remote traceframe-info-packet" $test {
82 -re
".*Support for .* is auto-detected, currently (\[a-z\]*).*$gdb_prompt $" {
83 set status $expect_out
(1,string
)
85 if { $
status == "enabled" } {
86 set traceframe_info_supported
1
88 set traceframe_info_supported
0
94 if { $traceframe_info_supported
== -1 } {
98 # Check whether we
're testing with our own GDBserver.
99 set is_gdbserver [target_is_gdbserver]
100 if { $is_gdbserver == -1 } {
104 # Now disassemble (IOW, read from read-only memory) while inspecting a
105 # trace frame, twice. Once with qXfer:traceframe-info:read left to
106 # auto, and once with it disabled, exercising the QTro fallback path
108 foreach tfinfo { auto off } {
109 with_test_prefix "qXfer:traceframe-info:read $tfinfo" {
111 clean_restart $testfile
113 gdb_test_no_output "set remote traceframe-info-packet $tfinfo"
115 prepare_for_trace_disassembly
117 set test "trace disassembly"
118 gdb_test_multiple "disassemble subr" $test {
119 -re "<(\.\[0-9\]+|)>:.*End of assembler dump.*$gdb_prompt $" {
122 -re "Cannot access memory.*$gdb_prompt $" {
123 if { $traceframe_info_supported == 0 } {
124 # If qXfer:traceframe-info:read is not supported,
125 # then there should be QTro support.
127 } elseif { $tfinfo == off && $is_gdbserver == 1 } {
128 # We we're testing with GDBserver
, we know both
129 # qXfer
:traceframe
-info:read and QTro are
130 # supported
(although supporting the former only
131 # would be sufficient
), so issue a FAIL instead of
132 # UNSUPPORTED
, giving us better visibility of QTro
136 # Otherwise
, qXfer
:traceframe
-info:read is
137 # supported
, making QTro optional
, so this isn
't
139 unsupported "$test (no QTro support)"