gdb/testsuite/
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / chng-syms.exp
CommitLineData
0b302171 1# Copyright 2004, 2007-2012 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
d8679d84
PH
21set testfile "chng-syms"
22set srcfile ${testfile}.c
23set binfile ${objdir}/${subdir}/${testfile}
24
25if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DVARIABLE=var1}] != "" } {
b60f0898
JB
26 untested chng-syms.exp
27 return -1
d8679d84
PH
28}
29
30set oldtimeout $timeout
31set timeout 10
32verbose "Timeout is now 10 seconds" 2
33
34proc expect_to_stop_here { ident } {
35 global gdb_prompt
36 global decimal
37
38 # the "at foo.c:36" output we get with -g.
39 # the "in func" output we get without -g.
40 gdb_expect {
41 -re "Breakpoint \[0-9\]*, stop_here .*$gdb_prompt $" {
42 return 1
43 }
44 -re "$gdb_prompt $" {
45 fail "running to stop_here $ident"
46 return 0
47 }
48 timeout {
49 fail "running to stop_here $ident (timeout)"
50 return 0
51 }
52 }
53 return 1
54}
55
56gdb_exit
57gdb_start
58gdb_reinitialize_dir $srcdir/$subdir
59gdb_load ${binfile}
60
abbab9d3 61gdb_test "break stop_here if (var1 == 42)" \
d8679d84
PH
62 "Breakpoint.*at.* file .*$srcfile, line.*" \
63 "setting conditional breakpoint on function"
64gdb_run_cmd
65
66expect_to_stop_here "first time"
67
68gdb_continue_to_end "breakpoint first time through"
69
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
74# the breakpoint.
75
76sleep 2
77if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DVARIABLE=var2}] != "" } {
78
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.
83
84 gdb_run_cmd
85 expect_to_stop_here "after re-compile fails"
86 gdb_continue_to_end "after re-compile fails"
87
88} else {
89
90 gdb_run_cmd
91 gdb_expect {
fda326dd 92 -re ".*$inferior_exited_re normally.*$gdb_prompt $" {
a195357f
DJ
93 pass "running with invalidated bpt condition after executable changes"
94 }
4487aabf 95 -re ".*Breakpoint .*,( 0x.* in)? (\[^ \]*)exit .*$gdb_prompt $" {
d8679d84
PH
96 pass "running with invalidated bpt condition after executable changes"
97 }
72fd54a9
FF
98 -re "$gdb_prompt $" {
99 fail "running with invalidated bpt condition after executable changes"
100 }
d8679d84
PH
101 timeout {
102 fail "(timeout) running with invalidated bpt condition after executable changes"
103 }
104 }
105
106}
107
108set timeout $oldtimeout
109verbose "Timeout is now $timeout seconds" 2
110return 0
This page took 1.246049 seconds and 4 git commands to generate.