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