]>
Commit | Line | Data |
---|---|---|
1d506c26 | 1 | # Copyright 2012-2024 Free Software Foundation, Inc. |
45814d45 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 | ||
d6195dc9 | 16 | require allow_shlib_tests |
45814d45 YQ |
17 | |
18 | load_lib mi-support.exp | |
19 | ||
20 | standard_testfile pending.c | |
21 | set libfile1 "pendshr1" | |
22 | set libfile2 "pendshr2" | |
23 | set executable $testfile | |
24 | set libsrc1 $srcdir/$subdir/$libfile1.c | |
25 | set libsrc2 $srcdir/$subdir/$libfile2.c | |
26 | set lib_sl1 [standard_output_file pendshr1.sl] | |
27 | set lib_sl2 [standard_output_file pendshr2.sl] | |
28 | set lib_opts "debug" | |
29 | ||
30 | if { [gdb_compile_shlib $libsrc1 $lib_sl1 $lib_opts] != "" | |
31 | || [gdb_compile_shlib $libsrc2 $lib_sl2 $lib_opts] != ""} { | |
84c93cd5 | 32 | untested "failed to compile shared library" |
45814d45 YQ |
33 | return -1 |
34 | } | |
35 | ||
36 | set MIFLAGS "-i=mi" | |
37 | ||
38 | set exec_opts [list debug shlib=$lib_sl1 shlib_load] | |
39 | if { [gdb_compile $srcdir/$subdir/$srcfile $binfile executable $exec_opts] != "" } { | |
84c93cd5 | 40 | untested "failed to compile" |
45814d45 YQ |
41 | return -1 |
42 | } | |
43 | ||
44 | proc test_insert_delete_modify { } { | |
45 | global mi_gdb_prompt | |
7beb7f68 | 46 | global lib_sl1 lib_sl2 |
b75d55d4 | 47 | global binfile |
45814d45 | 48 | |
b75d55d4 | 49 | mi_clean_restart $binfile |
45814d45 | 50 | |
7beb7f68 SM |
51 | mi_load_shlibs $lib_sl1 $lib_sl2 |
52 | ||
b75d55d4 | 53 | mi_runto_main |
45814d45 YQ |
54 | |
55 | mi_gdb_test "break marker" \ | |
56 | {(&.*)*.*~"Breakpoint 2 at.*\\n".*=breakpoint-created,bkpt=\{number="2",type="breakpoint".*\}.*\n\^done} | |
57 | ||
58 | # Verify that '=breakpoint-modified' notification is correctly emitted: | |
59 | ||
60 | # 1. when modifying command | |
61 | send_gdb "commands\n" | |
62 | gdb_expect { | |
63 | -re "End with" { | |
64 | } | |
65 | } | |
66 | ||
67 | send_gdb "silent\nend\n" | |
68 | set test "change command" | |
69 | gdb_expect { | |
70 | -re ".*=breakpoint-modified.*${mi_gdb_prompt}$" { | |
71 | pass $test | |
72 | } | |
73 | -re ".*${mi_gdb_prompt}$" { | |
74 | fail $test | |
75 | } | |
76 | timeout { | |
77 | fail "$test (timeout)" | |
78 | } | |
79 | } | |
80 | ||
e4b8388f | 81 | # Verify that '=breakpoint-created' notification is correctly emitted when |
45814d45 YQ |
82 | # creating any type of breakpoint. |
83 | ||
84 | set test "watch watch" | |
85 | mi_gdb_test ${test} \ | |
86 | {(&.*)*.*~".*atchpoint 3: .*\\n".*=breakpoint-created,bkpt=\{number="3",type="(hw |)watchpoint".*\}.*\n\^done} \ | |
87 | $test | |
88 | set test "trace marker" | |
89 | mi_gdb_test $test \ | |
90 | {(&.*)*.*~"Tracepoint 4 at .*\\n".*=breakpoint-created,bkpt=\{number="4",type="tracepoint".*\}.*\n\^done} \ | |
91 | $test | |
92 | set test "catch syscall" | |
93 | mi_gdb_test $test \ | |
94 | {(&.*)*.*~"Catchpoint 5 .*\\n".*=breakpoint-created,bkpt=\{number="5",type="catchpoint".*\}.*\n\^done} \ | |
95 | $test | |
96 | set test "dprintf marker, \"arg\" \"" | |
97 | mi_gdb_test $test \ | |
9db0d853 | 98 | {.*=breakpoint-created,bkpt=\{number="6",type="dprintf".*,script=\[\"printf \\\"arg\\\" \\\"\"\].*\}\r\n\^done} \ |
45814d45 YQ |
99 | $test |
100 | ||
101 | # 2. when modifying condition | |
102 | set test "condition 2 main > 0x0" | |
103 | mi_gdb_test $test \ | |
104 | {.*=breakpoint-modified,bkpt=\{number="2",.*,cond=\"main > 0x0\".*\}.*\n\^done} \ | |
105 | $test | |
6e854735 YQ |
106 | # Modify condition through MI command shouldn't trigger MI notification. |
107 | mi_gdb_test "-break-condition 2 main == 0x0" "\\^done" \ | |
108 | "-break-condition 2 main == 0x0" | |
45814d45 YQ |
109 | |
110 | # 3. when modifying enableness | |
111 | set test "disable 3" | |
112 | mi_gdb_test $test \ | |
113 | {.*=breakpoint-modified,bkpt=\{number="3",.*,enabled=\"n\".*\}.*\n\^done} \ | |
114 | $test | |
115 | set test "enable 3" | |
116 | mi_gdb_test $test \ | |
117 | {.*=breakpoint-modified,bkpt=\{number="3",.*,enabled=\"y\".*\}.*\n\^done} \ | |
118 | $test | |
6e854735 YQ |
119 | # Modify enableness through MI commands shouldn't trigger MI |
120 | # notification. | |
121 | mi_gdb_test "-break-enable 3" "\\^done" "-break-enable 3" | |
122 | mi_gdb_test "-break-disable 3" "\\^done" "-break-disable 3" | |
123 | ||
45814d45 YQ |
124 | # 4. when modifying ignore count. |
125 | set test "ignore 5 1" | |
126 | mi_gdb_test $test \ | |
127 | {.*=breakpoint-modified,bkpt=\{number="5",.*,ignore=\"1\".*\}.*\n\^done} \ | |
128 | $test | |
6e854735 YQ |
129 | # Modify ignore count through MI command shouldn't trigger MI |
130 | # notification. | |
131 | mi_gdb_test "-break-after 5 1" "\\^done" \ | |
132 | "-break-after 5 1" | |
133 | ||
45814d45 | 134 | # 5. when modifying pass count. |
45814d45 YQ |
135 | set test "passcount 1 4" |
136 | mi_gdb_test $test \ | |
6f6484cd | 137 | {.*=breakpoint-modified,bkpt=\{number="4",.*pass="1".*\}.*\n\^done} \ |
45814d45 | 138 | $test |
6e854735 YQ |
139 | # Modify pass count through MI command shouldn't trigger MI |
140 | # notification. | |
141 | mi_gdb_test "-break-passcount 4 1" "\\^done" \ | |
142 | "-break-passcount 4 1" | |
45814d45 YQ |
143 | |
144 | # Delete some breakpoints and verify that '=breakpoint-deleted | |
145 | # notification is correctly emitted. | |
146 | for {set i 3} {$i < 7} {incr i} { | |
147 | mi_gdb_test "delete ${i}" ".*=breakpoint-deleted,id=\"${i}\".*\\^done" \ | |
148 | "delete ${i}" | |
149 | } | |
150 | } | |
151 | ||
7beb7f68 SM |
152 | with_test_prefix "test_insert_delete_modify" { |
153 | test_insert_delete_modify | |
154 | } | |
45814d45 YQ |
155 | |
156 | # Test 'breakpoint-modified' notification is emited when pending breakpoints are | |
157 | # resolved. | |
158 | ||
0a251e08 YQ |
159 | proc test_pending_resolved { } { |
160 | with_test_prefix "pending resolved" { | |
161 | global decimal hex | |
162 | global srcdir | |
163 | global subdir | |
164 | global binfile | |
165 | global lib_sl1 lib_sl2 | |
166 | global mi_gdb_prompt | |
167 | ||
3ad2b4af | 168 | if {[mi_clean_restart $binfile]} { |
cdd42066 | 169 | return |
45814d45 | 170 | } |
0a251e08 YQ |
171 | mi_load_shlibs $lib_sl1 $lib_sl2 |
172 | ||
173 | # Create a pending breakpoint on pendfunc1 | |
174 | mi_gdb_test "-break-insert -f pendfunc1" \ | |
175 | {.*\^done,bkpt=.*addr=\"<PENDING>\".*} \ | |
176 | "insert breakpoint on pendfunc1" | |
177 | mi_run_cmd | |
178 | ||
179 | set test "breakpoint on pendfunc1 resolved" | |
180 | gdb_expect { | |
181 | -re ".*=breakpoint-modified,bkpt=\{number=\"1\".*addr=\"${hex}\".*,times=\"0\"" { | |
182 | pass $test | |
183 | exp_continue | |
184 | } | |
185 | -re ".*=breakpoint-modified,bkpt=\{number=\"1\".*addr=\"${hex}\".*,times=\"1\"" { | |
186 | pass "$test: hit_count is updated" | |
187 | } | |
188 | -re ".*${mi_gdb_prompt}$" { | |
189 | fail $test | |
190 | } | |
191 | timeout { | |
192 | fail "$test (timeout)" | |
193 | } | |
45814d45 | 194 | } |
0a251e08 YQ |
195 | mi_expect_stop "breakpoint-hit" "pendfunc1" ""\ |
196 | ".*" ".*" {"" "disp=\"keep\""} \ | |
197 | "continue to pendfunc1 breakpoint" | |
198 | ||
199 | # Delete breakpoint on pendfunc1 | |
200 | mi_gdb_test "-break-delete 1" {\^done} \ | |
201 | "delete breakpoint on pendfunc1" | |
202 | # Insert breakpoint on marker | |
203 | mi_gdb_test "-break-insert marker" {.*\^done,bkpt=.*} \ | |
204 | "insert breakpoint on marker" | |
205 | # Create a pending breakpoint on pendfunc3 | |
206 | mi_gdb_test "-break-insert -f pendfunc3" \ | |
207 | {.*\^done,bkpt=.*addr=\"<PENDING>\".*} \ | |
208 | "insert breakpoint on pendfunc3" | |
209 | ||
210 | mi_execute_to "exec-continue" "breakpoint-hit" "marker" ".*" ".*" ".*" \ | |
211 | {"" "disp=\"keep\""} "continue to marker 1" | |
212 | ||
213 | mi_send_resuming_command "exec-continue" "continuing execution to marker" | |
214 | ||
215 | set test "breakpoint on pendfunc3 resolved" | |
216 | gdb_expect { | |
217 | -re ".*=breakpoint-modified,bkpt=\{number=\"2\".*addr=\"${hex}\",.*func=\"marker\",.*times=\"1\"" { | |
218 | pass "$test: hit_count is updated" | |
219 | exp_continue | |
220 | } | |
221 | -re ".*=breakpoint-modified,bkpt=\{number=\"3\".*addr=\"${hex}\",.*func=\"pendfunc3\",.*times=\"0\"" { | |
222 | pass $test | |
223 | } | |
224 | -re ".*${mi_gdb_prompt}$" { | |
225 | fail $test | |
226 | } | |
227 | timeout { | |
228 | fail "$test (timeout)" | |
229 | } | |
45814d45 | 230 | } |
0a251e08 YQ |
231 | mi_expect_stop "breakpoint-hit" "marker" ".*" ".*" ".*" \ |
232 | {"" "disp=\"keep\""} "continue to marker 2" | |
233 | ||
234 | mi_send_resuming_command "exec-continue" "continuing to exit" | |
235 | set test "breakpoint on pendfunc3 pending again" | |
236 | gdb_expect { | |
237 | -re ".*=breakpoint-modified,bkpt=\{number=\"3\".*addr=\"<PENDING>\"" { | |
238 | pass $test | |
239 | } | |
240 | -re ".*${mi_gdb_prompt}$" { | |
241 | fail $test | |
242 | } | |
243 | timeout { | |
244 | fail "$test (timeout)" | |
245 | } | |
45814d45 | 246 | } |
45814d45 | 247 | |
0a251e08 | 248 | mi_expect_stop "exited-normally" "" "" "" "" "" "" |
45814d45 | 249 | } |
0a251e08 | 250 | } |
45814d45 | 251 | |
7beb7f68 SM |
252 | with_test_prefix "test_pending_resolved" { |
253 | test_pending_resolved | |
254 | } | |
bd7ccaa9 PM |
255 | |
256 | # Test auto-disable is effective when notifying breakpoint-modified. | |
257 | ||
258 | proc test_auto_disable { } { | |
259 | global mi_gdb_prompt | |
260 | global lib_sl1 lib_sl2 | |
261 | global binfile | |
262 | ||
263 | mi_clean_restart $binfile | |
264 | ||
265 | mi_load_shlibs $lib_sl1 $lib_sl2 | |
266 | ||
267 | mi_runto_main | |
268 | ||
269 | # Set the breakpoint. | |
270 | mi_gdb_test "-break-insert -f pendfunc1" \ | |
d5684c96 | 271 | {\^done,bkpt=\{number="2",type="breakpoint".*\}.*} |
bd7ccaa9 PM |
272 | |
273 | # Enable for one shot only. | |
274 | mi_gdb_test "-break-enable count 1 2" \ | |
d5684c96 | 275 | {\^done} |
bd7ccaa9 PM |
276 | |
277 | mi_send_resuming_command "exec-continue" "continuing execution to breakpoint" | |
278 | ||
279 | set test "breakpoint auto-disabling after enable count reached" | |
280 | gdb_expect { | |
281 | -re ".*=breakpoint-modified,bkpt=\{number=\"2\".*enabled=\"n\"" { | |
282 | pass $test | |
283 | } | |
284 | -re ".*${mi_gdb_prompt}$" { | |
285 | fail $test | |
286 | } | |
287 | timeout { | |
288 | fail "$test (timeout)" | |
289 | } | |
290 | } | |
291 | } | |
292 | ||
293 | with_test_prefix "test_auto_disable" { | |
294 | test_auto_disable | |
295 | } |