]>
Commit | Line | Data |
---|---|---|
32d0add0 | 1 | # Copyright 2012-2015 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] != ""} { | |
34 | untested "Could not compile either $libsrc1 or $libsrc2" | |
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] != "" } { | |
42 | untested "Failed to compile $srcfile" | |
43 | return -1 | |
44 | } | |
45 | ||
46 | proc 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 \ | |
6ef284bd | 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 | |
6e854735 YQ |
107 | # Modify condition through MI command shouldn't trigger MI notification. |
108 | mi_gdb_test "-break-condition 2 main == 0x0" "\\^done" \ | |
109 | "-break-condition 2 main == 0x0" | |
45814d45 YQ |
110 | |
111 | # 3. when modifying enableness | |
112 | set test "disable 3" | |
113 | mi_gdb_test $test \ | |
114 | {.*=breakpoint-modified,bkpt=\{number="3",.*,enabled=\"n\".*\}.*\n\^done} \ | |
115 | $test | |
116 | set test "enable 3" | |
117 | mi_gdb_test $test \ | |
118 | {.*=breakpoint-modified,bkpt=\{number="3",.*,enabled=\"y\".*\}.*\n\^done} \ | |
119 | $test | |
6e854735 YQ |
120 | # Modify enableness through MI commands shouldn't trigger MI |
121 | # notification. | |
122 | mi_gdb_test "-break-enable 3" "\\^done" "-break-enable 3" | |
123 | mi_gdb_test "-break-disable 3" "\\^done" "-break-disable 3" | |
124 | ||
45814d45 YQ |
125 | # 4. when modifying ignore count. |
126 | set test "ignore 5 1" | |
127 | mi_gdb_test $test \ | |
128 | {.*=breakpoint-modified,bkpt=\{number="5",.*,ignore=\"1\".*\}.*\n\^done} \ | |
129 | $test | |
6e854735 YQ |
130 | # Modify ignore count through MI command shouldn't trigger MI |
131 | # notification. | |
132 | mi_gdb_test "-break-after 5 1" "\\^done" \ | |
133 | "-break-after 5 1" | |
134 | ||
45814d45 | 135 | # 5. when modifying pass count. |
45814d45 YQ |
136 | set test "passcount 1 4" |
137 | mi_gdb_test $test \ | |
6f6484cd | 138 | {.*=breakpoint-modified,bkpt=\{number="4",.*pass="1".*\}.*\n\^done} \ |
45814d45 | 139 | $test |
6e854735 YQ |
140 | # Modify pass count through MI command shouldn't trigger MI |
141 | # notification. | |
142 | mi_gdb_test "-break-passcount 4 1" "\\^done" \ | |
143 | "-break-passcount 4 1" | |
45814d45 YQ |
144 | |
145 | # Delete some breakpoints and verify that '=breakpoint-deleted | |
146 | # notification is correctly emitted. | |
147 | for {set i 3} {$i < 7} {incr i} { | |
148 | mi_gdb_test "delete ${i}" ".*=breakpoint-deleted,id=\"${i}\".*\\^done" \ | |
149 | "delete ${i}" | |
150 | } | |
151 | } | |
152 | ||
153 | test_insert_delete_modify | |
154 | ||
155 | # Test 'breakpoint-modified' notification is emited when pending breakpoints are | |
156 | # resolved. | |
157 | ||
0a251e08 YQ |
158 | proc test_pending_resolved { } { |
159 | with_test_prefix "pending resolved" { | |
160 | global decimal hex | |
161 | global srcdir | |
162 | global subdir | |
163 | global binfile | |
164 | global lib_sl1 lib_sl2 | |
165 | global mi_gdb_prompt | |
166 | ||
167 | gdb_exit | |
168 | if [mi_gdb_start] { | |
169 | continue | |
45814d45 | 170 | } |
0a251e08 YQ |
171 | mi_gdb_reinitialize_dir $srcdir/$subdir |
172 | mi_gdb_load ${binfile} | |
173 | mi_load_shlibs $lib_sl1 $lib_sl2 | |
174 | ||
175 | # Create a pending breakpoint on pendfunc1 | |
176 | mi_gdb_test "-break-insert -f pendfunc1" \ | |
177 | {.*\^done,bkpt=.*addr=\"<PENDING>\".*} \ | |
178 | "insert breakpoint on pendfunc1" | |
179 | mi_run_cmd | |
180 | ||
181 | set test "breakpoint on pendfunc1 resolved" | |
182 | gdb_expect { | |
183 | -re ".*=breakpoint-modified,bkpt=\{number=\"1\".*addr=\"${hex}\".*,times=\"0\"" { | |
184 | pass $test | |
185 | exp_continue | |
186 | } | |
187 | -re ".*=breakpoint-modified,bkpt=\{number=\"1\".*addr=\"${hex}\".*,times=\"1\"" { | |
188 | pass "$test: hit_count is updated" | |
189 | } | |
190 | -re ".*${mi_gdb_prompt}$" { | |
191 | fail $test | |
192 | } | |
193 | timeout { | |
194 | fail "$test (timeout)" | |
195 | } | |
45814d45 | 196 | } |
0a251e08 YQ |
197 | mi_expect_stop "breakpoint-hit" "pendfunc1" ""\ |
198 | ".*" ".*" {"" "disp=\"keep\""} \ | |
199 | "continue to pendfunc1 breakpoint" | |
200 | ||
201 | # Delete breakpoint on pendfunc1 | |
202 | mi_gdb_test "-break-delete 1" {\^done} \ | |
203 | "delete breakpoint on pendfunc1" | |
204 | # Insert breakpoint on marker | |
205 | mi_gdb_test "-break-insert marker" {.*\^done,bkpt=.*} \ | |
206 | "insert breakpoint on marker" | |
207 | # Create a pending breakpoint on pendfunc3 | |
208 | mi_gdb_test "-break-insert -f pendfunc3" \ | |
209 | {.*\^done,bkpt=.*addr=\"<PENDING>\".*} \ | |
210 | "insert breakpoint on pendfunc3" | |
211 | ||
212 | mi_execute_to "exec-continue" "breakpoint-hit" "marker" ".*" ".*" ".*" \ | |
213 | {"" "disp=\"keep\""} "continue to marker 1" | |
214 | ||
215 | mi_send_resuming_command "exec-continue" "continuing execution to marker" | |
216 | ||
217 | set test "breakpoint on pendfunc3 resolved" | |
218 | gdb_expect { | |
219 | -re ".*=breakpoint-modified,bkpt=\{number=\"2\".*addr=\"${hex}\",.*func=\"marker\",.*times=\"1\"" { | |
220 | pass "$test: hit_count is updated" | |
221 | exp_continue | |
222 | } | |
223 | -re ".*=breakpoint-modified,bkpt=\{number=\"3\".*addr=\"${hex}\",.*func=\"pendfunc3\",.*times=\"0\"" { | |
224 | pass $test | |
225 | } | |
226 | -re ".*${mi_gdb_prompt}$" { | |
227 | fail $test | |
228 | } | |
229 | timeout { | |
230 | fail "$test (timeout)" | |
231 | } | |
45814d45 | 232 | } |
0a251e08 YQ |
233 | mi_expect_stop "breakpoint-hit" "marker" ".*" ".*" ".*" \ |
234 | {"" "disp=\"keep\""} "continue to marker 2" | |
235 | ||
236 | mi_send_resuming_command "exec-continue" "continuing to exit" | |
237 | set test "breakpoint on pendfunc3 pending again" | |
238 | gdb_expect { | |
239 | -re ".*=breakpoint-modified,bkpt=\{number=\"3\".*addr=\"<PENDING>\"" { | |
240 | pass $test | |
241 | } | |
242 | -re ".*${mi_gdb_prompt}$" { | |
243 | fail $test | |
244 | } | |
245 | timeout { | |
246 | fail "$test (timeout)" | |
247 | } | |
45814d45 | 248 | } |
45814d45 | 249 | |
0a251e08 | 250 | mi_expect_stop "exited-normally" "" "" "" "" "" "" |
45814d45 | 251 | } |
0a251e08 | 252 | } |
45814d45 YQ |
253 | |
254 | test_pending_resolved |