Commit | Line | Data |
---|---|---|
ecd75fc8 | 1 | # Copyright 2004-2014 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 | ||
f76495c8 | 21 | standard_testfile .c |
d8679d84 PH |
22 | |
23 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DVARIABLE=var1}] != "" } { | |
b60f0898 JB |
24 | untested chng-syms.exp |
25 | return -1 | |
d8679d84 PH |
26 | } |
27 | ||
28 | set oldtimeout $timeout | |
29 | set timeout 10 | |
30 | verbose "Timeout is now 10 seconds" 2 | |
31 | ||
32 | proc expect_to_stop_here { ident } { | |
33 | global gdb_prompt | |
34 | global decimal | |
35 | ||
36 | # the "at foo.c:36" output we get with -g. | |
37 | # the "in func" output we get without -g. | |
38 | gdb_expect { | |
39 | -re "Breakpoint \[0-9\]*, stop_here .*$gdb_prompt $" { | |
40 | return 1 | |
41 | } | |
42 | -re "$gdb_prompt $" { | |
43 | fail "running to stop_here $ident" | |
44 | return 0 | |
45 | } | |
46 | timeout { | |
47 | fail "running to stop_here $ident (timeout)" | |
48 | return 0 | |
49 | } | |
50 | } | |
51 | return 1 | |
52 | } | |
53 | ||
f76495c8 | 54 | clean_restart ${binfile} |
d8679d84 | 55 | |
abbab9d3 | 56 | gdb_test "break stop_here if (var1 == 42)" \ |
d8679d84 PH |
57 | "Breakpoint.*at.* file .*$srcfile, line.*" \ |
58 | "setting conditional breakpoint on function" | |
59 | gdb_run_cmd | |
60 | ||
61 | expect_to_stop_here "first time" | |
62 | ||
63 | gdb_continue_to_end "breakpoint first time through" | |
64 | ||
65 | # Now we recompile the executable, but without a variable named "var1", first | |
66 | # waiting to insure that even on fast machines, the file modification times | |
67 | # are distinct. This will force GDB to reload the file on the | |
68 | # next "run" command, causing an error when GDB tries to tries to reset | |
69 | # the breakpoint. | |
70 | ||
71 | sleep 2 | |
72 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DVARIABLE=var2}] != "" } { | |
73 | ||
74 | # Complication: Since GDB generally holds an open file descriptor on the | |
75 | # executable at this point, there are some systems in which the | |
76 | # re-compilation will fail. In such cases, we'll consider the test | |
77 | # (vacuously) passed providing that re-running it succeeds as before. | |
78 | ||
79 | gdb_run_cmd | |
80 | expect_to_stop_here "after re-compile fails" | |
81 | gdb_continue_to_end "after re-compile fails" | |
82 | ||
83 | } else { | |
84 | ||
85 | gdb_run_cmd | |
86 | gdb_expect { | |
fda326dd | 87 | -re ".*$inferior_exited_re normally.*$gdb_prompt $" { |
a195357f DJ |
88 | pass "running with invalidated bpt condition after executable changes" |
89 | } | |
4487aabf | 90 | -re ".*Breakpoint .*,( 0x.* in)? (\[^ \]*)exit .*$gdb_prompt $" { |
d8679d84 PH |
91 | pass "running with invalidated bpt condition after executable changes" |
92 | } | |
72fd54a9 FF |
93 | -re "$gdb_prompt $" { |
94 | fail "running with invalidated bpt condition after executable changes" | |
95 | } | |
d8679d84 PH |
96 | timeout { |
97 | fail "(timeout) running with invalidated bpt condition after executable changes" | |
98 | } | |
99 | } | |
100 | ||
101 | } | |
102 | ||
103 | set timeout $oldtimeout | |
104 | verbose "Timeout is now $timeout seconds" 2 | |
105 | return 0 |