OLD | NEW |
(Empty) | |
| 1 # Copyright 1998-2013 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 proc gdb_is_target_remote { } { |
| 39 global gdb_prompt |
| 40 |
| 41 set test "probe for target remote" |
| 42 gdb_test_multiple "maint print target-stack" $test { |
| 43 -re ".*emote serial target in gdb-specific protocol.*$gdb_prompt $" { |
| 44 pass $test |
| 45 return 1 |
| 46 } |
| 47 -re "$gdb_prompt $" { |
| 48 pass $test |
| 49 } |
| 50 } |
| 51 return 0 |
| 52 } |
| 53 |
| 54 if ![gdb_is_target_remote] { |
| 55 return -1 |
| 56 } |
| 57 |
| 58 if ![gdb_target_supports_trace] { |
| 59 unsupported "Current target does not support trace" |
| 60 return -1 |
| 61 } |
| 62 |
| 63 # Run a trace session, stop it, and then inspect the resulting trace |
| 64 # frame (IOW, returns while tfind mode is active). |
| 65 proc prepare_for_trace_disassembly { } { |
| 66 global gdb_prompt |
| 67 gdb_breakpoint "end" |
| 68 |
| 69 gdb_test "trace subr" "Tracepoint .*" \ |
| 70 "tracepoint at subr" |
| 71 |
| 72 gdb_trace_setactions "define action" \ |
| 73 "" \ |
| 74 "collect parm" "^$" |
| 75 |
| 76 gdb_test_no_output "tstart" |
| 77 |
| 78 gdb_test "continue" ".*Breakpoint \[0-9\]+, end .*" \ |
| 79 "advance through tracing" |
| 80 |
| 81 gdb_test "tstatus" ".*Collected 1 trace frame.*" \ |
| 82 "collected 1 trace frame" |
| 83 |
| 84 gdb_test_no_output "tstop" |
| 85 |
| 86 gdb_tfind_test "tfind start" "start" "0" |
| 87 } |
| 88 |
| 89 clean_restart $testfile |
| 90 runto_main |
| 91 |
| 92 # Trace once, issuing a tstatus, so that GDB tries |
| 93 # qXfer:trace-frame-info:read. |
| 94 prepare_for_trace_disassembly |
| 95 |
| 96 # Now check whether the packet is supported. |
| 97 set traceframe_info_supported -1 |
| 98 set test "probe for traceframe-info support" |
| 99 gdb_test_multiple "show remote traceframe-info-packet" $test { |
| 100 -re ".*Support for .* is auto-detected, currently (\[a-z\]*).*$gdb_prompt $"
{ |
| 101 set status $expect_out(1,string) |
| 102 |
| 103 if { $status == "enabled" } { |
| 104 set traceframe_info_supported 1 |
| 105 } else { |
| 106 set traceframe_info_supported 0 |
| 107 } |
| 108 |
| 109 pass $test |
| 110 } |
| 111 } |
| 112 if { $traceframe_info_supported == -1 } { |
| 113 return -1 |
| 114 } |
| 115 |
| 116 # Check whether we're testing with our own GDBserver. |
| 117 set is_gdbserver -1 |
| 118 set test "probe for GDBserver" |
| 119 gdb_test_multiple "monitor help" $test { |
| 120 -re "The following monitor commands are supported.*debug-hw-points.*remote-d
ebug.*GDBserver.*$gdb_prompt $" { |
| 121 set is_gdbserver 1 |
| 122 pass $test |
| 123 } |
| 124 -re "$gdb_prompt $" { |
| 125 set is_gdbserver 0 |
| 126 pass $test |
| 127 } |
| 128 } |
| 129 if { $is_gdbserver == -1 } { |
| 130 return -1 |
| 131 } |
| 132 |
| 133 # Now disassemble (IOW, read from read-only memory) while inspecting a |
| 134 # trace frame, twice. Once with qXfer:traceframe-info:read left to |
| 135 # auto, and once with it disabled, exercising the QTro fallback path |
| 136 # in the stub side. |
| 137 foreach tfinfo { auto off } { |
| 138 with_test_prefix "qXfer:traceframe-info:read $tfinfo" { |
| 139 |
| 140 clean_restart $testfile |
| 141 runto_main |
| 142 gdb_test_no_output "set remote traceframe-info-packet $tfinfo" |
| 143 |
| 144 prepare_for_trace_disassembly |
| 145 |
| 146 set test "trace disassembly" |
| 147 gdb_test_multiple "disassemble subr" $test { |
| 148 -re "<(\.\[0-9\]+|)>:.*End of assembler dump.*$gdb_prompt $" { |
| 149 pass $test |
| 150 } |
| 151 -re "Cannot access memory.*$gdb_prompt $" { |
| 152 if { $traceframe_info_supported == 0 } { |
| 153 # If qXfer:traceframe-info:read is not supported, |
| 154 # then there should be QTro support. |
| 155 fail $test |
| 156 } elseif { $tfinfo == off && $is_gdbserver == 1 } { |
| 157 # We we're testing with GDBserver, we know both |
| 158 # qXfer:traceframe-info:read and QTro are |
| 159 # supported (although supporting the former only |
| 160 # would be sufficient), so issue a FAIL instead of |
| 161 # UNSUPPORTED, giving us better visibility of QTro |
| 162 # regressions. |
| 163 fail $test |
| 164 } else { |
| 165 # Otherwise, qXfer:traceframe-info:read is |
| 166 # supported, making QTro optional, so this isn't |
| 167 # really a failure. |
| 168 unsupported "$test (no QTro support)" |
| 169 } |
| 170 } |
| 171 } |
| 172 } |
| 173 } |
OLD | NEW |