1 # Copyright 2004, 2007-2012 Free Software Foundation, Inc.
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.
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.
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/>.
16 # Author: Paul N. Hilfinger (Hilfinger@gnat.com)
18 # Test that GDB cleans up properly after errors that result when a
19 # breakpoint is reset.
22 # IDT/SIM apparently doesn't have enough file descriptors to allow the
23 # problem checked by this test to occur.
24 if [istarget "mips-idt-*"] {
28 set testfile "chng-syms"
29 set srcfile ${testfile}.c
30 set binfile ${objdir}/${subdir}/${testfile}
32 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DVARIABLE=var1}] != "" } {
33 untested chng-syms.exp
37 set oldtimeout $timeout
39 verbose "Timeout is now 10 seconds" 2
41 proc expect_to_stop_here { ident } {
45 # the "at foo.c:36" output we get with -g.
46 # the "in func" output we get without -g.
48 -re "Breakpoint \[0-9\]*, stop_here .*$gdb_prompt $" {
52 fail "running to stop_here $ident"
56 fail "running to stop_here $ident (timeout)"
65 gdb_reinitialize_dir $srcdir/$subdir
68 gdb_test "break stop_here if (var1 == 42)" \
69 "Breakpoint.*at.* file .*$srcfile, line.*" \
70 "setting conditional breakpoint on function"
73 expect_to_stop_here "first time"
75 gdb_continue_to_end "breakpoint first time through"
77 # Now we recompile the executable, but without a variable named "var1", first
78 # waiting to insure that even on fast machines, the file modification times
79 # are distinct. This will force GDB to reload the file on the
80 # next "run" command, causing an error when GDB tries to tries to reset
84 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DVARIABLE=var2}] != "" } {
86 # Complication: Since GDB generally holds an open file descriptor on the
87 # executable at this point, there are some systems in which the
88 # re-compilation will fail. In such cases, we'll consider the test
89 # (vacuously) passed providing that re-running it succeeds as before.
92 expect_to_stop_here "after re-compile fails"
93 gdb_continue_to_end "after re-compile fails"
99 -re ".*$inferior_exited_re normally.*$gdb_prompt $" {
100 pass "running with invalidated bpt condition after executable changes"
102 -re ".*Breakpoint .*,( 0x.* in)? (\[^ \]*)exit .*$gdb_prompt $" {
103 pass "running with invalidated bpt condition after executable changes"
105 -re "$gdb_prompt $" {
106 fail "running with invalidated bpt condition after executable changes"
109 fail "(timeout) running with invalidated bpt condition after executable changes"
115 set timeout $oldtimeout
116 verbose "Timeout is now $timeout seconds" 2