]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.base/reread.exp
run copyright.sh for 2011.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / reread.exp
CommitLineData
7b6bb8da 1# Copyright 1998, 2000, 2001, 2007, 2008, 2009, 2010, 2011
4c38e0a4 2# Free Software Foundation, Inc.
c906108c
SS
3
4# This program is free software; you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
e22f8b7c 6# the Free Software Foundation; either version 3 of the License, or
c906108c 7# (at your option) any later version.
e22f8b7c 8#
c906108c
SS
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
e22f8b7c 13#
c906108c 14# You should have received a copy of the GNU General Public License
e22f8b7c 15# along with this program. If not, see <http://www.gnu.org/licenses/>.
c906108c 16
c906108c
SS
17if $tracelevel then {
18 strace $tracelevel
19}
20
c906108c
SS
21set prototypes 1
22
23# build the first test case
24
25set testfile1 "reread1"
26set srcfile1 ${testfile1}.c
93076499
ND
27# Cygwin needs $EXEEXT.
28set binfile1 ${objdir}/${subdir}/${testfile1}$EXEEXT
c906108c 29
fc91c6c2 30if { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile1}" executable {debug nowarnings}] != "" } {
b60f0898
JB
31 untested reread.exp
32 return -1
c906108c
SS
33}
34
35# build the second test case
36
37set testfile2 "reread2"
38set srcfile2 ${testfile2}.c
93076499 39set binfile2 ${objdir}/${subdir}/${testfile2}$EXEEXT
c906108c 40
fc91c6c2 41if { [gdb_compile "${srcdir}/${subdir}/${srcfile2}" "${binfile2}" executable {debug nowarnings}] != "" } {
b60f0898
JB
42 untested reread.exp
43 return -1
c906108c
SS
44}
45
46# Start with a fresh gdb.
47
48set testfile "reread"
93076499 49set binfile ${objdir}/${subdir}/${testfile}$EXEEXT
c906108c
SS
50
51gdb_start
52gdb_reinitialize_dir $srcdir/$subdir
53
c906108c
SS
54# Load the first executable.
55
de7ff789 56gdb_test "shell mv ${binfile1} ${binfile}" ".*" ""
c906108c
SS
57gdb_load ${binfile}
58
59# Set a breakpoint at foo
60
61gdb_test "break foo" \
62 "Breakpoint.*at.* file .*$srcfile1, line 14.*" \
63 "breakpoint foo in first file"
64
65
66# Run, should see "Breakpoint 1, foo () at hello1.c:14"
67
68gdb_run_cmd
69
70gdb_expect {
71 -re ".*Breakpoint.* foo .* at .*$srcfile1:14.*$gdb_prompt $" {
72 pass "run to foo()";
73 }
74 -re ".*$gdb_prompt $" {
75 fail "run to foo()";
76 gdb_suppress_tests;
77 }
78 timeout { fail "run to foo() (timeout)" ; gdb_suppress_tests }
79}
80
81# Restore first executable to its original name, and move
82# second executable into its place. Ensure that the new
39ad761d 83# executable is at least a second newer than the old.
c906108c 84
de7ff789
MS
85gdb_test "shell mv ${binfile} ${binfile1}" ".*" ""
86gdb_test "shell mv ${binfile2} ${binfile}" ".*" ""
87gdb_test "shell sleep 1" ".*" ""
88gdb_test "shell touch ${binfile}" ".*" ""
c906108c
SS
89
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"
93
676a0442 94if [is_remote target] {
40f33b9b
MS
95 unsupported "run to foo() second time ";
96} else {
97 gdb_run_cmd
98 gdb_expect {
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 ";
102 }
103 -re ".*$gdb_prompt $" {
104 fail "run to foo() second time";
105 gdb_suppress_tests;
106 }
107 timeout {
108 fail "run to foo() second time (timeout)" ;
109 gdb_suppress_tests
110 }
c906108c 111 }
c906108c
SS
112}
113
39ad761d
JB
114
115### Second pass: verify that GDB checks the executable file's
116### timestamp when the program is *restarted*, not just when it exits.
117
676a0442 118if [is_remote target] {
39ad761d
JB
119 unsupported "second pass: GDB should check for changes before running"
120} else {
121
122 # Put the older executable back in place.
de7ff789
MS
123 gdb_test "shell mv ${binfile} ${binfile2}" ".*" ""
124 gdb_test "shell mv ${binfile1} ${binfile}" ".*" ""
39ad761d
JB
125
126 # Restart GDB entirely.
127 gdb_start
128 gdb_reinitialize_dir $srcdir/$subdir
129 gdb_load ${binfile}
130
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"
135 gdb_run_cmd
136 gdb_expect {
137 -re ".*Breakpoint.* foo .* at .*$srcfile1:14.*$gdb_prompt $" {
138 pass "second pass: run to foo()";
139 }
140 -re ".*$gdb_prompt $" {
141 fail "second pass: run to foo()";
142 gdb_suppress_tests;
143 }
144 timeout {
145 fail "second pass: run to foo() (timeout)"
146 gdb_suppress_tests
147 }
148 }
149
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_test "continue" ".*Program exited.*" \
153 "second pass: continue to completion"
154
155 # Now move the newer executable into place, and re-run. GDB
156 # should still notice that the executable file has changed,
157 # and still re-set the breakpoint appropriately.
de7ff789
MS
158 gdb_test "shell mv ${binfile} ${binfile1}" ".*" ""
159 gdb_test "shell mv ${binfile2} ${binfile}" ".*" ""
39ad761d
JB
160 gdb_run_cmd
161 gdb_expect {
162 -re ".*Breakpoint.* foo .* at .*:9.*$gdb_prompt $" {
163 pass "second pass: run to foo() second time ";
164 }
165 -re ".*$gdb_prompt $" {
166 fail "second pass: run to foo() second time";
167 gdb_suppress_tests;
168 }
169 timeout {
170 fail "second pass: run to foo() second time (timeout)" ;
171 gdb_suppress_tests
172 }
173 }
174}
175
c906108c
SS
176# End of tests.
177
178gdb_stop_suppressing_tests
179
180return 0