]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - 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
1 # Copyright 1998-2023 Free Software Foundation, Inc.
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
21 load_lib trace-support.exp
22
23 standard_testfile
24
25 if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug nopie}]} {
26 return -1
27 }
28
29 if ![runto_main] {
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
36 if ![gdb_is_target_remote] {
37 return -1
38 }
39
40 if ![gdb_target_supports_trace] {
41 unsupported "current target does not support trace"
42 return -1
43 }
44
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 { } {
48 global gdb_prompt
49 gdb_breakpoint "end" qualified
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
71 clean_restart $testfile
72 runto_main
73
74 # Trace once, issuing a tstatus, so that GDB tries
75 # qXfer:trace-frame-info:read.
76 prepare_for_trace_disassembly
77
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)
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 }
94 if { $traceframe_info_supported == -1 } {
95 return -1
96 }
97
98 # Check whether we're testing with our own GDBserver.
99 set is_gdbserver [target_is_gdbserver]
100 if { $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.
108 foreach tfinfo { auto off } {
109 with_test_prefix "qXfer:traceframe-info:read $tfinfo" {
110
111 clean_restart $testfile
112 runto_main
113 gdb_test_no_output "set remote traceframe-info-packet $tfinfo"
114
115 prepare_for_trace_disassembly
116
117 set test "trace disassembly"
118 gdb_test_multiple "disassemble subr" $test {
119 -re "<(\.\[0-9\]+|)>:.*End of assembler dump.*$gdb_prompt $" {
120 pass $test
121 }
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.
126 fail $test
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
133 # regressions.
134 fail $test
135 } else {
136 # Otherwise, qXfer:traceframe-info:read is
137 # supported, making QTro optional, so this isn't
138 # really a failure.
139 unsupported "$test (no QTro support)"
140 }
141 }
142 }
143 }
144 }