Commit | Line | Data |
---|---|---|
28e7fd62 | 1 | # Copyright 1998-2013 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 |
16 | set prototypes 1 |
17 | ||
18 | # build the first test case | |
19 | ||
20 | set testfile1 "reread1" | |
21 | set srcfile1 ${testfile1}.c | |
93076499 ND |
22 | # Cygwin needs $EXEEXT. |
23 | set binfile1 ${objdir}/${subdir}/${testfile1}$EXEEXT | |
c906108c | 24 | |
fc91c6c2 | 25 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile1}" executable {debug nowarnings}] != "" } { |
b60f0898 JB |
26 | untested reread.exp |
27 | return -1 | |
c906108c SS |
28 | } |
29 | ||
30 | # build the second test case | |
31 | ||
32 | set testfile2 "reread2" | |
33 | set srcfile2 ${testfile2}.c | |
93076499 | 34 | set binfile2 ${objdir}/${subdir}/${testfile2}$EXEEXT |
c906108c | 35 | |
f6eeced0 JK |
36 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile2}" "${binfile2}" executable {debug nowarnings}] != "" |
37 | && [gdb_compile "${srcdir}/${subdir}/${srcfile2}" "${binfile2}" executable {debug nowarnings additional_flags=-DNO_SECTIONS}] != ""} { | |
b60f0898 JB |
38 | untested reread.exp |
39 | return -1 | |
c906108c SS |
40 | } |
41 | ||
42 | # Start with a fresh gdb. | |
43 | ||
44 | set testfile "reread" | |
93076499 | 45 | set binfile ${objdir}/${subdir}/${testfile}$EXEEXT |
c906108c SS |
46 | |
47 | gdb_start | |
48 | gdb_reinitialize_dir $srcdir/$subdir | |
49 | ||
c906108c SS |
50 | # Load the first executable. |
51 | ||
56744f0a | 52 | gdb_rename_execfile ${binfile1} ${binfile} |
c906108c SS |
53 | gdb_load ${binfile} |
54 | ||
55 | # Set a breakpoint at foo | |
56 | ||
57 | gdb_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 | ||
64 | gdb_run_cmd | |
65 | ||
66 | gdb_expect { | |
67 | -re ".*Breakpoint.* foo .* at .*$srcfile1:14.*$gdb_prompt $" { | |
4ec70201 | 68 | pass "run to foo()" |
c906108c SS |
69 | } |
70 | -re ".*$gdb_prompt $" { | |
4ec70201 PA |
71 | fail "run to foo()" |
72 | gdb_suppress_tests | |
c906108c SS |
73 | } |
74 | timeout { fail "run to foo() (timeout)" ; gdb_suppress_tests } | |
75 | } | |
76 | ||
77 | # Restore first executable to its original name, and move | |
78 | # second executable into its place. Ensure that the new | |
39ad761d | 79 | # executable is at least a second newer than the old. |
c906108c | 80 | |
56744f0a JJ |
81 | gdb_rename_execfile ${binfile} ${binfile1} |
82 | gdb_rename_execfile ${binfile2} ${binfile} | |
de7ff789 | 83 | gdb_test "shell sleep 1" ".*" "" |
56744f0a | 84 | gdb_touch_execfile ${binfile} |
c906108c SS |
85 | |
86 | # Run a second time; GDB should detect that the executable has changed | |
87 | # and reset the breakpoints correctly. | |
88 | # Should see "Breakpoint 1, foo () at reread2.c:9" | |
89 | ||
676a0442 | 90 | if [is_remote target] { |
4ec70201 | 91 | unsupported "run to foo() second time " |
40f33b9b MS |
92 | } else { |
93 | gdb_run_cmd | |
94 | gdb_expect { | |
95 | # -re ".*re-reading symbols.*Breakpoint.* foo .* at .*$srcfile2:9.*$gdb_prompt $" {} | |
96 | -re ".*Breakpoint.* foo .* at .*:9.*$gdb_prompt $" { | |
4ec70201 | 97 | pass "run to foo() second time " |
40f33b9b MS |
98 | } |
99 | -re ".*$gdb_prompt $" { | |
4ec70201 PA |
100 | fail "run to foo() second time" |
101 | gdb_suppress_tests | |
40f33b9b MS |
102 | } |
103 | timeout { | |
4ec70201 | 104 | fail "run to foo() second time (timeout)" |
40f33b9b MS |
105 | gdb_suppress_tests |
106 | } | |
c906108c | 107 | } |
c906108c SS |
108 | } |
109 | ||
39ad761d JB |
110 | |
111 | ### Second pass: verify that GDB checks the executable file's | |
112 | ### timestamp when the program is *restarted*, not just when it exits. | |
113 | ||
676a0442 | 114 | if [is_remote target] { |
39ad761d JB |
115 | unsupported "second pass: GDB should check for changes before running" |
116 | } else { | |
117 | ||
118 | # Put the older executable back in place. | |
56744f0a JJ |
119 | gdb_rename_execfile ${binfile} ${binfile2} |
120 | gdb_rename_execfile ${binfile1} ${binfile} | |
39ad761d JB |
121 | |
122 | # Restart GDB entirely. | |
123 | gdb_start | |
124 | gdb_reinitialize_dir $srcdir/$subdir | |
125 | gdb_load ${binfile} | |
126 | ||
127 | # Set a breakpoint on foo and run to it. | |
128 | gdb_test "break foo" \ | |
129 | "Breakpoint.*at.* file .*$srcfile1, line 14.*" \ | |
130 | "second pass: breakpoint foo in first file" | |
131 | gdb_run_cmd | |
132 | gdb_expect { | |
133 | -re ".*Breakpoint.* foo .* at .*$srcfile1:14.*$gdb_prompt $" { | |
4ec70201 | 134 | pass "second pass: run to foo()" |
39ad761d JB |
135 | } |
136 | -re ".*$gdb_prompt $" { | |
4ec70201 PA |
137 | fail "second pass: run to foo()" |
138 | gdb_suppress_tests | |
39ad761d JB |
139 | } |
140 | timeout { | |
141 | fail "second pass: run to foo() (timeout)" | |
142 | gdb_suppress_tests | |
143 | } | |
144 | } | |
145 | ||
146 | # This time, let the program run to completion. If GDB checks the | |
147 | # executable file's timestamp now, it won't notice any change. | |
fda326dd | 148 | gdb_continue_to_end "second pass" |
39ad761d JB |
149 | |
150 | # Now move the newer executable into place, and re-run. GDB | |
151 | # should still notice that the executable file has changed, | |
152 | # and still re-set the breakpoint appropriately. | |
56744f0a JJ |
153 | gdb_rename_execfile ${binfile} ${binfile1} |
154 | gdb_rename_execfile ${binfile2} ${binfile} | |
39ad761d JB |
155 | gdb_run_cmd |
156 | gdb_expect { | |
157 | -re ".*Breakpoint.* foo .* at .*:9.*$gdb_prompt $" { | |
4ec70201 | 158 | pass "second pass: run to foo() second time " |
39ad761d JB |
159 | } |
160 | -re ".*$gdb_prompt $" { | |
4ec70201 PA |
161 | fail "second pass: run to foo() second time" |
162 | gdb_suppress_tests | |
39ad761d JB |
163 | } |
164 | timeout { | |
4ec70201 | 165 | fail "second pass: run to foo() second time (timeout)" |
39ad761d JB |
166 | gdb_suppress_tests |
167 | } | |
168 | } | |
169 | } | |
170 | ||
c906108c SS |
171 | # End of tests. |
172 | ||
173 | gdb_stop_suppressing_tests | |
174 | ||
175 | return 0 |