1 # Copyright 2017-2024 Free Software Foundation, Inc.
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.
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.
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/>.
18 set gdbfile [standard_output_file ${testfile}.gdb]
20 # Test rereading executable. See PR gdb/21337.
22 proc generate_cmd_file {gdbfile binfile} {
23 set ofd [open $gdbfile w]
25 puts $ofd "file ${binfile}"
26 puts $ofd "shell sleep 1; touch ${binfile}"
29 puts $ofd "file ${binfile}"
30 puts $ofd "shell sleep 1; touch ${binfile}"
33 puts $ofd "file ${binfile}"
34 puts $ofd "shell sleep 1; touch ${binfile}"
37 puts $ofd "p \"source-command-completed\""
43 if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} {
47 # Using the source command to read commands from a file is important,
48 # otherwise section data is freed and reallocated using the same
49 # memory locations and the bug is not exposed.
50 generate_cmd_file $gdbfile $binfile
52 gdb_test "source $gdbfile" ".*source-command-completed.*" \
53 "source $testfile.gdb 1"
54 # Sometimes the failure only occurs on the second invocation.
55 gdb_test "source $gdbfile" ".*source-command-completed.*" \
56 "source $testfile.gdb 2"