1 # Copyright 1998-2015 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 $testfile.exp $testfile $srcfile debug]} {
28 clean_restart $testfile
31 fail "Can't run to main to check for trace support"
35 # Check whether we're testing with the remote or extended-remote
36 # targets, and whether the target supports tracepoints.
38 if ![gdb_is_target_remote] {
42 if ![gdb_target_supports_trace] {
43 unsupported "Current target does not support trace"
47 # Run a trace session, stop it, and then inspect the resulting trace
48 # frame (IOW, returns while tfind mode is active).
49 proc prepare_for_trace_disassembly { } {
53 gdb_test "trace subr" "Tracepoint .*" \
56 gdb_trace_setactions "define action" \
60 gdb_test_no_output "tstart"
62 gdb_test "continue" ".*Breakpoint \[0-9\]+, end .*" \
63 "advance through tracing"
65 gdb_test "tstatus" ".*Collected 1 trace frame.*" \
66 "collected 1 trace frame"
68 gdb_test_no_output "tstop"
70 gdb_tfind_test "tfind start" "start" "0"
73 clean_restart $testfile
76 # Trace once, issuing a tstatus, so that GDB tries
77 # qXfer:trace-frame-info:read.
78 prepare_for_trace_disassembly
80 # Now check whether the packet is supported.
81 set traceframe_info_supported -1
82 set test "probe for traceframe-info support"
83 gdb_test_multiple "show remote traceframe-info-packet" $test {
84 -re ".*Support for .* is auto-detected, currently (\[a-z\]*).*$gdb_prompt $" {
85 set status $expect_out(1,string)
87 if { $status == "enabled" } {
88 set traceframe_info_supported 1
90 set traceframe_info_supported 0
96 if { $traceframe_info_supported == -1 } {
100 # Check whether we're testing with our own GDBserver.
101 set is_gdbserver [target_is_gdbserver]
102 if { $is_gdbserver == -1 } {
106 # Now disassemble (IOW, read from read-only memory) while inspecting a
107 # trace frame, twice. Once with qXfer:traceframe-info:read left to
108 # auto, and once with it disabled, exercising the QTro fallback path
110 foreach tfinfo { auto off } {
111 with_test_prefix "qXfer:traceframe-info:read $tfinfo" {
113 clean_restart $testfile
115 gdb_test_no_output "set remote traceframe-info-packet $tfinfo"
117 prepare_for_trace_disassembly
119 set test "trace disassembly"
120 gdb_test_multiple "disassemble subr" $test {
121 -re "<(\.\[0-9\]+|)>:.*End of assembler dump.*$gdb_prompt $" {
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.
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
138 # Otherwise, qXfer:traceframe-info:read is
139 # supported, making QTro optional, so this isn't
141 unsupported "$test (no QTro support)"