]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.trace/mi-tsv-changed.exp
Update copyright year range in all GDB files
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.trace / mi-tsv-changed.exp
CommitLineData
3666a048 1# Copyright 2012-2021 Free Software Foundation, Inc.
bb25a15c
YQ
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
16load_lib trace-support.exp
17load_lib mi-support.exp
18
19standard_testfile actions.c
8bca2978
SL
20
21if ![gdb_trace_common_supports_arch] {
22 unsupported "no trace-common.h support for arch"
23 return -1
24}
25
bb25a15c
YQ
26if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
27 executable {debug nowarnings}] != "" } {
5b362f04 28 untested "failed to compile"
bb25a15c
YQ
29 return -1
30}
31
134a2066 32# Test notifications on creating, deleting and modifying TSV.
bb25a15c 33
0a251e08
YQ
34proc test_create_delete_modify_tsv { } {
35 with_test_prefix "create delete modify" {
36 global binfile
37 global decimal
38 global testfile
39 global srcdir subdir
40 global mi_gdb_prompt
41
42 if [mi_gdb_start] {
43 return
44 }
45 mi_gdb_load ${binfile}
46
47 mi_gdb_test "tvariable \$tvar1" \
48 ".*=tsv-created,name=\"tvar1\",initial=\"0\"\\\\n.*\\^done" \
49 "tvariable \$tvar1"
50 mi_gdb_test "tvariable \$tvar1 = 1" \
51 ".*=tsv-modified,name=\"tvar1\",initial=\"1\".*\\^done" \
52 "tvariable \$tvar1 modified"
53 # No "=tsv-modified" notification is emitted, because the initial
54 # value is not changed.
55 mi_gdb_test "tvariable \$tvar1 = 1" \
56 ".*\\\$tvar1 = 1\\\\n\"\r\n~\"Trace state .*\\\\n.*\\^done" \
57 "tvariable \$tvar1 modified without notification"
58 mi_gdb_test "tvariable \$tvar2 = 45" \
59 ".*=tsv-created,name=\"tvar2\",initial=\"45\"\\\\n.*\\^done" \
60 "tvariable \$tvar2"
61
62 mi_gdb_test "delete tvariable \$tvar2" \
63 ".*=tsv-deleted,name=\"tvar2\"\\\\n.*\\^done" \
64 "delete tvariable \$tvar2"
65
66 mi_gdb_test "delete tvariable" \
67 ".*=tsv-deleted\\\\n.*\\^done" \
68 "delete all tvariables"
69
70 # Test target supports tracepoints or not.
71 clean_restart $testfile
72
73 if ![runto_main] {
bc6c7af4 74 fail "can't run to main to check for trace support"
0a251e08
YQ
75 return -1
76 }
134a2066 77
0a251e08 78 if ![gdb_target_supports_trace] {
bc6c7af4 79 unsupported "current target does not support trace"
0a251e08 80 return -1
134a2066 81 }
0a251e08
YQ
82 gdb_exit
83 if [mi_gdb_start] {
84 continue
134a2066 85 }
0a251e08
YQ
86
87 mi_gdb_reinitialize_dir $srcdir/$subdir
88 mi_gdb_load ${binfile}
89
90 mi_gdb_test "tvariable \$tvar3 = 3" \
91 ".*=tsv-created,name=\"tvar3\",initial=\"3\".*\\^done" \
92 "tvariable \$tvar3 modified"
93 mi_gdb_test "-break-insert -a gdb_c_test" \
94 {.*\^done,bkpt=.*} \
95 "insert tracepoint on gdb_c_test"
96 # Define an action that increases $tvar3
97 send_gdb "actions\n"
98 gdb_expect {
99 -re "End with" {
100 }
134a2066 101 }
0a251e08
YQ
102 send_gdb "collect \$tvar3 += 3\nend\n"
103 set test "define actions"
104 gdb_expect {
105 -re ".*${mi_gdb_prompt}$" {
106 pass $test
107 }
108 timeout {
109 fail "$test (timeout)"
110 }
111 }
112
113 mi_gdb_test "-break-insert begin" \
114 {.*\^done,bkpt=.*} \
115 "insert tracepoint on begin"
116 mi_gdb_test "-break-insert end" \
117 {.*\^done,bkpt=.*} \
118 "insert tracepoint on end"
119 mi_run_cmd
120
121 mi_expect_stop "breakpoint-hit" "begin" ""\
122 ".*" ".*" {"" "disp=\"keep\""} \
123 "continue to begin breakpoint"
124 mi_gdb_test "-trace-start" {.*\^done} "trace start"
125 mi_send_resuming_command "exec-continue" "continuing to end"
126 mi_gdb_test "-trace-stop" {.*} "trace stop"
127 # Force GDB to get the current value of trace state variable.
128 mi_gdb_test "-trace-list-variables" ".*" "list trace variables"
129 mi_gdb_test "tvariable \$tvar3 = 2" \
130 ".*=tsv-modified,name=\"tvar3\",initial=\"2\",current=\"6\".*\\^done" \
131 "tvariable \$tvar3 modified"
134a2066 132
0a251e08
YQ
133 }
134}
bb25a15c
YQ
135
136
137# Test when GDB connects to a disconnected stub, existing TSVs in
138# remote stub can be uploaded to GDB, and GDB emits MI notification
139# for new uploaded TSVs.
140
0a251e08
YQ
141proc test_upload_tsv { } {
142 with_test_prefix "upload" {
bb25a15c 143
0a251e08
YQ
144 global gdbserver_reconnect_p
145 global gdb_prompt
146 global testfile
147 global decimal
bb25a15c 148
0a251e08
YQ
149 set gdbserver_reconnect_p 1
150 if { [info proc gdb_reconnect] == "" } {
151 return 0
152 }
bb25a15c 153
0a251e08
YQ
154 clean_restart $testfile
155 if ![runto_main] then {
bc6c7af4 156 fail "can't run to main"
0a251e08
YQ
157 return 0
158 }
bb25a15c 159
0a251e08
YQ
160 gdb_test "tvariable \$tvar1" \
161 "Trace state variable \\\$tvar1 created, with initial value 0." \
bb95117e 162 "create a trace state variable"
0a251e08
YQ
163
164 gdb_test "tvariable \$tvar2 = 45" \
165 "Trace state variable \\\$tvar2 created, with initial value 45." \
166 "Create a trace state variable with initial value"
167 # Define a tracepoint otherwise tracing cannot be started.
168 gdb_test "trace main" "Tracepoint $decimal at .*"
169 gdb_test_no_output "tstart" "start trace experiment"
170
171 set test "disconnect"
172 gdb_test_multiple "disconnect" $test {
173 -re "Trace is running but will stop on detach; detach anyway\\? \\(y or n\\) $" {
174 pass $test
175
176 set test "disconnected"
177 gdb_test_multiple "y" $test {
178 -re "$gdb_prompt $" {
179 pass "$test"
180 }
bb25a15c
YQ
181 }
182 }
183 }
bb25a15c 184
0a251e08 185 gdb_exit
bb25a15c 186
0a251e08
YQ
187 if [mi_gdb_start] {
188 return
189 }
bb25a15c 190
0a251e08
YQ
191 global srcdir
192 global subdir
193 global binfile
bb25a15c 194
0a251e08
YQ
195 mi_gdb_reinitialize_dir $srcdir/$subdir
196 mi_gdb_load ${binfile}
bb25a15c 197
0a251e08
YQ
198 global gdbserver_protocol
199 global gdbserver_gdbport
bb25a15c 200
0a251e08 201 send_gdb "47-target-select $gdbserver_protocol $gdbserver_gdbport\n"
bb25a15c 202
0a251e08
YQ
203 global mi_gdb_prompt
204 set tsv1_created 0
205 set tsv2_created 0
206 gdb_expect {
207 -re "=tsv-created,name=\"tvar1\",initial=\"0\"" {
208 set tsv1_created 1
209 exp_continue
210 }
211 -re "=tsv-created,name=\"tvar2\",initial=\"45\"" {
212 set tsv2_created 1
213 exp_continue
214 }
215 -re ".*${mi_gdb_prompt}" {
216
217 }
bb25a15c 218 }
bb25a15c 219
0a251e08
YQ
220 if $tsv1_created {
221 pass "tsv1 created"
222 } else {
223 fail "tsv1 created"
224 }
225 if $tsv2_created {
226 pass "tsv2 created"
227 } else {
228 fail "tsv2 created"
bb25a15c 229 }
bb25a15c 230
0a251e08 231 set gdbserver_reconnect_p 0
bb25a15c 232 }
0a251e08 233}
bb25a15c 234
134a2066 235 test_create_delete_modify_tsv
bb25a15c
YQ
236
237# Test target supports tracepoints or not.
238
239clean_restart $testfile
240
241if ![runto_main] {
bc6c7af4 242 fail "can't run to main to check for trace support"
bb25a15c
YQ
243 return -1
244}
245
246if ![gdb_target_supports_trace] {
bc6c7af4 247 unsupported "current target does not support trace"
ae59b1da 248 return -1
bb25a15c
YQ
249}
250
251gdb_exit
252
253test_upload_tsv
254
255return 0