1 # Copyright 1998, 2000-2001, 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/>.
22 # build the first test case
24 set testfile1 "reread1"
25 set srcfile1 ${testfile1}.c
26 # Cygwin needs $EXEEXT.
27 set binfile1 ${objdir}/${subdir}/${testfile1}$EXEEXT
29 if { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile1}" executable {debug nowarnings}] != "" } {
34 # build the second test case
36 set testfile2 "reread2"
37 set srcfile2 ${testfile2}.c
38 set binfile2 ${objdir}/${subdir}/${testfile2}$EXEEXT
40 if { [gdb_compile "${srcdir}/${subdir}/${srcfile2}" "${binfile2}" executable {debug nowarnings}] != ""
41 && [gdb_compile "${srcdir}/${subdir}/${srcfile2}" "${binfile2}" executable {debug nowarnings additional_flags=-DNO_SECTIONS}] != ""} {
46 # Start with a fresh gdb.
49 set binfile ${objdir}/${subdir}/${testfile}$EXEEXT
52 gdb_reinitialize_dir $srcdir/$subdir
54 # Load the first executable.
56 gdb_rename_execfile ${binfile1} ${binfile}
59 # Set a breakpoint at foo
61 gdb_test "break foo" \
62 "Breakpoint.*at.* file .*$srcfile1, line 14.*" \
63 "breakpoint foo in first file"
66 # Run, should see "Breakpoint 1, foo () at hello1.c:14"
71 -re ".*Breakpoint.* foo .* at .*$srcfile1:14.*$gdb_prompt $" {
74 -re ".*$gdb_prompt $" {
78 timeout { fail "run to foo() (timeout)" ; gdb_suppress_tests }
81 # Restore first executable to its original name, and move
82 # second executable into its place. Ensure that the new
83 # executable is at least a second newer than the old.
85 gdb_rename_execfile ${binfile} ${binfile1}
86 gdb_rename_execfile ${binfile2} ${binfile}
87 gdb_test "shell sleep 1" ".*" ""
88 gdb_touch_execfile ${binfile}
90 # Run a second time; GDB should detect that the executable has changed
91 # and reset the breakpoints correctly.
92 # Should see "Breakpoint 1, foo () at reread2.c:9"
94 if [is_remote target] {
95 unsupported "run to foo() second time ";
99 # -re ".*re-reading symbols.*Breakpoint.* foo .* at .*$srcfile2:9.*$gdb_prompt $" {}
100 -re ".*Breakpoint.* foo .* at .*:9.*$gdb_prompt $" {
101 pass "run to foo() second time ";
103 -re ".*$gdb_prompt $" {
104 fail "run to foo() second time";
108 fail "run to foo() second time (timeout)" ;
115 ### Second pass: verify that GDB checks the executable file's
116 ### timestamp when the program is *restarted*, not just when it exits.
118 if [is_remote target] {
119 unsupported "second pass: GDB should check for changes before running"
122 # Put the older executable back in place.
123 gdb_rename_execfile ${binfile} ${binfile2}
124 gdb_rename_execfile ${binfile1} ${binfile}
126 # Restart GDB entirely.
128 gdb_reinitialize_dir $srcdir/$subdir
131 # Set a breakpoint on foo and run to it.
132 gdb_test "break foo" \
133 "Breakpoint.*at.* file .*$srcfile1, line 14.*" \
134 "second pass: breakpoint foo in first file"
137 -re ".*Breakpoint.* foo .* at .*$srcfile1:14.*$gdb_prompt $" {
138 pass "second pass: run to foo()";
140 -re ".*$gdb_prompt $" {
141 fail "second pass: run to foo()";
145 fail "second pass: run to foo() (timeout)"
150 # This time, let the program run to completion. If GDB checks the
151 # executable file's timestamp now, it won't notice any change.
152 gdb_continue_to_end "second pass"
154 # Now move the newer executable into place, and re-run. GDB
155 # should still notice that the executable file has changed,
156 # and still re-set the breakpoint appropriately.
157 gdb_rename_execfile ${binfile} ${binfile1}
158 gdb_rename_execfile ${binfile2} ${binfile}
161 -re ".*Breakpoint.* foo .* at .*:9.*$gdb_prompt $" {
162 pass "second pass: run to foo() second time ";
164 -re ".*$gdb_prompt $" {
165 fail "second pass: run to foo() second time";
169 fail "second pass: run to foo() second time (timeout)" ;
177 gdb_stop_suppressing_tests