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