]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.mi/mi-breakpoint-changed.exp
Update Copyright year range in all files maintained by GDB.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.mi / mi-breakpoint-changed.exp
CommitLineData
ecd75fc8 1# Copyright 2012-2014 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
16if {[skip_shlib_tests]} {
17 return 0
18}
19
20load_lib mi-support.exp
21
22standard_testfile pending.c
23set libfile1 "pendshr1"
24set libfile2 "pendshr2"
25set executable $testfile
26set libsrc1 $srcdir/$subdir/$libfile1.c
27set libsrc2 $srcdir/$subdir/$libfile2.c
28set lib_sl1 [standard_output_file pendshr1.sl]
29set lib_sl2 [standard_output_file pendshr2.sl]
30set lib_opts "debug"
31
32if { [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"
35 return -1
36}
37
38set MIFLAGS "-i=mi"
39
40set exec_opts [list debug shlib=$lib_sl1 shlib_load]
41if { [gdb_compile $srcdir/$subdir/$srcfile $binfile executable $exec_opts] != "" } {
42 untested "Failed to compile $srcfile"
43 return -1
44}
45
46proc test_insert_delete_modify { } {
47 global mi_gdb_prompt
48
49 gdb_exit
50 if [mi_gdb_start] {
51 continue
52 }
53
54 mi_run_to_main
55
56 mi_gdb_test "break marker" \
57 {(&.*)*.*~"Breakpoint 2 at.*\\n".*=breakpoint-created,bkpt=\{number="2",type="breakpoint".*\}.*\n\^done}
58
59 # Verify that '=breakpoint-modified' notification is correctly emitted:
60
61 # 1. when modifying command
62 send_gdb "commands\n"
63 gdb_expect {
64 -re "End with" {
65 }
66 }
67
68 send_gdb "silent\nend\n"
69 set test "change command"
70 gdb_expect {
71 -re ".*=breakpoint-modified.*${mi_gdb_prompt}$" {
72 pass $test
73 }
74 -re ".*${mi_gdb_prompt}$" {
75 fail $test
76 }
77 timeout {
78 fail "$test (timeout)"
79 }
80 }
81
e4b8388f 82 # Verify that '=breakpoint-created' notification is correctly emitted when
45814d45
YQ
83 # creating any type of breakpoint.
84
85 set test "watch watch"
86 mi_gdb_test ${test} \
87 {(&.*)*.*~".*atchpoint 3: .*\\n".*=breakpoint-created,bkpt=\{number="3",type="(hw |)watchpoint".*\}.*\n\^done} \
88 $test
89 set test "trace marker"
90 mi_gdb_test $test \
91 {(&.*)*.*~"Tracepoint 4 at .*\\n".*=breakpoint-created,bkpt=\{number="4",type="tracepoint".*\}.*\n\^done} \
92 $test
93 set test "catch syscall"
94 mi_gdb_test $test \
95 {(&.*)*.*~"Catchpoint 5 .*\\n".*=breakpoint-created,bkpt=\{number="5",type="catchpoint".*\}.*\n\^done} \
96 $test
97 set test "dprintf marker, \"arg\" \""
98 mi_gdb_test $test \
9d6e6e84 99 {.*=breakpoint-created,bkpt=\{number="6",type="dprintf".*,script=\{\"printf \\\\\"arg\\\\\" \\\\\"\"\}.*\}\r\n\^done} \
45814d45
YQ
100 $test
101
102 # 2. when modifying condition
103 set test "condition 2 main > 0x0"
104 mi_gdb_test $test \
105 {.*=breakpoint-modified,bkpt=\{number="2",.*,cond=\"main > 0x0\".*\}.*\n\^done} \
106 $test
107
108 # 3. when modifying enableness
109 set test "disable 3"
110 mi_gdb_test $test \
111 {.*=breakpoint-modified,bkpt=\{number="3",.*,enabled=\"n\".*\}.*\n\^done} \
112 $test
113 set test "enable 3"
114 mi_gdb_test $test \
115 {.*=breakpoint-modified,bkpt=\{number="3",.*,enabled=\"y\".*\}.*\n\^done} \
116 $test
117 # 4. when modifying ignore count.
118 set test "ignore 5 1"
119 mi_gdb_test $test \
120 {.*=breakpoint-modified,bkpt=\{number="5",.*,ignore=\"1\".*\}.*\n\^done} \
121 $test
122 # 5. when modifying pass count.
45814d45
YQ
123 set test "passcount 1 4"
124 mi_gdb_test $test \
6f6484cd 125 {.*=breakpoint-modified,bkpt=\{number="4",.*pass="1".*\}.*\n\^done} \
45814d45
YQ
126 $test
127
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" \
132 "delete ${i}"
133 }
134}
135
136test_insert_delete_modify
137
138# Test 'breakpoint-modified' notification is emited when pending breakpoints are
139# resolved.
140
0a251e08
YQ
141proc test_pending_resolved { } {
142 with_test_prefix "pending resolved" {
143 global decimal hex
144 global srcdir
145 global subdir
146 global binfile
147 global lib_sl1 lib_sl2
148 global mi_gdb_prompt
149
150 gdb_exit
151 if [mi_gdb_start] {
152 continue
45814d45 153 }
0a251e08
YQ
154 mi_gdb_reinitialize_dir $srcdir/$subdir
155 mi_gdb_load ${binfile}
156 mi_load_shlibs $lib_sl1 $lib_sl2
157
158 # Create a pending breakpoint on pendfunc1
159 mi_gdb_test "-break-insert -f pendfunc1" \
160 {.*\^done,bkpt=.*addr=\"<PENDING>\".*} \
161 "insert breakpoint on pendfunc1"
162 mi_run_cmd
163
164 set test "breakpoint on pendfunc1 resolved"
165 gdb_expect {
166 -re ".*=breakpoint-modified,bkpt=\{number=\"1\".*addr=\"${hex}\".*,times=\"0\"" {
167 pass $test
168 exp_continue
169 }
170 -re ".*=breakpoint-modified,bkpt=\{number=\"1\".*addr=\"${hex}\".*,times=\"1\"" {
171 pass "$test: hit_count is updated"
172 }
173 -re ".*${mi_gdb_prompt}$" {
174 fail $test
175 }
176 timeout {
177 fail "$test (timeout)"
178 }
45814d45 179 }
0a251e08
YQ
180 mi_expect_stop "breakpoint-hit" "pendfunc1" ""\
181 ".*" ".*" {"" "disp=\"keep\""} \
182 "continue to pendfunc1 breakpoint"
183
184 # Delete breakpoint on pendfunc1
185 mi_gdb_test "-break-delete 1" {\^done} \
186 "delete breakpoint on pendfunc1"
187 # Insert breakpoint on marker
188 mi_gdb_test "-break-insert marker" {.*\^done,bkpt=.*} \
189 "insert breakpoint on marker"
190 # Create a pending breakpoint on pendfunc3
191 mi_gdb_test "-break-insert -f pendfunc3" \
192 {.*\^done,bkpt=.*addr=\"<PENDING>\".*} \
193 "insert breakpoint on pendfunc3"
194
195 mi_execute_to "exec-continue" "breakpoint-hit" "marker" ".*" ".*" ".*" \
196 {"" "disp=\"keep\""} "continue to marker 1"
197
198 mi_send_resuming_command "exec-continue" "continuing execution to marker"
199
200 set test "breakpoint on pendfunc3 resolved"
201 gdb_expect {
202 -re ".*=breakpoint-modified,bkpt=\{number=\"2\".*addr=\"${hex}\",.*func=\"marker\",.*times=\"1\"" {
203 pass "$test: hit_count is updated"
204 exp_continue
205 }
206 -re ".*=breakpoint-modified,bkpt=\{number=\"3\".*addr=\"${hex}\",.*func=\"pendfunc3\",.*times=\"0\"" {
207 pass $test
208 }
209 -re ".*${mi_gdb_prompt}$" {
210 fail $test
211 }
212 timeout {
213 fail "$test (timeout)"
214 }
45814d45 215 }
0a251e08
YQ
216 mi_expect_stop "breakpoint-hit" "marker" ".*" ".*" ".*" \
217 {"" "disp=\"keep\""} "continue to marker 2"
218
219 mi_send_resuming_command "exec-continue" "continuing to exit"
220 set test "breakpoint on pendfunc3 pending again"
221 gdb_expect {
222 -re ".*=breakpoint-modified,bkpt=\{number=\"3\".*addr=\"<PENDING>\"" {
223 pass $test
224 }
225 -re ".*${mi_gdb_prompt}$" {
226 fail $test
227 }
228 timeout {
229 fail "$test (timeout)"
230 }
45814d45 231 }
45814d45 232
0a251e08 233 mi_expect_stop "exited-normally" "" "" "" "" "" ""
45814d45 234 }
0a251e08 235}
45814d45
YQ
236
237test_pending_resolved