| 1 | # Copyright 1998-2015 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 $testfile.exp $testfile $srcfile debug]} { |
| 26 | return -1 |
| 27 | } |
| 28 | clean_restart $testfile |
| 29 | |
| 30 | if ![runto_main] { |
| 31 | fail "Can't run to main to check for trace support" |
| 32 | return -1 |
| 33 | } |
| 34 | |
| 35 | # Check whether we're testing with the remote or extended-remote |
| 36 | # targets, and whether the target supports tracepoints. |
| 37 | |
| 38 | if ![gdb_is_target_remote] { |
| 39 | return -1 |
| 40 | } |
| 41 | |
| 42 | if ![gdb_target_supports_trace] { |
| 43 | unsupported "Current target does not support trace" |
| 44 | return -1 |
| 45 | } |
| 46 | |
| 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 { } { |
| 50 | global gdb_prompt |
| 51 | gdb_breakpoint "end" |
| 52 | |
| 53 | gdb_test "trace subr" "Tracepoint .*" \ |
| 54 | "tracepoint at subr" |
| 55 | |
| 56 | gdb_trace_setactions "define action" \ |
| 57 | "" \ |
| 58 | "collect parm" "^$" |
| 59 | |
| 60 | gdb_test_no_output "tstart" |
| 61 | |
| 62 | gdb_test "continue" ".*Breakpoint \[0-9\]+, end .*" \ |
| 63 | "advance through tracing" |
| 64 | |
| 65 | gdb_test "tstatus" ".*Collected 1 trace frame.*" \ |
| 66 | "collected 1 trace frame" |
| 67 | |
| 68 | gdb_test_no_output "tstop" |
| 69 | |
| 70 | gdb_tfind_test "tfind start" "start" "0" |
| 71 | } |
| 72 | |
| 73 | clean_restart $testfile |
| 74 | runto_main |
| 75 | |
| 76 | # Trace once, issuing a tstatus, so that GDB tries |
| 77 | # qXfer:trace-frame-info:read. |
| 78 | prepare_for_trace_disassembly |
| 79 | |
| 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) |
| 86 | |
| 87 | if { $status == "enabled" } { |
| 88 | set traceframe_info_supported 1 |
| 89 | } else { |
| 90 | set traceframe_info_supported 0 |
| 91 | } |
| 92 | |
| 93 | pass $test |
| 94 | } |
| 95 | } |
| 96 | if { $traceframe_info_supported == -1 } { |
| 97 | return -1 |
| 98 | } |
| 99 | |
| 100 | # Check whether we're testing with our own GDBserver. |
| 101 | set is_gdbserver [target_is_gdbserver] |
| 102 | if { $is_gdbserver == -1 } { |
| 103 | return -1 |
| 104 | } |
| 105 | |
| 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 |
| 109 | # in the stub side. |
| 110 | foreach tfinfo { auto off } { |
| 111 | with_test_prefix "qXfer:traceframe-info:read $tfinfo" { |
| 112 | |
| 113 | clean_restart $testfile |
| 114 | runto_main |
| 115 | gdb_test_no_output "set remote traceframe-info-packet $tfinfo" |
| 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 | } |