]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.ada/exec_changed.exp
9e69d136e31b860461ca27da11d9d48eb0d5b37c
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.ada / exec_changed.exp
1 # Copyright 2005-2023 Free Software Foundation, Inc.
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 3 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, see <http://www.gnu.org/licenses/>.
15
16 load_lib "ada.exp"
17
18 require allow_ada_tests
19
20 # This testcase verifies the behavior of the `start' command, which
21 # does not work when we use the gdb stub...
22 require !use_gdb_stub
23
24 standard_ada_testfile first
25
26 # Build the first test program (note that cygwin needs the $EXEEXT).
27 if {[gdb_compile_ada "${srcfile}" "${binfile}$EXEEXT" executable {debug}] != ""} {
28 return -1
29 }
30
31 # Build the second test program
32 set srcfile2 ${srcdir}/${subdir}/${testdir}/second.adb
33 set binfile2 [standard_output_file second$EXEEXT]
34
35 if {[gdb_compile_ada "${srcfile2}" "${binfile2}" executable {debug}] != ""} {
36 return -1
37 }
38
39 # Start with a fresh gdb.
40
41 set common_binfile [standard_output_file common$EXEEXT]
42
43 gdb_start
44 gdb_reinitialize_dir $srcdir/$subdir
45
46 # Load the first executable.
47
48 gdb_test "shell mv ${binfile} ${common_binfile}" "" \
49 "shell mv \${binfile} \${common_binfile}"
50 gdb_load ${common_binfile}
51
52 # Start the program, we should land in the program main procedure
53 if { [gdb_start_cmd] < 0 } {
54 fail start
55 return -1
56 }
57
58 gdb_test "" \
59 "first \\(\\) at .*first.adb.*" \
60 "start first"
61
62 # Restore first executable to its original name, and move
63 # second executable into its place. Ensure that the new
64 # executable is at least a second newer than the old.
65
66 gdb_test "shell mv ${common_binfile} ${binfile}" "" \
67 "shell mv \${common_binfile} \${binfile}"
68 gdb_test "shell mv ${binfile2} ${common_binfile}" "" \
69 "shell mv \${binfile2} \${common_binfile}"
70 gdb_test "shell sleep 1" "" "shell sleep 1, once"
71 gdb_test "shell touch ${common_binfile}" "" \
72 "shell touch \${common_binfile}"
73
74 # Start the program a second time, GDB should land in procedure Second
75 # this time.
76
77 if { [gdb_start_cmd] < 0 } {
78 fail "start second"
79 } else {
80 gdb_test "" \
81 "second \\(\\) at .*second.adb.*" \
82 "start second"
83 }
84
85 # Try again, this time with just changing the file time of first.
86
87 clean_restart "${binfile}$EXEEXT"
88
89 # Ensure we don't accidently use the main symbol cache.
90 gdb_test_no_output "mt set symbol-cache-size 0"
91
92 # Put something in the symbol lookup cache that will get looked up when
93 # starting after having re-read symbols. PR 17855.
94 gdb_breakpoint break_me
95
96 gdb_test "shell touch ${binfile}$EXEEXT" "" \
97 "shell touch \${binfile}\$EXEEXT"
98 gdb_test "shell sleep 1" "" "shell sleep 1, twice"
99
100 if { [gdb_start_cmd] < 0 } {
101 # PR 17855: At this point gdb may have crashed or gotten an internal
102 # error, but we still need to detect this. Just issue any simple command
103 # to verify gdb is still running. This will establish in gdb.log whether
104 # gdb is still running.
105 gdb_test_no_output "set \$check_gdb_running = 0" "check gdb running"
106 fail "start just first"
107 } else {
108 gdb_test "" \
109 "first \\(\\) at .*first.adb.*" \
110 "start just first"
111 }