forked from Imagelibrary/binutils-gdb
This patch applies the appropriate FIXME notes described in commit 5b6d1e4
"Multi-target support".
"You'll notice that remote.c includes some FIXME notes. These refer to
the fact that the global arrays that hold data for the remote packets
supported are still globals. For example, if we connect to two
different servers/stubs, then each might support different remote
protocol features. They might even be different architectures, like
e.g., one ARM baremetal stub, and a x86 gdbserver, to debug a
host/controller scenario as a single program. That isn't going to
work correctly today, because of said globals. I'm leaving fixing
that for another pass, since it does not appear to be trivial, and I'd
rather land the base work first. It's already useful to be able to
debug multiple instances of the same server (e.g., a distributed
cluster, where you have full control over the servers installed), so I
think as is it's already reasonable incremental progress."
Using this patch it is possible to configure per-remote targets'
feature packets.
Given the following setup for two gdbservers:
~~~~
gdbserver --multi :1234
gdbserver --disable-packet=vCont --multi :2345
~~~~
Before this patch configuring of range-stepping was not possible for one
of two connected remote targets with different support for the vCont
packet. As one of the targets supports vCont, it should be possible to
configure "set range-stepping". However, the output of GDB looks like:
(gdb) target extended-remote :1234
Remote debugging using :1234
(gdb) add-inferior -no-connection
[New inferior 2]
Added inferior 2
(gdb) inferior 2
[Switching to inferior 2 [<null>] (<noexec>)]
(gdb) target extended-remote :2345
Remote debugging using :2345
(gdb) set range-stepping on
warning: Range stepping is not supported by the current target
(gdb) inferior 1
[Switching to inferior 1 [<null>] (<noexec>)]
(gdb) set range-stepping on
warning: Range stepping is not supported by the current target
~~~~
Two warnings are shown. The warning for inferior 1 should not appear
as it is connected to a target supporting the vCont package.
~~~~
(gdb) target extended-remote :1234
Remote debugging using :1234
(gdb) add-inferior -no-connection
[New inferior 2]
Added inferior 2
(gdb) inferior 2
[Switching to inferior 2 [<null>] (<noexec>)]
(gdb) target extended-remote :2345
Remote debugging using :2345
(gdb) set range-stepping on
warning: Range stepping is not supported by the current target
(gdb) inferior 1
[Switching to inferior 1 [<null>] (<noexec>)]
(gdb) set range-stepping on
(gdb)
~~~~
Now only one warning is shown for inferior 2, which is connected to
a target not supporting vCont.
The per-remote target feature array is realized by a new class
remote_features, which stores the per-remote target array and
provides functions to determine supported features of the target.
A remote_target object now has a new member of that class.
Each time a new remote_target object is initialized, a new per-remote
target array is constructed based on the global remote_protocol_packets
array. The global array is initialized in the function _initialize_remote
and can be configured using the command line. Before this patch the
command line configuration affected current targets and future remote
targets (due to the global feature array used by all remote
targets). This behavior is different and the configuration applies as
follows:
- If a target is connected, the command line configuration affects the
current connection. All other existing remote targets are not
affected.
- If not connected, the command line configuration affects future
connections.
The show command displays the current remote target's configuration. If no
remote target is selected the default configuration for future
connections is shown.
If we have for instance the following setup with inferior 2 being
selected:
~~~~
(gdb) info inferiors
Num Description Connection Executable
1 <null> 1 (extended-remote :1234)
* 2 <null> 2 (extended-remote :2345)
~~~~
Before this patch, if we run 'set remote multiprocess-feature-packet', the
following configuration was set:
The feature array of all remote targets (in this setup the two connected
targets) and all future remote connections are affected.
After this patch, it will be configured as follows:
The feature array of target with port :2345 which is currently selected
will be configured. All other existing remote targets are not affected.
The show command 'show remote multiprocess-feature-packet' will display
the configuration of target with port :2345.
Due to this configuration change, it is required to adapt the test
"gdb/testsuite/gdb.multi/multi-target-info-inferiors.exp" to configure the
multiprocess-feature-packet before the connections are created.
To inform the gdb user about the new behaviour of the 'show remote
PACKET-NAME' commands and the new configuration impact for remote
targets using the 'set remote PACKET-NAME' commands the commands'
outputs are adapted. Due to this change it is required to adapt each
test using the set/show remote 'PACKET-NAME' commands.
90 lines
3.2 KiB
Plaintext
90 lines
3.2 KiB
Plaintext
# Copyright 2012-2023 Free Software Foundation, Inc.
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation; either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
standard_testfile
|
|
|
|
if { [prepare_for_testing "failed to prepare" ${testfile}] } {
|
|
return -1
|
|
}
|
|
|
|
if ![runto breakpt] {
|
|
return -1
|
|
}
|
|
|
|
# Basic attempt to read memory from globals.
|
|
gdb_test "x/5w global_var_1" \
|
|
"$hex:\[ \t\]+0\[ \t\]+0\[ \t\]+0\[ \t\]+0\r\n$hex:\[ \t\]+Cannot access memory at address $hex"
|
|
gdb_test "x/5w global_var_2" \
|
|
"$hex:\[ \t\]+Cannot access memory at address $hex"
|
|
|
|
|
|
# Try a find starting from each global, expecting the search to fail
|
|
# due to memory access failure.
|
|
#
|
|
# If EXPECT_WARNING is true, then expect the "Unable to access
|
|
# ... halting search" warning before the "Pattern not found" output.
|
|
# Otherwise, don't expect the warning.
|
|
#
|
|
# (EXPECT_WARNING is necessary because when testing with the RSP
|
|
# against servers that support the remote search memory packet, GDB
|
|
# does not print that "halting search" warning. While there are
|
|
# servers that do print the same warning message as GDB would if it
|
|
# were in charge of the search (like GDBserver), we're only parsing
|
|
# GDB's output here, not the server's output. And while we could read
|
|
# GDBserver's output from $inferior_spawn_id, having GDBserver print
|
|
# the warnings on its terminal doesn't really help users. Much better
|
|
# would be to extend the remote protocol to let the server tell GDB
|
|
# which memory range couldn't be accessed, and then let GDB print the
|
|
# warning instead of the server. See PR gdb/22293.)
|
|
|
|
proc test_not_found {expect_warning} {
|
|
global decimal hex
|
|
|
|
if {$expect_warning} {
|
|
set halting_search_re \
|
|
"warning: Unable to access $decimal bytes of target memory at $hex, halting search\.\r\n"
|
|
} else {
|
|
set halting_search_re ""
|
|
}
|
|
|
|
# Now try a find starting from each global.
|
|
gdb_test "find global_var_0, global_var_2, 0xff" \
|
|
"${halting_search_re}Pattern not found."
|
|
|
|
gdb_test "find global_var_1, global_var_2, 0xff" \
|
|
"${halting_search_re}Pattern not found."
|
|
|
|
gdb_test "find global_var_2, (global_var_2 + 16), 0xff" \
|
|
"${halting_search_re}Pattern not found."
|
|
}
|
|
|
|
# If testing with the RSP, also test with target-side search
|
|
# acceleration disabled. This serves as proxy for servers that don't
|
|
# support the memory search packet, when testing with GDBserver.
|
|
|
|
if {[target_info gdb_protocol] == "remote"
|
|
|| [target_info gdb_protocol] == "extended-remote"} {
|
|
test_not_found 0
|
|
with_test_prefix "search-memory-packet off" {
|
|
gdb_test \
|
|
"set remote search-memory-packet off" \
|
|
"Support for the 'qSearch:memory' packet on the current remote target is set to \"off\"."
|
|
|
|
test_not_found 0
|
|
}
|
|
} else {
|
|
test_not_found 1
|
|
}
|