1 # Copyright 2012 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 if {[skip_shlib_tests]} {
20 load_lib mi-support.exp
22 standard_testfile pending.c
23 set libfile1 "pendshr1"
24 set libfile2 "pendshr2"
25 set executable $testfile
26 set libsrc1 $srcdir/$subdir/$libfile1.c
27 set libsrc2 $srcdir/$subdir/$libfile2.c
28 set lib_sl1 [standard_output_file pendshr1.sl]
29 set lib_sl2 [standard_output_file pendshr2.sl]
32 if { [gdb_compile_shlib $libsrc1 $lib_sl1 $lib_opts] != ""
33 || [gdb_compile_shlib $libsrc2 $lib_sl2 $lib_opts] != ""} {
34 untested "Could not compile either $libsrc1 or $libsrc2"
40 set exec_opts [list debug shlib=$lib_sl1 shlib_load]
41 if { [gdb_compile $srcdir/$subdir/$srcfile $binfile executable $exec_opts] != "" } {
42 untested "Failed to compile $srcfile"
46 proc test_insert_delete_modify { } {
56 mi_gdb_test "break marker" \
57 {(&.*)*.*~"Breakpoint 2 at.*\\n".*=breakpoint-created,bkpt=\{number="2",type="breakpoint".*\}.*\n\^done}
59 # Verify that '=breakpoint-modified' notification is correctly emitted:
61 # 1. when modifying command
68 send_gdb "silent\nend\n"
69 set test "change command"
71 -re ".*=breakpoint-modified.*${mi_gdb_prompt}$" {
74 -re ".*${mi_gdb_prompt}$" {
78 fail "$test (timeout)"
82 # Verify that '=breakpoint-created' notification is correctly emittd when
83 # creating any type of breakpoint.
85 set test "watch watch"
87 {(&.*)*.*~".*atchpoint 3: .*\\n".*=breakpoint-created,bkpt=\{number="3",type="(hw |)watchpoint".*\}.*\n\^done} \
89 set test "trace marker"
91 {(&.*)*.*~"Tracepoint 4 at .*\\n".*=breakpoint-created,bkpt=\{number="4",type="tracepoint".*\}.*\n\^done} \
93 set test "catch syscall"
95 {(&.*)*.*~"Catchpoint 5 .*\\n".*=breakpoint-created,bkpt=\{number="5",type="catchpoint".*\}.*\n\^done} \
97 set test "dprintf marker, \"arg\" \""
99 {.*=breakpoint-created,bkpt=\{number="6",type="dprintf".*\}.*\n\^done} \
102 # 2. when modifying condition
103 set test "condition 2 main > 0x0"
105 {.*=breakpoint-modified,bkpt=\{number="2",.*,cond=\"main > 0x0\".*\}.*\n\^done} \
108 # 3. when modifying enableness
111 {.*=breakpoint-modified,bkpt=\{number="3",.*,enabled=\"n\".*\}.*\n\^done} \
115 {.*=breakpoint-modified,bkpt=\{number="3",.*,enabled=\"y\".*\}.*\n\^done} \
117 # 4. when modifying ignore count.
118 set test "ignore 5 1"
120 {.*=breakpoint-modified,bkpt=\{number="5",.*,ignore=\"1\".*\}.*\n\^done} \
122 # 5. when modifying pass count.
123 set test "passcount 1 4"
125 {.*=breakpoint-modified,bkpt=\{number="4",.*pass="1".*\}.*\n\^done} \
128 # Delete some breakpoints and verify that '=breakpoint-deleted
129 # notification is correctly emitted.
130 for {set i 3} {$i < 7} {incr i} {
131 mi_gdb_test "delete ${i}" ".*=breakpoint-deleted,id=\"${i}\".*\\^done" \
136 test_insert_delete_modify
138 # Test 'breakpoint-modified' notification is emited when pending breakpoints are
141 proc test_pending_resolved { } { with_test_prefix "pending resolved" {
146 global lib_sl1 lib_sl2
153 mi_gdb_reinitialize_dir $srcdir/$subdir
154 mi_gdb_load ${binfile}
155 mi_load_shlibs $lib_sl1 $lib_sl2
157 # Create a pending breakpoint on pendfunc1
158 mi_gdb_test "-break-insert -f pendfunc1" \
159 {.*\^done,bkpt=.*addr=\"<PENDING>\".*} \
160 "insert breakpoint on pendfunc1"
163 set test "breakpoint on pendfunc1 resolved"
165 -re ".*=breakpoint-modified,bkpt=\{number=\"1\".*addr=\"${hex}\".*,times=\"0\"" {
169 -re ".*=breakpoint-modified,bkpt=\{number=\"1\".*addr=\"${hex}\".*,times=\"1\"" {
170 pass "$test: hit_count is updated"
172 -re ".*${mi_gdb_prompt}$" {
176 fail "$test (timeout)"
179 mi_expect_stop "breakpoint-hit" "pendfunc1" ""\
180 ".*" ".*" {"" "disp=\"keep\""} \
181 "continue to pendfunc1 breakpoint"
183 # Delete breakpoint on pendfunc1
184 mi_gdb_test "-break-delete 1" {\^done} \
185 "delete breakpoint on pendfunc1"
186 # Insert breakpoint on marker
187 mi_gdb_test "-break-insert marker" {.*\^done,bkpt=.*} \
188 "insert breakpoint on marker"
189 # Create a pending breakpoint on pendfunc3
190 mi_gdb_test "-break-insert -f pendfunc3" \
191 {.*\^done,bkpt=.*addr=\"<PENDING>\".*} \
192 "insert breakpoint on pendfunc3"
194 mi_execute_to "exec-continue" "breakpoint-hit" "marker" ".*" ".*" ".*" \
195 {"" "disp=\"keep\""} "continue to marker 1"
197 mi_send_resuming_command "exec-continue" "continuing execution to marker"
199 set test "breakpoint on pendfunc3 resolved"
201 -re ".*=breakpoint-modified,bkpt=\{number=\"2\".*addr=\"${hex}\",.*func=\"marker\",.*times=\"1\"" {
202 pass "$test: hit_count is updated"
205 -re ".*=breakpoint-modified,bkpt=\{number=\"3\".*addr=\"${hex}\",.*func=\"pendfunc3\",.*times=\"0\"" {
208 -re ".*${mi_gdb_prompt}$" {
212 fail "$test (timeout)"
215 mi_expect_stop "breakpoint-hit" "marker" ".*" ".*" ".*" \
216 {"" "disp=\"keep\""} "continue to marker 2"
218 mi_send_resuming_command "exec-continue" "continuing to exit"
219 set test "breakpoint on pendfunc3 pending again"
221 -re ".*=breakpoint-modified,bkpt=\{number=\"3\".*addr=\"<PENDING>\"" {
224 -re ".*${mi_gdb_prompt}$" {
228 fail "$test (timeout)"
232 mi_expect_stop "exited-normally" "" "" "" "" "" ""
235 test_pending_resolved