Automatic Copyright Year update after running gdb/copyright.py
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.trace / disconnected-tracing.exp
CommitLineData
88b9d363 1# Copyright 2012-2022 Free Software Foundation, Inc.
c772f8e7
HZ
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# Test of disconnected-tracing.
17
4ec70201 18load_lib "trace-support.exp"
c772f8e7 19
497a5eb0 20standard_testfile
61e44cfa 21set executable $testfile
c772f8e7
HZ
22set expfile $testfile.exp
23set gdbserver_reconnect_p 1
24
25if { [info proc gdb_reconnect] == "" } {
26 unsupported "target does not support reconnect"
27 return -1
28}
29
5b362f04 30if [prepare_for_testing "failed to prepare" $executable $srcfile \
c772f8e7 31 {debug nowarnings}] {
c772f8e7
HZ
32 return -1
33}
34
35if ![runto_main] {
36 fail "can't run to main to check for trace support"
37 return -1
38}
39
40if ![gdb_target_supports_trace] {
41 unsupported "target does not support trace"
ae59b1da 42 return -1
c772f8e7
HZ
43}
44
8d735b87 45# Disconnect in tracing.
c772f8e7 46
0a251e08
YQ
47proc disconnected_tracing { } {
48 with_test_prefix "trace" {
49 global executable
50 global decimal
51 global srcfile
52
53 # Start with a fresh gdb.
54 clean_restart ${executable}
55 if ![runto_main] {
bc6c7af4 56 fail "can't run to main"
0a251e08
YQ
57 return -1
58 }
59
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" \
64 "collect foo" "^$"
194ed413 65 gdb_breakpoint "end" qualified
0a251e08
YQ
66
67 gdb_test_no_output "tstart"
68
69 gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*"
70 gdb_test_no_output "tstop"
71
72 gdb_test "info tracepoints" ".*in start at.*" \
73 "first info tracepoints"
74
75 gdb_test "disconnect" "Ending remote debugging\\." "first disconnect"
76 if { [gdb_reconnect] == 0 } {
77 pass "first reconnect after unload"
78 } else {
79 fail "first reconnect after unload"
80 return 0
81 }
82 gdb_test "info tracepoints" ".*in start at.*" \
83 "second info tracepoints"
84
85 delete_breakpoints
86 gdb_test "info tracepoints" ".*No tracepoints..*" \
87 "third info tracepoints"
88
89 gdb_test "disconnect" "Ending remote debugging\\." "second disconnect"
90 if { [gdb_reconnect] == 0 } {
91 pass "second reconnect after unload"
92 } else {
93 fail "second reconnect after unload"
94 return 0
95 }
96 gdb_test "tstatus"
97 gdb_test "info tracepoints" \
98 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
5ae4861a
YQ
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.*" \
0a251e08
YQ
103 "fourth info tracepoints"
104 }
105}
8d735b87
YQ
106
107disconnected_tracing
108
109# Disconnected in tfind
110
0a251e08
YQ
111proc disconnected_tfind { } {
112 with_test_prefix "tfind" {
113 global executable
114 global decimal
115
116 # Start with a fresh gdb.
117 clean_restart ${executable}
118 if ![runto_main] {
bc6c7af4 119 fail "can't run to main"
0a251e08
YQ
120 return -1
121 }
122
123 gdb_test_no_output "set confirm off"
124 gdb_test_no_output "set disconnected-tracing on"
125 gdb_test "trace start" ".*"
126 gdb_test_no_output "tstart"
127
194ed413 128 gdb_breakpoint "end" qualified
0a251e08
YQ
129 gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*"
130 gdb_test_no_output "tstop"
131
132 gdb_test "tfind" "Found trace frame 0, tracepoint .*" "tfind frame 0"
133 gdb_test "p \$trace_frame" ".*\\\$${decimal} = 0.*" \
134 "p \$trace_frame before disconnected"
135 gdb_test "p \$tracepoint" ".*\\\$${decimal} = 2.*" \
136 "p \$tracepoint before disconnected"
137
138 gdb_test "disconnect" "Ending remote debugging\\." "first disconnect"
139
140 gdb_test "p \$trace_frame" ".*\\\$${decimal} = -1.*"
141 gdb_test "p \$tracepoint" ".*\\\$${decimal} = -1.*"
142 gdb_test "p \$trace_line" ".*\\\$${decimal} = -1.*"
143 gdb_test "p \$trace_file" ".*\\\$${decimal} = void.*"
144 gdb_test "p \$trace_func" ".*\\\$${decimal} = void.*"
8d735b87 145 }
0a251e08 146}
c772f8e7 147
8d735b87 148disconnected_tfind
a35cfb40
MR
149
150# Reconnect for a clean gdbserver shutdown.
151gdb_reconnect
This page took 1.097221 seconds and 4 git commands to generate.