]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.base/reread-readsym.exp
Automatic Copyright Year update after running gdb/copyright.py
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / reread-readsym.exp
CommitLineData
4a94e368 1# Copyright 2017-2022 Free Software Foundation, Inc.
41664b45
DG
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
16standard_testfile
17
18set gdbfile [standard_output_file ${testfile}.gdb]
19
20# Test rereading executable. See PR gdb/21337.
21
22proc generate_cmd_file {gdbfile binfile} {
23 set ofd [open $gdbfile w]
24
25 puts $ofd "file ${binfile}"
26 puts $ofd "shell sleep 1; touch ${binfile}"
27 puts $ofd "run"
28 puts $ofd "file"
29 puts $ofd "file ${binfile}"
30 puts $ofd "shell sleep 1; touch ${binfile}"
31 puts $ofd "run"
32 puts $ofd "file"
33 puts $ofd "file ${binfile}"
34 puts $ofd "shell sleep 1; touch ${binfile}"
35 puts $ofd "run"
36 puts $ofd "file"
37 puts $ofd "p \"source-command-completed\""
38 close $ofd
39}
40
41if [use_gdb_stub] {
42 return 0
43}
44
45if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} {
46 return -1
47}
48
41664b45
DG
49# Using the source command to read commands from a file is important,
50# otherwise section data is freed and reallocated using the same
51# memory locations and the bug is not exposed.
52generate_cmd_file $gdbfile $binfile
53
54gdb_test "source $gdbfile" ".*source-command-completed.*" \
55 "source $testfile.gdb 1"
56# Sometimes the failure only occurs on the second invocation.
57gdb_test "source $gdbfile" ".*source-command-completed.*" \
58 "source $testfile.gdb 2"