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.
205 lines
6.6 KiB
Plaintext
205 lines
6.6 KiB
Plaintext
# Copyright 1999-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 only on boards that actually use the remote protocol.
|
|
if {[target_info gdb_protocol] != "remote"
|
|
&& [target_info gdb_protocol] != "extended-remote"} {
|
|
unsupported "requires remote protocol"
|
|
return
|
|
}
|
|
|
|
standard_testfile .c
|
|
|
|
set result [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}]
|
|
if {$result != ""} {
|
|
untested "failed to compile"
|
|
return -1
|
|
}
|
|
|
|
gdb_start
|
|
|
|
# Make sure we're disconnected, in case we're testing with an
|
|
# extended-remote board, therefore already connected.
|
|
gdb_test "disconnect" ".*"
|
|
|
|
#
|
|
# Part ONE: Check the down load commands
|
|
#
|
|
|
|
gdb_test "show remote memory-write-packet-size" \
|
|
"The memory-write-packet-size is 0 \\(default\\). The actual limit will be further reduced dependent on the target\." \
|
|
"write-packet default"
|
|
|
|
gdb_test "set remote memory-write-packet-size" \
|
|
"Argument required .integer, `fixed' or `limited'.\." \
|
|
"set write-packet - NULL"
|
|
|
|
gdb_test_no_output "set remote memory-write-packet-size 20"
|
|
gdb_test "show remote memory-write-packet-size" \
|
|
"The memory-write-packet-size is 20. The actual limit will be further reduced dependent on the target\." \
|
|
"set write-packet - small"
|
|
|
|
gdb_test_no_output "set remote memory-write-packet-size 1"
|
|
gdb_test "show remote memory-write-packet-size" \
|
|
"The memory-write-packet-size is 1. The actual limit will be further reduced dependent on the target\." \
|
|
"set write-packet - very-small"
|
|
|
|
gdb_test_no_output "set remote memory-write-packet-size 0"
|
|
gdb_test "show remote memory-write-packet-size" \
|
|
"The memory-write-packet-size is 0 \\(default\\). The actual limit will be further reduced dependent on the target\." \
|
|
"write-packet default again"
|
|
|
|
set test "set remote memory-write-packet-size fixed"
|
|
gdb_test_multiple $test $test {
|
|
-re "Change the packet size. .y or n. " {
|
|
gdb_test_multiple "y" $test {
|
|
-re "$gdb_prompt $" {
|
|
pass $test
|
|
}
|
|
}
|
|
}
|
|
}
|
|
gdb_test "show remote memory-write-packet-size" \
|
|
"The memory-write-packet-size is 0 \\(default\\). Packets are fixed at 16384 bytes\." \
|
|
"write-packet default fixed"
|
|
|
|
gdb_test_no_output "set remote memory-write-packet-size limit"
|
|
gdb_test "show remote memory-write-packet-size" \
|
|
"The memory-write-packet-size is 0 \\(default\\). The actual limit will be further reduced dependent on the target\." \
|
|
"write-packet default limit again"
|
|
|
|
#
|
|
# Part TWO: Check the download behavior.
|
|
#
|
|
|
|
proc gdb_load_timed {executable class writesize} {
|
|
global test gdb_prompt
|
|
set test "timed download `[file tail $executable]' - $class, $writesize"
|
|
|
|
if {$writesize != ""} {
|
|
gdb_test_no_output "set remote memory-write-packet-size $writesize" \
|
|
"$test - set packet size"
|
|
|
|
send_gdb "set remote memory-write-packet-size $class\n"
|
|
gdb_expect 5 {
|
|
-re ".*Change the packet size.*$" {
|
|
send_gdb "y\n"
|
|
gdb_expect 5 {
|
|
-re ".*$gdb_prompt $" {
|
|
pass "$test - set write size class"
|
|
}
|
|
timeout {
|
|
fail "$test - set write size class"
|
|
return
|
|
}
|
|
}
|
|
}
|
|
-re ".*$gdb_prompt $" { }
|
|
timeout {
|
|
fail "$test - set write size class"
|
|
return
|
|
}
|
|
}
|
|
}
|
|
|
|
# Do not try to load using fixed sizes; we may overflow the remote target.
|
|
if { $class == "fixed" } {
|
|
return
|
|
}
|
|
|
|
set load_begin_time [clock clicks]
|
|
set result [gdb_load $executable]
|
|
set load_end_time [clock clicks]
|
|
if {$result != 0} {
|
|
fail "$test - loading executable"
|
|
return
|
|
}
|
|
verbose "$test - time [expr ($load_end_time - $load_begin_time) / 1000] ms"
|
|
pass $test
|
|
}
|
|
|
|
clean_restart $binfile
|
|
|
|
# These download tests won't actually download anything on !is_remote
|
|
# target boards, but we run them anyway because it's simpler, and
|
|
# harmless.
|
|
|
|
# Typically about 400-1 bytes can be downloaded
|
|
gdb_load_timed $binfile "limit" 398
|
|
gdb_load_timed $binfile "limit" 400
|
|
|
|
# Absolute max is 16384
|
|
gdb_load_timed $binfile "fixed" 0
|
|
gdb_load_timed $binfile "fixed" 16385
|
|
|
|
# fall back to the default
|
|
gdb_load_timed $binfile "limit" 0
|
|
|
|
# Get size of data uploaded
|
|
|
|
#
|
|
# Query GDB for the size of various types
|
|
#
|
|
|
|
# Get the size of random_data table (defaults to 48K).
|
|
set sizeof_random_data [get_sizeof "random_data" 48*1024]
|
|
|
|
#
|
|
# Part THREE: Check the upload behavour
|
|
#
|
|
if {![runto_main]} {
|
|
return
|
|
}
|
|
|
|
# Carefully check memory around each of the most common packet edge
|
|
# conditions
|
|
|
|
gdb_test "x/8ub random_data" \
|
|
"<random_data>:\[ \t\]+60\[ \t\]+74\[ \t\]+216\[ \t\]+38\[ \t\]+149\[ \t\]+49\[ \t\]+207\[ \t\]+44"
|
|
|
|
gdb_test "x/8ub random_data + 400 - 4" \
|
|
"<random_data\\+396>:\[ \t\]+185\[ \t\]+255\[ \t\]+50\[ \t\]+140\[ \t\]+237\[ \t\]+172\[ \t\]+143\[ \t\]+93"
|
|
|
|
if {$sizeof_random_data > 16380} {
|
|
gdb_test "x/8ub random_data + 16384 - 4" \
|
|
"<random_data\\+16380>:\[ \t\]+178\[ \t\]+180\[ \t\]+135\[ \t\]+93\[ \t\]+70\[ \t\]+62\[ \t\]+205\[ \t\]+76"
|
|
}
|
|
|
|
# Read a chunk just larger than the packet size (reduce the packet
|
|
# size to make life easier)
|
|
gdb_test_no_output "set remote memory-read-packet-size 16"
|
|
|
|
gdb_test "show remote memory-read-packet-size" \
|
|
"The memory-read-packet-size is 16. Packets are limited to 20 bytes."
|
|
gdb_test "x/17ub random_data" \
|
|
"<random_data>:\[ \t\]+60\[ \t\]+74\[ \t\]+216\[ \t\]+38\[ \t\]+149\[ \t\]+49\[ \t\]+207\[ \t\]+44.*<random_data\\+8>:\[ \t\]+124\[ \t\]+38\[ \t\]+93\[ \t\]+125\[ \t\]+232\[ \t\]+67\[ \t\]+228\[ \t\]+56.*<random_data\\+16>:\[ \t\]+161"
|
|
|
|
# Regression test for gdb/15289. Make sure -1 is accepted and handled
|
|
# as "unlimited".
|
|
gdb_test_no_output "set remote hardware-watchpoint-limit -1"
|
|
gdb_test_no_output "set remote hardware-breakpoint-limit -1"
|
|
|
|
# This is just being thorough. Assume (at least) a 32-bit host int,
|
|
# and make sure 32-bit INT_MAX is accepted by a zinteger command.
|
|
gdb_test_no_output "set remote hardware-watchpoint-limit 2147483647"
|
|
gdb_test_no_output "set remote hardware-breakpoint-limit 2147483647"
|
|
|
|
# Check the X/P/p alias commands display the correct packet names.
|
|
foreach pkt {X P p} {
|
|
gdb_test "show remote ${pkt}-packet" "Support for the '${pkt}' packet on the current remote target is .*"
|
|
}
|
|
|
|
gdb_exit
|