1 |
24 |
jeremybenn |
# Copyright 2003, 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
|
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 .
|
15 |
|
|
|
16 |
|
|
# This file was created by Jeff Johnston. (jjohnstn@redhat.com)
|
17 |
|
|
|
18 |
|
|
if $tracelevel then {
|
19 |
|
|
strace $tracelevel
|
20 |
|
|
}
|
21 |
|
|
|
22 |
|
|
#
|
23 |
|
|
# test running programs
|
24 |
|
|
#
|
25 |
|
|
set prms_id 0
|
26 |
|
|
set bug_id 0
|
27 |
|
|
|
28 |
|
|
if {[skip_shlib_tests]} {
|
29 |
|
|
return 0
|
30 |
|
|
}
|
31 |
|
|
|
32 |
|
|
set testfile "pending"
|
33 |
|
|
set libfile "pendshr"
|
34 |
|
|
set srcfile $testfile.c
|
35 |
|
|
set libsrc $srcdir/$subdir/$libfile.c
|
36 |
|
|
set binfile $objdir/$subdir/$testfile
|
37 |
|
|
set lib_sl $objdir/$subdir/$libfile.sl
|
38 |
|
|
|
39 |
|
|
set lib_opts debug
|
40 |
|
|
set exec_opts [list debug shlib=$lib_sl]
|
41 |
|
|
|
42 |
|
|
if [get_compiler_info ${binfile}] {
|
43 |
|
|
return -1
|
44 |
|
|
}
|
45 |
|
|
|
46 |
|
|
if { [gdb_compile_shlib $libsrc $lib_sl $lib_opts] != ""
|
47 |
|
|
|| [gdb_compile $srcdir/$subdir/$srcfile $binfile executable $exec_opts] != ""} {
|
48 |
|
|
untested "Could not compile either $libsrc or $srcdir/$subdir/$srcfile."
|
49 |
|
|
return -1
|
50 |
|
|
}
|
51 |
|
|
|
52 |
|
|
# Start with a fresh gdb.
|
53 |
|
|
|
54 |
|
|
gdb_exit
|
55 |
|
|
gdb_start
|
56 |
|
|
gdb_reinitialize_dir $srcdir/$subdir
|
57 |
|
|
gdb_load ${binfile}
|
58 |
|
|
gdb_load_shlibs $lib_sl
|
59 |
|
|
|
60 |
|
|
if [target_info exists gdb_stub] {
|
61 |
|
|
gdb_step_for_stub;
|
62 |
|
|
}
|
63 |
|
|
#
|
64 |
|
|
# Test setting, querying, and modifying pending breakpoints
|
65 |
|
|
#
|
66 |
|
|
|
67 |
|
|
gdb_test_multiple "break pendfunc1" "set pending breakpoint" {
|
68 |
|
|
-re ".*Make breakpoint pending.*y or \\\[n\\\]. $" {
|
69 |
|
|
gdb_test "y" "Breakpoint.*pendfunc1.*pending." "set pending breakpoint"
|
70 |
|
|
}
|
71 |
|
|
}
|
72 |
|
|
|
73 |
|
|
gdb_test "info break" \
|
74 |
|
|
"Num Type\[ \]+Disp Enb Address\[ \]+What.*
|
75 |
|
|
\[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*pendfunc1.*" \
|
76 |
|
|
"single pending breakpoint info"
|
77 |
|
|
|
78 |
|
|
#
|
79 |
|
|
# Test breaking at existing function
|
80 |
|
|
#
|
81 |
|
|
|
82 |
|
|
set mainline [gdb_get_line_number "break main here"]
|
83 |
|
|
|
84 |
|
|
gdb_test "break main" \
|
85 |
|
|
"Breakpoint.*at.* file .*$srcfile, line $mainline.*" \
|
86 |
|
|
"breakpoint function"
|
87 |
|
|
|
88 |
|
|
gdb_test "info break" \
|
89 |
|
|
"Num Type\[ \]+Disp Enb Address\[ \]+What.*
|
90 |
|
|
\[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*pendfunc1.*
|
91 |
|
|
\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$mainline" \
|
92 |
|
|
"pending plus real breakpoint info"
|
93 |
|
|
|
94 |
|
|
|
95 |
|
|
#
|
96 |
|
|
# Test not setting a pending breakpoint
|
97 |
|
|
#
|
98 |
|
|
gdb_test_multiple "break pendfunc2" "Don't set pending breakpoint" {
|
99 |
|
|
-re ".*Make breakpoint pending.*y or \\\[n\\\]. $" {
|
100 |
|
|
gdb_test "n" "" "Don't set pending breakpoint"
|
101 |
|
|
}
|
102 |
|
|
}
|
103 |
|
|
|
104 |
|
|
#
|
105 |
|
|
# Add condition to pending breakpoint
|
106 |
|
|
#
|
107 |
|
|
|
108 |
|
|
gdb_test "condition 1 k == 1" ""
|
109 |
|
|
|
110 |
|
|
gdb_test "info break" \
|
111 |
|
|
"Num Type\[ \]+Disp Enb Address\[ \]+What.*
|
112 |
|
|
\[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*pendfunc1.*
|
113 |
|
|
\[\t \]+stop only if k == 1.*
|
114 |
|
|
\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$mainline" \
|
115 |
|
|
"pending plus condition"
|
116 |
|
|
|
117 |
|
|
#
|
118 |
|
|
# Disable pending breakpoint
|
119 |
|
|
#
|
120 |
|
|
|
121 |
|
|
gdb_test "disable 1" ""
|
122 |
|
|
|
123 |
|
|
gdb_test "info break" \
|
124 |
|
|
"Num Type\[ \]+Disp Enb Address\[ \]+What.*
|
125 |
|
|
\[0-9\]+\[\t \]+breakpoint keep n.*PENDING.*pendfunc1.*
|
126 |
|
|
\[\t \]+stop only if k == 1.*
|
127 |
|
|
\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$mainline" \
|
128 |
|
|
"pending disabled"
|
129 |
|
|
|
130 |
|
|
#
|
131 |
|
|
# Add commands to pending breakpoint
|
132 |
|
|
#
|
133 |
|
|
gdb_test "commands 1\nprint k\nend" "" \
|
134 |
|
|
"Set commands for pending breakpoint"
|
135 |
|
|
|
136 |
|
|
gdb_test "info break" \
|
137 |
|
|
"Num Type\[ \]+Disp Enb Address\[ \]+What.*
|
138 |
|
|
\[0-9\]+\[\t \]+breakpoint keep n.*PENDING.*pendfunc1.*
|
139 |
|
|
\[\t \]+stop only if k == 1.*
|
140 |
|
|
\[\t \]+print k.*
|
141 |
|
|
\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$mainline" \
|
142 |
|
|
"pending disabled plus commands"
|
143 |
|
|
|
144 |
|
|
#
|
145 |
|
|
# Try a pending break for a line in a source file with a condition
|
146 |
|
|
#
|
147 |
|
|
|
148 |
|
|
set bp2_loc [gdb_get_line_number "y = x + 4" ${libfile}.c]
|
149 |
|
|
gdb_test_multiple "break pendshr.c:$bp2_loc if x > 3" "Set pending breakpoint 2" {
|
150 |
|
|
-re ".*Make breakpoint pending.*y or \\\[n\\\]. $" {
|
151 |
|
|
gdb_test "y" "Breakpoint.*pendshr.c:$bp2_loc.*pending." \
|
152 |
|
|
"Set pending breakpoint 2"
|
153 |
|
|
}
|
154 |
|
|
}
|
155 |
|
|
|
156 |
|
|
gdb_test "info break" \
|
157 |
|
|
"Num Type\[ \]+Disp Enb Address\[ \]+What.*
|
158 |
|
|
\[0-9\]+\[\t \]+breakpoint keep n.*PENDING.*pendfunc1.*
|
159 |
|
|
\[\t \]+stop only if k == 1.*
|
160 |
|
|
\[\t \]+print k.*
|
161 |
|
|
\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$mainline.*
|
162 |
|
|
\[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*pendshr.c:$bp2_loc if x > 3.*" \
|
163 |
|
|
"multiple pending breakpoints"
|
164 |
|
|
|
165 |
|
|
|
166 |
|
|
#
|
167 |
|
|
# Try a pending break for a line in a source file with ignore count:
|
168 |
|
|
#
|
169 |
|
|
|
170 |
|
|
set bp3_loc [gdb_get_line_number "printf" ${libfile}.c]
|
171 |
|
|
gdb_test_multiple "break pendshr.c:$bp3_loc" "Set pending breakpoint 3" {
|
172 |
|
|
-re ".*Make breakpoint pending.*y or \\\[n\\\]. $" {
|
173 |
|
|
gdb_test "y" "Breakpoint.*pendshr.c:$bp3_loc.*pending." \
|
174 |
|
|
"Set pending breakpoint 3"
|
175 |
|
|
}
|
176 |
|
|
}
|
177 |
|
|
|
178 |
|
|
gdb_test {ignore $bpnum 2} "Will ignore next 2 crossings of breakpoint .*" \
|
179 |
|
|
"set ignore count on pending breakpoint 3"
|
180 |
|
|
|
181 |
|
|
gdb_test "info break" \
|
182 |
|
|
"Num Type\[ \]+Disp Enb Address\[ \]+What.*
|
183 |
|
|
\[0-9\]+\[\t \]+breakpoint keep n.*PENDING.*pendfunc1.*
|
184 |
|
|
\[\t \]+stop only if k == 1.*
|
185 |
|
|
\[\t \]+print k.*
|
186 |
|
|
\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$mainline.*
|
187 |
|
|
\[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*pendshr.c:$bp2_loc if x > 3.*
|
188 |
|
|
\[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*pendshr.c:$bp3_loc.*ignore next 2 hits.*" \
|
189 |
|
|
"multiple pending breakpoints 2"
|
190 |
|
|
|
191 |
|
|
#
|
192 |
|
|
# Run to main which should resolve a pending breakpoint
|
193 |
|
|
#
|
194 |
|
|
|
195 |
|
|
gdb_run_cmd
|
196 |
|
|
gdb_test "" \
|
197 |
|
|
".*Breakpoint.*, main.*$mainline.*" \
|
198 |
|
|
"running to main"
|
199 |
|
|
|
200 |
|
|
#
|
201 |
|
|
# Re-enable the first pending breakpoint which should resolve
|
202 |
|
|
#
|
203 |
|
|
|
204 |
|
|
gdb_test "enable 1" \
|
205 |
|
|
"" \
|
206 |
|
|
"re-enabling pending breakpoint that can resolve instantly"
|
207 |
|
|
|
208 |
|
|
#
|
209 |
|
|
# Continue to verify conditionals and commands for breakpoints are honored
|
210 |
|
|
#
|
211 |
|
|
|
212 |
|
|
gdb_test "continue" \
|
213 |
|
|
".*Breakpoint.*pendfunc1.*at.*pendshr.c:$bp2_loc.*4;" \
|
214 |
|
|
"continue to resolved breakpoint 2"
|
215 |
|
|
|
216 |
|
|
gdb_test "continue" \
|
217 |
|
|
".*Breakpoint.*pendfunc1.*at.*pendshr.c:$bp2_loc.*
|
218 |
|
|
\[$\]1 = 1." \
|
219 |
|
|
"continue to resolved breakpoint 1"
|
220 |
|
|
|
221 |
|
|
#
|
222 |
|
|
# Disable the other two breakpoints, and continue to the one with
|
223 |
|
|
# the ignore count. Make sure you hit it the third time, x should
|
224 |
|
|
# be 3 then.
|
225 |
|
|
#
|
226 |
|
|
|
227 |
|
|
gdb_test "disable 7" "" "Disable other breakpoints"
|
228 |
|
|
gdb_test "disable 5" "" "Disable other breakpoints"
|
229 |
|
|
|
230 |
|
|
gdb_test "continue" \
|
231 |
|
|
".*Breakpoint.*pendfunc1.*\\\(x=3\\\) at.*pendshr.c:$bp3_loc.*printf.*;" \
|
232 |
|
|
"continue to resolved breakpoint 3"
|
233 |
|
|
|
234 |
|
|
delete_breakpoints
|
235 |
|
|
|
236 |
|
|
gdb_breakpoint "main"
|
237 |
|
|
|
238 |
|
|
#
|
239 |
|
|
# Set non-existent pending breakpoint
|
240 |
|
|
#
|
241 |
|
|
gdb_test_multiple "break imaginary" "set imaginary pending breakpoint" {
|
242 |
|
|
-re ".*Make breakpoint pending.*y or \\\[n\\\]. $" {
|
243 |
|
|
gdb_test "y" "Breakpoint.*imaginary.*pending." \
|
244 |
|
|
"set imaginary pending breakpoint"
|
245 |
|
|
}
|
246 |
|
|
}
|
247 |
|
|
|
248 |
|
|
#
|
249 |
|
|
# rerun program and make sure that any pending breakpoint remains and no
|
250 |
|
|
# error messages are issued for the missing function
|
251 |
|
|
#
|
252 |
|
|
|
253 |
|
|
rerun_to_main
|
254 |
|
|
|
255 |
|
|
gdb_test "info break" \
|
256 |
|
|
"Num Type\[ \]+Disp Enb Address\[ \]+What.*
|
257 |
|
|
\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$mainline.*
|
258 |
|
|
\[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*imaginary.*" \
|
259 |
|
|
"verify pending breakpoint after restart"
|