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