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.
361 lines
11 KiB
Plaintext
361 lines
11 KiB
Plaintext
# Copyright 2011-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/>.
|
|
|
|
load_lib "trace-support.exp"
|
|
|
|
require allow_shlib_tests
|
|
|
|
require gdb_trace_common_supports_arch
|
|
|
|
standard_testfile
|
|
set libfile1 "change-loc-1"
|
|
set libfile2 "change-loc-2"
|
|
set executable $testfile
|
|
set libsrc1 $srcdir/$subdir/$libfile1.c
|
|
set libsrc2 $srcdir/$subdir/$libfile2.c
|
|
set lib_sl1 [standard_output_file $libfile1.sl]
|
|
set lib_sl2 [standard_output_file $libfile2.sl]
|
|
|
|
set lib_opts debug
|
|
|
|
# Some targets have leading underscores on assembly symbols.
|
|
set additional_flags [list debug shlib=$lib_sl1 shlib_load [gdb_target_symbol_prefix_flags]]
|
|
|
|
if { [gdb_compile_shlib $libsrc1 $lib_sl1 $lib_opts] != ""
|
|
|| [gdb_compile_shlib $libsrc2 $lib_sl2 $lib_opts] != ""
|
|
|| [gdb_compile $srcdir/$subdir/$srcfile $binfile executable $additional_flags] != ""} {
|
|
untested "failed to compile"
|
|
return -1
|
|
}
|
|
|
|
clean_restart $executable
|
|
|
|
gdb_load_shlib $lib_sl1
|
|
gdb_load_shlib $lib_sl2
|
|
|
|
if ![runto_main] {
|
|
return -1
|
|
}
|
|
|
|
if {![gdb_target_supports_trace]} {
|
|
unsupported "current target does not support trace"
|
|
return -1
|
|
}
|
|
|
|
|
|
# Set tracepoint during tracing experiment.
|
|
|
|
proc tracepoint_change_loc_1 { trace_type } {
|
|
with_test_prefix "1 $trace_type" {
|
|
global testfile
|
|
global srcfile
|
|
global pcreg
|
|
global gdb_prompt
|
|
|
|
clean_restart ${testfile}
|
|
if ![runto_main] {
|
|
return -1
|
|
}
|
|
gdb_test_no_output "delete break 1"
|
|
|
|
# Set a tracepoint we'll never meet. Just to avoid the
|
|
# complain after type `tstart' later.
|
|
gdb_test "next" ".*"
|
|
gdb_test "trace main" \
|
|
"Tracepoint \[0-9\] at.* file .*$srcfile, line.*" \
|
|
"set tracepoint on main"
|
|
|
|
gdb_test "break marker" \
|
|
"Breakpoint.*at.* file .*$srcfile, line.*" \
|
|
"breakpoint on marker"
|
|
|
|
gdb_test_no_output "tstart"
|
|
|
|
gdb_test "continue" ".*Breakpoint.*marker.*at.*$srcfile.*" \
|
|
"continue to marker 1"
|
|
# Set a tracepoint during tracing.
|
|
set test "set tracepoint on set_tracepoint"
|
|
gdb_test_multiple "${trace_type} set_tracepoint" $test {
|
|
-re "Target returns error code .* too far .*$gdb_prompt $" {
|
|
if [string equal $trace_type "ftrace"] {
|
|
# The target was unable to install the fast tracepoint
|
|
# (e.g., jump pad too far from tracepoint).
|
|
pass "$test (too far)"
|
|
} else {
|
|
fail $test
|
|
}
|
|
}
|
|
-re "\r\n$gdb_prompt $" {
|
|
pass $test
|
|
}
|
|
}
|
|
|
|
gdb_trace_setactions "set action for tracepoint" "" \
|
|
"collect \$$pcreg" "^$"
|
|
|
|
# tracepoint has two locations after shlib change-loc-1 is loaded.
|
|
gdb_test "info trace" \
|
|
"Num Type\[ \]+Disp Enb Address\[ \]+What.*
|
|
\[0-9\]+\[\t \]+\(|fast \)tracepoint\[ \]+keep y.*\<MULTIPLE\>.*4\.1.* in func4.*4\.2.* in func4.*" \
|
|
"tracepoint with two locations"
|
|
|
|
set test "continue to marker 2"
|
|
gdb_test_multiple "continue" $test {
|
|
-re "Target returns error code .* too far .*$gdb_prompt $" {
|
|
if [string equal $trace_type "ftrace"] {
|
|
# Expected if the target was unable to install the
|
|
# fast tracepoint (e.g., jump pad too far from
|
|
# tracepoint).
|
|
pass "$test (too far)"
|
|
# Skip the rest of the tests.
|
|
return
|
|
} else {
|
|
fail "continue to marker 2"
|
|
fail $test
|
|
}
|
|
|
|
}
|
|
-re ".*Breakpoint.*marker.*at.*$srcfile.*$gdb_prompt $" {
|
|
pass "continue to marker 2"
|
|
}
|
|
}
|
|
|
|
# tracepoint has three locations after shlib change-loc-2 is
|
|
# loaded.
|
|
gdb_test "info trace" \
|
|
"Num Type\[ \]+Disp Enb Address\[ \]+What.*
|
|
\[0-9\]+\[\t \]+\(|fast \)tracepoint\[ \]+keep y.*\<MULTIPLE\>.*4\.1.* in func4.*4\.2.* in func4.*4\.3.* in func4 .*" \
|
|
"tracepoint with three locations"
|
|
|
|
gdb_test "continue" ".*Breakpoint.*marker.*at.*$srcfile.*" \
|
|
"continue to marker 3"
|
|
|
|
# shlib is unloaded, there are still three locations, but one
|
|
# is pending.
|
|
gdb_test "info trace" \
|
|
"Num Type\[ \]+Disp Enb Address\[ \]+What.*
|
|
\[0-9\]+\[\t \]+\(|fast \)tracepoint\[ \]+keep y.*\<MULTIPLE\>.*
|
|
(4\.\[1-3].* in func4.*\tinstalled on target.*){2}" \
|
|
"tracepoint with two locations - installed (unload)"
|
|
|
|
gdb_test "info trace" \
|
|
"Num Type\[ \]+Disp Enb Address\[ \]+What.*
|
|
\[0-9\]+\[\t \]+\(|fast \)tracepoint\[ \]+keep y.*\<MULTIPLE\>.*
|
|
4\.\[1-3].* \<PENDING\>\[\t \]+set_tracepoint.*" \
|
|
"tracepoint with two locations - pending (unload)"
|
|
|
|
gdb_test_no_output "tstop"
|
|
|
|
gdb_test "tfind" "Found trace frame 0, tracepoint 4.*" \
|
|
"tfind frame 0"
|
|
gdb_test "tfind" \
|
|
"Target failed to find requested trace frame\\..*"
|
|
}
|
|
}
|
|
|
|
# Set pending tracepoint.
|
|
|
|
proc tracepoint_change_loc_2 { trace_type } {
|
|
with_test_prefix "2 $trace_type" {
|
|
global srcdir
|
|
global srcfile
|
|
global subdir
|
|
global pcreg
|
|
global binfile
|
|
global gdb_prompt
|
|
|
|
clean_restart
|
|
|
|
gdb_test_multiple "${trace_type} set_tracepoint" "set pending tracepoint" {
|
|
-re ".*Make \(|fast \)tracepoint pending.*y or \\\[n\\\]. $" {
|
|
gdb_test "y" "\(Fast t|T\)racepoint.*set_tracepoint.*pending." "set pending tracepoint"
|
|
}
|
|
}
|
|
|
|
gdb_trace_setactions "set action for tracepoint" "" \
|
|
"collect \$$pcreg" "^$"
|
|
|
|
# tracepoint has no location information now. Make sure nothing
|
|
# else is displayed.
|
|
gdb_test "info trace" \
|
|
"Num Type\[ \]+Disp Enb Address\[ \]+What.*
|
|
\[0-9\]+\[\t \]+\(|fast \)tracepoint\[ \]+keep y.*PENDING.*set_tracepoint\r\n\[\t \]+collect \\$$pcreg\r" \
|
|
"single pending tracepoint info (without symbols)"
|
|
|
|
gdb_load ${binfile}
|
|
# tracepoint has one location after executable is loaded.
|
|
gdb_test "info trace" \
|
|
"Num Type\[ \]+Disp Enb Address\[ \]+What.*
|
|
\[0-9\]+\[\t \]+\(|fast \)tracepoint\[ \]+keep y.*func4.*" \
|
|
"tracepoint with one location"
|
|
|
|
set main_bp 0
|
|
gdb_test_multiple "break -q main" "set breakpoint on main" {
|
|
-re "Breakpoint (\[0-9\]*) at .*, line.*$gdb_prompt $" {
|
|
set main_bp $expect_out(1,string)
|
|
}
|
|
}
|
|
gdb_run_cmd
|
|
|
|
gdb_test "" \
|
|
".*Breakpoint.*main.*at.*$srcfile.*" \
|
|
"run to main"
|
|
gdb_test_no_output "delete break $main_bp"
|
|
|
|
# tracepoint has two locations after shlib change-loc-1 is loaded.
|
|
gdb_test "info trace" \
|
|
"Num Type\[ \]+Disp Enb Address\[ \]+What.*
|
|
\[0-9\]+\[\t \]+\(|fast \)tracepoint\[ \]+keep y.*\<MULTIPLE\>.*1\.1.* in func4.*1\.2.* in func4.*" \
|
|
"tracepoint with two locations"
|
|
|
|
gdb_test "break marker" "Breakpoint.*at.* file .*$srcfile, line.*" \
|
|
"breakpoint on marker"
|
|
|
|
# tracepoint with two locations will be downloaded and installed.
|
|
set test "tstart"
|
|
gdb_test_multiple "tstart" $test {
|
|
-re "^tstart\r\n$gdb_prompt $" {
|
|
pass "tstart"
|
|
}
|
|
-re "Target returns error code .* too far .*$gdb_prompt $" {
|
|
if [string equal $trace_type "ftrace"] {
|
|
# The target was unable to install the fast tracepoint
|
|
# (e.g., jump pad too far from tracepoint).
|
|
pass "$test (too far)"
|
|
# Skip the rest of the tests.
|
|
return
|
|
} else {
|
|
fail $test
|
|
}
|
|
}
|
|
}
|
|
|
|
gdb_test "continue" ".*Breakpoint.*marker.*at.*$srcfile.*" \
|
|
"continue to marker 1"
|
|
|
|
gdb_test "continue" ".*Breakpoint.*marker.*at.*$srcfile.*" \
|
|
"continue to marker 2"
|
|
|
|
# tracepoint has three locations after shlib change-loc-2 is loaded.
|
|
gdb_test "info trace" \
|
|
"Num Type\[ \]+Disp Enb Address\[ \]+What.*
|
|
\[0-9\]+\[\t \]+\(|fast \)tracepoint\[ \]+keep y.*\<MULTIPLE\>.*1\.1.* in func4.*1\.2.* in func4.*1\.3.* in func4 .*" \
|
|
"tracepoint with three locations"
|
|
|
|
gdb_test "continue" ".*Breakpoint.*marker.*at.*$srcfile.*" \
|
|
"continue to marker 3"
|
|
|
|
# shlib is unloaded, there are still three locations, but one is pending.
|
|
gdb_test "info trace" \
|
|
"Num Type\[ \]+Disp Enb Address\[ \]+What.*
|
|
\[0-9\]+\[\t \]+\(|fast \)tracepoint\[ \]+keep y.*\<MULTIPLE\>.*
|
|
(1\.\[1-3].* in func4.*\tinstalled on target.*){2}" \
|
|
"tracepoint with two locations - installed (unload)"
|
|
|
|
gdb_test "info trace" \
|
|
"Num Type\[ \]+Disp Enb Address\[ \]+What.*
|
|
\[0-9\]+\[\t \]+\(|fast \)tracepoint\[ \]+keep y.*\<MULTIPLE\>.*
|
|
1\.\[1-3].* \<PENDING\>\[\t \]+set_tracepoint.*" \
|
|
"tracepoint with two locations - pending (unload)"
|
|
|
|
gdb_test_no_output "tstop"
|
|
|
|
gdb_test "tfind" "Found trace frame 0, tracepoint 1.*" "tfind frame 0"
|
|
gdb_test "tfind" "Found trace frame 1, tracepoint 1.*" "tfind frame 1"
|
|
gdb_test "tfind" "Found trace frame 2, tracepoint 1.*" "tfind frame 2"
|
|
gdb_test "tfind" "Target failed to find requested trace frame\\..*"
|
|
}
|
|
}
|
|
|
|
# Test that setting a tracepoint while the trace experiment is ongoing
|
|
# doesn't work when we force-disable the InstallInTrace RSP feature.
|
|
|
|
proc tracepoint_install_in_trace_disabled { trace_type } {
|
|
with_test_prefix "InstallInTrace disabled: $trace_type" {
|
|
global testfile
|
|
global srcfile
|
|
global pcreg
|
|
global gdb_prompt
|
|
|
|
clean_restart ${testfile}
|
|
if ![runto_main] {
|
|
return -1
|
|
}
|
|
|
|
# This test only makes sense with the remote target.
|
|
if ![gdb_is_target_remote] {
|
|
return
|
|
}
|
|
|
|
gdb_test_no_output "delete break 1"
|
|
|
|
# Set a tracepoint we'll never meet. Just to avoid the
|
|
# complain after `tstart' later.
|
|
gdb_test "next" ".*"
|
|
gdb_test "trace main" \
|
|
"Tracepoint \[0-9\] at.* file .*$srcfile, line.*" \
|
|
"set tracepoint on main"
|
|
|
|
gdb_test "break marker" "Breakpoint.*at.* file .*$srcfile, line.*" \
|
|
"breakpoint on marker"
|
|
|
|
gdb_test_no_output "tstart"
|
|
|
|
# Force-disable the InstallInTrace RSP feature.
|
|
gdb_test \
|
|
"set remote install-in-trace-packet off" \
|
|
"Support for the 'InstallInTrace' packet on the current remote target is set to \"off\"."
|
|
|
|
# Set a tracepoint while a trace experiment is ongoing.
|
|
gdb_test "${trace_type} set_tracepoint" \
|
|
"racepoint .* at .* set_tracepoint.*" \
|
|
"set tracepoint on set_tracepoint"
|
|
|
|
gdb_trace_setactions "set action for tracepoint" "" \
|
|
"collect \$$pcreg" "^$"
|
|
|
|
# Make sure the tracepoint is _not_ installed on the target.
|
|
gdb_test "info trace" \
|
|
"Num Type\[ \]+Disp Enb Address\[ \]+What.*
|
|
\[0-9\]+\[\t \]+\(|fast \)tracepoint\[ \]+keep y.*installed on target.*\<MULTIPLE\>.*4\.1.* in func4.*not installed on target.*4\.2.* in func4.*not installed on target.*" \
|
|
"tracepoint is not installed"
|
|
|
|
gdb_test "continue" ".*Breakpoint.*marker.*at.*$srcfile.*" \
|
|
"continue to marker"
|
|
|
|
gdb_test_no_output "tstop"
|
|
|
|
# Nothing should have been collected.
|
|
gdb_test "tfind" "Target failed to find requested trace frame\\..*"
|
|
}
|
|
}
|
|
|
|
tracepoint_change_loc_1 "trace"
|
|
tracepoint_change_loc_2 "trace"
|
|
tracepoint_install_in_trace_disabled "trace"
|
|
|
|
# Re-compile test case with IPA.
|
|
set libipa [get_in_proc_agent]
|
|
gdb_load_shlib $libipa
|
|
|
|
if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile executable \
|
|
[list debug nowarnings shlib=$libipa shlib=$lib_sl1 shlib_load] ] != "" } {
|
|
untested "failed to compile"
|
|
return -1
|
|
}
|
|
|
|
tracepoint_change_loc_1 "ftrace"
|
|
tracepoint_change_loc_2 "ftrace"
|
|
tracepoint_install_in_trace_disabled "ftrace"
|