Don't suppress errors inserting/removing hardware breakpoints in shared
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.trace / qtro.exp
1 # Copyright 1998-2014 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 -1
102 set test "probe for GDBserver"
103 gdb_test_multiple "monitor help" $test {
104 -re "The following monitor commands are supported.*debug-hw-points.*remote-debug.*GDBserver.*$gdb_prompt $" {
105 set is_gdbserver 1
106 pass $test
107 }
108 -re "$gdb_prompt $" {
109 set is_gdbserver 0
110 pass $test
111 }
112 }
113 if { $is_gdbserver == -1 } {
114 return -1
115 }
116
117 # Now disassemble (IOW, read from read-only memory) while inspecting a
118 # trace frame, twice. Once with qXfer:traceframe-info:read left to
119 # auto, and once with it disabled, exercising the QTro fallback path
120 # in the stub side.
121 foreach tfinfo { auto off } {
122 with_test_prefix "qXfer:traceframe-info:read $tfinfo" {
123
124 clean_restart $testfile
125 runto_main
126 gdb_test_no_output "set remote traceframe-info-packet $tfinfo"
127
128 prepare_for_trace_disassembly
129
130 set test "trace disassembly"
131 gdb_test_multiple "disassemble subr" $test {
132 -re "<(\.\[0-9\]+|)>:.*End of assembler dump.*$gdb_prompt $" {
133 pass $test
134 }
135 -re "Cannot access memory.*$gdb_prompt $" {
136 if { $traceframe_info_supported == 0 } {
137 # If qXfer:traceframe-info:read is not supported,
138 # then there should be QTro support.
139 fail $test
140 } elseif { $tfinfo == off && $is_gdbserver == 1 } {
141 # We we're testing with GDBserver, we know both
142 # qXfer:traceframe-info:read and QTro are
143 # supported (although supporting the former only
144 # would be sufficient), so issue a FAIL instead of
145 # UNSUPPORTED, giving us better visibility of QTro
146 # regressions.
147 fail $test
148 } else {
149 # Otherwise, qXfer:traceframe-info:read is
150 # supported, making QTro optional, so this isn't
151 # really a failure.
152 unsupported "$test (no QTro support)"
153 }
154 }
155 }
156 }
157 }
This page took 0.050069 seconds and 4 git commands to generate.