Remove checks of the return value from bfd_cache_ookup()
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / pending.exp
CommitLineData
18fe2033
JJ
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
25if $tracelevel then {
26 strace $tracelevel
27}
28
29#
30# test running programs
31#
32set prms_id 0
33set bug_id 0
34
35# are we on a target board?
36if ![isnative] then {
37 return 0
38}
39
40set testfile "pending"
41set libfile "pendshr"
42set srcfile ${testfile}.c
43set binfile ${objdir}/${subdir}/${testfile}
44
45if [get_compiler_info ${binfile}] {
46 return -1
47}
48
49if { [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
56if {$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
75if {[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
79if [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
88if { ($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}
97if {[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
101gdb_exit
102gdb_start
103gdb_reinitialize_dir $srcdir/$subdir
104gdb_load ${binfile}
105
106if [target_info exists gdb_stub] {
107 gdb_step_for_stub;
108}
109#
110# Test setting, querying, and modifying pending breakpoints
111#
112
113gdb_test_multiple "break pendfunc1" "set pending breakpoint" {
9f27c604 114 -re ".*Make breakpoint pending.*y or \\\[n\\\]. $" {
18fe2033
JJ
115 gdb_test "y" "Breakpoint.*pendfunc1.*pending." "set pending breakpoint"
116 }
117}
118
119gdb_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
128set mainline [gdb_get_line_number "break main here"]
129
130gdb_test "break main" \
131 "Breakpoint.*at.* file .*$srcfile, line $mainline.*" \
132 "breakpoint function"
133
134gdb_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#
144gdb_test_multiple "break pendfunc2" "Don't set pending breakpoint" {
9f27c604 145 -re ".*Make breakpoint pending.*y or \\\[n\\\]. $" {
18fe2033
JJ
146 gdb_test "n" "" "Don't set pending breakpoint"
147 }
148}
149
150#
151# Add condition to pending breakpoint
152#
153
d2dc51db 154gdb_test "condition 1 k == 1" ""
18fe2033
JJ
155
156gdb_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
d2dc51db 167gdb_test "disable 1" ""
18fe2033
JJ
168
169gdb_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#
179gdb_test "commands 1\nprint k\nend" "" \
180 "Set commands for pending breakpoint"
181
182gdb_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
194gdb_test_multiple "break pendshr.c:26 if x > 3" "Set pending breakpoint 2" {
9f27c604 195 -re ".*Make breakpoint pending.*y or \\\[n\\\]. $" {
18fe2033
JJ
196 gdb_test "y" "Breakpoint.*pendshr.c:26.*pending." \
197 "Set pending breakpoint 2"
198 }
199}
200
201gdb_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
214gdb_test "run" \
215"Breakpoint.*at.*
216Pending breakpoint \"pendshr.c:26 if x > 3\" resolved.*
217Breakpoint.*, main.*$mainline.*" \
218"running to main"
219
220#
221# Re-enable the first pending breakpoint which should resolve
222#
223
224gdb_test "enable 1" \
225"Breakpoint.*at.*
226Pending 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
233gdb_test "continue" \
234".*Breakpoint.*pendfunc1.*at.*pendshr.c:26.*4;" \
235"continue to resolved breakpoint 2"
236
237gdb_test "continue" \
238".*Breakpoint.*pendfunc1.*at.*pendshr.c:26.*
239\[$\]1 = 1." \
240"continue to resolved breakpoint 1"
241
242delete_breakpoints
243
244gdb_breakpoint "main"
245
246#
247# Set non-existent pending breakpoint
248#
249gdb_test_multiple "break imaginary" "set imaginary pending breakpoint" {
9f27c604 250 -re ".*Make breakpoint pending.*y or \\\[n\\\]. $" {
18fe2033
JJ
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
261rerun_to_main
262gdb_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.078461 seconds and 4 git commands to generate.