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