2009-07-01 Tristan Gingold <gingold@adacore.com>
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / chng-syms.exp
CommitLineData
0fb0cc75 1# Copyright 2004, 2007, 2008, 2009 Free Software Foundation, Inc.
d8679d84
PH
2
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
e22f8b7c 5# the Free Software Foundation; either version 3 of the License, or
d8679d84
PH
6# (at your option) any later version.
7#
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.
12#
13# You should have received a copy of the GNU General Public License
e22f8b7c 14# along with this program. If not, see <http://www.gnu.org/licenses/>.
d8679d84 15
d8679d84
PH
16# Author: Paul N. Hilfinger (Hilfinger@gnat.com)
17
18# Test that GDB cleans up properly after errors that result when a
19# breakpoint is reset.
20
21if $tracelevel then {
22 strace $tracelevel
23}
24
25set prms_id 0
26set bug_id 0
27
28# IDT/SIM apparently doesn't have enough file descriptors to allow the
29# problem checked by this test to occur.
30if [istarget "mips-idt-*"] {
31 return 0;
32}
33
34set testfile "chng-syms"
35set srcfile ${testfile}.c
36set binfile ${objdir}/${subdir}/${testfile}
37
38if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DVARIABLE=var1}] != "" } {
b60f0898
JB
39 untested chng-syms.exp
40 return -1
d8679d84
PH
41}
42
43set oldtimeout $timeout
44set timeout 10
45verbose "Timeout is now 10 seconds" 2
46
47proc expect_to_stop_here { ident } {
48 global gdb_prompt
49 global decimal
50
51 # the "at foo.c:36" output we get with -g.
52 # the "in func" output we get without -g.
53 gdb_expect {
54 -re "Breakpoint \[0-9\]*, stop_here .*$gdb_prompt $" {
55 return 1
56 }
57 -re "$gdb_prompt $" {
58 fail "running to stop_here $ident"
59 return 0
60 }
61 timeout {
62 fail "running to stop_here $ident (timeout)"
63 return 0
64 }
65 }
66 return 1
67}
68
69gdb_exit
70gdb_start
71gdb_reinitialize_dir $srcdir/$subdir
72gdb_load ${binfile}
73
abbab9d3 74gdb_test "break stop_here if (var1 == 42)" \
d8679d84
PH
75 "Breakpoint.*at.* file .*$srcfile, line.*" \
76 "setting conditional breakpoint on function"
77gdb_run_cmd
78
79expect_to_stop_here "first time"
80
81gdb_continue_to_end "breakpoint first time through"
82
83# Now we recompile the executable, but without a variable named "var1", first
84# waiting to insure that even on fast machines, the file modification times
85# are distinct. This will force GDB to reload the file on the
86# next "run" command, causing an error when GDB tries to tries to reset
87# the breakpoint.
88
89sleep 2
90if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DVARIABLE=var2}] != "" } {
91
92# Complication: Since GDB generally holds an open file descriptor on the
93# executable at this point, there are some systems in which the
94# re-compilation will fail. In such cases, we'll consider the test
95# (vacuously) passed providing that re-running it succeeds as before.
96
97 gdb_run_cmd
98 expect_to_stop_here "after re-compile fails"
99 gdb_continue_to_end "after re-compile fails"
100
101} else {
102
103 gdb_run_cmd
104 gdb_expect {
4487aabf 105 -re ".*Program exited normally.*$gdb_prompt $" {
a195357f
DJ
106 pass "running with invalidated bpt condition after executable changes"
107 }
4487aabf 108 -re ".*Breakpoint .*,( 0x.* in)? (\[^ \]*)exit .*$gdb_prompt $" {
d8679d84
PH
109 pass "running with invalidated bpt condition after executable changes"
110 }
72fd54a9
FF
111 -re "$gdb_prompt $" {
112 fail "running with invalidated bpt condition after executable changes"
113 }
d8679d84
PH
114 timeout {
115 fail "(timeout) running with invalidated bpt condition after executable changes"
116 }
117 }
118
119}
120
121set timeout $oldtimeout
122verbose "Timeout is now $timeout seconds" 2
123return 0
This page took 0.531317 seconds and 4 git commands to generate.