1 # Copyright 2017-2019 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\""
45 if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} {
49 # Start with a fresh gdb.
50 clean_restart ${testfile}
52 # Using the source command to read commands from a file is important,
53 # otherwise section data is freed and reallocated using the same
54 # memory locations and the bug is not exposed.
55 generate_cmd_file $gdbfile $binfile
57 gdb_test "source $gdbfile" ".*source-command-completed.*" \
58 "source $testfile.gdb 1"
59 # Sometimes the failure only occurs on the second invocation.
60 gdb_test "source $gdbfile" ".*source-command-completed.*" \
61 "source $testfile.gdb 2"