1 # Copyright 2012-2023 Free Software Foundation, Inc.
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.
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.
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/>.
16 require allow_shlib_tests
18 load_lib mi-support.exp
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]
30 if { [gdb_compile_shlib $libsrc1 $lib_sl1 $lib_opts] != ""
31 || [gdb_compile_shlib $libsrc2 $lib_sl2 $lib_opts] != ""} {
32 untested "failed to compile shared library"
38 set exec_opts [list debug shlib=$lib_sl1 shlib_load]
39 if { [gdb_compile $srcdir/$subdir/$srcfile $binfile executable $exec_opts] != "" } {
40 untested "failed to compile"
44 proc test_insert_delete_modify { } {
46 global lib_sl1 lib_sl2
49 mi_clean_restart $binfile
51 mi_load_shlibs $lib_sl1 $lib_sl2
55 mi_gdb_test "break marker" \
56 {(&.*)*.*~"Breakpoint 2 at.*\\n".*=breakpoint-created,bkpt=\{number="2",type="breakpoint".*\}.*\n\^done}
58 # Verify that '=breakpoint-modified' notification is correctly emitted:
60 # 1. when modifying command
67 send_gdb "silent\nend\n"
68 set test "change command"
70 -re ".*=breakpoint-modified.*${mi_gdb_prompt}$" {
73 -re ".*${mi_gdb_prompt}$" {
77 fail "$test (timeout)"
81 # Verify that '=breakpoint-created' notification is correctly emitted when
82 # creating any type of breakpoint.
84 set test "watch watch"
86 {(&.*)*.*~".*atchpoint 3: .*\\n".*=breakpoint-created,bkpt=\{number="3",type="(hw |)watchpoint".*\}.*\n\^done} \
88 set test "trace marker"
90 {(&.*)*.*~"Tracepoint 4 at .*\\n".*=breakpoint-created,bkpt=\{number="4",type="tracepoint".*\}.*\n\^done} \
92 set test "catch syscall"
94 {(&.*)*.*~"Catchpoint 5 .*\\n".*=breakpoint-created,bkpt=\{number="5",type="catchpoint".*\}.*\n\^done} \
96 set test "dprintf marker, \"arg\" \""
98 {.*=breakpoint-created,bkpt=\{number="6",type="dprintf".*,script=\[\"printf \\\"arg\\\" \\\"\"\].*\}\r\n\^done} \
101 # 2. when modifying condition
102 set test "condition 2 main > 0x0"
104 {.*=breakpoint-modified,bkpt=\{number="2",.*,cond=\"main > 0x0\".*\}.*\n\^done} \
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"
110 # 3. when modifying enableness
113 {.*=breakpoint-modified,bkpt=\{number="3",.*,enabled=\"n\".*\}.*\n\^done} \
117 {.*=breakpoint-modified,bkpt=\{number="3",.*,enabled=\"y\".*\}.*\n\^done} \
119 # Modify enableness through MI commands shouldn't trigger MI
121 mi_gdb_test "-break-enable 3" "\\^done" "-break-enable 3"
122 mi_gdb_test "-break-disable 3" "\\^done" "-break-disable 3"
124 # 4. when modifying ignore count.
125 set test "ignore 5 1"
127 {.*=breakpoint-modified,bkpt=\{number="5",.*,ignore=\"1\".*\}.*\n\^done} \
129 # Modify ignore count through MI command shouldn't trigger MI
131 mi_gdb_test "-break-after 5 1" "\\^done" \
134 # 5. when modifying pass count.
135 set test "passcount 1 4"
137 {.*=breakpoint-modified,bkpt=\{number="4",.*pass="1".*\}.*\n\^done} \
139 # Modify pass count through MI command shouldn't trigger MI
141 mi_gdb_test "-break-passcount 4 1" "\\^done" \
142 "-break-passcount 4 1"
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" \
152 with_test_prefix "test_insert_delete_modify" {
153 test_insert_delete_modify
156 # Test 'breakpoint-modified' notification is emited when pending breakpoints are
159 proc test_pending_resolved { } {
160 with_test_prefix "pending resolved" {
165 global lib_sl1 lib_sl2
168 if {[mi_clean_restart $binfile]} {
171 mi_load_shlibs $lib_sl1 $lib_sl2
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"
179 set test "breakpoint on pendfunc1 resolved"
181 -re ".*=breakpoint-modified,bkpt=\{number=\"1\".*addr=\"${hex}\".*,times=\"0\"" {
185 -re ".*=breakpoint-modified,bkpt=\{number=\"1\".*addr=\"${hex}\".*,times=\"1\"" {
186 pass "$test: hit_count is updated"
188 -re ".*${mi_gdb_prompt}$" {
192 fail "$test (timeout)"
195 mi_expect_stop "breakpoint-hit" "pendfunc1" ""\
196 ".*" ".*" {"" "disp=\"keep\""} \
197 "continue to pendfunc1 breakpoint"
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"
210 mi_execute_to "exec-continue" "breakpoint-hit" "marker" ".*" ".*" ".*" \
211 {"" "disp=\"keep\""} "continue to marker 1"
213 mi_send_resuming_command "exec-continue" "continuing execution to marker"
215 set test "breakpoint on pendfunc3 resolved"
217 -re ".*=breakpoint-modified,bkpt=\{number=\"2\".*addr=\"${hex}\",.*func=\"marker\",.*times=\"1\"" {
218 pass "$test: hit_count is updated"
221 -re ".*=breakpoint-modified,bkpt=\{number=\"3\".*addr=\"${hex}\",.*func=\"pendfunc3\",.*times=\"0\"" {
224 -re ".*${mi_gdb_prompt}$" {
228 fail "$test (timeout)"
231 mi_expect_stop "breakpoint-hit" "marker" ".*" ".*" ".*" \
232 {"" "disp=\"keep\""} "continue to marker 2"
234 mi_send_resuming_command "exec-continue" "continuing to exit"
235 set test "breakpoint on pendfunc3 pending again"
237 -re ".*=breakpoint-modified,bkpt=\{number=\"3\".*addr=\"<PENDING>\"" {
240 -re ".*${mi_gdb_prompt}$" {
244 fail "$test (timeout)"
248 mi_expect_stop "exited-normally" "" "" "" "" "" ""
252 with_test_prefix "test_pending_resolved" {
253 test_pending_resolved
256 # Test auto-disable is effective when notifying breakpoint-modified.
258 proc test_auto_disable { } {
260 global lib_sl1 lib_sl2
263 mi_clean_restart $binfile
265 mi_load_shlibs $lib_sl1 $lib_sl2
269 # Set the breakpoint.
270 mi_gdb_test "-break-insert -f pendfunc1" \
271 {\^done,bkpt=\{number="2",type="breakpoint".*\}.*}
273 # Enable for one shot only.
274 mi_gdb_test "-break-enable count 1 2" \
277 mi_send_resuming_command "exec-continue" "continuing execution to breakpoint"
279 set test "breakpoint auto-disabling after enable count reached"
281 -re ".*=breakpoint-modified,bkpt=\{number=\"2\".*enabled=\"n\"" {
284 -re ".*${mi_gdb_prompt}$" {
288 fail "$test (timeout)"
293 with_test_prefix "test_auto_disable" {