]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.trace/qtro.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.trace / qtro.exp
CommitLineData
1d506c26 1# Copyright 1998-2024 Free Software Foundation, Inc.
9779ab84
PA
2#
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.
7#
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.
12#
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/>.
15
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.
20
21load_lib trace-support.exp
22
23standard_testfile
24
ba22ff86 25if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug nopie}]} {
9779ab84
PA
26 return -1
27}
9779ab84
PA
28
29if ![runto_main] {
9779ab84
PA
30 return -1
31}
32
33# Check whether we're testing with the remote or extended-remote
34# targets, and whether the target supports tracepoints.
35
9779ab84
PA
36if ![gdb_is_target_remote] {
37 return -1
38}
39
40if ![gdb_target_supports_trace] {
bc6c7af4 41 unsupported "current target does not support trace"
4ec70201 42 return -1
9779ab84
PA
43}
44
45# Run a trace session, stop it, and then inspect the resulting trace
46# frame (IOW, returns while tfind mode is active).
47proc prepare_for_trace_disassembly { } {
48 global gdb_prompt
194ed413 49 gdb_breakpoint "end" qualified
9779ab84
PA
50
51 gdb_test "trace subr" "Tracepoint .*" \
52 "tracepoint at subr"
53
54 gdb_trace_setactions "define action" \
55 "" \
56 "collect parm" "^$"
57
58 gdb_test_no_output "tstart"
59
60 gdb_test "continue" ".*Breakpoint \[0-9\]+, end .*" \
61 "advance through tracing"
62
63 gdb_test "tstatus" ".*Collected 1 trace frame.*" \
64 "collected 1 trace frame"
65
66 gdb_test_no_output "tstop"
67
68 gdb_tfind_test "tfind start" "start" "0"
69}
70
71clean_restart $testfile
72runto_main
73
74# Trace once, issuing a tstatus, so that GDB tries
75# qXfer:trace-frame-info:read.
76prepare_for_trace_disassembly
77
78# Now check whether the packet is supported.
79set traceframe_info_supported -1
80set test "probe for traceframe-info support"
81gdb_test_multiple "show remote traceframe-info-packet" $test {
ff52c073 82 -re ".*Support for .* is \"auto\", currently (\[a-z\]*).*$gdb_prompt $" {
9779ab84
PA
83 set status $expect_out(1,string)
84
85 if { $status == "enabled" } {
86 set traceframe_info_supported 1
87 } else {
88 set traceframe_info_supported 0
89 }
90
91 pass $test
92 }
93}
94if { $traceframe_info_supported == -1 } {
95 return -1
96}
97
98# Check whether we're testing with our own GDBserver.
0a46d518 99set is_gdbserver [target_is_gdbserver]
9779ab84
PA
100if { $is_gdbserver == -1 } {
101 return -1
102}
103
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
107# in the stub side.
108foreach tfinfo { auto off } {
109 with_test_prefix "qXfer:traceframe-info:read $tfinfo" {
110
111 clean_restart $testfile
112 runto_main
ff52c073
CS
113 gdb_test \
114 "set remote traceframe-info-packet $tfinfo" \
115 "Support for the 'qXfer:traceframe-info:read' packet on the current remote target is set to *.*$tfinfo*.*"
9779ab84
PA
116
117 prepare_for_trace_disassembly
118
119 set test "trace disassembly"
120 gdb_test_multiple "disassemble subr" $test {
121 -re "<(\.\[0-9\]+|)>:.*End of assembler dump.*$gdb_prompt $" {
122 pass $test
123 }
124 -re "Cannot access memory.*$gdb_prompt $" {
125 if { $traceframe_info_supported == 0 } {
126 # If qXfer:traceframe-info:read is not supported,
127 # then there should be QTro support.
128 fail $test
129 } elseif { $tfinfo == off && $is_gdbserver == 1 } {
130 # We we're testing with GDBserver, we know both
131 # qXfer:traceframe-info:read and QTro are
132 # supported (although supporting the former only
133 # would be sufficient), so issue a FAIL instead of
134 # UNSUPPORTED, giving us better visibility of QTro
135 # regressions.
136 fail $test
137 } else {
138 # Otherwise, qXfer:traceframe-info:read is
139 # supported, making QTro optional, so this isn't
140 # really a failure.
141 unsupported "$test (no QTro support)"
142 }
143 }
144 }
145 }
146}