1 # Copyright 2012-2013 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 # Test of disconnected-tracing.
18 load_lib "trace-support.exp";
21 set executable $testfile
22 set expfile $testfile.exp
23 set gdbserver_reconnect_p 1
25 if { [info proc gdb_reconnect] == "" } {
26 unsupported "target does not support reconnect"
30 if [prepare_for_testing $expfile $executable $srcfile \
32 untested "failed to prepare for trace tests"
37 fail "can't run to main to check for trace support"
41 if ![gdb_target_supports_trace] {
42 unsupported "target does not support trace"
46 # Disconnect in tracing.
48 proc disconnected_tracing { } { with_test_prefix "trace" {
53 # Start with a fresh gdb.
54 clean_restart ${executable}
56 fail "Can't run to main"
60 gdb_test_no_output "set confirm off"
61 gdb_test_no_output "set disconnected-tracing on"
62 gdb_test "trace start" ".*"
63 gdb_trace_setactions "collect on tracepoint 2" "2" \
65 gdb_test "break end" "Breakpoint ${decimal} at .*"
67 gdb_test_no_output "tstart"
69 gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*"
70 gdb_test_no_output "tstop"
72 gdb_test "info tracepoints" ".*in start at.*" \
73 "first info tracepoints"
75 gdb_test "disconnect" "Ending remote debugging\\." "first disconnect"
76 if { [gdb_reconnect] == 0 } {
77 pass "first reconnect after unload"
79 fail "first reconnect after unload"
82 gdb_test "info tracepoints" ".*in start at.*" \
83 "second info tracepoints"
86 gdb_test "info tracepoints" ".*No tracepoints..*" \
87 "third info tracepoints"
89 gdb_test "disconnect" "Ending remote debugging\\." "second disconnect"
90 if { [gdb_reconnect] == 0 } {
91 pass "second reconnect after unload"
93 fail "second reconnect after unload"
97 gdb_test "info tracepoints" \
98 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
99 \[0-9\]+\[\t \]+tracepoint keep y.* in start at .*$srcfile:\[0-9\]+.
100 \[\t \]+tracepoint already hit 1 time.
101 \[\t \]+trace buffer usage ${decimal} bytes.
102 \[\t \]+collect foo.*" \
103 "fourth info tracepoints"
108 # Disconnected in tfind
110 proc disconnected_tfind { } { with_test_prefix "tfind" {
114 # Start with a fresh gdb.
115 clean_restart ${executable}
117 fail "Can't run to main"
121 gdb_test_no_output "set confirm off"
122 gdb_test_no_output "set disconnected-tracing on"
123 gdb_test "trace start" ".*"
124 gdb_test_no_output "tstart"
126 gdb_test "break end" "Breakpoint ${decimal} at .*"
127 gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*"
128 gdb_test_no_output "tstop"
130 gdb_test "tfind" "Found trace frame 0, tracepoint .*" "tfind frame 0"
131 gdb_test "p \$trace_frame" ".*\\\$${decimal} = 0.*" \
132 "p \$trace_frame before disconnected"
133 gdb_test "p \$tracepoint" ".*\\\$${decimal} = 2.*" \
134 "p \$tracepoint before disconnected"
136 gdb_test "disconnect" "Ending remote debugging\\." "first disconnect"
138 gdb_test "p \$trace_frame" ".*\\\$${decimal} = -1.*"
139 gdb_test "p \$tracepoint" ".*\\\$${decimal} = -1.*"
140 gdb_test "p \$trace_line" ".*\\\$${decimal} = -1.*"
141 gdb_test "p \$trace_file" ".*\\\$${decimal} = void.*"
142 gdb_test "p \$trace_func" ".*\\\$${decimal} = void.*"