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