2 # Free Software Foundation, Inc.
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.
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.
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.
18 # Please email any bugs, comments, and/or additions to this file to:
19 # bug-gdb@prep.ai.mit.edu
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).
30 # test running programs
35 # are we on a target board?
40 set testfile "pending"
42 set srcfile ${testfile}.c
43 set binfile ${objdir}/${subdir}/${testfile}
45 if [get_compiler_info ${binfile}] {
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."
53 # Build the shared libraries this test case needs.
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"
63 # don't know what the compiler is...
64 set additional_flags ""
67 if { ([istarget "powerpc*-*-aix*"]
68 || [istarget "rs6000*-*-aix*"]) } {
69 set additional_flags ""
71 set additional_flags "additional_flags=-fpic"
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."
79 if [istarget "hppa*-*-hpux*"] {
80 remote_exec build "ld -b ${objdir}/${subdir}/${libfile}.o -o ${objdir}/${subdir}/${libfile}.sl"
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."
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}"
95 set additional_flags ""
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."
103 gdb_reinitialize_dir $srcdir/$subdir
106 if [target_info exists gdb_stub] {
110 # Test setting, querying, and modifying pending breakpoints
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"
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"
125 # Test breaking at existing function
128 set mainline [gdb_get_line_number "break main here"]
130 gdb_test "break main" \
131 "Breakpoint.*at.* file .*$srcfile, line $mainline.*" \
132 "breakpoint function"
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"
142 # Test not setting a pending breakpoint
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"
151 # Add condition to pending breakpoint
154 gdb_test "condition 1 k == 1\n" ""
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"
164 # Disable pending breakpoint
167 gdb_test "disable 1\n" ""
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" \
177 # Add commands to pending breakpoint
179 gdb_test "commands 1\nprint k\nend" "" \
180 "Set commands for pending breakpoint"
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.*
187 \[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$mainline" \
188 "pending disabled plus commands"
191 # Try a pending break for a line in a source file with a condition
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"
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.*
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"
211 # Run to main which should resolve a pending breakpoint
216 Pending breakpoint \"pendshr.c:26 if x > 3\" resolved.*
217 Breakpoint.*, main.*$mainline.*" \
221 # Re-enable the first pending breakpoint which should resolve
224 gdb_test "enable 1" \
226 Pending breakpoint \"pendfunc1.* resolved.*" \
227 "re-enabling pending breakpoint that can resolve instantly"
230 # Continue to verify conditionals and commands for breakpoints are honored
233 gdb_test "continue" \
234 ".*Breakpoint.*pendfunc1.*at.*pendshr.c:26.*4;" \
235 "continue to resolved breakpoint 2"
237 gdb_test "continue" \
238 ".*Breakpoint.*pendfunc1.*at.*pendshr.c:26.*
240 "continue to resolved breakpoint 1"
244 gdb_breakpoint "main"
247 # Set non-existent pending breakpoint
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"
257 # rerun program and make sure that any pending breakpoint remains and no
258 # error messages are issued for the missing function
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"