Update/correct copyright notices.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / reread.exp
CommitLineData
b6ba6518 1# Copyright 1998, 2000, 2001 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
5# the Free Software Foundation; either version 2 of the License, or
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
14# along with this program; if not, write to the Free Software
15# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16
17# Please email any bugs, comments, and/or additions to this file to:
18# bug-gdb@prep.ai.mit.edu
19
20if $tracelevel then {
21 strace $tracelevel
22}
23
24set prms_id 0
25set bug_id 0
26
27set prototypes 1
28
29# build the first test case
30
31set testfile1 "reread1"
32set srcfile1 ${testfile1}.c
93076499
ND
33# Cygwin needs $EXEEXT.
34set binfile1 ${objdir}/${subdir}/${testfile1}$EXEEXT
c906108c
SS
35
36if { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile1}" executable {debug additional_flags=-w}] != "" } {
37 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
38}
39
40# build the second test case
41
42set testfile2 "reread2"
43set srcfile2 ${testfile2}.c
93076499 44set binfile2 ${objdir}/${subdir}/${testfile2}$EXEEXT
c906108c
SS
45
46if { [gdb_compile "${srcdir}/${subdir}/${srcfile2}" "${binfile2}" executable {debug additional_flags=-w}] != "" } {
47 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
48}
49
50# Start with a fresh gdb.
51
52set testfile "reread"
93076499 53set binfile ${objdir}/${subdir}/${testfile}$EXEEXT
c906108c
SS
54
55gdb_start
56gdb_reinitialize_dir $srcdir/$subdir
57
58set prms_id 13484
59set bug_id 0
60
61# Load the first executable.
62
63gdb_test "shell mv ${binfile1} ${binfile}" "" ""
64gdb_load ${binfile}
65
66# Set a breakpoint at foo
67
68gdb_test "break foo" \
69 "Breakpoint.*at.* file .*$srcfile1, line 14.*" \
70 "breakpoint foo in first file"
71
72
73# Run, should see "Breakpoint 1, foo () at hello1.c:14"
74
75gdb_run_cmd
76
77gdb_expect {
78 -re ".*Breakpoint.* foo .* at .*$srcfile1:14.*$gdb_prompt $" {
79 pass "run to foo()";
80 }
81 -re ".*$gdb_prompt $" {
82 fail "run to foo()";
83 gdb_suppress_tests;
84 }
85 timeout { fail "run to foo() (timeout)" ; gdb_suppress_tests }
86}
87
88# Restore first executable to its original name, and move
89# second executable into its place. Ensure that the new
90# executable is at least a second older than the old.
91
92gdb_test "shell mv ${binfile} ${binfile1}" "" ""
93gdb_test "shell mv ${binfile2} ${binfile}" "" ""
94gdb_test "shell sleep 1" "" ""
95gdb_test "shell touch ${binfile}" "" ""
96
97# Run a second time; GDB should detect that the executable has changed
98# and reset the breakpoints correctly.
99# Should see "Breakpoint 1, foo () at reread2.c:9"
100
40f33b9b
MS
101if ![isnative] {
102 unsupported "run to foo() second time ";
103} else {
104 gdb_run_cmd
105 gdb_expect {
106 # -re ".*re-reading symbols.*Breakpoint.* foo .* at .*$srcfile2:9.*$gdb_prompt $" {}
107 -re ".*Breakpoint.* foo .* at .*:9.*$gdb_prompt $" {
108 pass "run to foo() second time ";
109 }
110 -re ".*$gdb_prompt $" {
111 fail "run to foo() second time";
112 gdb_suppress_tests;
113 }
114 timeout {
115 fail "run to foo() second time (timeout)" ;
116 gdb_suppress_tests
117 }
c906108c 118 }
c906108c
SS
119}
120
121# End of tests.
122
123gdb_stop_suppressing_tests
124
125return 0
This page took 0.101441 seconds and 4 git commands to generate.