update copyright year range in GDB files
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / reread.exp
CommitLineData
61baf725 1# Copyright 1998-2017 Free Software Foundation, Inc.
c906108c
SS
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
c906108c 6# (at your option) any later version.
e22f8b7c 7#
c906108c
SS
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.
e22f8b7c 12#
c906108c 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/>.
c906108c 15
c906108c
SS
16set prototypes 1
17
18# build the first test case
19
20set testfile1 "reread1"
21set srcfile1 ${testfile1}.c
93076499 22# Cygwin needs $EXEEXT.
822bd149 23set binfile1 [standard_output_file ${testfile1}$EXEEXT]
c906108c 24
fc91c6c2 25if { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile1}" executable {debug nowarnings}] != "" } {
84c93cd5 26 untested "failed to compile first testcase"
b60f0898 27 return -1
c906108c
SS
28}
29
30# build the second test case
31
32set testfile2 "reread2"
33set srcfile2 ${testfile2}.c
822bd149 34set binfile2 [standard_output_file ${testfile2}$EXEEXT]
c906108c 35
f6eeced0
JK
36if { [gdb_compile "${srcdir}/${subdir}/${srcfile2}" "${binfile2}" executable {debug nowarnings}] != ""
37 && [gdb_compile "${srcdir}/${subdir}/${srcfile2}" "${binfile2}" executable {debug nowarnings additional_flags=-DNO_SECTIONS}] != ""} {
84c93cd5 38 untested "failed to compile second testcase"
b60f0898 39 return -1
c906108c
SS
40}
41
42# Start with a fresh gdb.
43
44set testfile "reread"
822bd149 45set binfile [standard_output_file ${testfile}$EXEEXT]
c906108c
SS
46
47gdb_start
48gdb_reinitialize_dir $srcdir/$subdir
49
c906108c
SS
50# Load the first executable.
51
56744f0a 52gdb_rename_execfile ${binfile1} ${binfile}
c906108c
SS
53gdb_load ${binfile}
54
55# Set a breakpoint at foo
56
57gdb_test "break foo" \
58 "Breakpoint.*at.* file .*$srcfile1, line 14.*" \
59 "breakpoint foo in first file"
60
61
62# Run, should see "Breakpoint 1, foo () at hello1.c:14"
63
64gdb_run_cmd
fa43b1d7 65gdb_test "" "Breakpoint.* foo .* at .*$srcfile1:14.*" "run to foo()"
c906108c
SS
66
67# Restore first executable to its original name, and move
68# second executable into its place. Ensure that the new
39ad761d 69# executable is at least a second newer than the old.
c906108c 70
56744f0a
JJ
71gdb_rename_execfile ${binfile} ${binfile1}
72gdb_rename_execfile ${binfile2} ${binfile}
de7ff789 73gdb_test "shell sleep 1" ".*" ""
56744f0a 74gdb_touch_execfile ${binfile}
c906108c
SS
75
76# Run a second time; GDB should detect that the executable has changed
77# and reset the breakpoints correctly.
78# Should see "Breakpoint 1, foo () at reread2.c:9"
79
fa43b1d7 80set test "run to foo() second time"
676a0442 81if [is_remote target] {
fa43b1d7 82 unsupported $test
40f33b9b
MS
83} else {
84 gdb_run_cmd
fa43b1d7 85 gdb_test "" "Breakpoint.* foo .* at .*:9.*" $test
c906108c
SS
86}
87
39ad761d
JB
88
89### Second pass: verify that GDB checks the executable file's
90### timestamp when the program is *restarted*, not just when it exits.
91
676a0442 92if [is_remote target] {
39ad761d
JB
93 unsupported "second pass: GDB should check for changes before running"
94} else {
95
96 # Put the older executable back in place.
56744f0a
JJ
97 gdb_rename_execfile ${binfile} ${binfile2}
98 gdb_rename_execfile ${binfile1} ${binfile}
39ad761d
JB
99
100 # Restart GDB entirely.
41e99568 101 clean_restart ${binfile}
39ad761d
JB
102
103 # Set a breakpoint on foo and run to it.
104 gdb_test "break foo" \
105 "Breakpoint.*at.* file .*$srcfile1, line 14.*" \
106 "second pass: breakpoint foo in first file"
107 gdb_run_cmd
fa43b1d7 108 gdb_test "" "Breakpoint.* foo .* at .*$srcfile1:14.*" "second pass: run to foo()"
39ad761d
JB
109
110 # This time, let the program run to completion. If GDB checks the
111 # executable file's timestamp now, it won't notice any change.
fda326dd 112 gdb_continue_to_end "second pass"
39ad761d
JB
113
114 # Now move the newer executable into place, and re-run. GDB
115 # should still notice that the executable file has changed,
116 # and still re-set the breakpoint appropriately.
56744f0a
JJ
117 gdb_rename_execfile ${binfile} ${binfile1}
118 gdb_rename_execfile ${binfile2} ${binfile}
39ad761d 119 gdb_run_cmd
fa43b1d7 120 gdb_test "" "Breakpoint.* foo .* at .*:9.*" "second pass: run to foo() second time"
39ad761d
JB
121}
122
c906108c
SS
123# End of tests.
124
c906108c 125return 0
This page took 1.767639 seconds and 4 git commands to generate.