]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.base/load-command.exp
gdb_is_target_native -> gdb_protocol_is_native
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / load-command.exp
CommitLineData
1d506c26 1# Copyright 2018-2024 Free Software Foundation, Inc.
3275ef47
SM
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# Test the "load" command.
17
18standard_testfile
19
c7a2ee64
PA
20if [gdb_protocol_is_native] {
21 unsupported "the native target does not support the load command"
22 return
23}
24
3275ef47
SM
25# Disable generation of position independent executable (PIE). Otherwise, we
26# would have to manually specify an offset to load.
27
dbb17692 28set opts {debug nopie}
3275ef47
SM
29
30if [prepare_for_testing "failed to prepare" $testfile $srcfile $opts] {
31 return -1
32}
33
34if ![runto_main] {
3275ef47
SM
35 return -1
36}
37
3275ef47
SM
38# Manually change the value of the_variable.
39gdb_test "print/x the_variable" " = 0x1234" "check initial value of the_variable"
40gdb_test_no_output "set the_variable = 0x5555" "manually change the_variable"
41gdb_test "print/x the_variable" " = 0x5555" "check manually changed value of the_variable"
42
d294324c
TV
43with_test_prefix "reload" {
44 # Re-load the binary using the load command.
45 gdb_test "load ${binfile}" ".*Loading section .data.*Transfer rate:.*" \
46 "re-load binary"
47
48 # Re-loading the binary should have reset the variable value.
49 gdb_test "print/x the_variable" " = 0x1234" \
50 "check initial value of the_variable"
51}