Commit | Line | Data |
---|---|---|
7b6bb8da | 1 | # Copyright 2005, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. |
9f0d94e8 JB |
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 |
9f0d94e8 | 6 | # (at your option) any later version. |
e22f8b7c | 7 | # |
9f0d94e8 JB |
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 | # |
9f0d94e8 | 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/>. |
9f0d94e8 JB |
15 | |
16 | if $tracelevel then { | |
17 | strace $tracelevel | |
18 | } | |
19 | ||
20 | load_lib "ada.exp" | |
21 | ||
ec3c07fc NS |
22 | if { [skip_ada_tests] } { return -1 } |
23 | ||
8ed5dd9e JB |
24 | # This testcase verifies the behavior of the `start' command, which |
25 | # does not work when we use the gdb stub... | |
26 | if [target_info exists use_gdb_stub] { | |
27 | untested exec_changed.exp | |
28 | return | |
29 | } | |
30 | ||
9f0d94e8 JB |
31 | set testdir "exec_changed" |
32 | file mkdir ${objdir}/${subdir}/${testdir} | |
33 | ||
34 | # Build the first test program (note that cygwin needs the $EXEEXT). | |
35 | set testfile1 "${testdir}/first" | |
36 | set srcfile1 ${srcdir}/${subdir}/${testfile1}.adb | |
37 | set binfile1 ${objdir}/${subdir}/${testfile1}$EXEEXT | |
38 | ||
ec3c07fc NS |
39 | if {[gdb_compile_ada "${srcfile1}" "${binfile1}" executable {debug}] != ""} { |
40 | return -1 | |
9f0d94e8 JB |
41 | } |
42 | ||
43 | # Build the second test program | |
44 | set testfile2 "${testdir}/second" | |
45 | set srcfile2 ${srcdir}/${subdir}/${testfile2}.adb | |
46 | set binfile2 ${objdir}/${subdir}/${testfile2}$EXEEXT | |
47 | ||
ec3c07fc NS |
48 | if {[gdb_compile_ada "${srcfile2}" "${binfile2}" executable {debug}] != ""} { |
49 | return -1 | |
9f0d94e8 JB |
50 | } |
51 | ||
52 | # Start with a fresh gdb. | |
53 | ||
54 | set testfile "${testdir}/common" | |
55 | set binfile ${objdir}/${subdir}/${testfile}$EXEEXT | |
56 | ||
57 | gdb_start | |
58 | gdb_reinitialize_dir $srcdir/$subdir | |
59 | ||
60 | # Load the first executable. | |
61 | ||
de7ff789 | 62 | gdb_test "shell mv ${binfile1} ${binfile}" ".*" "" |
9f0d94e8 JB |
63 | gdb_load ${binfile} |
64 | ||
65 | # Start the program, we should land in the program main procedure | |
b741e217 DJ |
66 | if { [gdb_start_cmd] < 0 } { |
67 | untested start | |
68 | return -1 | |
69 | } | |
70 | ||
71 | gdb_test "" \ | |
9f0d94e8 JB |
72 | "first \\(\\) at .*first.adb.*" \ |
73 | "start first" | |
74 | ||
75 | # Restore first executable to its original name, and move | |
76 | # second executable into its place. Ensure that the new | |
77 | # executable is at least a second newer than the old. | |
78 | ||
de7ff789 MS |
79 | gdb_test "shell mv ${binfile} ${binfile1}" ".*" "" |
80 | gdb_test "shell mv ${binfile2} ${binfile}" ".*" "" | |
81 | gdb_test "shell sleep 1" ".*" "" | |
82 | gdb_test "shell touch ${binfile}" ".*" "" | |
9f0d94e8 | 83 | |
9f0d94e8 JB |
84 | # Start the program a second time, GDB should land in procedure Second |
85 | # this time. | |
86 | ||
b741e217 DJ |
87 | if { [gdb_start_cmd] < 0 } { |
88 | fail "start second" | |
9f0d94e8 | 89 | } else { |
b741e217 | 90 | gdb_test "" \ |
9f0d94e8 JB |
91 | "second \\(\\) at .*second.adb.*" \ |
92 | "start second" | |
93 | } |