2004-02-23 Jeff Johnston <jjohnstn@redhat.com>
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / pending.exp
1 # Copyright 2003, 2004
2 # Free Software Foundation, Inc.
3
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
18 # Please email any bugs, comments, and/or additions to this file to:
19 # bug-gdb@prep.ai.mit.edu
20
21 # This file was created by Jeff Johnston. (jjohnstn@redhat.com)
22 # The shared library compilation portion was copied from shlib-call.exp which was
23 # written by Elena Zannoni (ezannoni@redhat.com).
24
25 if $tracelevel then {
26 strace $tracelevel
27 }
28
29 #
30 # test running programs
31 #
32 set prms_id 0
33 set bug_id 0
34
35 # are we on a target board?
36 if ![isnative] then {
37 return 0
38 }
39
40 set testfile "pending"
41 set libfile "pendshr"
42 set srcfile ${testfile}.c
43 set binfile ${objdir}/${subdir}/${testfile}
44
45 if [get_compiler_info ${binfile}] {
46 return -1
47 }
48
49 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}.o" object {debug}] != "" } {
50 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
51 }
52
53 # Build the shared libraries this test case needs.
54 #
55
56 if {$gcc_compiled == 0} {
57 if [istarget "hppa*-hp-hpux*"] then {
58 set additional_flags "additional_flags=+z"
59 } elseif { [istarget "mips-sgi-irix*"] } {
60 # Disable SGI compiler's implicit -Dsgi
61 set additional_flags "additional_flags=-Usgi"
62 } else {
63 # don't know what the compiler is...
64 set additional_flags ""
65 }
66 } else {
67 if { ([istarget "powerpc*-*-aix*"]
68 || [istarget "rs6000*-*-aix*"]) } {
69 set additional_flags ""
70 } else {
71 set additional_flags "additional_flags=-fpic"
72 }
73 }
74
75 if {[gdb_compile "${srcdir}/${subdir}/${libfile}.c" "${objdir}/${subdir}/${libfile}.o" object [list debug $additional_flags]] != ""} {
76 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
77 }
78
79 if [istarget "hppa*-*-hpux*"] {
80 remote_exec build "ld -b ${objdir}/${subdir}/${libfile}.o -o ${objdir}/${subdir}/${libfile}.sl"
81 } else {
82 set additional_flags "additional_flags=-shared"
83 if {[gdb_compile "${objdir}/${subdir}/${libfile}.o" "${objdir}/${subdir}/${libfile}.sl" executable [list debug $additional_flags]] != ""} {
84 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
85 }
86 }
87
88 if { ($gcc_compiled
89 && ([istarget "powerpc*-*-aix*"]
90 || [istarget "rs6000*-*-aix*"] )) } {
91 set additional_flags "additional_flags=-L${objdir}/${subdir}"
92 } elseif { [istarget "mips-sgi-irix*"] } {
93 set additional_flags "additional_flags=-rpath ${objdir}/${subdir}"
94 } else {
95 set additional_flags ""
96 }
97 if {[gdb_compile "${objdir}/${subdir}/${testfile}.o ${objdir}/${subdir}/${libfile}.sl" "${binfile}" executable [list debug $additional_flags]] != ""} {
98 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
99 }
100
101 gdb_exit
102 gdb_start
103 gdb_reinitialize_dir $srcdir/$subdir
104 gdb_load ${binfile}
105
106 if [target_info exists gdb_stub] {
107 gdb_step_for_stub;
108 }
109 #
110 # Test setting, querying, and modifying pending breakpoints
111 #
112
113 gdb_test_multiple "break pendfunc1" "set pending breakpoint" {
114 -re ".*Make breakpoint pending.*y or \\\[n\\\]. $" {
115 gdb_test "y" "Breakpoint.*pendfunc1.*pending." "set pending breakpoint"
116 }
117 }
118
119 gdb_test "info break" \
120 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
121 \[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*pendfunc1.*" \
122 "single pending breakpoint info"
123
124 #
125 # Test breaking at existing function
126 #
127
128 set mainline [gdb_get_line_number "break main here"]
129
130 gdb_test "break main" \
131 "Breakpoint.*at.* file .*$srcfile, line $mainline.*" \
132 "breakpoint function"
133
134 gdb_test "info break" \
135 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
136 \[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*pendfunc1.*
137 \[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$mainline" \
138 "pending plus real breakpoint info"
139
140
141 #
142 # Test not setting a pending breakpoint
143 #
144 gdb_test_multiple "break pendfunc2" "Don't set pending breakpoint" {
145 -re ".*Make breakpoint pending.*y or \\\[n\\\]. $" {
146 gdb_test "n" "" "Don't set pending breakpoint"
147 }
148 }
149
150 #
151 # Add condition to pending breakpoint
152 #
153
154 gdb_test "condition 1 k == 1" ""
155
156 gdb_test "info break" \
157 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
158 \[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*pendfunc1.*
159 \[\t \]+stop only if k == 1.*
160 \[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$mainline" \
161 "pending plus condition"
162
163 #
164 # Disable pending breakpoint
165 #
166
167 gdb_test "disable 1" ""
168
169 gdb_test "info break" \
170 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
171 \[0-9\]+\[\t \]+breakpoint keep n.*PENDING.*pendfunc1.*
172 \[\t \]+stop only if k == 1.*
173 \[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$mainline" \
174 "pending disabled"
175
176 #
177 # Add commands to pending breakpoint
178 #
179 gdb_test "commands 1\nprint k\nend" "" \
180 "Set commands for pending breakpoint"
181
182 gdb_test "info break" \
183 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
184 \[0-9\]+\[\t \]+breakpoint keep n.*PENDING.*pendfunc1.*
185 \[\t \]+stop only if k == 1.*
186 \[\t \]+print k.*
187 \[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$mainline" \
188 "pending disabled plus commands"
189
190 #
191 # Try a pending break for a line in a source file with a condition
192 #
193
194 gdb_test_multiple "break pendshr.c:26 if x > 3" "Set pending breakpoint 2" {
195 -re ".*Make breakpoint pending.*y or \\\[n\\\]. $" {
196 gdb_test "y" "Breakpoint.*pendshr.c:26.*pending." \
197 "Set pending breakpoint 2"
198 }
199 }
200
201 gdb_test "info break" \
202 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
203 \[0-9\]+\[\t \]+breakpoint keep n.*PENDING.*pendfunc1.*
204 \[\t \]+stop only if k == 1.*
205 \[\t \]+print k.*
206 \[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$mainline.*
207 \[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*pendshr.c:26 if x > 3.*" \
208 "multiple pending breakpoints"
209
210 #
211 # Run to main which should resolve a pending breakpoint
212 #
213
214 gdb_test "run" \
215 "Breakpoint.*at.*
216 Pending breakpoint \"pendshr.c:26 if x > 3\" resolved.*
217 Breakpoint.*, main.*$mainline.*" \
218 "running to main"
219
220 #
221 # Re-enable the first pending breakpoint which should resolve
222 #
223
224 gdb_test "enable 1" \
225 "Breakpoint.*at.*
226 Pending breakpoint \"pendfunc1.* resolved.*" \
227 "re-enabling pending breakpoint that can resolve instantly"
228
229 #
230 # Continue to verify conditionals and commands for breakpoints are honored
231 #
232
233 gdb_test "continue" \
234 ".*Breakpoint.*pendfunc1.*at.*pendshr.c:26.*4;" \
235 "continue to resolved breakpoint 2"
236
237 gdb_test "continue" \
238 ".*Breakpoint.*pendfunc1.*at.*pendshr.c:26.*
239 \[$\]1 = 1." \
240 "continue to resolved breakpoint 1"
241
242 delete_breakpoints
243
244 gdb_breakpoint "main"
245
246 #
247 # Set non-existent pending breakpoint
248 #
249 gdb_test_multiple "break imaginary" "set imaginary pending breakpoint" {
250 -re ".*Make breakpoint pending.*y or \\\[n\\\]. $" {
251 gdb_test "y" "Breakpoint.*imaginary.*pending." \
252 "set imaginary pending breakpoint"
253 }
254 }
255
256 #
257 # rerun program and make sure that any pending breakpoint remains and no
258 # error messages are issued for the missing function
259 #
260
261 rerun_to_main
262 gdb_test "info break" \
263 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
264 \[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$mainline.*
265 \[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*imaginary.*" \
266 "verify pending breakpoint after restart"
This page took 0.03654 seconds and 5 git commands to generate.