1 # Copyright 2012-2024 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 "failed to prepare" $executable $srcfile \
39 if ![gdb_target_supports_trace] {
40 unsupported "target does not support trace"
44 # Disconnect in tracing.
46 proc disconnected_tracing { } {
47 with_test_prefix "trace" {
52 # Start with a fresh gdb.
53 clean_restart ${executable}
58 gdb_test_no_output "set confirm off"
59 gdb_test_no_output "set disconnected-tracing on"
60 gdb_test "trace start" ".*"
61 gdb_trace_setactions "collect on tracepoint 2" "2" \
63 gdb_breakpoint "end" qualified
65 gdb_test_no_output "tstart"
67 gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*"
68 gdb_test_no_output "tstop"
70 gdb_test "info tracepoints" ".*in start at.*" \
71 "first info tracepoints"
73 gdb_test "disconnect" "Ending remote debugging\\." "first disconnect"
74 if { [gdb_reconnect] == 0 } {
75 pass "first reconnect after unload"
77 fail "first reconnect after unload"
80 gdb_test "info tracepoints" ".*in start at.*" \
81 "second info tracepoints"
84 gdb_test "info tracepoints" ".*No tracepoints..*" \
85 "third info tracepoints"
87 gdb_test "disconnect" "Ending remote debugging\\." "second disconnect"
88 if { [gdb_reconnect] == 0 } {
89 pass "second reconnect after unload"
91 fail "second reconnect after unload"
95 gdb_test "info tracepoints" \
96 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
97 \[0-9\]+\[\t \]+tracepoint keep y.* in start at .*$srcfile:\[0-9\]+.
98 \[\t \]+tracepoint already hit 1 time.
99 \[\t \]+trace buffer usage ${decimal} bytes.
100 \[\t \]+collect foo.*" \
101 "fourth info tracepoints"
107 # Disconnected in tfind
109 proc disconnected_tfind { } {
110 with_test_prefix "tfind" {
114 # Start with a fresh gdb.
115 clean_restart ${executable}
120 gdb_test_no_output "set confirm off"
121 gdb_test_no_output "set disconnected-tracing on"
122 gdb_test "trace start" ".*"
123 gdb_test_no_output "tstart"
125 gdb_breakpoint "end" qualified
126 gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*"
127 gdb_test_no_output "tstop"
129 gdb_test "tfind" "Found trace frame 0, tracepoint .*" "tfind frame 0"
130 gdb_test "p \$trace_frame" ".*\\\$${decimal} = 0.*" \
131 "p \$trace_frame before disconnected"
132 gdb_test "p \$tracepoint" ".*\\\$${decimal} = 2.*" \
133 "p \$tracepoint before disconnected"
135 gdb_test "disconnect" "Ending remote debugging\\." "first disconnect"
137 gdb_test "p \$trace_frame" ".*\\\$${decimal} = -1.*"
138 gdb_test "p \$tracepoint" ".*\\\$${decimal} = -1.*"
139 gdb_test "p \$trace_line" ".*\\\$${decimal} = -1.*"
140 gdb_test "p \$trace_file" ".*\\\$${decimal} = void.*"
141 gdb_test "p \$trace_func" ".*\\\$${decimal} = void.*"
147 # Reconnect for a clean gdbserver shutdown.