]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.trace/disconnected-tracing.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.trace / disconnected-tracing.exp
1 # Copyright 2012-2024 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 # Test of disconnected-tracing.
17
18 load_lib "trace-support.exp"
19
20 standard_testfile
21 set executable $testfile
22 set expfile $testfile.exp
23 set gdbserver_reconnect_p 1
24
25 if { [info proc gdb_reconnect] == "" } {
26 unsupported "target does not support reconnect"
27 return -1
28 }
29
30 if [prepare_for_testing "failed to prepare" $executable $srcfile \
31 {debug nowarnings}] {
32 return -1
33 }
34
35 if ![runto_main] {
36 return -1
37 }
38
39 if ![gdb_target_supports_trace] {
40 unsupported "target does not support trace"
41 return -1
42 }
43
44 # Disconnect in tracing.
45
46 proc disconnected_tracing { } {
47 with_test_prefix "trace" {
48 global executable
49 global decimal
50 global srcfile
51
52 # Start with a fresh gdb.
53 clean_restart ${executable}
54 if ![runto_main] {
55 return -1
56 }
57
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" \
62 "collect foo" "^$"
63 gdb_breakpoint "end" qualified
64
65 gdb_test_no_output "tstart"
66
67 gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*"
68 gdb_test_no_output "tstop"
69
70 gdb_test "info tracepoints" ".*in start at.*" \
71 "first info tracepoints"
72
73 gdb_test "disconnect" "Ending remote debugging\\." "first disconnect"
74 if { [gdb_reconnect] == 0 } {
75 pass "first reconnect after unload"
76 } else {
77 fail "first reconnect after unload"
78 return 0
79 }
80 gdb_test "info tracepoints" ".*in start at.*" \
81 "second info tracepoints"
82
83 delete_breakpoints
84 gdb_test "info tracepoints" ".*No tracepoints..*" \
85 "third info tracepoints"
86
87 gdb_test "disconnect" "Ending remote debugging\\." "second disconnect"
88 if { [gdb_reconnect] == 0 } {
89 pass "second reconnect after unload"
90 } else {
91 fail "second reconnect after unload"
92 return 0
93 }
94 gdb_test "tstatus"
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"
102 }
103 }
104
105 disconnected_tracing
106
107 # Disconnected in tfind
108
109 proc disconnected_tfind { } {
110 with_test_prefix "tfind" {
111 global executable
112 global decimal
113
114 # Start with a fresh gdb.
115 clean_restart ${executable}
116 if ![runto_main] {
117 return -1
118 }
119
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"
124
125 gdb_breakpoint "end" qualified
126 gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*"
127 gdb_test_no_output "tstop"
128
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"
134
135 gdb_test "disconnect" "Ending remote debugging\\." "first disconnect"
136
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.*"
142 }
143 }
144
145 disconnected_tfind
146
147 # Reconnect for a clean gdbserver shutdown.
148 gdb_reconnect