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.
21 set testfile "chng-syms"
22 set srcfile ${testfile}.c
23 set binfile ${objdir}/${subdir}/${testfile}
25 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DVARIABLE=var1}] != "" } {
26 untested chng-syms.exp
30 set oldtimeout $timeout
32 verbose "Timeout is now 10 seconds" 2
34 proc expect_to_stop_here { ident } {
38 # the "at foo.c:36" output we get with -g.
39 # the "in func" output we get without -g.
41 -re "Breakpoint \[0-9\]*, stop_here .*$gdb_prompt $" {
45 fail "running to stop_here $ident"
49 fail "running to stop_here $ident (timeout)"
58 gdb_reinitialize_dir $srcdir/$subdir
61 gdb_test "break stop_here if (var1 == 42)" \
62 "Breakpoint.*at.* file .*$srcfile, line.*" \
63 "setting conditional breakpoint on function"
66 expect_to_stop_here "first time"
68 gdb_continue_to_end "breakpoint first time through"
70 # Now we recompile the executable, but without a variable named "var1", first
71 # waiting to insure that even on fast machines, the file modification times
72 # are distinct. This will force GDB to reload the file on the
73 # next "run" command, causing an error when GDB tries to tries to reset
77 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DVARIABLE=var2}] != "" } {
79 # Complication: Since GDB generally holds an open file descriptor on the
80 # executable at this point, there are some systems in which the
81 # re-compilation will fail. In such cases, we'll consider the test
82 # (vacuously) passed providing that re-running it succeeds as before.
85 expect_to_stop_here "after re-compile fails"
86 gdb_continue_to_end "after re-compile fails"
92 -re ".*$inferior_exited_re normally.*$gdb_prompt $" {
93 pass "running with invalidated bpt condition after executable changes"
95 -re ".*Breakpoint .*,( 0x.* in)? (\[^ \]*)exit .*$gdb_prompt $" {
96 pass "running with invalidated bpt condition after executable changes"
99 fail "running with invalidated bpt condition after executable changes"
102 fail "(timeout) running with invalidated bpt condition after executable changes"
108 set timeout $oldtimeout
109 verbose "Timeout is now $timeout seconds" 2