Commit | Line | Data |
---|---|---|
32d0add0 | 1 | # Copyright 2012-2015 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 | |
20 | if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \ | |
21 | executable {debug nowarnings}] != "" } { | |
22 | untested mi-tsv-changed.exp | |
23 | return -1 | |
24 | } | |
25 | ||
134a2066 | 26 | # Test notifications on creating, deleting and modifying TSV. |
bb25a15c | 27 | |
0a251e08 YQ |
28 | proc test_create_delete_modify_tsv { } { |
29 | with_test_prefix "create delete modify" { | |
30 | global binfile | |
31 | global decimal | |
32 | global testfile | |
33 | global srcdir subdir | |
34 | global mi_gdb_prompt | |
35 | ||
36 | if [mi_gdb_start] { | |
37 | return | |
38 | } | |
39 | mi_gdb_load ${binfile} | |
40 | ||
41 | mi_gdb_test "tvariable \$tvar1" \ | |
42 | ".*=tsv-created,name=\"tvar1\",initial=\"0\"\\\\n.*\\^done" \ | |
43 | "tvariable \$tvar1" | |
44 | mi_gdb_test "tvariable \$tvar1 = 1" \ | |
45 | ".*=tsv-modified,name=\"tvar1\",initial=\"1\".*\\^done" \ | |
46 | "tvariable \$tvar1 modified" | |
47 | # No "=tsv-modified" notification is emitted, because the initial | |
48 | # value is not changed. | |
49 | mi_gdb_test "tvariable \$tvar1 = 1" \ | |
50 | ".*\\\$tvar1 = 1\\\\n\"\r\n~\"Trace state .*\\\\n.*\\^done" \ | |
51 | "tvariable \$tvar1 modified without notification" | |
52 | mi_gdb_test "tvariable \$tvar2 = 45" \ | |
53 | ".*=tsv-created,name=\"tvar2\",initial=\"45\"\\\\n.*\\^done" \ | |
54 | "tvariable \$tvar2" | |
55 | ||
56 | mi_gdb_test "delete tvariable \$tvar2" \ | |
57 | ".*=tsv-deleted,name=\"tvar2\"\\\\n.*\\^done" \ | |
58 | "delete tvariable \$tvar2" | |
59 | ||
60 | mi_gdb_test "delete tvariable" \ | |
61 | ".*=tsv-deleted\\\\n.*\\^done" \ | |
62 | "delete all tvariables" | |
63 | ||
64 | # Test target supports tracepoints or not. | |
65 | clean_restart $testfile | |
66 | ||
67 | if ![runto_main] { | |
68 | fail "Can't run to main to check for trace support" | |
69 | return -1 | |
70 | } | |
134a2066 | 71 | |
0a251e08 YQ |
72 | if ![gdb_target_supports_trace] { |
73 | unsupported "Current target does not support trace" | |
74 | return -1 | |
134a2066 | 75 | } |
0a251e08 YQ |
76 | gdb_exit |
77 | if [mi_gdb_start] { | |
78 | continue | |
134a2066 | 79 | } |
0a251e08 YQ |
80 | |
81 | mi_gdb_reinitialize_dir $srcdir/$subdir | |
82 | mi_gdb_load ${binfile} | |
83 | ||
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 YQ |
148 | clean_restart $testfile |
149 | if ![runto_main] then { | |
150 | fail "Can't run to main" | |
151 | return 0 | |
152 | } | |
bb25a15c | 153 | |
0a251e08 YQ |
154 | gdb_test "tvariable \$tvar1" \ |
155 | "Trace state variable \\\$tvar1 created, with initial value 0." \ | |
156 | "Create a trace state variable" | |
157 | ||
158 | gdb_test "tvariable \$tvar2 = 45" \ | |
159 | "Trace state variable \\\$tvar2 created, with initial value 45." \ | |
160 | "Create a trace state variable with initial value" | |
161 | # Define a tracepoint otherwise tracing cannot be started. | |
162 | gdb_test "trace main" "Tracepoint $decimal at .*" | |
163 | gdb_test_no_output "tstart" "start trace experiment" | |
164 | ||
165 | set test "disconnect" | |
166 | gdb_test_multiple "disconnect" $test { | |
167 | -re "Trace is running but will stop on detach; detach anyway\\? \\(y or n\\) $" { | |
168 | pass $test | |
169 | ||
170 | set test "disconnected" | |
171 | gdb_test_multiple "y" $test { | |
172 | -re "$gdb_prompt $" { | |
173 | pass "$test" | |
174 | } | |
bb25a15c YQ |
175 | } |
176 | } | |
177 | } | |
bb25a15c | 178 | |
0a251e08 | 179 | gdb_exit |
bb25a15c | 180 | |
0a251e08 YQ |
181 | if [mi_gdb_start] { |
182 | return | |
183 | } | |
bb25a15c | 184 | |
0a251e08 YQ |
185 | global srcdir |
186 | global subdir | |
187 | global binfile | |
bb25a15c | 188 | |
0a251e08 YQ |
189 | mi_gdb_reinitialize_dir $srcdir/$subdir |
190 | mi_gdb_load ${binfile} | |
bb25a15c | 191 | |
0a251e08 YQ |
192 | global gdbserver_protocol |
193 | global gdbserver_gdbport | |
bb25a15c | 194 | |
0a251e08 | 195 | send_gdb "47-target-select $gdbserver_protocol $gdbserver_gdbport\n" |
bb25a15c | 196 | |
0a251e08 YQ |
197 | global mi_gdb_prompt |
198 | set tsv1_created 0 | |
199 | set tsv2_created 0 | |
200 | gdb_expect { | |
201 | -re "=tsv-created,name=\"tvar1\",initial=\"0\"" { | |
202 | set tsv1_created 1 | |
203 | exp_continue | |
204 | } | |
205 | -re "=tsv-created,name=\"tvar2\",initial=\"45\"" { | |
206 | set tsv2_created 1 | |
207 | exp_continue | |
208 | } | |
209 | -re ".*${mi_gdb_prompt}" { | |
210 | ||
211 | } | |
bb25a15c | 212 | } |
bb25a15c | 213 | |
0a251e08 YQ |
214 | if $tsv1_created { |
215 | pass "tsv1 created" | |
216 | } else { | |
217 | fail "tsv1 created" | |
218 | } | |
219 | if $tsv2_created { | |
220 | pass "tsv2 created" | |
221 | } else { | |
222 | fail "tsv2 created" | |
bb25a15c | 223 | } |
bb25a15c | 224 | |
0a251e08 | 225 | set gdbserver_reconnect_p 0 |
bb25a15c | 226 | } |
0a251e08 | 227 | } |
bb25a15c | 228 | |
134a2066 | 229 | test_create_delete_modify_tsv |
bb25a15c YQ |
230 | |
231 | # Test target supports tracepoints or not. | |
232 | ||
233 | clean_restart $testfile | |
234 | ||
235 | if ![runto_main] { | |
236 | fail "Can't run to main to check for trace support" | |
237 | return -1 | |
238 | } | |
239 | ||
240 | if ![gdb_target_supports_trace] { | |
241 | unsupported "Current target does not support trace" | |
ae59b1da | 242 | return -1 |
bb25a15c YQ |
243 | } |
244 | ||
245 | gdb_exit | |
246 | ||
247 | test_upload_tsv | |
248 | ||
249 | return 0 |