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.
147 lines
4.9 KiB
Plaintext
147 lines
4.9 KiB
Plaintext
# Copyright 2017-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/>.
|
|
|
|
# Test "info inferiors" and "info connections" with multiple targets.
|
|
|
|
load_lib gdb-python.exp
|
|
|
|
source $srcdir/$subdir/multi-target.exp.tcl
|
|
|
|
if {![multi_target_prepare]} {
|
|
return
|
|
}
|
|
|
|
# Cache the result of calling allow_python_tests into a local variable.
|
|
set run_python_tests [allow_python_tests]
|
|
|
|
# Test "info inferiors" and "info connections". MULTI_PROCESS
|
|
# indicates whether the multi-process feature of remote targets is
|
|
# turned off or on.
|
|
proc test_info_inferiors {multi_process} {
|
|
|
|
setup "off" $multi_process
|
|
|
|
if { $::run_python_tests } {
|
|
gdb_test_no_output "source ${::remote_python_file}" "load python file"
|
|
}
|
|
|
|
# Get the description for inferior INF for when the current
|
|
# inferior id is CURRENT.
|
|
proc inf_desc {inf current} {
|
|
set ws "\[ \t\]+"
|
|
global decimal
|
|
upvar multi_process multi_process
|
|
|
|
if {($multi_process == "off") && ($inf == 2 || $inf == 5)} {
|
|
set desc "Remote target"
|
|
} else {
|
|
set desc "process ${decimal}"
|
|
}
|
|
|
|
set desc "${inf}${ws}${desc}${ws}"
|
|
if {$inf == $current} {
|
|
return "\\* $desc"
|
|
} else {
|
|
return " $desc"
|
|
}
|
|
}
|
|
|
|
# Get the "Num" column for CONNECTION for when the current
|
|
# inferior id is CURRENT_INF.
|
|
proc connection_num {connection current_inf} {
|
|
switch $current_inf {
|
|
"4" { set current_connection "1"}
|
|
"5" { set current_connection "4"}
|
|
"6" { set current_connection "5"}
|
|
default { set current_connection $current_inf}
|
|
}
|
|
if {$connection == $current_connection} {
|
|
return "\\* $connection"
|
|
} else {
|
|
return " $connection"
|
|
}
|
|
}
|
|
|
|
set ws "\[ \t\]+"
|
|
global decimal binfile
|
|
|
|
# Test "info connections" and "info inferior" by switching to each
|
|
# inferior one by one.
|
|
for {set inf 1} {$inf <= 6} {incr inf} {
|
|
with_test_prefix "inferior $inf" {
|
|
gdb_test "inferior $inf" "Switching to inferior $inf.*"
|
|
|
|
gdb_test "info connections" \
|
|
[multi_line \
|
|
"Num${ws}What${ws}Description${ws}" \
|
|
"[connection_num 1 $inf]${ws}native${ws}Native process${ws}" \
|
|
"[connection_num 2 $inf]${ws}extended-remote localhost:$decimal${ws}Extended remote target using gdb-specific protocol${ws}" \
|
|
"[connection_num 3 $inf]${ws}core${ws}Local core dump file${ws}" \
|
|
"[connection_num 4 $inf]${ws}extended-remote localhost:$decimal${ws}Extended remote target using gdb-specific protocol${ws}" \
|
|
"[connection_num 5 $inf]${ws}core${ws}Local core dump file${ws}" \
|
|
]
|
|
|
|
if { $::run_python_tests } {
|
|
gdb_test "python info_connections()" \
|
|
[multi_line \
|
|
"Num${ws}What${ws}Description" \
|
|
"[connection_num 1 $inf]${ws}native${ws}Native process" \
|
|
"[connection_num 2 $inf]${ws}extended-remote localhost:$decimal${ws}Extended remote target using gdb-specific protocol" \
|
|
"[connection_num 3 $inf]${ws}core${ws}Local core dump file" \
|
|
"[connection_num 4 $inf]${ws}extended-remote localhost:$decimal${ws}Extended remote target using gdb-specific protocol" \
|
|
"[connection_num 5 $inf]${ws}core${ws}Local core dump file" \
|
|
]
|
|
}
|
|
|
|
gdb_test "info inferiors" \
|
|
[multi_line \
|
|
"Num${ws}Description${ws}Connection${ws}Executable${ws}" \
|
|
"[inf_desc 1 $inf]1 \\(native\\)${ws}${binfile}${ws}" \
|
|
"[inf_desc 2 $inf]2 \\(extended-remote localhost:$decimal\\)${ws}${binfile}${ws}" \
|
|
"[inf_desc 3 $inf]3 \\(core\\)${ws}${binfile}${ws}" \
|
|
"[inf_desc 4 $inf]1 \\(native\\)${ws}${binfile}${ws}" \
|
|
"[inf_desc 5 $inf]4 \\(extended-remote localhost:$decimal\\)${ws}${binfile}${ws}" \
|
|
"[inf_desc 6 $inf]5 \\(core\\)${ws}${binfile}${ws}" \
|
|
]
|
|
|
|
if { $::run_python_tests } {
|
|
gdb_test "python info_inferiors()" \
|
|
[multi_line \
|
|
"Inferior 1, Connection #1: native" \
|
|
"Inferior 2, Connection #2: extended-remote localhost:$decimal" \
|
|
"Inferior 3, Connection #3: core" \
|
|
"Inferior 4, Connection #1: native" \
|
|
"Inferior 5, Connection #4: extended-remote localhost:$decimal" \
|
|
"Inferior 6, Connection #5: core" \
|
|
]
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if { $run_python_tests } {
|
|
set remote_python_file [gdb_remote_download host \
|
|
${srcdir}/${subdir}/${testfile}.py]
|
|
}
|
|
|
|
# Test "info inferiors" and "info connections" commands.
|
|
with_test_prefix "info-inferiors" {
|
|
foreach_with_prefix multi_process {"on" "off"} {
|
|
test_info_inferiors $multi_process
|
|
}
|
|
}
|
|
|
|
multi_target_cleanup
|