From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7869) id B67413858D1E; Mon, 30 Jan 2023 14:32:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B67413858D1E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1675089163; bh=iMelIEhgsPts6njwVoBldnlJclmJblmhwBEhaPxj+Gg=; h=From:To:Subject:Date:From; b=wi/OUBacDsqfGjLKVQ3OLDN4IHgkt6Qcb5dIQnK3K53kQ4l4LJqQbLjal2mVfRXtx VgjK7PVEhahZIqD9sE4gxZtDHda3QxUD/q+1mHOteeyIxWbH/TThBvyXTmkWCdBmwY YEeBmQ/77RVbbvs3QAwq6ixcArUs7cprgH079BlY= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Christina Schimpe To: gdb-cvs@sourceware.org Subject: [binutils-gdb] gdb: Make global feature array a per-remote target array X-Act-Checkin: binutils-gdb X-Git-Author: Christina Schimpe X-Git-Refname: refs/heads/master X-Git-Oldrev: 594a01c217143dce2f1f3181bcca4047b4a44107 X-Git-Newrev: ff52c0736a637fec4938f4b957bc8847c709b13c Message-Id: <20230130143243.B67413858D1E@sourceware.org> Date: Mon, 30 Jan 2023 14:32:43 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Dff52c0736a63= 7fec4938f4b957bc8847c709b13c commit ff52c0736a637fec4938f4b957bc8847c709b13c Author: Christina Schimpe Date: Thu Nov 18 16:13:16 2021 +0000 gdb: Make global feature array a per-remote target array =20 This patch applies the appropriate FIXME notes described in commit 5b6d= 1e4 "Multi-target support". =20 "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." =20 Using this patch it is possible to configure per-remote targets' feature packets. =20 Given the following setup for two gdbservers: =20 ~~~~ gdbserver --multi :1234 gdbserver --disable-packet=3DvCont --multi :2345 ~~~~ =20 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: =20 (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 [] ()] (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 [] ()] (gdb) set range-stepping on warning: Range stepping is not supported by the current target ~~~~ =20 Two warnings are shown. The warning for inferior 1 should not appear as it is connected to a target supporting the vCont package. =20 ~~~~ (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 [] ()] (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 [] ()] (gdb) set range-stepping on (gdb) ~~~~ =20 Now only one warning is shown for inferior 2, which is connected to a target not supporting vCont. =20 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. =20 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_rem= ote 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: =20 - If a target is connected, the command line configuration affects the current connection. All other existing remote targets are not affected. =20 - If not connected, the command line configuration affects future connections. =20 The show command displays the current remote target's configuration. I= f no remote target is selected the default configuration for future connections is shown. =20 If we have for instance the following setup with inferior 2 being selected: ~~~~ (gdb) info inferiors Num Description Connection Executable 1 1 (extended-remote :1234) * 2 2 (extended-remote :2345) ~~~~ =20 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. =20 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. =20 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. =20 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. Diff: --- gdb/NEWS | 14 + gdb/doc/gdb.texinfo | 10 +- gdb/remote.c | 1462 ++++++++++------= ---- gdb/testsuite/gdb.base/cond-eval-mode.exp | 9 +- gdb/testsuite/gdb.base/dprintf.exp | 5 +- gdb/testsuite/gdb.base/find-unmapped.exp | 5 +- .../gdb.base/hbreak-in-shr-unsupported.exp | 4 +- gdb/testsuite/gdb.base/remote.exp | 2 +- .../gdb.multi/multi-target-info-inferiors.exp | 6 +- gdb/testsuite/gdb.multi/multi-target.exp.tcl | 8 +- .../gdb.server/connect-without-multi-process.exp | 4 +- gdb/testsuite/gdb.server/exit-multiple-threads.exp | 9 +- gdb/testsuite/gdb.server/ext-restart.exp | 5 +- gdb/testsuite/gdb.server/ext-wrapper.exp | 5 +- gdb/testsuite/gdb.server/server-exec-info.exp | 5 +- gdb/testsuite/gdb.server/server-kill.exp | 4 +- .../gdb.server/stop-reply-no-thread-multi.exp | 8 +- gdb/testsuite/gdb.server/stop-reply-no-thread.exp | 9 +- .../gdb.threads/process-dies-while-handling-bp.exp | 9 +- gdb/testsuite/gdb.trace/change-loc.exp | 4 +- gdb/testsuite/gdb.trace/qtro.exp | 6 +- 21 files changed, 868 insertions(+), 725 deletions(-) diff --git a/gdb/NEWS b/gdb/NEWS index 2bc1672632a..9a40932b79d 100644 --- a/gdb/NEWS +++ b/gdb/NEWS @@ -3,6 +3,20 @@ =20 *** Changes since GDB 13 =20 +* Multi-target feature configuration + + GDB now supports the individual configuration of remote targets' feature + sets. Based on the current selection of a target, the commands 'set rem= ote + -packet (on|off|auto)' and 'show remote -packet' can be used= to + configure a target's feature packet and to display its configuration, + respectively. + + The configuration of the packet itself applies to the currently selected + target (if available). If no target is selected, it applies to future r= emote + connections. Similarly, the show commands print the configuration of the + currently selected target. If no remote target is selected, the default + configuration for future connections is shown. + * MI version 1 has been removed. =20 * GDB has initial built-in support for the Debugger Adapter Protocol. diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index b5fad2cb16e..afbb4dea998 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -23880,8 +23880,14 @@ in @value{GDBN}. You may want to report the probl= em to the @value{GDBN} developers. =20 For each packet @var{name}, the command to enable or disable the -packet is @code{set remote @var{name}-packet}. The available settings -are: +packet is @code{set remote @var{name}-packet}. If you configure a packet,= the +configuration will apply for all future remote targets if no target is sel= ected. +In case there is a target selected, only the configuration of the current = target +is changed. All other existing remote targets' features are not affected. +The command to print the current configuration of a packet is +@code{show remote @var{name}-packet}. It displays the current remote targ= et's +configuration. If no remote target is selected, the default configuration= for +future connections is shown. The available settings are: =20 @multitable @columnfractions 0.28 0.32 0.25 @item Command Name diff --git a/gdb/remote.c b/gdb/remote.c index aaac434bc2b..e4333291de8 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -70,12 +70,12 @@ #include "gdbsupport/agent.h" #include "btrace.h" #include "record-btrace.h" -#include #include "gdbsupport/scoped_restore.h" #include "gdbsupport/environ.h" #include "gdbsupport/byte-vector.h" #include "gdbsupport/search.h" #include +#include #include #include "async-event.h" #include "gdbsupport/selftest.h" @@ -116,6 +116,36 @@ enum packet_support PACKET_DISABLE }; =20 +/* Convert the packet support auto_boolean to a name used for gdb printing= . */ + +static const char * +get_packet_support_name (auto_boolean support) +{ + switch (support) + { + case AUTO_BOOLEAN_TRUE: + return "on"; + case AUTO_BOOLEAN_FALSE: + return "off"; + case AUTO_BOOLEAN_AUTO: + return "auto"; + default: + gdb_assert_not_reached ("invalid var_auto_boolean"); + } +} + +/* Convert the target type (future remote target or currently connected ta= rget) + to a name used for gdb printing. */ + +static const char * +get_target_type_name (bool target_connected) +{ + if (target_connected) + return _("on the current remote target"); + else + return _("on future remote targets"); +} + /* Analyze a packet's return value and update the packet config accordingly. */ =20 @@ -126,6 +156,155 @@ enum packet_result PACKET_UNKNOWN }; =20 +/* Enumeration of packets for a remote target. */ + +enum { + PACKET_vCont =3D 0, + PACKET_X, + PACKET_qSymbol, + PACKET_P, + PACKET_p, + PACKET_Z0, + PACKET_Z1, + PACKET_Z2, + PACKET_Z3, + PACKET_Z4, + PACKET_vFile_setfs, + PACKET_vFile_open, + PACKET_vFile_pread, + PACKET_vFile_pwrite, + PACKET_vFile_close, + PACKET_vFile_unlink, + PACKET_vFile_readlink, + PACKET_vFile_fstat, + PACKET_qXfer_auxv, + PACKET_qXfer_features, + PACKET_qXfer_exec_file, + PACKET_qXfer_libraries, + PACKET_qXfer_libraries_svr4, + PACKET_qXfer_memory_map, + PACKET_qXfer_osdata, + PACKET_qXfer_threads, + PACKET_qXfer_statictrace_read, + PACKET_qXfer_traceframe_info, + PACKET_qXfer_uib, + PACKET_qGetTIBAddr, + PACKET_qGetTLSAddr, + PACKET_qSupported, + PACKET_qTStatus, + PACKET_QPassSignals, + PACKET_QCatchSyscalls, + PACKET_QProgramSignals, + PACKET_QSetWorkingDir, + PACKET_QStartupWithShell, + PACKET_QEnvironmentHexEncoded, + PACKET_QEnvironmentReset, + PACKET_QEnvironmentUnset, + PACKET_qCRC, + PACKET_qSearch_memory, + PACKET_vAttach, + PACKET_vRun, + PACKET_QStartNoAckMode, + PACKET_vKill, + PACKET_qXfer_siginfo_read, + PACKET_qXfer_siginfo_write, + PACKET_qAttached, + + /* Support for conditional tracepoints. */ + PACKET_ConditionalTracepoints, + + /* Support for target-side breakpoint conditions. */ + PACKET_ConditionalBreakpoints, + + /* Support for target-side breakpoint commands. */ + PACKET_BreakpointCommands, + + /* Support for fast tracepoints. */ + PACKET_FastTracepoints, + + /* Support for static tracepoints. */ + PACKET_StaticTracepoints, + + /* Support for installing tracepoints while a trace experiment is + running. */ + PACKET_InstallInTrace, + + PACKET_bc, + PACKET_bs, + PACKET_TracepointSource, + PACKET_QAllow, + PACKET_qXfer_fdpic, + PACKET_QDisableRandomization, + PACKET_QAgent, + PACKET_QTBuffer_size, + PACKET_Qbtrace_off, + PACKET_Qbtrace_bts, + PACKET_Qbtrace_pt, + PACKET_qXfer_btrace, + + /* Support for the QNonStop packet. */ + PACKET_QNonStop, + + /* Support for the QThreadEvents packet. */ + PACKET_QThreadEvents, + + /* Support for multi-process extensions. */ + PACKET_multiprocess_feature, + + /* Support for enabling and disabling tracepoints while a trace + experiment is running. */ + PACKET_EnableDisableTracepoints_feature, + + /* Support for collecting strings using the tracenz bytecode. */ + PACKET_tracenz_feature, + + /* Support for continuing to run a trace experiment while GDB is + disconnected. */ + PACKET_DisconnectedTracing_feature, + + /* Support for qXfer:libraries-svr4:read with a non-empty annex. */ + PACKET_augmented_libraries_svr4_read_feature, + + /* Support for the qXfer:btrace-conf:read packet. */ + PACKET_qXfer_btrace_conf, + + /* Support for the Qbtrace-conf:bts:size packet. */ + PACKET_Qbtrace_conf_bts_size, + + /* Support for swbreak+ feature. */ + PACKET_swbreak_feature, + + /* Support for hwbreak+ feature. */ + PACKET_hwbreak_feature, + + /* Support for fork events. */ + PACKET_fork_event_feature, + + /* Support for vfork events. */ + PACKET_vfork_event_feature, + + /* Support for the Qbtrace-conf:pt:size packet. */ + PACKET_Qbtrace_conf_pt_size, + + /* Support for exec events. */ + PACKET_exec_event_feature, + + /* Support for query supported vCont actions. */ + PACKET_vContSupported, + + /* Support remote CTRL-C. */ + PACKET_vCtrlC, + + /* Support TARGET_WAITKIND_NO_RESUMED. */ + PACKET_no_resumed, + + /* Support for memory tagging, allocation tag fetch/store + packets and the tag violation stop replies. */ + PACKET_memory_tagging_feature, + + PACKET_MAX +}; + struct threads_listing_context; =20 /* Stub vCont actions support. @@ -394,6 +573,96 @@ static const target_info remote_target_info =3D { remote_doc }; =20 +/* Description of a remote packet. */ + +struct packet_description +{ + /* Name of the packet used for gdb output. */ + const char *name; + + /* Title of the packet, used by the set/show remote name-packet + commands to identify the individual packages and gdb output. */ + const char *title; +}; + +/* Configuration of a remote packet. */ + +struct packet_config +{ + /* If auto, GDB auto-detects support for this packet or feature, + either through qSupported, or by trying the packet and looking + at the response. If true, GDB assumes the target supports this + packet. If false, the packet is disabled. Configs that don't + have an associated command always have this set to auto. */ + enum auto_boolean detect; + + /* Does the target support this packet? */ + enum packet_support support; +}; + +/* This global array contains packet descriptions (name and title). */ +static packet_description packets_descriptions[PACKET_MAX]; +/* This global array contains the default configuration for every new + per-remote target array. */ +static packet_config remote_protocol_packets[PACKET_MAX]; + +/* Description of a remote target's features. It stores the configuration + and provides functions to determine supported features of the target. = */ + +struct remote_features +{ + remote_features () + { + std::copy (std::begin (remote_protocol_packets), + std::end (remote_protocol_packets), + std::begin (m_protocol_packets)); + } + ~remote_features () =3D default; + + DISABLE_COPY_AND_ASSIGN (remote_features); + + /* Returns whether a given packet defined by its enum value is supported= . */ + enum packet_support packet_support (int) const; + + /* Returns the packet's corresponding "set remote foo-packet" command + state. See struct packet_config for more details. */ + enum auto_boolean packet_set_cmd_state (int packet) const + { return m_protocol_packets[packet].detect; } + + /* Returns true if the multi-process extensions are in effect. */ + int remote_multi_process_p () const + { return packet_support (PACKET_multiprocess_feature) =3D=3D PACKET_ENAB= LE; } + + /* Returns true if fork events are supported. */ + int remote_fork_event_p () const + { return packet_support (PACKET_fork_event_feature) =3D=3D PACKET_ENABLE= ; } + + /* Returns true if vfork events are supported. */ + int remote_vfork_event_p () const + { return packet_support (PACKET_vfork_event_feature) =3D=3D PACKET_ENABL= E; } + + /* Returns true if exec events are supported. */ + int remote_exec_event_p () const + { return packet_support (PACKET_exec_event_feature) =3D=3D PACKET_ENABLE= ; } + + /* Returns true if memory tagging is supported, false otherwise. */ + bool remote_memory_tagging_p () const + { return packet_support (PACKET_memory_tagging_feature) =3D=3D PACKET_EN= ABLE; } + + /* Reset all packets back to "unknown support". Called when opening a + new connection to a remote target. */ + void reset_all_packet_configs_support (); + +/* Check result value in BUF for packet WHICH_PACKET and update the packet= 's + support configuration accordingly. */ + packet_result packet_ok (const char *buf, const int which_packet); + packet_result packet_ok (const gdb::char_vector &buf, const int which_pa= cket); + + /* The per-remote target array which stores a remote's packet + configurations. */ + packet_config m_protocol_packets[PACKET_MAX]; +}; + class remote_target : public process_stratum_target { public: @@ -584,8 +853,16 @@ public: =20 bool supports_string_tracing () override; =20 + int remote_supports_cond_tracepoints (); + bool supports_evaluation_of_breakpoint_conditions () override; =20 + int remote_supports_fast_tracepoints (); + + int remote_supports_static_tracepoints (); + + int remote_supports_install_in_trace (); + bool can_run_breakpoint_commands () override; =20 void trace_init () override; @@ -932,19 +1209,21 @@ public: /* Remote specific methods. */ const gdb_byte *writebuf, ULONGEST offset, LONGEST len, ULONGEST *xfered_len, - struct packet_config *packet); + const unsigned int which_packet); =20 target_xfer_status remote_read_qxfer (const char *object_name, const char *annex, gdb_byte *readbuf, ULONGEST offset, LONGEST len, ULONGEST *xfered_len, - struct packet_config *packet); + const unsigned int which_packet); =20 void push_stop_reply (struct stop_reply *new_event); =20 bool vcont_r_supported (); =20 + remote_features m_features; + private: =20 bool start_remote_1 (int from_tty, int extended_p); @@ -1067,7 +1346,12 @@ static CORE_ADDR remote_address_masked (CORE_ADDR); =20 static int stub_unpack_int (const char *buff, int fieldlength); =20 -struct packet_config; +static void set_remote_protocol_packet_cmd (const char *args, int from_tty, + cmd_list_element *c); + +static void show_packet_config_cmd (ui_file *file, + const unsigned int which_packet, + remote_target *remote); =20 static void show_remote_protocol_packet_cmd (struct ui_file *file, int from_tty, @@ -1889,34 +2173,52 @@ remote_target::get_memory_read_packet_size () return size; } =20 -=0C +static enum packet_support packet_config_support (const packet_config *con= fig); =20 -struct packet_config - { - const char *name; - const char *title; =20 - /* If auto, GDB auto-detects support for this packet or feature, - either through qSupported, or by trying the packet and looking - at the response. If true, GDB assumes the target supports this - packet. If false, the packet is disabled. Configs that don't - have an associated command always have this set to auto. */ - enum auto_boolean detect; +static void +set_remote_protocol_packet_cmd (const char *args, int from_tty, + cmd_list_element *c) +{ + remote_target *remote =3D get_current_remote_target (); + gdb_assert (c->var.has_value ()); =20 - /* The "show remote foo-packet" command created for this packet. */ - cmd_list_element *show_cmd; + auto *default_config =3D static_cast (c->context ()); + const int packet_idx =3D std::distance (remote_protocol_packets, + default_config); =20 - /* Does the target support this packet? */ - enum packet_support support; - }; + if (packet_idx >=3D 0 && packet_idx < PACKET_MAX) + { + const char *name =3D packets_descriptions[packet_idx].name; + const auto_boolean value =3D c->var->get (); + const char *support =3D get_packet_support_name (value); + const char *target_type =3D get_target_type_name (remote !=3D nullpt= r); =20 -static enum packet_support packet_config_support (struct packet_config *co= nfig); -static enum packet_support packet_support (int packet); + if (remote !=3D nullptr) + remote->m_features.m_protocol_packets[packet_idx].detect =3D value; + else + remote_protocol_packets[packet_idx].detect =3D value; + + gdb_printf (_("Support for the '%s' packet %s is set to \"%s\".\n"),= name, + target_type, support); + return; + } + + internal_error (_("Could not find config for %s"), c->name); +} =20 static void -show_packet_config_cmd (ui_file *file, struct packet_config *config) +show_packet_config_cmd (ui_file *file, const unsigned int which_packet, + remote_target *remote) { const char *support =3D "internal-error"; + const char *target_type =3D get_target_type_name (remote !=3D nullptr); + + packet_config *config; + if (remote !=3D nullptr) + config =3D &remote->m_features.m_protocol_packets[which_packet]; + else + config =3D &remote_protocol_packets[which_packet]; =20 switch (packet_config_support (config)) { @@ -1934,25 +2236,30 @@ show_packet_config_cmd (ui_file *file, struct packe= t_config *config) { case AUTO_BOOLEAN_AUTO: gdb_printf (file, - _("Support for the `%s' packet " - "is auto-detected, currently %s.\n"), - config->name, support); + _("Support for the '%s' packet %s is \"auto\", " + "currently %s.\n"), + packets_descriptions[which_packet].name, target_type, + support); break; case AUTO_BOOLEAN_TRUE: case AUTO_BOOLEAN_FALSE: gdb_printf (file, - _("Support for the `%s' packet is currently %s.\n"), - config->name, support); + _("Support for the '%s' packet %s is \"%s\".\n"), + packets_descriptions[which_packet].name, target_type, + get_packet_support_name (config->detect)); break; } } =20 static void -add_packet_config_cmd (struct packet_config *config, const char *name, +add_packet_config_cmd (const unsigned int which_packet, const char *name, const char *title, int legacy) { - config->name =3D name; - config->title =3D title; + packets_descriptions[which_packet].name =3D name; + packets_descriptions[which_packet].title =3D title; + + packet_config *config =3D &remote_protocol_packets[which_packet]; + gdb::unique_xmalloc_ptr set_doc =3D xstrprintf ("Set use of remote protocol `%s' (%s) packet.", name, title); @@ -1965,10 +2272,11 @@ add_packet_config_cmd (struct packet_config *config= , const char *name, =3D add_setshow_auto_boolean_cmd (cmd_name.release (), class_obscure, &config->detect, set_doc.get (), show_doc.get (), NULL, /* help_doc */ - NULL, + set_remote_protocol_packet_cmd, show_remote_protocol_packet_cmd, &remote_set_cmdlist, &remote_show_cmdlist); - config->show_cmd =3D cmds.show; + cmds.show->set_context (config); + cmds.set->set_context (config); =20 /* set/show remote NAME-packet {auto,on,off} -- legacy. */ if (legacy) @@ -2019,9 +2327,12 @@ packet_check_result (const gdb::char_vector &buf) return packet_check_result (buf.data ()); } =20 -static enum packet_result -packet_ok (const char *buf, struct packet_config *config) +packet_result +remote_features::packet_ok (const char *buf, const int which_packet) { + packet_config *config =3D &m_protocol_packets[which_packet]; + packet_description *descr =3D &packets_descriptions[which_packet]; + enum packet_result result; =20 if (config->detect !=3D AUTO_BOOLEAN_TRUE @@ -2037,7 +2348,7 @@ packet_ok (const char *buf, struct packet_config *con= fig) if (config->support =3D=3D PACKET_SUPPORT_UNKNOWN) { remote_debug_printf ("Packet %s (%s) is supported", - config->name, config->title); + descr->name, descr->title); config->support =3D PACKET_ENABLE; } break; @@ -2049,17 +2360,17 @@ packet_ok (const char *buf, struct packet_config *c= onfig) /* If the stub previously indicated that the packet was supported then there is a protocol error. */ error (_("Protocol error: %s (%s) conflicting enabled responses."), - config->name, config->title); + descr->name, descr->title); } else if (config->detect =3D=3D AUTO_BOOLEAN_TRUE) { /* The user set it wrong. */ error (_("Enabled packet %s (%s) not recognized by stub"), - config->name, config->title); + descr->name, descr->title); } =20 - remote_debug_printf ("Packet %s (%s) is NOT supported", - config->name, config->title); + remote_debug_printf ("Packet %s (%s) is NOT supported", descr->name, + descr->title); config->support =3D PACKET_DISABLE; break; } @@ -2067,171 +2378,10 @@ packet_ok (const char *buf, struct packet_config *= config) return result; } =20 -static enum packet_result -packet_ok (const gdb::char_vector &buf, struct packet_config *config) -{ - return packet_ok (buf.data (), config); -} - -enum { - PACKET_vCont =3D 0, - PACKET_X, - PACKET_qSymbol, - PACKET_P, - PACKET_p, - PACKET_Z0, - PACKET_Z1, - PACKET_Z2, - PACKET_Z3, - PACKET_Z4, - PACKET_vFile_setfs, - PACKET_vFile_open, - PACKET_vFile_pread, - PACKET_vFile_pwrite, - PACKET_vFile_close, - PACKET_vFile_unlink, - PACKET_vFile_readlink, - PACKET_vFile_fstat, - PACKET_qXfer_auxv, - PACKET_qXfer_features, - PACKET_qXfer_exec_file, - PACKET_qXfer_libraries, - PACKET_qXfer_libraries_svr4, - PACKET_qXfer_memory_map, - PACKET_qXfer_osdata, - PACKET_qXfer_threads, - PACKET_qXfer_statictrace_read, - PACKET_qXfer_traceframe_info, - PACKET_qXfer_uib, - PACKET_qGetTIBAddr, - PACKET_qGetTLSAddr, - PACKET_qSupported, - PACKET_qTStatus, - PACKET_QPassSignals, - PACKET_QCatchSyscalls, - PACKET_QProgramSignals, - PACKET_QSetWorkingDir, - PACKET_QStartupWithShell, - PACKET_QEnvironmentHexEncoded, - PACKET_QEnvironmentReset, - PACKET_QEnvironmentUnset, - PACKET_qCRC, - PACKET_qSearch_memory, - PACKET_vAttach, - PACKET_vRun, - PACKET_QStartNoAckMode, - PACKET_vKill, - PACKET_qXfer_siginfo_read, - PACKET_qXfer_siginfo_write, - PACKET_qAttached, - - /* Support for conditional tracepoints. */ - PACKET_ConditionalTracepoints, - - /* Support for target-side breakpoint conditions. */ - PACKET_ConditionalBreakpoints, - - /* Support for target-side breakpoint commands. */ - PACKET_BreakpointCommands, - - /* Support for fast tracepoints. */ - PACKET_FastTracepoints, - - /* Support for static tracepoints. */ - PACKET_StaticTracepoints, - - /* Support for installing tracepoints while a trace experiment is - running. */ - PACKET_InstallInTrace, - - PACKET_bc, - PACKET_bs, - PACKET_TracepointSource, - PACKET_QAllow, - PACKET_qXfer_fdpic, - PACKET_QDisableRandomization, - PACKET_QAgent, - PACKET_QTBuffer_size, - PACKET_Qbtrace_off, - PACKET_Qbtrace_bts, - PACKET_Qbtrace_pt, - PACKET_qXfer_btrace, - - /* Support for the QNonStop packet. */ - PACKET_QNonStop, - - /* Support for the QThreadEvents packet. */ - PACKET_QThreadEvents, - - /* Support for multi-process extensions. */ - PACKET_multiprocess_feature, - - /* Support for enabling and disabling tracepoints while a trace - experiment is running. */ - PACKET_EnableDisableTracepoints_feature, - - /* Support for collecting strings using the tracenz bytecode. */ - PACKET_tracenz_feature, - - /* Support for continuing to run a trace experiment while GDB is - disconnected. */ - PACKET_DisconnectedTracing_feature, - - /* Support for qXfer:libraries-svr4:read with a non-empty annex. */ - PACKET_augmented_libraries_svr4_read_feature, - - /* Support for the qXfer:btrace-conf:read packet. */ - PACKET_qXfer_btrace_conf, - - /* Support for the Qbtrace-conf:bts:size packet. */ - PACKET_Qbtrace_conf_bts_size, - - /* Support for swbreak+ feature. */ - PACKET_swbreak_feature, - - /* Support for hwbreak+ feature. */ - PACKET_hwbreak_feature, - - /* Support for fork events. */ - PACKET_fork_event_feature, - - /* Support for vfork events. */ - PACKET_vfork_event_feature, - - /* Support for the Qbtrace-conf:pt:size packet. */ - PACKET_Qbtrace_conf_pt_size, - - /* Support for exec events. */ - PACKET_exec_event_feature, - - /* Support for query supported vCont actions. */ - PACKET_vContSupported, - - /* Support remote CTRL-C. */ - PACKET_vCtrlC, - - /* Support TARGET_WAITKIND_NO_RESUMED. */ - PACKET_no_resumed, - - /* Support for memory tagging, allocation tag fetch/store - packets and the tag violation stop replies. */ - PACKET_memory_tagging_feature, - - PACKET_MAX -}; - -/* FIXME: needs to be per-remote-target. Ignoring this for now, - assuming all remote targets are the same server (thus all support - the same packets). */ -static struct packet_config remote_protocol_packets[PACKET_MAX]; - -/* Returns the packet's corresponding "set remote foo-packet" command - state. See struct packet_config for more details. */ - -static enum auto_boolean -packet_set_cmd_state (int packet) +packet_result +remote_features::packet_ok (const gdb::char_vector &buf, const int which_p= acket) { - return remote_protocol_packets[packet].detect; + return packet_ok (buf.data (), which_packet); } =20 /* Returns whether a given packet or feature is supported. This takes @@ -2239,7 +2389,7 @@ packet_set_cmd_state (int packet) command, which may be used to bypass auto-detection. */ =20 static enum packet_support -packet_config_support (struct packet_config *config) +packet_config_support (const packet_config *config) { switch (config->detect) { @@ -2254,14 +2404,10 @@ packet_config_support (struct packet_config *config) } } =20 -/* Same as packet_config_support, but takes the packet's enum value as - argument. */ - -static enum packet_support -packet_support (int packet) +packet_support +remote_features::packet_support (int packet) const { - struct packet_config *config =3D &remote_protocol_packets[packet]; - + const packet_config *config =3D &m_protocol_packets[packet]; return packet_config_support (config); } =20 @@ -2270,21 +2416,19 @@ show_remote_protocol_packet_cmd (struct ui_file *fi= le, int from_tty, struct cmd_list_element *c, const char *value) { - struct packet_config *packet; + remote_target *remote =3D get_current_remote_target (); gdb_assert (c->var.has_value ()); =20 - for (packet =3D remote_protocol_packets; - packet < &remote_protocol_packets[PACKET_MAX]; - packet++) + auto *default_config =3D static_cast (c->context ()); + const int packet_idx =3D std::distance (remote_protocol_packets, + default_config); + + if (packet_idx >=3D 0 && packet_idx < PACKET_MAX) { - if (c =3D=3D packet->show_cmd) - { - show_packet_config_cmd (file, packet); - return; - } + show_packet_config_cmd (file, packet_idx, remote); + return; } - internal_error (_("Could not find config for %s"), - c->name); + internal_error (_("Could not find config for %s"), c->name); } =20 /* Should we try one of the 'Z' requests? */ @@ -2308,10 +2452,23 @@ static void set_remote_protocol_Z_packet_cmd (const char *args, int from_tty, struct cmd_list_element *c) { + remote_target *remote =3D get_current_remote_target (); int i; =20 for (i =3D 0; i < NR_Z_PACKET_TYPES; i++) - remote_protocol_packets[PACKET_Z0 + i].detect =3D remote_Z_packet_dete= ct; + { + if (remote !=3D nullptr) + remote->m_features.m_protocol_packets[PACKET_Z0 + i].detect + =3D remote_Z_packet_detect; + else + remote_protocol_packets[PACKET_Z0 + i].detect =3D remote_Z_packet_detect; + } + + const char *support =3D get_packet_support_name (remote_Z_packet_detect); + const char *target_type =3D get_target_type_name (remote !=3D nullptr); + gdb_printf (_("Use of Z packets %s is set to \"%s\".\n"), target_type, + support); + } =20 static void @@ -2319,52 +2476,11 @@ show_remote_protocol_Z_packet_cmd (struct ui_file *= file, int from_tty, struct cmd_list_element *c, const char *value) { + remote_target *remote =3D get_current_remote_target (); int i; =20 for (i =3D 0; i < NR_Z_PACKET_TYPES; i++) - { - show_packet_config_cmd (file, &remote_protocol_packets[PACKET_Z0 + i= ]); - } -} - -/* Returns true if the multi-process extensions are in effect. */ - -static int -remote_multi_process_p (struct remote_state *rs) -{ - return packet_support (PACKET_multiprocess_feature) =3D=3D PACKET_ENABLE; -} - -/* Returns true if fork events are supported. */ - -static int -remote_fork_event_p (struct remote_state *rs) -{ - return packet_support (PACKET_fork_event_feature) =3D=3D PACKET_ENABLE; -} - -/* Returns true if vfork events are supported. */ - -static int -remote_vfork_event_p (struct remote_state *rs) -{ - return packet_support (PACKET_vfork_event_feature) =3D=3D PACKET_ENABLE; -} - -/* Returns true if exec events are supported. */ - -static int -remote_exec_event_p (struct remote_state *rs) -{ - return packet_support (PACKET_exec_event_feature) =3D=3D PACKET_ENABLE; -} - -/* Returns true if memory tagging is supported, false otherwise. */ - -static bool -remote_memory_tagging_p () -{ - return packet_support (PACKET_memory_tagging_feature) =3D=3D PACKET_ENAB= LE; + show_packet_config_cmd (file, PACKET_Z0 + i, remote); } =20 /* Insert fork catchpoint target routine. If fork events are enabled @@ -2373,9 +2489,7 @@ remote_memory_tagging_p () int remote_target::insert_fork_catchpoint (int pid) { - struct remote_state *rs =3D get_remote_state (); - - return !remote_fork_event_p (rs); + return !m_features.remote_fork_event_p (); } =20 /* Remove fork catchpoint target routine. Nothing to do, just @@ -2393,9 +2507,7 @@ remote_target::remove_fork_catchpoint (int pid) int remote_target::insert_vfork_catchpoint (int pid) { - struct remote_state *rs =3D get_remote_state (); - - return !remote_vfork_event_p (rs); + return !m_features.remote_vfork_event_p (); } =20 /* Remove vfork catchpoint target routine. Nothing to do, just @@ -2413,9 +2525,7 @@ remote_target::remove_vfork_catchpoint (int pid) int remote_target::insert_exec_catchpoint (int pid) { - struct remote_state *rs =3D get_remote_state (); - - return !remote_exec_event_p (rs); + return !m_features.remote_exec_event_p (); } =20 /* Remove exec catchpoint target routine. Nothing to do, just @@ -2444,10 +2554,10 @@ remote_target::remote_query_attached (int pid) struct remote_state *rs =3D get_remote_state (); size_t size =3D get_remote_packet_size (); =20 - if (packet_support (PACKET_qAttached) =3D=3D PACKET_DISABLE) + if (m_features.packet_support (PACKET_qAttached) =3D=3D PACKET_DISABLE) return 0; =20 - if (remote_multi_process_p (rs)) + if (m_features.remote_multi_process_p ()) xsnprintf (rs->buf.data (), size, "qAttached:%x", pid); else xsnprintf (rs->buf.data (), size, "qAttached"); @@ -2455,8 +2565,7 @@ remote_target::remote_query_attached (int pid) putpkt (rs->buf); getpkt (&rs->buf, 0); =20 - switch (packet_ok (rs->buf, - &remote_protocol_packets[PACKET_qAttached])) + switch (m_features.packet_ok (rs->buf, PACKET_qAttached)) { case PACKET_OK: if (strcmp (rs->buf.data (), "1") =3D=3D 0) @@ -2656,8 +2765,7 @@ remote_target::remote_notice_new_inferior (ptid_t cur= rthread, bool executing) thread, so notifications are emitted in a sensible order. */ if (find_inferior_pid (this, currthread.pid ()) =3D=3D NULL) { - struct remote_state *rs =3D get_remote_state (); - bool fake_pid_p =3D !remote_multi_process_p (rs); + bool fake_pid_p =3D !m_features.remote_multi_process_p (); =20 inf =3D remote_add_inferior (fake_pid_p, currthread.pid (), -1, 1); @@ -2720,7 +2828,7 @@ record_currthread (struct remote_state *rs, ptid_t cu= rrthread) void remote_target::pass_signals (gdb::array_view pass_sig= nals) { - if (packet_support (PACKET_QPassSignals) !=3D PACKET_DISABLE) + if (m_features.packet_support (PACKET_QPassSignals) !=3D PACKET_DISABLE) { char *pass_packet, *p; int count =3D 0; @@ -2754,7 +2862,7 @@ remote_target::pass_signals (gdb::array_view pass_signals) { putpkt (pass_packet); getpkt (&rs->buf, 0); - packet_ok (rs->buf, &remote_protocol_packets[PACKET_QPassSignals]); + m_features.packet_ok (rs->buf, PACKET_QPassSignals); xfree (rs->last_pass_packet); rs->last_pass_packet =3D pass_packet; } @@ -2774,7 +2882,7 @@ remote_target::set_syscall_catchpoint (int pid, bool = needed, int any_count, enum packet_result result; int n_sysno =3D 0; =20 - if (packet_support (PACKET_QCatchSyscalls) =3D=3D PACKET_DISABLE) + if (m_features.packet_support (PACKET_QCatchSyscalls) =3D=3D PACKET_DISA= BLE) { /* Not supported. */ return 1; @@ -2827,7 +2935,7 @@ remote_target::set_syscall_catchpoint (int pid, bool = needed, int any_count, =20 putpkt (catch_packet); getpkt (&rs->buf, 0); - result =3D packet_ok (rs->buf, &remote_protocol_packets[PACKET_QCatchSys= calls]); + result =3D m_features.packet_ok (rs->buf, PACKET_QCatchSyscalls); if (result =3D=3D PACKET_OK) return 0; else @@ -2840,7 +2948,7 @@ remote_target::set_syscall_catchpoint (int pid, bool = needed, int any_count, void remote_target::program_signals (gdb::array_view signa= ls) { - if (packet_support (PACKET_QProgramSignals) !=3D PACKET_DISABLE) + if (m_features.packet_support (PACKET_QProgramSignals) !=3D PACKET_DISAB= LE) { char *packet, *p; int count =3D 0; @@ -2875,7 +2983,7 @@ remote_target::program_signals (gdb::array_view signals) { putpkt (packet); getpkt (&rs->buf, 0); - packet_ok (rs->buf, &remote_protocol_packets[PACKET_QProgramSignals]); + m_features.packet_ok (rs->buf, PACKET_QProgramSignals); xfree (rs->last_program_signals_packet); rs->last_program_signals_packet =3D packet; } @@ -2941,12 +3049,12 @@ remote_target::set_continue_thread (ptid_t ptid) void remote_target::set_general_process () { - struct remote_state *rs =3D get_remote_state (); - /* If the remote can't handle multiple processes, don't bother. */ - if (!remote_multi_process_p (rs)) + if (!m_features.remote_multi_process_p ()) return; =20 + remote_state *rs =3D get_remote_state (); + /* We only need to change the remote current thread if it's pointing at some other process. */ if (rs->general_thread.pid () !=3D inferior_ptid.pid ()) @@ -3096,9 +3204,8 @@ char * remote_target::write_ptid (char *buf, const char *endbuf, ptid_t ptid) { int pid, tid; - struct remote_state *rs =3D get_remote_state (); =20 - if (remote_multi_process_p (rs)) + if (m_features.remote_multi_process_p ()) { pid =3D ptid.pid (); if (pid < 0) @@ -3860,7 +3967,7 @@ int remote_target::remote_get_threads_with_qxfer (threads_listing_context *con= text) { #if defined(HAVE_LIBEXPAT) - if (packet_support (PACKET_qXfer_threads) =3D=3D PACKET_ENABLE) + if (m_features.packet_support (PACKET_qXfer_threads) =3D=3D PACKET_ENABL= E) { gdb::optional xml =3D target_read_stralloc (this, TARGET_OBJECT_THREADS, NULL); @@ -4052,7 +4159,7 @@ remote_target::extra_thread_info (thread_info *tp) if (!extra.empty ()) return extra.c_str (); =20 - if (packet_support (PACKET_qXfer_threads) =3D=3D PACKET_ENABLE) + if (m_features.packet_support (PACKET_qXfer_threads) =3D=3D PACKET_ENABL= E) { /* If we're using qXfer:threads:read, then the extra info is included in the XML. So if we didn't have anything cached, @@ -4477,7 +4584,6 @@ remote_target::get_current_thread (const char *wait_s= tatus) thread_info * remote_target::add_current_inferior_and_thread (const char *wait_status) { - struct remote_state *rs =3D get_remote_state (); bool fake_pid_p =3D false; =20 switch_to_no_thread (); @@ -4488,7 +4594,7 @@ remote_target::add_current_inferior_and_thread (const= char *wait_status) =20 if (curr_ptid !=3D null_ptid) { - if (!remote_multi_process_p (rs)) + if (!m_features.remote_multi_process_p ()) fake_pid_p =3D true; } else @@ -4750,7 +4856,6 @@ remote_target::start_remote_1 (int from_tty, int exte= nded_p) REMOTE_SCOPED_DEBUG_ENTER_EXIT; =20 struct remote_state *rs =3D get_remote_state (); - struct packet_config *noack_config; =20 /* Signal other parts that we're going through the initial setup, and so things may not be stable yet. E.g., we don't try to @@ -4774,7 +4879,7 @@ remote_target::start_remote_1 (int from_tty, int exte= nded_p) remote_query_supported (); =20 /* If the stub wants to get a QAllow, compose one and send it. */ - if (packet_support (PACKET_QAllow) !=3D PACKET_DISABLE) + if (m_features.packet_support (PACKET_QAllow) !=3D PACKET_DISABLE) set_permissions (); =20 /* gdbserver < 7.7 (before its fix from 2013-12-11) did reply to any @@ -4790,7 +4895,10 @@ remote_target::start_remote_1 (int from_tty, int ext= ended_p) putpkt (v_mustreplyempty); getpkt (&rs->buf, 0); if (strcmp (rs->buf.data (), "OK") =3D=3D 0) - remote_protocol_packets[PACKET_vFile_setfs].support =3D PACKET_DISAB= LE; + { + m_features.m_protocol_packets[PACKET_vFile_setfs].support + =3D PACKET_DISABLE; + } else if (strcmp (rs->buf.data (), "") !=3D 0) error (_("Remote replied unexpectedly to '%s': %s"), v_mustreplyempt= y, rs->buf.data ()); @@ -4809,12 +4917,11 @@ remote_target::start_remote_1 (int from_tty, int ex= tended_p) If FALSE, then don't activate noack mode, regardless of what the stub claimed should be the default with qSupported. */ =20 - noack_config =3D &remote_protocol_packets[PACKET_QStartNoAckMode]; - if (packet_config_support (noack_config) !=3D PACKET_DISABLE) + if (m_features.packet_support (PACKET_QStartNoAckMode) !=3D PACKET_DISAB= LE) { putpkt ("QStartNoAckMode"); getpkt (&rs->buf, 0); - if (packet_ok (rs->buf, noack_config) =3D=3D PACKET_OK) + if (m_features.packet_ok (rs->buf, PACKET_QStartNoAckMode) =3D=3D PA= CKET_OK) rs->noack_mode =3D 1; } =20 @@ -4844,7 +4951,7 @@ remote_target::start_remote_1 (int from_tty, int exte= nded_p) =20 if (target_is_non_stop_p ()) { - if (packet_support (PACKET_QNonStop) !=3D PACKET_ENABLE) + if (m_features.packet_support (PACKET_QNonStop) !=3D PACKET_ENABLE) error (_("Non-stop mode requested, but remote " "does not support non-stop")); =20 @@ -4861,7 +4968,7 @@ remote_target::start_remote_1 (int from_tty, int exte= nded_p) stopped. */ this->update_thread_list (); } - else if (packet_support (PACKET_QNonStop) =3D=3D PACKET_ENABLE) + else if (m_features.packet_support (PACKET_QNonStop) =3D=3D PACKET_ENABL= E) { /* Don't assume that the stub can operate in all-stop mode. Request it explicitly. */ @@ -5102,16 +5209,13 @@ extended_remote_target::open (const char *name, int= from_tty) open_1 (name, from_tty, 1 /*extended_p */); } =20 -/* Reset all packets back to "unknown support". Called when opening a - new connection to a remote target. */ - -static void -reset_all_packet_configs_support (void) +void +remote_features::reset_all_packet_configs_support () { int i; =20 for (i =3D 0; i < PACKET_MAX; i++) - remote_protocol_packets[i].support =3D PACKET_SUPPORT_UNKNOWN; + m_protocol_packets[i].support =3D PACKET_SUPPORT_UNKNOWN; } =20 /* Initialize all packet configs. */ @@ -5141,7 +5245,7 @@ remote_target::remote_check_symbols () inferiors without execution. */ gdb_assert (target_has_execution ()); =20 - if (packet_support (PACKET_qSymbol) =3D=3D PACKET_DISABLE) + if (m_features.packet_support (PACKET_qSymbol) =3D=3D PACKET_DISABLE) return; =20 /* Make sure the remote is pointing at the right process. Note @@ -5157,7 +5261,7 @@ remote_target::remote_check_symbols () =20 putpkt ("qSymbol::"); getpkt (&reply, 0); - packet_ok (reply, &remote_protocol_packets[PACKET_qSymbol]); + m_features.packet_ok (reply, PACKET_qSymbol); =20 while (startswith (reply.data (), "qSymbol:")) { @@ -5281,7 +5385,7 @@ remote_supported_packet (remote_target *remote, return; } =20 - remote_protocol_packets[feature->packet].support =3D support; + remote->m_features.m_protocol_packets[feature->packet].support =3D suppo= rt; } =20 void @@ -5489,47 +5593,57 @@ remote_target::remote_query_supported () containing no features. */ =20 rs->buf[0] =3D 0; - if (packet_support (PACKET_qSupported) !=3D PACKET_DISABLE) + if (m_features.packet_support (PACKET_qSupported) !=3D PACKET_DISABLE) { std::string q; =20 - if (packet_set_cmd_state (PACKET_multiprocess_feature) !=3D AUTO_BOO= LEAN_FALSE) + if (m_features.packet_set_cmd_state (PACKET_multiprocess_feature) + !=3D AUTO_BOOLEAN_FALSE) remote_query_supported_append (&q, "multiprocess+"); =20 - if (packet_set_cmd_state (PACKET_swbreak_feature) !=3D AUTO_BOOLEAN_= FALSE) + if (m_features.packet_set_cmd_state (PACKET_swbreak_feature) + !=3D AUTO_BOOLEAN_FALSE) remote_query_supported_append (&q, "swbreak+"); - if (packet_set_cmd_state (PACKET_hwbreak_feature) !=3D AUTO_BOOLEAN_= FALSE) + + if (m_features.packet_set_cmd_state (PACKET_hwbreak_feature) + !=3D AUTO_BOOLEAN_FALSE) remote_query_supported_append (&q, "hwbreak+"); =20 remote_query_supported_append (&q, "qRelocInsn+"); =20 - if (packet_set_cmd_state (PACKET_fork_event_feature) + if (m_features.packet_set_cmd_state (PACKET_fork_event_feature) !=3D AUTO_BOOLEAN_FALSE) remote_query_supported_append (&q, "fork-events+"); - if (packet_set_cmd_state (PACKET_vfork_event_feature) + + if (m_features.packet_set_cmd_state (PACKET_vfork_event_feature) !=3D AUTO_BOOLEAN_FALSE) remote_query_supported_append (&q, "vfork-events+"); - if (packet_set_cmd_state (PACKET_exec_event_feature) + + if (m_features.packet_set_cmd_state (PACKET_exec_event_feature) !=3D AUTO_BOOLEAN_FALSE) remote_query_supported_append (&q, "exec-events+"); =20 - if (packet_set_cmd_state (PACKET_vContSupported) !=3D AUTO_BOOLEAN_F= ALSE) + if (m_features.packet_set_cmd_state (PACKET_vContSupported) + !=3D AUTO_BOOLEAN_FALSE) remote_query_supported_append (&q, "vContSupported+"); =20 - if (packet_set_cmd_state (PACKET_QThreadEvents) !=3D AUTO_BOOLEAN_FA= LSE) + if (m_features.packet_set_cmd_state (PACKET_QThreadEvents) + !=3D AUTO_BOOLEAN_FALSE) remote_query_supported_append (&q, "QThreadEvents+"); =20 - if (packet_set_cmd_state (PACKET_no_resumed) !=3D AUTO_BOOLEAN_FALSE) + if (m_features.packet_set_cmd_state (PACKET_no_resumed) + !=3D AUTO_BOOLEAN_FALSE) remote_query_supported_append (&q, "no-resumed+"); =20 - if (packet_set_cmd_state (PACKET_memory_tagging_feature) + if (m_features.packet_set_cmd_state (PACKET_memory_tagging_feature) !=3D AUTO_BOOLEAN_FALSE) remote_query_supported_append (&q, "memory-tagging+"); =20 /* Keep this one last to work around a gdbserver <=3D 7.10 bug in the qSupported:xmlRegisters=3Di386 handling. */ if (remote_support_xml !=3D NULL - && packet_support (PACKET_qXfer_features) !=3D PACKET_DISABLE) + && (m_features.packet_support (PACKET_qXfer_features) + !=3D PACKET_DISABLE)) remote_query_supported_append (&q, remote_support_xml); =20 q =3D "qSupported:" + q; @@ -5539,8 +5653,7 @@ remote_target::remote_query_supported () =20 /* If an error occured, warn, but do not return - just reset the buffer to empty and go on to disable features. */ - if (packet_ok (rs->buf, &remote_protocol_packets[PACKET_qSupported]) - =3D=3D PACKET_ERROR) + if (m_features.packet_ok (rs->buf, PACKET_qSupported) =3D=3D PACKET_= ERROR) { warning (_("Remote failure reply: %s"), rs->buf.data ()); rs->buf[0] =3D 0; @@ -5817,7 +5930,7 @@ remote_target::open_1 (const char *name, int from_tty= , int extended_p) =20 /* Reset the target state; these things will be queried either by remote_query_supported or as they are needed. */ - reset_all_packet_configs_support (); + remote->m_features.reset_all_packet_configs_support (); rs->explicit_packet_size =3D 0; rs->noack_mode =3D 0; rs->extended =3D extended_p; @@ -5930,7 +6043,7 @@ remote_target::remote_detach_pid (int pid) GDBserver to select GDB's current process. */ set_general_process (); =20 - if (remote_multi_process_p (rs)) + if (m_features.remote_multi_process_p ()) xsnprintf (rs->buf.data (), get_remote_packet_size (), "D;%x", pid); else strcpy (rs->buf.data (), "D"); @@ -6061,10 +6174,10 @@ remote_target::follow_fork (inferior *child_inf, pt= id_t child_ptid, process_stratum_target::follow_fork (child_inf, child_ptid, fork_kind, follow_child, detach_fork); =20 - struct remote_state *rs =3D get_remote_state (); - - if ((fork_kind =3D=3D TARGET_WAITKIND_FORKED && remote_fork_event_p (rs)) - || (fork_kind =3D=3D TARGET_WAITKIND_VFORKED && remote_vfork_event_p= (rs))) + if ((fork_kind =3D=3D TARGET_WAITKIND_FORKED + && m_features.remote_fork_event_p ()) + || (fork_kind =3D=3D TARGET_WAITKIND_VFORKED + && m_features.remote_vfork_event_p ())) { /* When following the parent and detaching the child, we detach the child here. For the case of following the child and @@ -6130,7 +6243,7 @@ extended_remote_target::attach (const char *args, int= from_tty) /* Remote PID can be freely equal to getpid, do not check it here the sa= me way as in other targets. */ =20 - if (packet_support (PACKET_vAttach) =3D=3D PACKET_DISABLE) + if (m_features.packet_support (PACKET_vAttach) =3D=3D PACKET_DISABLE) error (_("This target does not support attaching to a process")); =20 target_announce_attach (from_tty, pid); @@ -6139,8 +6252,7 @@ extended_remote_target::attach (const char *args, int= from_tty) putpkt (rs->buf); getpkt (&rs->buf, 0); =20 - switch (packet_ok (rs->buf, - &remote_protocol_packets[PACKET_vAttach])) + switch (m_features.packet_ok (rs->buf, PACKET_vAttach)) { case PACKET_OK: if (!target_is_non_stop_p ()) @@ -6281,7 +6393,7 @@ remote_target::remote_vcont_probe () buf[0] =3D 0; } =20 - packet_ok (rs->buf, &remote_protocol_packets[PACKET_vCont]); + m_features.packet_ok (rs->buf, PACKET_vCont); rs->supports_vCont_probed =3D true; } =20 @@ -6311,7 +6423,7 @@ remote_target::append_resumption (char *p, char *endp, threads with a wildcard (though the protocol allows it, so stubs shouldn't make an active effort to forbid it). */ - && !(remote_multi_process_p (rs) && ptid.is_pid ())) + && !(m_features.remote_multi_process_p () && ptid.is_pid ())) { struct thread_info *tp; =20 @@ -6345,7 +6457,7 @@ remote_target::append_resumption (char *p, char *endp, else p +=3D xsnprintf (p, endp - p, ";c"); =20 - if (remote_multi_process_p (rs) && ptid.is_pid ()) + if (m_features.remote_multi_process_p () && ptid.is_pid ()) { ptid_t nptid; =20 @@ -6429,9 +6541,9 @@ remote_target::remote_resume_with_hc (ptid_t ptid, in= t step, warning (_(" - Can't pass signal %d to target in reverse: ignored."), siggnal); =20 - if (step && packet_support (PACKET_bs) =3D=3D PACKET_DISABLE) + if (step && m_features.packet_support (PACKET_bs) =3D=3D PACKET_DISA= BLE) error (_("Remote reverse-step not supported.")); - if (!step && packet_support (PACKET_bc) =3D=3D PACKET_DISABLE) + if (!step && m_features.packet_support (PACKET_bc) =3D=3D PACKET_DIS= ABLE) error (_("Remote reverse-continue not supported.")); =20 strcpy (buf, step ? "bs" : "bc"); @@ -6468,10 +6580,10 @@ remote_target::remote_resume_with_vcont (ptid_t sco= pe_ptid, int step, if (::execution_direction =3D=3D EXEC_REVERSE) return 0; =20 - if (packet_support (PACKET_vCont) =3D=3D PACKET_SUPPORT_UNKNOWN) + if (m_features.packet_support (PACKET_vCont) =3D=3D PACKET_SUPPORT_UNKNO= WN) remote_vcont_probe (); =20 - if (packet_support (PACKET_vCont) =3D=3D PACKET_DISABLE) + if (m_features.packet_support (PACKET_vCont) =3D=3D PACKET_DISABLE) return 0; =20 p =3D rs->buf.data (); @@ -7006,7 +7118,7 @@ remote_target::remote_stop_ns (ptid_t ptid) =20 /* FIXME: This supports_vCont_probed check is a workaround until packet_support is per-connection. */ - if (packet_support (PACKET_vCont) =3D=3D PACKET_SUPPORT_UNKNOWN + if (m_features.packet_support (PACKET_vCont) =3D=3D PACKET_SUPPORT_UNKNO= WN || !rs->supports_vCont_probed) remote_vcont_probe (); =20 @@ -7014,7 +7126,7 @@ remote_target::remote_stop_ns (ptid_t ptid) error (_("Remote server does not support stopping threads")); =20 if (ptid =3D=3D minus_one_ptid - || (!remote_multi_process_p (rs) && ptid.is_pid ())) + || (!m_features.remote_multi_process_p () && ptid.is_pid ())) p +=3D xsnprintf (p, endp - p, "vCont;t"); else { @@ -7088,7 +7200,7 @@ remote_target::remote_interrupt_ns () putpkt (rs->buf); getpkt (&rs->buf, 0); =20 - switch (packet_ok (rs->buf, &remote_protocol_packets[PACKET_vCtrlC])) + switch (m_features.packet_ok (rs->buf, PACKET_vCtrlC)) { case PACKET_OK: break; @@ -7596,7 +7708,8 @@ Packet: '%s'\n"), =20 /* Make sure the stub doesn't forget to indicate support with qSupported. */ - if (packet_support (PACKET_swbreak_feature) !=3D PACKET_ENABLE) + if (m_features.packet_support (PACKET_swbreak_feature) + !=3D PACKET_ENABLE) error (_("Unexpected swbreak stop reason")); =20 /* The value part is documented as "must be empty", @@ -7610,7 +7723,8 @@ Packet: '%s'\n"), =20 /* Make sure the stub doesn't forget to indicate support with qSupported. */ - if (packet_support (PACKET_hwbreak_feature) !=3D PACKET_ENABLE) + if (m_features.packet_support (PACKET_hwbreak_feature) + !=3D PACKET_ENABLE) error (_("Unexpected hwbreak stop reason")); =20 /* See above. */ @@ -8381,7 +8495,7 @@ remote_target::fetch_register_using_p (struct regcach= e *regcache, gdb_byte *regp =3D (gdb_byte *) alloca (register_size (gdbarch, reg->reg= num)); int i; =20 - if (packet_support (PACKET_p) =3D=3D PACKET_DISABLE) + if (m_features.packet_support (PACKET_p) =3D=3D PACKET_DISABLE) return 0; =20 if (reg->pnum =3D=3D -1) @@ -8396,7 +8510,7 @@ remote_target::fetch_register_using_p (struct regcach= e *regcache, =20 buf =3D rs->buf.data (); =20 - switch (packet_ok (rs->buf, &remote_protocol_packets[PACKET_p])) + switch (m_features.packet_ok (rs->buf, PACKET_p)) { case PACKET_OK: break; @@ -8661,7 +8775,7 @@ remote_target::prepare_to_store (struct regcache *reg= cache) int i; =20 /* Make sure the entire registers array is valid. */ - switch (packet_support (PACKET_P)) + switch (m_features.packet_support (PACKET_P)) { case PACKET_DISABLE: case PACKET_SUPPORT_UNKNOWN: @@ -8689,7 +8803,7 @@ remote_target::store_register_using_P (const struct r= egcache *regcache, gdb_byte *regp =3D (gdb_byte *) alloca (register_size (gdbarch, reg->reg= num)); char *p; =20 - if (packet_support (PACKET_P) =3D=3D PACKET_DISABLE) + if (m_features.packet_support (PACKET_P) =3D=3D PACKET_DISABLE) return 0; =20 if (reg->pnum =3D=3D -1) @@ -8702,7 +8816,7 @@ remote_target::store_register_using_P (const struct r= egcache *regcache, putpkt (rs->buf); getpkt (&rs->buf, 0); =20 - switch (packet_ok (rs->buf, &remote_protocol_packets[PACKET_P])) + switch (m_features.packet_ok (rs->buf, PACKET_P)) { case PACKET_OK: return 1; @@ -8885,7 +8999,7 @@ remote_target::check_binary_download (CORE_ADDR addr) { struct remote_state *rs =3D get_remote_state (); =20 - switch (packet_support (PACKET_X)) + switch (m_features.packet_support (PACKET_X)) { case PACKET_DISABLE: break; @@ -8909,12 +9023,12 @@ remote_target::check_binary_download (CORE_ADDR add= r) if (rs->buf[0] =3D=3D '\0') { remote_debug_printf ("binary downloading NOT supported by target"); - remote_protocol_packets[PACKET_X].support =3D PACKET_DISABLE; + m_features.m_protocol_packets[PACKET_X].support =3D PACKET_DISABLE; } else { remote_debug_printf ("binary downloading supported by target"); - remote_protocol_packets[PACKET_X].support =3D PACKET_ENABLE; + m_features.m_protocol_packets[PACKET_X].support =3D PACKET_ENABLE; } break; } @@ -9139,7 +9253,7 @@ remote_target::remote_write_bytes (CORE_ADDR memaddr,= const gdb_byte *myaddr, /* Check whether the target supports binary download. */ check_binary_download (memaddr); =20 - switch (packet_support (PACKET_X)) + switch (m_features.packet_support (PACKET_X)) { case PACKET_ENABLE: packet_format =3D "X"; @@ -10103,11 +10217,10 @@ remote_target::kill () { int res =3D -1; inferior *inf =3D find_inferior_pid (this, inferior_ptid.pid ()); - struct remote_state *rs =3D get_remote_state (); =20 gdb_assert (inf !=3D nullptr); =20 - if (packet_support (PACKET_vKill) !=3D PACKET_DISABLE) + if (m_features.packet_support (PACKET_vKill) !=3D PACKET_DISABLE) { /* If we're stopped while forking and we haven't followed yet, kill the child task. We need to do this before killing the @@ -10126,7 +10239,7 @@ remote_target::kill () /* If we are in 'target remote' mode and we are killing the only inferior, then we will tell gdbserver to exit and unpush the target. */ - if (res =3D=3D -1 && !remote_multi_process_p (rs) + if (res =3D=3D -1 && !m_features.remote_multi_process_p () && number_of_live_inferiors (this) =3D=3D 1) { remote_kill_k (); @@ -10148,7 +10261,7 @@ remote_target::kill () int remote_target::remote_vkill (int pid) { - if (packet_support (PACKET_vKill) =3D=3D PACKET_DISABLE) + if (m_features.packet_support (PACKET_vKill) =3D=3D PACKET_DISABLE) return -1; =20 remote_state *rs =3D get_remote_state (); @@ -10158,8 +10271,7 @@ remote_target::remote_vkill (int pid) putpkt (rs->buf); getpkt (&rs->buf, 0); =20 - switch (packet_ok (rs->buf, - &remote_protocol_packets[PACKET_vKill])) + switch (m_features.packet_ok (rs->buf, PACKET_vKill)) { case PACKET_OK: return 0; @@ -10255,7 +10367,8 @@ remote_target::mourn_inferior () bool extended_remote_target::supports_disable_randomization () { - return packet_support (PACKET_QDisableRandomization) =3D=3D PACKET_ENABL= E; + return (m_features.packet_support (PACKET_QDisableRandomization) + =3D=3D PACKET_ENABLE); } =20 void @@ -10283,7 +10396,7 @@ remote_target::extended_remote_run (const std::stri= ng &args) =20 /* If the user has disabled vRun support, or we have detected that support is not available, do not try it. */ - if (packet_support (PACKET_vRun) =3D=3D PACKET_DISABLE) + if (m_features.packet_support (PACKET_vRun) =3D=3D PACKET_DISABLE) return -1; =20 strcpy (rs->buf.data (), "vRun;"); @@ -10314,7 +10427,7 @@ remote_target::extended_remote_run (const std::stri= ng &args) putpkt (rs->buf); getpkt (&rs->buf, 0); =20 - switch (packet_ok (rs->buf, &remote_protocol_packets[PACKET_vRun])) + switch (m_features.packet_ok (rs->buf, PACKET_vRun)) { case PACKET_OK: /* We have a wait response. All is well. */ @@ -10367,7 +10480,7 @@ remote_target::extended_remote_environment_support = () { remote_state *rs =3D get_remote_state (); =20 - if (packet_support (PACKET_QEnvironmentReset) !=3D PACKET_DISABLE) + if (m_features.packet_support (PACKET_QEnvironmentReset) !=3D PACKET_DIS= ABLE) { putpkt ("QEnvironmentReset"); getpkt (&rs->buf, 0); @@ -10377,12 +10490,16 @@ remote_target::extended_remote_environment_suppor= t () =20 gdb_environ *e =3D ¤t_inferior ()->environment; =20 - if (packet_support (PACKET_QEnvironmentHexEncoded) !=3D PACKET_DISABLE) - for (const std::string &el : e->user_set_env ()) - send_environment_packet ("set", "QEnvironmentHexEncoded", - el.c_str ()); + if (m_features.packet_support (PACKET_QEnvironmentHexEncoded) + !=3D PACKET_DISABLE) + { + for (const std::string &el : e->user_set_env ()) + send_environment_packet ("set", "QEnvironmentHexEncoded", + el.c_str ()); + } + =20 - if (packet_support (PACKET_QEnvironmentUnset) !=3D PACKET_DISABLE) + if (m_features.packet_support (PACKET_QEnvironmentUnset) !=3D PACKET_DIS= ABLE) for (const std::string &el : e->user_unset_env ()) send_environment_packet ("unset", "QEnvironmentUnset", el.c_str ()); } @@ -10393,7 +10510,7 @@ remote_target::extended_remote_environment_support = () void remote_target::extended_remote_set_inferior_cwd () { - if (packet_support (PACKET_QSetWorkingDir) !=3D PACKET_DISABLE) + if (m_features.packet_support (PACKET_QSetWorkingDir) !=3D PACKET_DISABL= E) { const std::string &inferior_cwd =3D current_inferior ()->cwd (); remote_state *rs =3D get_remote_state (); @@ -10417,9 +10534,7 @@ remote_target::extended_remote_set_inferior_cwd () =20 putpkt (rs->buf); getpkt (&rs->buf, 0); - if (packet_ok (rs->buf, - &remote_protocol_packets[PACKET_QSetWorkingDir]) - !=3D PACKET_OK) + if (m_features.packet_ok (rs->buf, PACKET_QSetWorkingDir) !=3D PACKE= T_OK) error (_("\ Remote replied unexpectedly while setting the inferior's working\n\ directory: %s"), @@ -10455,7 +10570,7 @@ extended_remote_target::create_inferior (const char= *exec_file, =20 /* If startup-with-shell is on, we inform gdbserver to start the remote inferior using a shell. */ - if (packet_support (PACKET_QStartupWithShell) !=3D PACKET_DISABLE) + if (m_features.packet_support (PACKET_QStartupWithShell) !=3D PACKET_DIS= ABLE) { xsnprintf (rs->buf.data (), get_remote_packet_size (), "QStartupWithShell:%d", startup_with_shell ? 1 : 0); @@ -10561,7 +10676,7 @@ remote_target::insert_breakpoint (struct gdbarch *g= dbarch, fails, and the user has explicitly requested the Z support then report an error, otherwise, mark it disabled and go on. */ =20 - if (packet_support (PACKET_Z0) !=3D PACKET_DISABLE) + if (m_features.packet_support (PACKET_Z0) !=3D PACKET_DISABLE) { CORE_ADDR addr =3D bp_tgt->reqstd_address; struct remote_state *rs; @@ -10592,7 +10707,7 @@ remote_target::insert_breakpoint (struct gdbarch *g= dbarch, putpkt (rs->buf); getpkt (&rs->buf, 0); =20 - switch (packet_ok (rs->buf, &remote_protocol_packets[PACKET_Z0])) + switch (m_features.packet_ok (rs->buf, PACKET_Z0)) { case PACKET_ERROR: return -1; @@ -10620,7 +10735,7 @@ remote_target::remove_breakpoint (struct gdbarch *g= dbarch, CORE_ADDR addr =3D bp_tgt->placed_address; struct remote_state *rs =3D get_remote_state (); =20 - if (packet_support (PACKET_Z0) !=3D PACKET_DISABLE) + if (m_features.packet_support (PACKET_Z0) !=3D PACKET_DISABLE) { char *p =3D rs->buf.data (); char *endbuf =3D p + get_remote_packet_size (); @@ -10675,7 +10790,7 @@ remote_target::insert_watchpoint (CORE_ADDR addr, i= nt len, char *p; enum Z_packet_type packet =3D watchpoint_to_Z_packet (type); =20 - if (packet_support (PACKET_Z0 + packet) =3D=3D PACKET_DISABLE) + if (m_features.packet_support (PACKET_Z0 + packet) =3D=3D PACKET_DISABLE) return 1; =20 /* Make sure the remote is pointing at the right process, if @@ -10692,7 +10807,7 @@ remote_target::insert_watchpoint (CORE_ADDR addr, i= nt len, putpkt (rs->buf); getpkt (&rs->buf, 0); =20 - switch (packet_ok (rs->buf, &remote_protocol_packets[PACKET_Z0 + packet]= )) + switch (m_features.packet_ok (rs->buf, PACKET_Z0 + packet)) { case PACKET_ERROR: return -1; @@ -10723,7 +10838,7 @@ remote_target::remove_watchpoint (CORE_ADDR addr, i= nt len, char *p; enum Z_packet_type packet =3D watchpoint_to_Z_packet (type); =20 - if (packet_support (PACKET_Z0 + packet) =3D=3D PACKET_DISABLE) + if (m_features.packet_support (PACKET_Z0 + packet) =3D=3D PACKET_DISABLE) return -1; =20 /* Make sure the remote is pointing at the right process, if @@ -10739,7 +10854,7 @@ remote_target::remove_watchpoint (CORE_ADDR addr, i= nt len, putpkt (rs->buf); getpkt (&rs->buf, 0); =20 - switch (packet_ok (rs->buf, &remote_protocol_packets[PACKET_Z0 + packet]= )) + switch (m_features.packet_ok (rs->buf, PACKET_Z0 + packet)) { case PACKET_ERROR: case PACKET_UNKNOWN: @@ -10812,7 +10927,7 @@ remote_target::stopped_by_sw_breakpoint () bool remote_target::supports_stopped_by_sw_breakpoint () { - return (packet_support (PACKET_swbreak_feature) =3D=3D PACKET_ENABLE); + return (m_features.packet_support (PACKET_swbreak_feature) =3D=3D PACKET= _ENABLE); } =20 /* The to_stopped_by_hw_breakpoint method of target remote. */ @@ -10833,7 +10948,7 @@ remote_target::stopped_by_hw_breakpoint () bool remote_target::supports_stopped_by_hw_breakpoint () { - return (packet_support (PACKET_hwbreak_feature) =3D=3D PACKET_ENABLE); + return (m_features.packet_support (PACKET_hwbreak_feature) =3D=3D PACKET= _ENABLE); } =20 bool @@ -10872,7 +10987,7 @@ remote_target::insert_hw_breakpoint (struct gdbarch= *gdbarch, char *p, *endbuf; char *message; =20 - if (packet_support (PACKET_Z1) =3D=3D PACKET_DISABLE) + if (m_features.packet_support (PACKET_Z1) =3D=3D PACKET_DISABLE) return -1; =20 /* Make sure the remote is pointing at the right process, if @@ -10901,7 +11016,7 @@ remote_target::insert_hw_breakpoint (struct gdbarch= *gdbarch, putpkt (rs->buf); getpkt (&rs->buf, 0); =20 - switch (packet_ok (rs->buf, &remote_protocol_packets[PACKET_Z1])) + switch (m_features.packet_ok (rs->buf, PACKET_Z1)) { case PACKET_ERROR: if (rs->buf[1] =3D=3D '.') @@ -10929,7 +11044,7 @@ remote_target::remove_hw_breakpoint (struct gdbarch= *gdbarch, char *p =3D rs->buf.data (); char *endbuf =3D p + get_remote_packet_size (); =20 - if (packet_support (PACKET_Z1) =3D=3D PACKET_DISABLE) + if (m_features.packet_support (PACKET_Z1) =3D=3D PACKET_DISABLE) return -1; =20 /* Make sure the remote is pointing at the right process, if @@ -10948,7 +11063,7 @@ remote_target::remove_hw_breakpoint (struct gdbarch= *gdbarch, putpkt (rs->buf); getpkt (&rs->buf, 0); =20 - switch (packet_ok (rs->buf, &remote_protocol_packets[PACKET_Z1])) + switch (m_features.packet_ok (rs->buf, PACKET_Z1)) { case PACKET_ERROR: case PACKET_UNKNOWN: @@ -10971,7 +11086,7 @@ remote_target::verify_memory (const gdb_byte *data,= CORE_ADDR lma, ULONGEST size /* It doesn't make sense to use qCRC if the remote target is connected but not running. */ if (target_has_execution () - && packet_support (PACKET_qCRC) !=3D PACKET_DISABLE) + && m_features.packet_support (PACKET_qCRC) !=3D PACKET_DISABLE) { enum packet_result result; =20 @@ -10989,8 +11104,7 @@ remote_target::verify_memory (const gdb_byte *data,= CORE_ADDR lma, ULONGEST size =20 getpkt (&rs->buf, 0); =20 - result =3D packet_ok (rs->buf, - &remote_protocol_packets[PACKET_qCRC]); + result =3D m_features.packet_ok (rs->buf, PACKET_qCRC); if (result =3D=3D PACKET_ERROR) return -1; else if (result =3D=3D PACKET_OK) @@ -11089,14 +11203,14 @@ remote_target::remote_write_qxfer (const char *ob= ject_name, const char *annex, const gdb_byte *writebuf, ULONGEST offset, LONGEST len, ULONGEST *xfered_len, - struct packet_config *packet) + const unsigned int which_packet) { int i, buf_len; ULONGEST n; struct remote_state *rs =3D get_remote_state (); int max_size =3D get_memory_write_packet_size ();=20 =20 - if (packet_config_support (packet) =3D=3D PACKET_DISABLE) + if (m_features.packet_support (which_packet) =3D=3D PACKET_DISABLE) return TARGET_XFER_E_IO; =20 /* Insert header. */ @@ -11112,7 +11226,7 @@ remote_target::remote_write_qxfer (const char *obje= ct_name, =20 if (putpkt_binary (rs->buf.data (), i + buf_len) < 0 || getpkt_sane (&rs->buf, 0) < 0 - || packet_ok (rs->buf, packet) !=3D PACKET_OK) + || m_features.packet_ok (rs->buf, which_packet) !=3D PACKET_OK) return TARGET_XFER_E_IO; =20 unpack_varlen_hex (rs->buf.data (), &n); @@ -11134,12 +11248,12 @@ remote_target::remote_read_qxfer (const char *obj= ect_name, gdb_byte *readbuf, ULONGEST offset, LONGEST len, ULONGEST *xfered_len, - struct packet_config *packet) + const unsigned int which_packet) { struct remote_state *rs =3D get_remote_state (); LONGEST i, n, packet_len; =20 - if (packet_config_support (packet) =3D=3D PACKET_DISABLE) + if (m_features.packet_support (which_packet) =3D=3D PACKET_DISABLE) return TARGET_XFER_E_IO; =20 /* Check whether we've cached an end-of-object packet that matches @@ -11176,7 +11290,8 @@ remote_target::remote_read_qxfer (const char *objec= t_name, =20 rs->buf[0] =3D '\0'; packet_len =3D getpkt_sane (&rs->buf, 0); - if (packet_len < 0 || packet_ok (rs->buf, packet) !=3D PACKET_OK) + if (packet_len < 0 + || m_features.packet_ok (rs->buf, which_packet) !=3D PACKET_OK) return TARGET_XFER_E_IO; =20 if (rs->buf[0] !=3D 'l' && rs->buf[0] !=3D 'm') @@ -11250,13 +11365,10 @@ remote_target::xfer_partial (enum target_object o= bject, { if (readbuf) return remote_read_qxfer ("siginfo", annex, readbuf, offset, len, - xfered_len, &remote_protocol_packets - [PACKET_qXfer_siginfo_read]); + xfered_len, PACKET_qXfer_siginfo_read); else - return remote_write_qxfer ("siginfo", annex, - writebuf, offset, len, xfered_len, - &remote_protocol_packets - [PACKET_qXfer_siginfo_write]); + return remote_write_qxfer ("siginfo", annex, writebuf, offset, len, + xfered_len, PACKET_qXfer_siginfo_write); } =20 if (object =3D=3D TARGET_OBJECT_STATIC_TRACE_DATA) @@ -11264,8 +11376,7 @@ remote_target::xfer_partial (enum target_object obj= ect, if (readbuf) return remote_read_qxfer ("statictrace", annex, readbuf, offset, len, xfered_len, - &remote_protocol_packets - [PACKET_qXfer_statictrace_read]); + PACKET_qXfer_statictrace_read); else return TARGET_XFER_E_IO; } @@ -11294,74 +11405,71 @@ remote_target::xfer_partial (enum target_object o= bject, =20 case TARGET_OBJECT_AUXV: gdb_assert (annex =3D=3D NULL); - return remote_read_qxfer ("auxv", annex, readbuf, offset, len, - xfered_len, - &remote_protocol_packets[PACKET_qXfer_auxv]); + return remote_read_qxfer + ("auxv", annex, readbuf, offset, len, xfered_len, PACKET_qXfer_auxv); =20 case TARGET_OBJECT_AVAILABLE_FEATURES: return remote_read_qxfer ("features", annex, readbuf, offset, len, xfered_len, - &remote_protocol_packets[PACKET_qXfer_features]); + PACKET_qXfer_features); =20 case TARGET_OBJECT_LIBRARIES: return remote_read_qxfer ("libraries", annex, readbuf, offset, len, xfered_len, - &remote_protocol_packets[PACKET_qXfer_libraries]); + PACKET_qXfer_libraries); =20 case TARGET_OBJECT_LIBRARIES_SVR4: return remote_read_qxfer ("libraries-svr4", annex, readbuf, offset, len, xfered_len, - &remote_protocol_packets[PACKET_qXfer_libraries_svr4]); + PACKET_qXfer_libraries_svr4); =20 case TARGET_OBJECT_MEMORY_MAP: gdb_assert (annex =3D=3D NULL); - return remote_read_qxfer ("memory-map", annex, readbuf, offset, len, - xfered_len, - &remote_protocol_packets[PACKET_qXfer_memory_map]); + return remote_read_qxfer + ("memory-map", annex, readbuf, offset, len, xfered_len, + PACKET_qXfer_memory_map); =20 case TARGET_OBJECT_OSDATA: /* Should only get here if we're connected. */ gdb_assert (rs->remote_desc); return remote_read_qxfer ("osdata", annex, readbuf, offset, len, xfered_len, - &remote_protocol_packets[PACKET_qXfer_osdata]); + PACKET_qXfer_osdata); =20 case TARGET_OBJECT_THREADS: gdb_assert (annex =3D=3D NULL); - return remote_read_qxfer ("threads", annex, readbuf, offset, len, - xfered_len, - &remote_protocol_packets[PACKET_qXfer_threads]); + return remote_read_qxfer + ("threads", annex, readbuf, offset, len, xfered_len, + PACKET_qXfer_threads); =20 case TARGET_OBJECT_TRACEFRAME_INFO: gdb_assert (annex =3D=3D NULL); return remote_read_qxfer ("traceframe-info", annex, readbuf, offset, len, xfered_len, - &remote_protocol_packets[PACKET_qXfer_traceframe_info]); + PACKET_qXfer_traceframe_info); =20 case TARGET_OBJECT_FDPIC: - return remote_read_qxfer ("fdpic", annex, readbuf, offset, len, - xfered_len, - &remote_protocol_packets[PACKET_qXfer_fdpic]); + return remote_read_qxfer + ("fdpic", annex, readbuf, offset, len, xfered_len, PACKET_qXfer_fdpic); =20 case TARGET_OBJECT_OPENVMS_UIB: - return remote_read_qxfer ("uib", annex, readbuf, offset, len, - xfered_len, - &remote_protocol_packets[PACKET_qXfer_uib]); + return remote_read_qxfer + ("uib", annex, readbuf, offset, len, xfered_len, PACKET_qXfer_uib); =20 case TARGET_OBJECT_BTRACE: - return remote_read_qxfer ("btrace", annex, readbuf, offset, len, - xfered_len, - &remote_protocol_packets[PACKET_qXfer_btrace]); + return remote_read_qxfer + ("btrace", annex, readbuf, offset, len, xfered_len, + PACKET_qXfer_btrace); =20 case TARGET_OBJECT_BTRACE_CONF: - return remote_read_qxfer ("btrace-conf", annex, readbuf, offset, - len, xfered_len, - &remote_protocol_packets[PACKET_qXfer_btrace_conf]); + return remote_read_qxfer + ("btrace-conf", annex, readbuf, offset, len, xfered_len, + PACKET_qXfer_btrace_conf); =20 case TARGET_OBJECT_EXEC_FILE: - return remote_read_qxfer ("exec-file", annex, readbuf, offset, - len, xfered_len, - &remote_protocol_packets[PACKET_qXfer_exec_file]); + return remote_read_qxfer + ("exec-file", annex, readbuf, offset, len, xfered_len, + PACKET_qXfer_exec_file); =20 default: return TARGET_XFER_E_IO; @@ -11427,8 +11535,7 @@ remote_target::search_memory (CORE_ADDR start_addr,= ULONGEST search_space_len, int addr_size =3D gdbarch_addr_bit (target_gdbarch ()) / 8; struct remote_state *rs =3D get_remote_state (); int max_size =3D get_memory_write_packet_size (); - struct packet_config *packet =3D - &remote_protocol_packets[PACKET_qSearch_memory]; + /* Number of packet bytes used to encode the pattern; this could be more than PATTERN_LEN due to escape characters. */ int escaped_pattern_len; @@ -11445,9 +11552,8 @@ remote_target::search_memory (CORE_ADDR start_addr,= ULONGEST search_space_len, }; =20 /* Don't go to the target if we don't have to. This is done before - checking packet_config_support to avoid the possibility that a - success for this edge case means the facility works in - general. */ + checking packet_support to avoid the possibility that a success for t= his + edge case means the facility works in general. */ if (pattern_len > search_space_len) return 0; if (pattern_len =3D=3D 0) @@ -11459,7 +11565,7 @@ remote_target::search_memory (CORE_ADDR start_addr,= ULONGEST search_space_len, /* If we already know the packet isn't supported, fall back to the simple way of searching memory. */ =20 - if (packet_config_support (packet) =3D=3D PACKET_DISABLE) + if (m_features.packet_support (PACKET_qSearch_memory) =3D=3D PACKET_DISA= BLE) { /* Target doesn't provided special support, fall back and use the standard support (copy memory and do the search here). */ @@ -11489,11 +11595,11 @@ remote_target::search_memory (CORE_ADDR start_add= r, ULONGEST search_space_len, =20 if (putpkt_binary (rs->buf.data (), i + escaped_pattern_len) < 0 || getpkt_sane (&rs->buf, 0) < 0 - || packet_ok (rs->buf, packet) !=3D PACKET_OK) + || m_features.packet_ok (rs->buf, PACKET_qSearch_memory) !=3D PACKET= _OK) { /* The request may not have worked because the command is not supported. If so, fall back to the simple way. */ - if (packet_config_support (packet) =3D=3D PACKET_DISABLE) + if (m_features.packet_support (PACKET_qSearch_memory) =3D=3D PACKET_= DISABLE) { return simple_search_memory (read_memory, start_addr, search_space_len, pattern, pattern_len, found_addrp); @@ -11836,8 +11942,6 @@ init_remote_threadtests (void) std::string remote_target::pid_to_str (ptid_t ptid) { - struct remote_state *rs =3D get_remote_state (); - if (ptid =3D=3D null_ptid) return normal_pid_to_str (ptid); else if (ptid.is_pid ()) @@ -11853,7 +11957,7 @@ remote_target::pid_to_str (ptid_t ptid) connecting with extended-remote and the stub already being attached to a process, and reporting yes to qAttached, hence no smart special casing here. */ - if (!remote_multi_process_p (rs)) + if (!m_features.remote_multi_process_p ()) return "Remote target"; =20 return normal_pid_to_str (ptid); @@ -11862,7 +11966,7 @@ remote_target::pid_to_str (ptid_t ptid) { if (magic_null_ptid =3D=3D ptid) return "Thread
"; - else if (remote_multi_process_p (rs)) + else if (m_features.remote_multi_process_p ()) if (ptid.lwp () =3D=3D 0) return normal_pid_to_str (ptid); else @@ -11880,7 +11984,7 @@ CORE_ADDR remote_target::get_thread_local_address (ptid_t ptid, CORE_ADDR lm, CORE_ADDR offset) { - if (packet_support (PACKET_qGetTLSAddr) !=3D PACKET_DISABLE) + if (m_features.packet_support (PACKET_qGetTLSAddr) !=3D PACKET_DISABLE) { struct remote_state *rs =3D get_remote_state (); char *p =3D rs->buf.data (); @@ -11898,8 +12002,7 @@ remote_target::get_thread_local_address (ptid_t pti= d, CORE_ADDR lm, =20 putpkt (rs->buf); getpkt (&rs->buf, 0); - result =3D packet_ok (rs->buf, - &remote_protocol_packets[PACKET_qGetTLSAddr]); + result =3D m_features.packet_ok (rs->buf, PACKET_qGetTLSAddr); if (result =3D=3D PACKET_OK) { ULONGEST addr; @@ -11927,7 +12030,7 @@ remote_target::get_thread_local_address (ptid_t pti= d, CORE_ADDR lm, bool remote_target::get_tib_address (ptid_t ptid, CORE_ADDR *addr) { - if (packet_support (PACKET_qGetTIBAddr) !=3D PACKET_DISABLE) + if (m_features.packet_support (PACKET_qGetTIBAddr) !=3D PACKET_DISABLE) { struct remote_state *rs =3D get_remote_state (); char *p =3D rs->buf.data (); @@ -11941,8 +12044,7 @@ remote_target::get_tib_address (ptid_t ptid, CORE_A= DDR *addr) =20 putpkt (rs->buf); getpkt (&rs->buf, 0); - result =3D packet_ok (rs->buf, - &remote_protocol_packets[PACKET_qGetTIBAddr]); + result =3D m_features.packet_ok (rs->buf, PACKET_qGetTIBAddr); if (result =3D=3D PACKET_OK) { ULONGEST val; @@ -12193,7 +12295,7 @@ remote_target::remote_hostio_send_command (int comm= and_bytes, int which_packet, int ret, bytes_read; const char *attachment_tmp; =20 - if (packet_support (which_packet) =3D=3D PACKET_DISABLE) + if (m_features.packet_support (which_packet) =3D=3D PACKET_DISABLE) { *remote_errno =3D FILEIO_ENOSYS; return -1; @@ -12210,7 +12312,7 @@ remote_target::remote_hostio_send_command (int comm= and_bytes, int which_packet, return -1; } =20 - switch (packet_ok (rs->buf, &remote_protocol_packets[which_packet])) + switch (m_features.packet_ok (rs->buf, which_packet)) { case PACKET_ERROR: *remote_errno =3D FILEIO_EINVAL; @@ -12280,7 +12382,7 @@ remote_target::remote_hostio_set_filesystem (struct= inferior *inf, char arg[9]; int ret; =20 - if (packet_support (PACKET_vFile_setfs) =3D=3D PACKET_DISABLE) + if (m_features.packet_support (PACKET_vFile_setfs) =3D=3D PACKET_DISABLE) return 0; =20 if (rs->fs_pid !=3D -1 && required_pid =3D=3D rs->fs_pid) @@ -12294,7 +12396,7 @@ remote_target::remote_hostio_set_filesystem (struct= inferior *inf, ret =3D remote_hostio_send_command (p - rs->buf.data (), PACKET_vFile_se= tfs, remote_errno, NULL, NULL); =20 - if (packet_support (PACKET_vFile_setfs) =3D=3D PACKET_DISABLE) + if (m_features.packet_support (PACKET_vFile_setfs) =3D=3D PACKET_DISABLE) return 0; =20 if (ret =3D=3D 0) @@ -12666,7 +12768,7 @@ remote_target::filesystem_is_local () does not support vFile:open. */ if (gdb_sysroot =3D=3D TARGET_SYSROOT_PREFIX) { - enum packet_support ps =3D packet_support (PACKET_vFile_open); + packet_support ps =3D m_features.packet_support (PACKET_vFile_open); =20 if (ps =3D=3D PACKET_SUPPORT_UNKNOWN) { @@ -12683,7 +12785,7 @@ remote_target::filesystem_is_local () if (fd >=3D 0) remote_hostio_close (fd, &remote_errno); =20 - ps =3D packet_support (PACKET_vFile_open); + ps =3D m_features.packet_support (PACKET_vFile_open); } =20 if (ps =3D=3D PACKET_DISABLE) @@ -12988,8 +13090,8 @@ remote_delete_command (const char *args, int from_t= ty) bool remote_target::can_execute_reverse () { - if (packet_support (PACKET_bs) =3D=3D PACKET_ENABLE - || packet_support (PACKET_bc) =3D=3D PACKET_ENABLE) + if (m_features.packet_support (PACKET_bs) =3D=3D PACKET_ENABLE + || m_features.packet_support (PACKET_bc) =3D=3D PACKET_ENABLE) return true; else return false; @@ -13011,58 +13113,58 @@ remote_target::supports_disable_randomization () bool remote_target::supports_multi_process () { - struct remote_state *rs =3D get_remote_state (); - - return remote_multi_process_p (rs); + return m_features.remote_multi_process_p (); } =20 -static int -remote_supports_cond_tracepoints () +int +remote_target::remote_supports_cond_tracepoints () { - return packet_support (PACKET_ConditionalTracepoints) =3D=3D PACKET_ENAB= LE; + return (m_features.packet_support (PACKET_ConditionalTracepoints) + =3D=3D PACKET_ENABLE); } =20 bool remote_target::supports_evaluation_of_breakpoint_conditions () { - return packet_support (PACKET_ConditionalBreakpoints) =3D=3D PACKET_ENAB= LE; + return (m_features.packet_support (PACKET_ConditionalBreakpoints) + =3D=3D PACKET_ENABLE); } =20 -static int -remote_supports_fast_tracepoints () +int +remote_target::remote_supports_fast_tracepoints () { - return packet_support (PACKET_FastTracepoints) =3D=3D PACKET_ENABLE; + return m_features.packet_support (PACKET_FastTracepoints) =3D=3D PACKET_= ENABLE; } =20 -static int -remote_supports_static_tracepoints () +int +remote_target::remote_supports_static_tracepoints () { - return packet_support (PACKET_StaticTracepoints) =3D=3D PACKET_ENABLE; + return m_features.packet_support (PACKET_StaticTracepoints) =3D=3D PACKE= T_ENABLE; } =20 -static int -remote_supports_install_in_trace () +int +remote_target::remote_supports_install_in_trace () { - return packet_support (PACKET_InstallInTrace) =3D=3D PACKET_ENABLE; + return m_features.packet_support (PACKET_InstallInTrace) =3D=3D PACKET_E= NABLE; } =20 bool remote_target::supports_enable_disable_tracepoint () { - return (packet_support (PACKET_EnableDisableTracepoints_feature) + return (m_features.packet_support (PACKET_EnableDisableTracepoints_featu= re) =3D=3D PACKET_ENABLE); } =20 bool remote_target::supports_string_tracing () { - return packet_support (PACKET_tracenz_feature) =3D=3D PACKET_ENABLE; + return m_features.packet_support (PACKET_tracenz_feature) =3D=3D PACKET_= ENABLE; } =20 bool remote_target::can_run_breakpoint_commands () { - return packet_support (PACKET_BreakpointCommands) =3D=3D PACKET_ENABLE; + return m_features.packet_support (PACKET_BreakpointCommands) =3D=3D PACK= ET_ENABLE; } =20 void @@ -13306,7 +13408,7 @@ remote_target::download_tracepoint (struct bp_locat= ion *loc) error (_("Error on target while setting tracepoints.")); } =20 - if (packet_support (PACKET_TracepointSource) =3D=3D PACKET_ENABLE) + if (m_features.packet_support (PACKET_TracepointSource) =3D=3D PACKET_EN= ABLE) { if (b->locspec !=3D nullptr) { @@ -13463,7 +13565,8 @@ remote_target::trace_set_readonly_regions () sec_length =3D 1 + strlen (tmp1) + 1 + strlen (tmp2); if (offset + sec_length + 1 > rs->buf.size ()) { - if (packet_support (PACKET_qXfer_traceframe_info) !=3D PACKET_ENABLE) + if (m_features.packet_support (PACKET_qXfer_traceframe_info) + !=3D PACKET_ENABLE) warning (_("\ Too many sections for read-only sections definition packet.")); break; @@ -13500,7 +13603,7 @@ remote_target::get_trace_status (struct trace_statu= s *ts) enum packet_result result; struct remote_state *rs =3D get_remote_state (); =20 - if (packet_support (PACKET_qTStatus) =3D=3D PACKET_DISABLE) + if (m_features.packet_support (PACKET_qTStatus) =3D=3D PACKET_DISABLE) return -1; =20 /* FIXME we need to get register block size some other way. */ @@ -13523,7 +13626,7 @@ remote_target::get_trace_status (struct trace_statu= s *ts) throw; } =20 - result =3D packet_ok (p, &remote_protocol_packets[PACKET_qTStatus]); + result =3D m_features.packet_ok (p, PACKET_qTStatus); =20 /* If the remote target doesn't do tracing, flag it. */ if (result =3D=3D PACKET_UNKNOWN) @@ -13778,7 +13881,8 @@ remote_target::set_disconnected_tracing (int val) { struct remote_state *rs =3D get_remote_state (); =20 - if (packet_support (PACKET_DisconnectedTracing_feature) =3D=3D PACKET_EN= ABLE) + if (m_features.packet_support (PACKET_DisconnectedTracing_feature) + =3D=3D PACKET_ENABLE) { char *reply; =20 @@ -13872,7 +13976,7 @@ remote_target::get_min_fast_tracepoint_insn_len () void remote_target::set_trace_buffer_size (LONGEST val) { - if (packet_support (PACKET_QTBuffer_size) !=3D PACKET_DISABLE) + if (m_features.packet_support (PACKET_QTBuffer_size) !=3D PACKET_DISABLE) { struct remote_state *rs =3D get_remote_state (); char *buf =3D rs->buf.data (); @@ -13892,8 +13996,7 @@ remote_target::set_trace_buffer_size (LONGEST val) =20 putpkt (rs->buf); remote_get_noisy_reply (); - result =3D packet_ok (rs->buf, - &remote_protocol_packets[PACKET_QTBuffer_size]); + result =3D m_features.packet_ok (rs->buf, PACKET_QTBuffer_size); =20 if (result !=3D PACKET_OK) warning (_("Bogus reply from target: %s"), rs->buf.data ()); @@ -13949,7 +14052,7 @@ remote_target::set_trace_notes (const char *user, c= onst char *notes, bool remote_target::use_agent (bool use) { - if (packet_support (PACKET_QAgent) !=3D PACKET_DISABLE) + if (m_features.packet_support (PACKET_QAgent) !=3D PACKET_DISABLE) { struct remote_state *rs =3D get_remote_state (); =20 @@ -13971,7 +14074,7 @@ remote_target::use_agent (bool use) bool remote_target::can_use_agent () { - return (packet_support (PACKET_QAgent) !=3D PACKET_DISABLE); + return (m_features.packet_support (PACKET_QAgent) !=3D PACKET_DISABLE); } =20 struct btrace_target_info @@ -13996,7 +14099,6 @@ remote_btrace_reset (remote_state *rs) void remote_target::btrace_sync_conf (const btrace_config *conf) { - struct packet_config *packet; struct remote_state *rs; char *buf, *pos, *endbuf; =20 @@ -14004,18 +14106,19 @@ remote_target::btrace_sync_conf (const btrace_con= fig *conf) buf =3D rs->buf.data (); endbuf =3D buf + get_remote_packet_size (); =20 - packet =3D &remote_protocol_packets[PACKET_Qbtrace_conf_bts_size]; - if (packet_config_support (packet) =3D=3D PACKET_ENABLE + if (m_features.packet_support (PACKET_Qbtrace_conf_bts_size) =3D=3D PACK= ET_ENABLE && conf->bts.size !=3D rs->btrace_config.bts.size) { pos =3D buf; - pos +=3D xsnprintf (pos, endbuf - pos, "%s=3D0x%x", packet->name, + pos +=3D xsnprintf (pos, endbuf - pos, "%s=3D0x%x", + packets_descriptions[PACKET_Qbtrace_conf_bts_size].name, conf->bts.size); =20 putpkt (buf); getpkt (&rs->buf, 0); =20 - if (packet_ok (buf, packet) =3D=3D PACKET_ERROR) + if (m_features.packet_ok (buf, PACKET_Qbtrace_conf_bts_size) + =3D=3D PACKET_ERROR) { if (buf[0] =3D=3D 'E' && buf[1] =3D=3D '.') error (_("Failed to configure the BTS buffer size: %s"), buf + 2); @@ -14026,18 +14129,19 @@ remote_target::btrace_sync_conf (const btrace_con= fig *conf) rs->btrace_config.bts.size =3D conf->bts.size; } =20 - packet =3D &remote_protocol_packets[PACKET_Qbtrace_conf_pt_size]; - if (packet_config_support (packet) =3D=3D PACKET_ENABLE + if (m_features.packet_support (PACKET_Qbtrace_conf_pt_size) =3D=3D PACKE= T_ENABLE && conf->pt.size !=3D rs->btrace_config.pt.size) { pos =3D buf; - pos +=3D xsnprintf (pos, endbuf - pos, "%s=3D0x%x", packet->name, + pos +=3D xsnprintf (pos, endbuf - pos, "%s=3D0x%x", + packets_descriptions[PACKET_Qbtrace_conf_pt_size].name, conf->pt.size); =20 putpkt (buf); getpkt (&rs->buf, 0); =20 - if (packet_ok (buf, packet) =3D=3D PACKET_ERROR) + if (m_features.packet_ok (buf, PACKET_Qbtrace_conf_pt_size) + =3D=3D PACKET_ERROR) { if (buf[0] =3D=3D 'E' && buf[1] =3D=3D '.') error (_("Failed to configure the trace buffer size: %s"), buf + 2); @@ -14078,7 +14182,7 @@ remote_target::remote_btrace_maybe_reopen () =20 /* Don't bother walking the entirety of the remote thread list when we know the feature isn't supported by the remote. */ - if (packet_support (PACKET_qXfer_btrace_conf) !=3D PACKET_ENABLE) + if (m_features.packet_support (PACKET_qXfer_btrace_conf) !=3D PACKET_ENA= BLE) return; =20 for (thread_info *tp : all_non_exited_threads (this)) @@ -14132,17 +14236,21 @@ remote_target::enable_btrace (thread_info *tp, char *buf =3D rs->buf.data (); char *endbuf =3D buf + get_remote_packet_size (); =20 + unsigned int which_packet; switch (conf->format) { case BTRACE_FORMAT_BTS: - packet =3D &remote_protocol_packets[PACKET_Qbtrace_bts]; + which_packet =3D PACKET_Qbtrace_bts; break; - case BTRACE_FORMAT_PT: - packet =3D &remote_protocol_packets[PACKET_Qbtrace_pt]; + which_packet =3D PACKET_Qbtrace_pt; break; + default: + internal_error (_("Bad branch btrace format: %u."), + (unsigned int) conf->format); } =20 + packet =3D &m_features.m_protocol_packets[which_packet]; if (packet =3D=3D NULL || packet_config_support (packet) !=3D PACKET_ENA= BLE) error (_("Target does not support branch tracing.")); =20 @@ -14151,11 +14259,12 @@ remote_target::enable_btrace (thread_info *tp, ptid_t ptid =3D tp->ptid; set_general_thread (ptid); =20 - buf +=3D xsnprintf (buf, endbuf - buf, "%s", packet->name); + buf +=3D xsnprintf (buf, endbuf - buf, "%s", + packets_descriptions[which_packet].name); putpkt (rs->buf); getpkt (&rs->buf, 0); =20 - if (packet_ok (rs->buf, packet) =3D=3D PACKET_ERROR) + if (m_features.packet_ok (rs->buf, which_packet) =3D=3D PACKET_ERROR) { if (rs->buf[0] =3D=3D 'E' && rs->buf[1] =3D=3D '.') error (_("Could not enable branch tracing for %s: %s"), @@ -14188,21 +14297,21 @@ remote_target::enable_btrace (thread_info *tp, void remote_target::disable_btrace (struct btrace_target_info *tinfo) { - struct packet_config *packet =3D &remote_protocol_packets[PACKET_Qbtrace= _off]; struct remote_state *rs =3D get_remote_state (); char *buf =3D rs->buf.data (); char *endbuf =3D buf + get_remote_packet_size (); =20 - if (packet_config_support (packet) !=3D PACKET_ENABLE) + if (m_features.packet_support (PACKET_Qbtrace_off) !=3D PACKET_ENABLE) error (_("Target does not support branch tracing.")); =20 set_general_thread (tinfo->ptid); =20 - buf +=3D xsnprintf (buf, endbuf - buf, "%s", packet->name); + buf +=3D xsnprintf (buf, endbuf - buf, "%s", + packets_descriptions[PACKET_Qbtrace_off].name); putpkt (rs->buf); getpkt (&rs->buf, 0); =20 - if (packet_ok (rs->buf, packet) =3D=3D PACKET_ERROR) + if (m_features.packet_ok (rs->buf, PACKET_Qbtrace_off) =3D=3D PACKET_ERR= OR) { if (rs->buf[0] =3D=3D 'E' && rs->buf[1] =3D=3D '.') error (_("Could not disable branch tracing for %s: %s"), @@ -14231,10 +14340,9 @@ remote_target::read_btrace (struct btrace_data *bt= race, struct btrace_target_info *tinfo, enum btrace_read_type type) { - struct packet_config *packet =3D &remote_protocol_packets[PACKET_qXfer_b= trace]; const char *annex; =20 - if (packet_config_support (packet) !=3D PACKET_ENABLE) + if (m_features.packet_support (PACKET_qXfer_btrace) !=3D PACKET_ENABLE) error (_("Target does not support branch tracing.")); =20 #if !defined(HAVE_LIBEXPAT) @@ -14277,8 +14385,9 @@ remote_target::btrace_conf (const struct btrace_tar= get_info *tinfo) bool remote_target::augmented_libraries_svr4_read () { - return (packet_support (PACKET_augmented_libraries_svr4_read_feature) - =3D=3D PACKET_ENABLE); + return + (m_features.packet_support (PACKET_augmented_libraries_svr4_read_featu= re) + =3D=3D PACKET_ENABLE); } =20 /* Implementation of to_load. */ @@ -14299,7 +14408,7 @@ remote_target::pid_to_exec_file (int pid) static gdb::optional filename; char *annex =3D NULL; =20 - if (packet_support (PACKET_qXfer_exec_file) !=3D PACKET_ENABLE) + if (m_features.packet_support (PACKET_qXfer_exec_file) !=3D PACKET_ENABL= E) return NULL; =20 inferior *inf =3D find_inferior_pid (this, pid); @@ -14330,11 +14439,11 @@ remote_target::can_do_single_step () feature. If the stub doesn't support vContSupported feature, we have conservatively to think target doesn't supports single step. */ - if (packet_support (PACKET_vContSupported) =3D=3D PACKET_ENABLE) + if (m_features.packet_support (PACKET_vContSupported) =3D=3D PACKET_ENAB= LE) { struct remote_state *rs =3D get_remote_state (); =20 - if (packet_support (PACKET_vCont) =3D=3D PACKET_SUPPORT_UNKNOWN) + if (m_features.packet_support (PACKET_vCont) =3D=3D PACKET_SUPPORT_U= NKNOWN) remote_vcont_probe (); =20 return rs->supports_vCont.s && rs->supports_vCont.S; @@ -14474,15 +14583,14 @@ remote_target::thread_events (int enable) struct remote_state *rs =3D get_remote_state (); size_t size =3D get_remote_packet_size (); =20 - if (packet_support (PACKET_QThreadEvents) =3D=3D PACKET_DISABLE) + if (m_features.packet_support (PACKET_QThreadEvents) =3D=3D PACKET_DISAB= LE) return; =20 xsnprintf (rs->buf.data (), size, "QThreadEvents:%x", enable ? 1 : 0); putpkt (rs->buf); getpkt (&rs->buf, 0); =20 - switch (packet_ok (rs->buf, - &remote_protocol_packets[PACKET_QThreadEvents])) + switch (m_features.packet_ok (rs->buf, PACKET_QThreadEvents)) { case PACKET_OK: if (strcmp (rs->buf.data (), "OK") !=3D 0) @@ -14646,10 +14754,10 @@ show_range_stepping (struct ui_file *file, int fr= om_tty, bool remote_target::vcont_r_supported () { - if (packet_support (PACKET_vCont) =3D=3D PACKET_SUPPORT_UNKNOWN) + if (m_features.packet_support (PACKET_vCont) =3D=3D PACKET_SUPPORT_UNKNO= WN) remote_vcont_probe (); =20 - return (packet_support (PACKET_vCont) =3D=3D PACKET_ENABLE + return (m_features.packet_support (PACKET_vCont) =3D=3D PACKET_ENABLE && get_remote_state ()->supports_vCont.r); } =20 @@ -14692,7 +14800,7 @@ show_remote_timeout (struct ui_file *file, int from= _tty, bool remote_target::supports_memory_tagging () { - return remote_memory_tagging_p (); + return m_features.remote_memory_tagging_p (); } =20 /* Create the qMemTags packet given ADDRESS, LEN and TYPE. */ @@ -14758,7 +14866,7 @@ remote_target::fetch_memtags (CORE_ADDR address, si= ze_t len, gdb::byte_vector &tags, int type) { /* Make sure the qMemTags packet is supported. */ - if (!remote_memory_tagging_p ()) + if (!m_features.remote_memory_tagging_p ()) gdb_assert_not_reached ("remote fetch_memtags called with packet disab= led"); =20 struct remote_state *rs =3D get_remote_state (); @@ -14778,7 +14886,7 @@ remote_target::store_memtags (CORE_ADDR address, si= ze_t len, const gdb::byte_vector &tags, int type) { /* Make sure the QMemTags packet is supported. */ - if (!remote_memory_tagging_p ()) + if (!m_features.remote_memory_tagging_p ()) gdb_assert_not_reached ("remote store_memtags called with packet disab= led"); =20 struct remote_state *rs =3D get_remote_state (); @@ -14813,7 +14921,7 @@ test_memory_tagging_functions () remote_target remote; =20 struct packet_config *config - =3D &remote_protocol_packets[PACKET_memory_tagging_feature]; + =3D &remote.m_features.m_protocol_packets[PACKET_memory_tagging_featur= e]; =20 scoped_restore restore_memtag_support_ =3D make_scoped_restore (&config->support); @@ -15028,257 +15136,221 @@ Show the maximum size of the address (in bits) = in a memory packet."), NULL, =20 init_all_packet_configs (); =20 - add_packet_config_cmd (&remote_protocol_packets[PACKET_X], - "X", "binary-download", 1); + add_packet_config_cmd (PACKET_X, "X", "binary-download", 1); =20 - add_packet_config_cmd (&remote_protocol_packets[PACKET_vCont], - "vCont", "verbose-resume", 0); + add_packet_config_cmd (PACKET_vCont, "vCont", "verbose-resume", 0); =20 - add_packet_config_cmd (&remote_protocol_packets[PACKET_QPassSignals], - "QPassSignals", "pass-signals", 0); + add_packet_config_cmd (PACKET_QPassSignals, "QPassSignals", "pass-signal= s", + 0); =20 - add_packet_config_cmd (&remote_protocol_packets[PACKET_QCatchSyscalls], - "QCatchSyscalls", "catch-syscalls", 0); + add_packet_config_cmd (PACKET_QCatchSyscalls, "QCatchSyscalls", + "catch-syscalls", 0); =20 - add_packet_config_cmd (&remote_protocol_packets[PACKET_QProgramSignals], - "QProgramSignals", "program-signals", 0); + add_packet_config_cmd (PACKET_QProgramSignals, "QProgramSignals", + "program-signals", 0); =20 - add_packet_config_cmd (&remote_protocol_packets[PACKET_QSetWorkingDir], - "QSetWorkingDir", "set-working-dir", 0); + add_packet_config_cmd (PACKET_QSetWorkingDir, "QSetWorkingDir", + "set-working-dir", 0); =20 - add_packet_config_cmd (&remote_protocol_packets[PACKET_QStartupWithShell= ], - "QStartupWithShell", "startup-with-shell", 0); + add_packet_config_cmd (PACKET_QStartupWithShell, "QStartupWithShell", + "startup-with-shell", 0); =20 - add_packet_config_cmd (&remote_protocol_packets - [PACKET_QEnvironmentHexEncoded], - "QEnvironmentHexEncoded", "environment-hex-encoded", - 0); + add_packet_config_cmd (PACKET_QEnvironmentHexEncoded,"QEnvironmentHexEnc= oded", + "environment-hex-encoded", 0); =20 - add_packet_config_cmd (&remote_protocol_packets[PACKET_QEnvironmentReset= ], - "QEnvironmentReset", "environment-reset", - 0); + add_packet_config_cmd (PACKET_QEnvironmentReset, "QEnvironmentReset", + "environment-reset", 0); =20 - add_packet_config_cmd (&remote_protocol_packets[PACKET_QEnvironmentUnset= ], - "QEnvironmentUnset", "environment-unset", - 0); + add_packet_config_cmd (PACKET_QEnvironmentUnset, "QEnvironmentUnset", + "environment-unset", 0); =20 - add_packet_config_cmd (&remote_protocol_packets[PACKET_qSymbol], - "qSymbol", "symbol-lookup", 0); + add_packet_config_cmd (PACKET_qSymbol, "qSymbol", "symbol-lookup", 0); =20 - add_packet_config_cmd (&remote_protocol_packets[PACKET_P], - "P", "set-register", 1); + add_packet_config_cmd (PACKET_P, "P", "set-register", 1); =20 - add_packet_config_cmd (&remote_protocol_packets[PACKET_p], - "p", "fetch-register", 1); + add_packet_config_cmd (PACKET_p, "p", "fetch-register", 1); =20 - add_packet_config_cmd (&remote_protocol_packets[PACKET_Z0], - "Z0", "software-breakpoint", 0); + add_packet_config_cmd (PACKET_Z0, "Z0", "software-breakpoint", 0); =20 - add_packet_config_cmd (&remote_protocol_packets[PACKET_Z1], - "Z1", "hardware-breakpoint", 0); + add_packet_config_cmd (PACKET_Z1, "Z1", "hardware-breakpoint", 0); =20 - add_packet_config_cmd (&remote_protocol_packets[PACKET_Z2], - "Z2", "write-watchpoint", 0); + add_packet_config_cmd (PACKET_Z2, "Z2", "write-watchpoint", 0); =20 - add_packet_config_cmd (&remote_protocol_packets[PACKET_Z3], - "Z3", "read-watchpoint", 0); + add_packet_config_cmd (PACKET_Z3, "Z3", "read-watchpoint", 0); =20 - add_packet_config_cmd (&remote_protocol_packets[PACKET_Z4], - "Z4", "access-watchpoint", 0); + add_packet_config_cmd (PACKET_Z4, "Z4", "access-watchpoint", 0); =20 - add_packet_config_cmd (&remote_protocol_packets[PACKET_qXfer_auxv], - "qXfer:auxv:read", "read-aux-vector", 0); + add_packet_config_cmd (PACKET_qXfer_auxv, "qXfer:auxv:read", + "read-aux-vector", 0); =20 - add_packet_config_cmd (&remote_protocol_packets[PACKET_qXfer_exec_file], - "qXfer:exec-file:read", "pid-to-exec-file", 0); + add_packet_config_cmd (PACKET_qXfer_exec_file, "qXfer:exec-file:read", + "pid-to-exec-file", 0); =20 - add_packet_config_cmd (&remote_protocol_packets[PACKET_qXfer_features], + add_packet_config_cmd (PACKET_qXfer_features, "qXfer:features:read", "target-features", 0); =20 - add_packet_config_cmd (&remote_protocol_packets[PACKET_qXfer_libraries], - "qXfer:libraries:read", "library-info", 0); + add_packet_config_cmd (PACKET_qXfer_libraries, "qXfer:libraries:read", + "library-info", 0); =20 - add_packet_config_cmd (&remote_protocol_packets[PACKET_qXfer_libraries_s= vr4], + add_packet_config_cmd (PACKET_qXfer_libraries_svr4, "qXfer:libraries-svr4:read", "library-info-svr4", 0); =20 - add_packet_config_cmd (&remote_protocol_packets[PACKET_qXfer_memory_map], - "qXfer:memory-map:read", "memory-map", 0); + add_packet_config_cmd (PACKET_qXfer_memory_map, "qXfer:memory-map:read", + "memory-map", 0); =20 - add_packet_config_cmd (&remote_protocol_packets[PACKET_qXfer_osdata], - "qXfer:osdata:read", "osdata", 0); + add_packet_config_cmd (PACKET_qXfer_osdata, "qXfer:osdata:read", "osdata= ", 0); =20 - add_packet_config_cmd (&remote_protocol_packets[PACKET_qXfer_threads], - "qXfer:threads:read", "threads", 0); + add_packet_config_cmd (PACKET_qXfer_threads, "qXfer:threads:read", "thre= ads", + 0); =20 - add_packet_config_cmd (&remote_protocol_packets[PACKET_qXfer_siginfo_rea= d], - "qXfer:siginfo:read", "read-siginfo-object", 0); + add_packet_config_cmd (PACKET_qXfer_siginfo_read, "qXfer:siginfo:read", + "read-siginfo-object", 0); =20 - add_packet_config_cmd (&remote_protocol_packets[PACKET_qXfer_siginfo_wri= te], - "qXfer:siginfo:write", "write-siginfo-object", 0); + add_packet_config_cmd (PACKET_qXfer_siginfo_write, "qXfer:siginfo:write", + "write-siginfo-object", 0); =20 - add_packet_config_cmd - (&remote_protocol_packets[PACKET_qXfer_traceframe_info], - "qXfer:traceframe-info:read", "traceframe-info", 0); + add_packet_config_cmd (PACKET_qXfer_traceframe_info, + "qXfer:traceframe-info:read", "traceframe-info", 0); =20 - add_packet_config_cmd (&remote_protocol_packets[PACKET_qXfer_uib], - "qXfer:uib:read", "unwind-info-block", 0); + add_packet_config_cmd (PACKET_qXfer_uib, "qXfer:uib:read", + "unwind-info-block", 0); =20 - add_packet_config_cmd (&remote_protocol_packets[PACKET_qGetTLSAddr], - "qGetTLSAddr", "get-thread-local-storage-address", - 0); + add_packet_config_cmd (PACKET_qGetTLSAddr, "qGetTLSAddr", + "get-thread-local-storage-address", 0); =20 - add_packet_config_cmd (&remote_protocol_packets[PACKET_qGetTIBAddr], - "qGetTIBAddr", "get-thread-information-block-address", - 0); + add_packet_config_cmd (PACKET_qGetTIBAddr, "qGetTIBAddr", + "get-thread-information-block-address", 0); =20 - add_packet_config_cmd (&remote_protocol_packets[PACKET_bc], - "bc", "reverse-continue", 0); + add_packet_config_cmd (PACKET_bc, "bc", "reverse-continue", 0); =20 - add_packet_config_cmd (&remote_protocol_packets[PACKET_bs], - "bs", "reverse-step", 0); + add_packet_config_cmd (PACKET_bs, "bs", "reverse-step", 0); =20 - add_packet_config_cmd (&remote_protocol_packets[PACKET_qSupported], - "qSupported", "supported-packets", 0); + add_packet_config_cmd (PACKET_qSupported, "qSupported", "supported-packe= ts", + 0); =20 - add_packet_config_cmd (&remote_protocol_packets[PACKET_qSearch_memory], - "qSearch:memory", "search-memory", 0); + add_packet_config_cmd (PACKET_qSearch_memory, "qSearch:memory", + "search-memory", 0); =20 - add_packet_config_cmd (&remote_protocol_packets[PACKET_qTStatus], - "qTStatus", "trace-status", 0); + add_packet_config_cmd (PACKET_qTStatus, "qTStatus", "trace-status", 0); =20 - add_packet_config_cmd (&remote_protocol_packets[PACKET_vFile_setfs], - "vFile:setfs", "hostio-setfs", 0); + add_packet_config_cmd (PACKET_vFile_setfs, "vFile:setfs", "hostio-setfs"= , 0); =20 - add_packet_config_cmd (&remote_protocol_packets[PACKET_vFile_open], - "vFile:open", "hostio-open", 0); + add_packet_config_cmd (PACKET_vFile_open, "vFile:open", "hostio-open", 0= ); =20 - add_packet_config_cmd (&remote_protocol_packets[PACKET_vFile_pread], - "vFile:pread", "hostio-pread", 0); + add_packet_config_cmd (PACKET_vFile_pread, "vFile:pread", "hostio-pread"= , 0); =20 - add_packet_config_cmd (&remote_protocol_packets[PACKET_vFile_pwrite], - "vFile:pwrite", "hostio-pwrite", 0); + add_packet_config_cmd (PACKET_vFile_pwrite, "vFile:pwrite", "hostio-pwri= te", + 0); =20 - add_packet_config_cmd (&remote_protocol_packets[PACKET_vFile_close], - "vFile:close", "hostio-close", 0); + add_packet_config_cmd (PACKET_vFile_close, "vFile:close", "hostio-close"= , 0); =20 - add_packet_config_cmd (&remote_protocol_packets[PACKET_vFile_unlink], - "vFile:unlink", "hostio-unlink", 0); + add_packet_config_cmd (PACKET_vFile_unlink, "vFile:unlink", "hostio-unli= nk", + 0); =20 - add_packet_config_cmd (&remote_protocol_packets[PACKET_vFile_readlink], - "vFile:readlink", "hostio-readlink", 0); + add_packet_config_cmd (PACKET_vFile_readlink, "vFile:readlink", + "hostio-readlink", 0); =20 - add_packet_config_cmd (&remote_protocol_packets[PACKET_vFile_fstat], - "vFile:fstat", "hostio-fstat", 0); + add_packet_config_cmd (PACKET_vFile[...] [diff truncated at 100000 bytes]