This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH v2] Fix several "set remote foo-packet on/off" commands.


On 04/01/2014 01:06 PM, Pedro Alves wrote:

> Here's what I'm folding into v2 of the patch.

And here's the resulting v2.  I've fixed a couple typos in the commit
log entry, but otherwise, nothing else changed.

------
Subject: [PATCH] Fix several "set remote foo-packet on/off" commands.

For several RSP packets, there's a corresponding "set remote
foo-packet on/off/auto" command that one can use do bypass
auto-detection of support for the packet or feature.  However, I
noticed that setting several of these commands to 'on' or 'off'
doesn't actually have any effect.  These are, at least:

 set remote breakpoint-commands-packet
 set remote conditional-breakpoints-packet
 set remote fast-tracepoints-packet
 set remote static-tracepoints-packet
 set remote install-in-trace-packet

These are commands that control a remote protocol feature that doesn't
have a corresponding regular packet, and because of that we cache the
knowledge of the remote side support as returned by the qSupported
packet in the remote_state object.

E.g., in the case of the 'set remote breakpoint-commands-packet'
command, whether the feature is supported is recorded in the
'breakpoint_commands' field of the remote_state object.

Whether to bypass packet support auto-detection or not is controlled
by the 'detect' field of the corresponding packet's packet_config
structure.  That field is the variable associated directly with the
"set remote foo-packet" command.  Actual remote stub support for the
packet (or feature) is recorded in the 'support' field of the same
structure.

However, when the user toggles the command, the 'support' field is
also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN,
discarding the knowledge of whether the target actually supports the
feature.  If one toggles back to 'auto', it's no big issue for real
packets, as they'll just end up re-probed the next time they might be
necessary.  But features whose support is only reported through
qSupported don't get their corresponding (manually added/maintained)
fields in remote_state objected updated.  As we lost the actual status
of the target support for the feature, GDB would need to probe the
qSupported features again, which GDB doesn't do.

But we can avoid that extra traffic, and clean things up, IMO.
Instead of going in that direction, this patch completely decouples
struct packet_config's 'detect' and 'support' fields.  E.g., when the
user does "set remote foo-packet off", instead of setting the packet
config's 'support' field to PACKET_DISABLE, the 'support' field is not
touched at all anymore.  That is, we end up respecting this simple
table:

| packet_config->detect | packet_config->support | should use packet/feature? |
|-----------------------+------------------------+----------------------------|
| auto                  | PACKET_ENABLE          | PACKET_ENABLE              |
| auto                  | PACKET_DISABLE         | PACKET_DISABLE             |
| auto                  | PACKET_UNKNOWN         | PACKET_UNKNOWN             |
| yes                   | don't care             | PACKET_ENABLE              |
| no                    | don't care             | PACKET_DISABLE             |

This is implemented by the new packet_support function.  With that, we
need to update this pattern throughout:

  if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE)

to do this instead:

  if (packet_support (PACKET_qAttached) == PACKET_DISABLE)

where as mentioned, the packet_support function takes struct
packet_config's 'detect' field into account, like in the table above.

As when the packet is force-disabled or force-enabled, the 'support'
field is just ignored, if the command is set back to auto, we'll
resume respecting whatever the target said it supports.  IOW, the end
result is that the 'support' field always represents whether the
target actually supports the packet or not.

After all that, the manually maintained breakpoint_commands and
equivalent fields of struct remote_state can then be eliminated, with
references replaced by checking the result of calling the
packet_support function on the corresponding packet or feature.  This
required adding new PACKET_foo enum values for several features that
didn't have it yet.  (The patch does not add corresponding "set remote
foo-packet" style commands though, focusing only on bug fixing and
laying the groundwork).

Tested on x86_64 Fedora 17, native GDBserver.  The new tests all fail
without this patch.

gdb/
2014-04-01  Pedro Alves  <palves@redhat.com>

	* remote.c (struct remote_state): Remove multi_process_aware,
	non_stop_aware, cond_tracepoints, cond_breakpoints,
	breakpoint_commands, fast_tracepoints, static_tracepoints,
	install_in_trace, disconnected_tracing,
	enable_disable_tracepoints, string_tracing, and
	augmented_libraries_svr4_read fields.
	(remote_multi_process_p): Move further below in the file.
	(struct packet_config): Add comments.
	(update_packet_config): Delete function.
	(show_packet_config_cmd): Use packet_config_support.
	(add_packet_config_cmd): Use NULL as set callback.
	(packet_ok): "set remote foo-packet"-style commands no longer
	change config->supported -- adjust.
	(PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints)
	(PACKET_BreakpointCommands, PACKET_FastTracepoints)
	(PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments.
	(PACKET_QNonStop, PACKET_multiprocess_feature)
	(PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature)
	(PACKET_DisconnectedTracing_feature)
	(PACKET_augmented_libraries_svr4_read_feature): New enum values.
	(set_remote_protocol_packet_cmd): Delete function.
	(packet_config_support, packet_support): New functions.
	(set_remote_protocol_Z_packet_cmd): Don't call
	update_packet_config.
	(remote_query_attached, remote_pass_signals)
	(remote_program_signals, remote_threads_info)
	(remote_threads_extra_info, remote_start_remote): Use
	packet_support.
	(remote_start_remote): Use packet_config_support and
	packet_support.
	(init_all_packet_configs): Set all packets to unknown support,
	instead of calling update_packet_config.
	(remote_check_symbols): Use packet_support.
	(remote_supported_packet): Unconditionally set the packet config's
	support status.
	(remote_multi_process_feature, remote_non_stop_feature)
	(remote_cond_tracepoint_feature, remote_cond_breakpoint_feature)
	(remote_breakpoint_commands_feature)
	(remote_fast_tracepoint_feature, remote_static_tracepoint_feature)
	(remote_install_in_trace_feature)
	(remote_disconnected_tracing_feature)
	(remote_enable_disable_tracepoint_feature)
	(remote_string_tracing_feature)
	(remote_augmented_libraries_svr4_read_feature): Delete functions.
	(remote_protocol_features): Adjust to use remote_supported_packet
	for "augmented-libraries-svr4-read", "multiprocess", "QNonStop",
	"ConditionalTracepoints", "ConditionalBreakpoints",
	"BreakpointCommands", "FastTracepoints", "StaticTracepoints",
	"InstallInTrace", "DisconnectedTracing", "DisconnectedTracing",
	"EnableDisableTracepoints", and "tracenz".
	(remote_query_supported): Use packet_support.
	(remote_open_1): Adjust.
	(extended_remote_attach_1): Use packet_support.  Switch on the
	result of packet_ok instead of checking whether the packet ended
	up disabled.
	(remote_vcont_resume): Use packet_support.
	(remote_resume, remote_stop_ns, fetch_register_using_p)
	(remote_prepare_to_store, store_register_using_P)
	(check_binary_download, remote_write_bytes): Use packet_support.
	(remote_vkill): Use packet_support.  Switch on the result of
	packet_ok instead of checking whether the packet ended up
	disabled.
	(extended_remote_supports_disable_randomization): Use
	packet_support.
	(extended_remote_run): Switch on the result of packet_ok instead
	of checking whether the packet ended up disabled.
	(remote_insert_breakpoint, remote_remove_breakpoint)
	(remote_insert_watchpoint, remote_remove_watchpoint)
	(remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use
	packet_support.
	(remote_search_memory): Use packet_config_support.
	(remote_get_thread_local_address, remote_get_tib_address)
	(remote_hostio_send_command, remote_can_execute_reverse): Use
	packet_support.
	(remote_supports_cond_tracepoints)
	(remote_supports_cond_breakpoints)
	(remote_supports_fast_tracepoints)
	(remote_supports_static_tracepoints)
	(remote_supports_install_in_trace)
	(remote_supports_enable_disable_tracepoint)
	(remote_supports_string_tracing)
	(remote_can_run_breakpoint_commands): Rewrite, checking whether
	the packet config says the feature is enabled or disabled.
	(remote_download_tracepoint, remote_trace_set_readonly_regions)
	(remote_get_trace_status): Use packet_support.
	(remote_set_disconnected_tracing): Adjust to check whether the
	feature is enabled with packet_support.
	(remote_set_trace_buffer_size, remote_use_agent)
	(remote_can_use_agent, remote_supports_btrace): Use
	packet_support.
	(remote_enable_btrace, remote_disable_btrace, remote_read_btrace):
	Use packet_config_support.
	(remote_augmented_libraries_svr4_read): Rewrite, checking whether
	the packet config says the feature is enabled or disabled.
	(set_range_stepping): Use packet_support.

gdb/testsuite/
2014-04-01  Pedro Alves  <palves@redhat.com>

	* gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to
	user.
	(top level): Test that "set remote conditional-breakpoints-packet
	off" works as intended.
	* gdb.base/dprintf.exp: Test that "set remote
	breakpoint-commands-packet off" works as intended.
	* gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled):
	New function.
	(top level): Call it.
	* gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set
	remote fast-tracepoints-packet off" works as intended.
	* gdb.trace/qtro.exp (gdb_is_target_remote): Moved ...
	* lib/gdb.exp (gdb_is_target_remote): ... here.
---
 gdb/remote.c                              | 587 +++++++++++-------------------
 gdb/testsuite/gdb.base/cond-eval-mode.exp |  14 +-
 gdb/testsuite/gdb.base/dprintf.exp        |  10 +
 gdb/testsuite/gdb.trace/change-loc.exp    |  64 ++++
 gdb/testsuite/gdb.trace/ftrace.exp        |  16 +
 gdb/testsuite/gdb.trace/qtro.exp          |  19 -
 gdb/testsuite/lib/gdb.exp                 |  19 +
 7 files changed, 336 insertions(+), 393 deletions(-)

diff --git a/gdb/remote.c b/gdb/remote.c
index be8c423..dcd3cdd 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -183,11 +183,6 @@ struct packet_config;
 
 static void show_packet_config_cmd (struct packet_config *config);
 
-static void update_packet_config (struct packet_config *config);
-
-static void set_remote_protocol_packet_cmd (char *args, int from_tty,
-					    struct cmd_list_element *c);
-
 static void show_remote_protocol_packet_cmd (struct ui_file *file,
 					     int from_tty,
 					     struct cmd_list_element *c,
@@ -311,10 +306,6 @@ struct remote_state
   /* True if we're connected in extended remote mode.  */
   int extended;
 
-  /* True if the stub reported support for multi-process
-     extensions.  */
-  int multi_process_aware;
-
   /* True if we resumed the target and we're waiting for the target to
      stop.  In the mean time, we can't start another command/query.
      The remote server wouldn't be ready to process it, so we'd
@@ -323,48 +314,9 @@ struct remote_state
      because we allow GDB commands while the target is running.  */
   int waiting_for_stop_reply;
 
-  /* True if the stub reports support for non-stop mode.  */
-  int non_stop_aware;
-
   /* The status of the stub support for the various vCont actions.  */
   struct vCont_action_support supports_vCont;
 
-  /* True if the stub reports support for conditional tracepoints.  */
-  int cond_tracepoints;
-
-  /* True if the stub reports support for target-side breakpoint
-     conditions.  */
-  int cond_breakpoints;
-
-  /* True if the stub reports support for target-side breakpoint
-     commands.  */
-  int breakpoint_commands;
-
-  /* True if the stub reports support for fast tracepoints.  */
-  int fast_tracepoints;
-
-  /* True if the stub reports support for static tracepoints.  */
-  int static_tracepoints;
-
-  /* True if the stub reports support for installing tracepoint while
-     tracing.  */
-  int install_in_trace;
-
-  /* True if the stub can continue running a trace while GDB is
-     disconnected.  */
-  int disconnected_tracing;
-
-  /* True if the stub reports support for enabling and disabling
-     tracepoints while a trace experiment is running.  */
-  int enable_disable_tracepoints;
-
-  /* True if the stub can collect strings using tracenz bytecode.  */
-  int string_tracing;
-
-  /* True if the stub supports qXfer:libraries-svr4:read with a
-     non-empty annex.  */
-  int augmented_libraries_svr4_read;
-
   /* Nonzero if the user has pressed Ctrl-C, but the target hasn't
      responded to that.  */
   int ctrlc_pending_p;
@@ -442,13 +394,6 @@ free_private_thread_info (struct private_thread_info *info)
   xfree (info);
 }
 
-/* Returns true if the multi-process extensions are in effect.  */
-static int
-remote_multi_process_p (struct remote_state *rs)
-{
-  return rs->multi_process_aware;
-}
-
 /* This data could be associated with a target, but we do not always
    have access to the current target when we need it, so for now it is
    static.  This will be fine for as long as only one target is in use
@@ -1118,7 +1063,14 @@ struct packet_config
   {
     const char *name;
     const char *title;
+
+    /* 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.  */
     enum auto_boolean detect;
+
+    /* Does the target support this packet?  */
     enum packet_support support;
   };
 
@@ -1132,29 +1084,15 @@ enum packet_result
   PACKET_UNKNOWN
 };
 
-static void
-update_packet_config (struct packet_config *config)
-{
-  switch (config->detect)
-    {
-    case AUTO_BOOLEAN_TRUE:
-      config->support = PACKET_ENABLE;
-      break;
-    case AUTO_BOOLEAN_FALSE:
-      config->support = PACKET_DISABLE;
-      break;
-    case AUTO_BOOLEAN_AUTO:
-      config->support = PACKET_SUPPORT_UNKNOWN;
-      break;
-    }
-}
+static enum packet_support packet_config_support (struct packet_config *config);
+static enum packet_support packet_support (int packet);
 
 static void
 show_packet_config_cmd (struct packet_config *config)
 {
   char *support = "internal-error";
 
-  switch (config->support)
+  switch (packet_config_support (config))
     {
     case PACKET_ENABLE:
       support = "enabled";
@@ -1203,7 +1141,7 @@ add_packet_config_cmd (struct packet_config *config, const char *name,
   add_setshow_auto_boolean_cmd (cmd_name, class_obscure,
 				&config->detect, set_doc,
 				show_doc, NULL, /* help_doc */
-				set_remote_protocol_packet_cmd,
+				NULL,
 				show_remote_protocol_packet_cmd,
 				&remote_set_cmdlist, &remote_show_cmdlist);
   /* The command code copies the documentation strings.  */
@@ -1253,54 +1191,48 @@ packet_ok (const char *buf, struct packet_config *config)
 {
   enum packet_result result;
 
+  if (config->detect != AUTO_BOOLEAN_TRUE
+      && config->support == PACKET_DISABLE)
+    internal_error (__FILE__, __LINE__,
+		    _("packet_ok: attempt to use a disabled packet"));
+
   result = packet_check_result (buf);
   switch (result)
     {
     case PACKET_OK:
     case PACKET_ERROR:
       /* The stub recognized the packet request.  */
-      switch (config->support)
+      if (config->support == PACKET_SUPPORT_UNKNOWN)
 	{
-	case PACKET_SUPPORT_UNKNOWN:
 	  if (remote_debug)
 	    fprintf_unfiltered (gdb_stdlog,
-				    "Packet %s (%s) is supported\n",
-				    config->name, config->title);
+				"Packet %s (%s) is supported\n",
+				config->name, config->title);
 	  config->support = PACKET_ENABLE;
-	  break;
-	case PACKET_DISABLE:
-	  internal_error (__FILE__, __LINE__,
-			  _("packet_ok: attempt to use a disabled packet"));
-	  break;
-	case PACKET_ENABLE:
-	  break;
 	}
       break;
     case PACKET_UNKNOWN:
       /* The stub does not support the packet.  */
-      switch (config->support)
+      if (config->detect == AUTO_BOOLEAN_AUTO
+	  && config->support == PACKET_ENABLE)
 	{
-	case PACKET_ENABLE:
-	  if (config->detect == AUTO_BOOLEAN_AUTO)
-	    /* 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);
-	  else
-	    /* The user set it wrong.  */
-	    error (_("Enabled packet %s (%s) not recognized by stub"),
-		   config->name, config->title);
-	  break;
-	case PACKET_SUPPORT_UNKNOWN:
-	  if (remote_debug)
-	    fprintf_unfiltered (gdb_stdlog,
-				"Packet %s (%s) is NOT supported\n",
-				config->name, config->title);
-	  config->support = PACKET_DISABLE;
-	  break;
-	case PACKET_DISABLE:
-	  break;
+	  /* 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);
+	}
+      else if (config->detect == AUTO_BOOLEAN_TRUE)
+	{
+	  /* The user set it wrong.  */
+	  error (_("Enabled packet %s (%s) not recognized by stub"),
+		 config->name, config->title);
 	}
+
+      if (remote_debug)
+	fprintf_unfiltered (gdb_stdlog,
+			    "Packet %s (%s) is NOT supported\n",
+			    config->name, config->title);
+      config->support = PACKET_DISABLE;
       break;
     }
 
@@ -1350,12 +1282,26 @@ enum {
   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,
@@ -1367,29 +1313,61 @@ enum {
   PACKET_Qbtrace_off,
   PACKET_Qbtrace_bts,
   PACKET_qXfer_btrace,
+
+  /* Support for the QNonStop packet.  */
+  PACKET_QNonStop,
+
+  /* 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,
+
   PACKET_MAX
 };
 
 static struct packet_config remote_protocol_packets[PACKET_MAX];
 
-static void
-set_remote_protocol_packet_cmd (char *args, int from_tty,
-				struct cmd_list_element *c)
-{
-  struct packet_config *packet;
+/* Returns whether a given packet or feature is supported.  This takes
+   into account the state of the corresponding "set remote foo-packet"
+   command, which may be used to bypass auto-detection.  */
 
-  for (packet = remote_protocol_packets;
-       packet < &remote_protocol_packets[PACKET_MAX];
-       packet++)
+static enum packet_support
+packet_config_support (struct packet_config *config)
+{
+  switch (config->detect)
     {
-      if (&packet->detect == c->var)
-	{
-	  update_packet_config (packet);
-	  return;
-	}
+    case AUTO_BOOLEAN_TRUE:
+      return PACKET_ENABLE;
+    case AUTO_BOOLEAN_FALSE:
+      return PACKET_DISABLE;
+    case AUTO_BOOLEAN_AUTO:
+      return config->support;
+    default:
+      gdb_assert_not_reached (_("bad switch"));
     }
-  internal_error (__FILE__, __LINE__, _("Could not find config for %s"),
-		  c->name);
+}
+
+/* Same as packet_config_support, but takes the packet's enum value as
+   argument.  */
+
+static enum packet_support
+packet_support (int packet)
+{
+  struct packet_config *config = &remote_protocol_packets[packet];
+
+  return packet_config_support (config);
 }
 
 static void
@@ -1437,10 +1415,7 @@ set_remote_protocol_Z_packet_cmd (char *args, int from_tty,
   int i;
 
   for (i = 0; i < NR_Z_PACKET_TYPES; i++)
-    {
-      remote_protocol_packets[PACKET_Z0 + i].detect = remote_Z_packet_detect;
-      update_packet_config (&remote_protocol_packets[PACKET_Z0 + i]);
-    }
+    remote_protocol_packets[PACKET_Z0 + i].detect = remote_Z_packet_detect;
 }
 
 static void
@@ -1456,6 +1431,14 @@ show_remote_protocol_Z_packet_cmd (struct ui_file *file, int from_tty,
     }
 }
 
+/* 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) == PACKET_ENABLE;
+}
+
 /* Tokens for use by the asynchronous signal handlers for SIGINT.  */
 static struct async_signal_handler *async_sigint_remote_twice_token;
 static struct async_signal_handler *async_sigint_remote_token;
@@ -1481,7 +1464,7 @@ remote_query_attached (int pid)
   struct remote_state *rs = get_remote_state ();
   size_t size = get_remote_packet_size ();
 
-  if (remote_protocol_packets[PACKET_qAttached].support == PACKET_DISABLE)
+  if (packet_support (PACKET_qAttached) == PACKET_DISABLE)
     return 0;
 
   if (remote_multi_process_p (rs))
@@ -1701,7 +1684,7 @@ static void
 remote_pass_signals (struct target_ops *self,
 		     int numsigs, unsigned char *pass_signals)
 {
-  if (remote_protocol_packets[PACKET_QPassSignals].support != PACKET_DISABLE)
+  if (packet_support (PACKET_QPassSignals) != PACKET_DISABLE)
     {
       char *pass_packet, *p;
       int count = 0, i;
@@ -1752,7 +1735,7 @@ static void
 remote_program_signals (struct target_ops *self,
 			int numsigs, unsigned char *signals)
 {
-  if (remote_protocol_packets[PACKET_QProgramSignals].support != PACKET_DISABLE)
+  if (packet_support (PACKET_QProgramSignals) != PACKET_DISABLE)
     {
       char *packet, *p;
       int count = 0, i;
@@ -2699,7 +2682,7 @@ remote_threads_info (struct target_ops *ops)
     error (_("Command can only be used when connected to the remote target."));
 
 #if defined(HAVE_LIBEXPAT)
-  if (remote_protocol_packets[PACKET_qXfer_threads].support == PACKET_ENABLE)
+  if (packet_support (PACKET_qXfer_threads) == PACKET_ENABLE)
     {
       char *xml = target_read_stralloc (&current_target,
 					 TARGET_OBJECT_THREADS, NULL);
@@ -2831,7 +2814,7 @@ remote_threads_extra_info (struct target_ops *self, struct thread_info *tp)
        server doesn't know about it.  */
     return NULL;
 
-  if (remote_protocol_packets[PACKET_qXfer_threads].support == PACKET_ENABLE)
+  if (packet_support (PACKET_qXfer_threads) == PACKET_ENABLE)
     {
       struct thread_info *info = find_thread_ptid (tp->ptid);
 
@@ -3357,7 +3340,7 @@ remote_start_remote (int from_tty, struct target_ops *target, int extended_p)
   remote_query_supported ();
 
   /* If the stub wants to get a QAllow, compose one and send it.  */
-  if (remote_protocol_packets[PACKET_QAllow].support != PACKET_DISABLE)
+  if (packet_support (PACKET_QAllow) != PACKET_DISABLE)
     remote_set_permissions (target);
 
   /* Next, we possibly activate noack mode.
@@ -3374,10 +3357,7 @@ remote_start_remote (int from_tty, struct target_ops *target, int extended_p)
      stub claimed should be the default with qSupported.  */
 
   noack_config = &remote_protocol_packets[PACKET_QStartNoAckMode];
-
-  if (noack_config->detect == AUTO_BOOLEAN_TRUE
-      || (noack_config->detect == AUTO_BOOLEAN_AUTO
-	  && noack_config->support == PACKET_ENABLE))
+  if (packet_config_support (noack_config) != PACKET_DISABLE)
     {
       putpkt ("QStartNoAckMode");
       getpkt (&rs->buf, &rs->buf_size, 0);
@@ -3411,7 +3391,7 @@ remote_start_remote (int from_tty, struct target_ops *target, int extended_p)
 
   if (non_stop)
     {
-      if (!rs->non_stop_aware)
+      if (packet_support (PACKET_QNonStop) != PACKET_ENABLE)
 	error (_("Non-stop mode requested, but remote "
 		 "does not support non-stop"));
 
@@ -3427,7 +3407,7 @@ remote_start_remote (int from_tty, struct target_ops *target, int extended_p)
 	 stopped.  */
       remote_threads_info (target);
     }
-  else if (rs->non_stop_aware)
+  else if (packet_support (PACKET_QNonStop) == PACKET_ENABLE)
     {
       /* Don't assume that the stub can operate in all-stop mode.
 	 Request it explicitly.  */
@@ -3660,7 +3640,7 @@ init_all_packet_configs (void)
   int i;
 
   for (i = 0; i < PACKET_MAX; i++)
-    update_packet_config (&remote_protocol_packets[i]);
+    remote_protocol_packets[i].support = PACKET_SUPPORT_UNKNOWN;
 }
 
 /* Symbol look-up.  */
@@ -3681,7 +3661,7 @@ remote_check_symbols (void)
   if (!target_has_execution)
     return;
 
-  if (remote_protocol_packets[PACKET_qSymbol].support == PACKET_DISABLE)
+  if (packet_support (PACKET_qSymbol) == PACKET_DISABLE)
     return;
 
   /* Make sure the remote is pointing at the right process.  Note
@@ -3819,9 +3799,7 @@ remote_supported_packet (const struct protocol_feature *feature,
       return;
     }
 
-  if (remote_protocol_packets[feature->packet].support
-      == PACKET_SUPPORT_UNKNOWN)
-    remote_protocol_packets[feature->packet].support = support;
+  remote_protocol_packets[feature->packet].support = support;
 }
 
 static void
@@ -3863,124 +3841,6 @@ remote_packet_size (const struct protocol_feature *feature,
   rs->explicit_packet_size = packet_size;
 }
 
-static void
-remote_multi_process_feature (const struct protocol_feature *feature,
-			      enum packet_support support, const char *value)
-{
-  struct remote_state *rs = get_remote_state ();
-
-  rs->multi_process_aware = (support == PACKET_ENABLE);
-}
-
-static void
-remote_non_stop_feature (const struct protocol_feature *feature,
-			      enum packet_support support, const char *value)
-{
-  struct remote_state *rs = get_remote_state ();
-
-  rs->non_stop_aware = (support == PACKET_ENABLE);
-}
-
-static void
-remote_cond_tracepoint_feature (const struct protocol_feature *feature,
-				       enum packet_support support,
-				       const char *value)
-{
-  struct remote_state *rs = get_remote_state ();
-
-  rs->cond_tracepoints = (support == PACKET_ENABLE);
-}
-
-static void
-remote_cond_breakpoint_feature (const struct protocol_feature *feature,
-				enum packet_support support,
-				const char *value)
-{
-  struct remote_state *rs = get_remote_state ();
-
-  rs->cond_breakpoints = (support == PACKET_ENABLE);
-}
-
-static void
-remote_breakpoint_commands_feature (const struct protocol_feature *feature,
-				    enum packet_support support,
-				    const char *value)
-{
-  struct remote_state *rs = get_remote_state ();
-
-  rs->breakpoint_commands = (support == PACKET_ENABLE);
-}
-
-static void
-remote_fast_tracepoint_feature (const struct protocol_feature *feature,
-				enum packet_support support,
-				const char *value)
-{
-  struct remote_state *rs = get_remote_state ();
-
-  rs->fast_tracepoints = (support == PACKET_ENABLE);
-}
-
-static void
-remote_static_tracepoint_feature (const struct protocol_feature *feature,
-				  enum packet_support support,
-				  const char *value)
-{
-  struct remote_state *rs = get_remote_state ();
-
-  rs->static_tracepoints = (support == PACKET_ENABLE);
-}
-
-static void
-remote_install_in_trace_feature (const struct protocol_feature *feature,
-				 enum packet_support support,
-				 const char *value)
-{
-  struct remote_state *rs = get_remote_state ();
-
-  rs->install_in_trace = (support == PACKET_ENABLE);
-}
-
-static void
-remote_disconnected_tracing_feature (const struct protocol_feature *feature,
-				     enum packet_support support,
-				     const char *value)
-{
-  struct remote_state *rs = get_remote_state ();
-
-  rs->disconnected_tracing = (support == PACKET_ENABLE);
-}
-
-static void
-remote_enable_disable_tracepoint_feature (const struct protocol_feature *feature,
-					  enum packet_support support,
-					  const char *value)
-{
-  struct remote_state *rs = get_remote_state ();
-
-  rs->enable_disable_tracepoints = (support == PACKET_ENABLE);
-}
-
-static void
-remote_string_tracing_feature (const struct protocol_feature *feature,
-			       enum packet_support support,
-			       const char *value)
-{
-  struct remote_state *rs = get_remote_state ();
-
-  rs->string_tracing = (support == PACKET_ENABLE);
-}
-
-static void
-remote_augmented_libraries_svr4_read_feature
-  (const struct protocol_feature *feature,
-   enum packet_support support, const char *value)
-{
-  struct remote_state *rs = get_remote_state ();
-
-  rs->augmented_libraries_svr4_read = (support == PACKET_ENABLE);
-}
-
 static const struct protocol_feature remote_protocol_features[] = {
   { "PacketSize", PACKET_DISABLE, remote_packet_size, -1 },
   { "qXfer:auxv:read", PACKET_DISABLE, remote_supported_packet,
@@ -3992,7 +3852,7 @@ static const struct protocol_feature remote_protocol_features[] = {
   { "qXfer:libraries-svr4:read", PACKET_DISABLE, remote_supported_packet,
     PACKET_qXfer_libraries_svr4 },
   { "augmented-libraries-svr4-read", PACKET_DISABLE,
-    remote_augmented_libraries_svr4_read_feature, -1 },
+    remote_supported_packet, PACKET_augmented_libraries_svr4_read_feature },
   { "qXfer:memory-map:read", PACKET_DISABLE, remote_supported_packet,
     PACKET_qXfer_memory_map },
   { "qXfer:spu:read", PACKET_DISABLE, remote_supported_packet,
@@ -4011,26 +3871,27 @@ static const struct protocol_feature remote_protocol_features[] = {
     PACKET_QProgramSignals },
   { "QStartNoAckMode", PACKET_DISABLE, remote_supported_packet,
     PACKET_QStartNoAckMode },
-  { "multiprocess", PACKET_DISABLE, remote_multi_process_feature, -1 },
-  { "QNonStop", PACKET_DISABLE, remote_non_stop_feature, -1 },
+  { "multiprocess", PACKET_DISABLE, remote_supported_packet,
+    PACKET_multiprocess_feature },
+  { "QNonStop", PACKET_DISABLE, remote_supported_packet, PACKET_QNonStop },
   { "qXfer:siginfo:read", PACKET_DISABLE, remote_supported_packet,
     PACKET_qXfer_siginfo_read },
   { "qXfer:siginfo:write", PACKET_DISABLE, remote_supported_packet,
     PACKET_qXfer_siginfo_write },
-  { "ConditionalTracepoints", PACKET_DISABLE, remote_cond_tracepoint_feature,
+  { "ConditionalTracepoints", PACKET_DISABLE, remote_supported_packet,
     PACKET_ConditionalTracepoints },
-  { "ConditionalBreakpoints", PACKET_DISABLE, remote_cond_breakpoint_feature,
+  { "ConditionalBreakpoints", PACKET_DISABLE, remote_supported_packet,
     PACKET_ConditionalBreakpoints },
-  { "BreakpointCommands", PACKET_DISABLE, remote_breakpoint_commands_feature,
+  { "BreakpointCommands", PACKET_DISABLE, remote_supported_packet,
     PACKET_BreakpointCommands },
-  { "FastTracepoints", PACKET_DISABLE, remote_fast_tracepoint_feature,
+  { "FastTracepoints", PACKET_DISABLE, remote_supported_packet,
     PACKET_FastTracepoints },
-  { "StaticTracepoints", PACKET_DISABLE, remote_static_tracepoint_feature,
+  { "StaticTracepoints", PACKET_DISABLE, remote_supported_packet,
     PACKET_StaticTracepoints },
-  {"InstallInTrace", PACKET_DISABLE, remote_install_in_trace_feature,
+  {"InstallInTrace", PACKET_DISABLE, remote_supported_packet,
    PACKET_InstallInTrace},
-  { "DisconnectedTracing", PACKET_DISABLE, remote_disconnected_tracing_feature,
-    -1 },
+  { "DisconnectedTracing", PACKET_DISABLE, remote_supported_packet,
+    PACKET_DisconnectedTracing_feature },
   { "ReverseContinue", PACKET_DISABLE, remote_supported_packet,
     PACKET_bc },
   { "ReverseStep", PACKET_DISABLE, remote_supported_packet,
@@ -4039,8 +3900,8 @@ static const struct protocol_feature remote_protocol_features[] = {
     PACKET_TracepointSource },
   { "QAllow", PACKET_DISABLE, remote_supported_packet,
     PACKET_QAllow },
-  { "EnableDisableTracepoints", PACKET_DISABLE,
-    remote_enable_disable_tracepoint_feature, -1 },
+  { "EnableDisableTracepoints", PACKET_DISABLE, remote_supported_packet,
+    PACKET_EnableDisableTracepoints_feature },
   { "qXfer:fdpic:read", PACKET_DISABLE, remote_supported_packet,
     PACKET_qXfer_fdpic },
   { "qXfer:uib:read", PACKET_DISABLE, remote_supported_packet,
@@ -4050,8 +3911,7 @@ static const struct protocol_feature remote_protocol_features[] = {
   { "QAgent", PACKET_DISABLE, remote_supported_packet, PACKET_QAgent},
   { "QTBuffer:size", PACKET_DISABLE,
     remote_supported_packet, PACKET_QTBuffer_size},
-  { "tracenz", PACKET_DISABLE,
-    remote_string_tracing_feature, -1 },
+  { "tracenz", PACKET_DISABLE, remote_supported_packet, PACKET_tracenz_feature },
   { "Qbtrace:off", PACKET_DISABLE, remote_supported_packet, PACKET_Qbtrace_off },
   { "Qbtrace:bts", PACKET_DISABLE, remote_supported_packet, PACKET_Qbtrace_bts },
   { "qXfer:btrace:read", PACKET_DISABLE, remote_supported_packet,
@@ -4117,7 +3977,7 @@ remote_query_supported (void)
      containing no features.  */
 
   rs->buf[0] = 0;
-  if (remote_protocol_packets[PACKET_qSupported].support != PACKET_DISABLE)
+  if (packet_support (PACKET_qSupported) != PACKET_DISABLE)
     {
       char *q = NULL;
       struct cleanup *old_chain = make_cleanup (free_current_contents, &q);
@@ -4336,9 +4196,7 @@ remote_open_1 (char *name, int from_tty,
   rs->cached_wait_status = 0;
   rs->explicit_packet_size = 0;
   rs->noack_mode = 0;
-  rs->multi_process_aware = 0;
   rs->extended = extended_p;
-  rs->non_stop_aware = 0;
   rs->waiting_for_stop_reply = 0;
   rs->ctrlc_pending_p = 0;
 
@@ -4502,7 +4360,7 @@ extended_remote_attach_1 (struct target_ops *target, char *args, int from_tty)
   /* Remote PID can be freely equal to getpid, do not check it here the same
      way as in other targets.  */
 
-  if (remote_protocol_packets[PACKET_vAttach].support == PACKET_DISABLE)
+  if (packet_support (PACKET_vAttach) == PACKET_DISABLE)
     error (_("This target does not support attaching to a process"));
 
   if (from_tty)
@@ -4523,9 +4381,10 @@ extended_remote_attach_1 (struct target_ops *target, char *args, int from_tty)
   putpkt (rs->buf);
   getpkt (&rs->buf, &rs->buf_size, 0);
 
-  if (packet_ok (rs->buf,
-		 &remote_protocol_packets[PACKET_vAttach]) == PACKET_OK)
+  switch (packet_ok (rs->buf,
+		     &remote_protocol_packets[PACKET_vAttach]))
     {
+    case PACKET_OK:
       if (!non_stop)
 	{
 	  /* Save the reply for later.  */
@@ -4536,12 +4395,13 @@ extended_remote_attach_1 (struct target_ops *target, char *args, int from_tty)
 	error (_("Attaching to %s failed with: %s"),
 	       target_pid_to_str (pid_to_ptid (pid)),
 	       rs->buf);
+      break;
+    case PACKET_UNKNOWN:
+      error (_("This target does not support attaching to a process"));
+    default:
+      error (_("Attaching to %s failed"),
+	     target_pid_to_str (pid_to_ptid (pid)));
     }
-  else if (remote_protocol_packets[PACKET_vAttach].support == PACKET_DISABLE)
-    error (_("This target does not support attaching to a process"));
-  else
-    error (_("Attaching to %s failed"),
-	   target_pid_to_str (pid_to_ptid (pid)));
 
   set_current_inferior (remote_add_inferior (0, pid, 1));
 
@@ -4780,10 +4640,10 @@ remote_vcont_resume (ptid_t ptid, int step, enum gdb_signal siggnal)
   char *p;
   char *endp;
 
-  if (remote_protocol_packets[PACKET_vCont].support == PACKET_SUPPORT_UNKNOWN)
+  if (packet_support (PACKET_vCont) == PACKET_SUPPORT_UNKNOWN)
     remote_vcont_probe (rs);
 
-  if (remote_protocol_packets[PACKET_vCont].support == PACKET_DISABLE)
+  if (packet_support (PACKET_vCont) == PACKET_DISABLE)
     return 0;
 
   p = rs->buf;
@@ -4886,11 +4746,9 @@ remote_resume (struct target_ops *ops,
 	warning (_(" - Can't pass signal %d to target in reverse: ignored."),
 		 siggnal);
 
-      if (step 
-	  && remote_protocol_packets[PACKET_bs].support == PACKET_DISABLE)
+      if (step && packet_support (PACKET_bs) == PACKET_DISABLE)
 	error (_("Remote reverse-step not supported."));
-      if (!step
-	  && remote_protocol_packets[PACKET_bc].support == PACKET_DISABLE)
+      if (!step && packet_support (PACKET_bc) == PACKET_DISABLE)
 	error (_("Remote reverse-continue not supported."));
 
       strcpy (buf, step ? "bs" : "bc");
@@ -5025,7 +4883,7 @@ remote_stop_ns (ptid_t ptid)
   char *p = rs->buf;
   char *endp = rs->buf + get_remote_packet_size ();
 
-  if (remote_protocol_packets[PACKET_vCont].support == PACKET_SUPPORT_UNKNOWN)
+  if (packet_support (PACKET_vCont) == PACKET_SUPPORT_UNKNOWN)
     remote_vcont_probe (rs);
 
   if (!rs->supports_vCont.t)
@@ -6087,7 +5945,7 @@ fetch_register_using_p (struct regcache *regcache, struct packet_reg *reg)
   char regp[MAX_REGISTER_SIZE];
   int i;
 
-  if (remote_protocol_packets[PACKET_p].support == PACKET_DISABLE)
+  if (packet_support (PACKET_p) == PACKET_DISABLE)
     return 0;
 
   if (reg->pnum == -1)
@@ -6350,7 +6208,7 @@ remote_prepare_to_store (struct target_ops *self, struct regcache *regcache)
   gdb_byte buf[MAX_REGISTER_SIZE];
 
   /* Make sure the entire registers array is valid.  */
-  switch (remote_protocol_packets[PACKET_P].support)
+  switch (packet_support (PACKET_P))
     {
     case PACKET_DISABLE:
     case PACKET_SUPPORT_UNKNOWN:
@@ -6378,7 +6236,7 @@ store_register_using_P (const struct regcache *regcache,
   gdb_byte regp[MAX_REGISTER_SIZE];
   char *p;
 
-  if (remote_protocol_packets[PACKET_P].support == PACKET_DISABLE)
+  if (packet_support (PACKET_P) == PACKET_DISABLE)
     return 0;
 
   if (reg->pnum == -1)
@@ -6575,7 +6433,7 @@ check_binary_download (CORE_ADDR addr)
 {
   struct remote_state *rs = get_remote_state ();
 
-  switch (remote_protocol_packets[PACKET_X].support)
+  switch (packet_support (PACKET_X))
     {
     case PACKET_DISABLE:
       break;
@@ -6804,7 +6662,7 @@ remote_write_bytes (CORE_ADDR memaddr, const gdb_byte *myaddr, ULONGEST len,
   /* Check whether the target supports binary download.  */
   check_binary_download (memaddr);
 
-  switch (remote_protocol_packets[PACKET_X].support)
+  switch (packet_support (PACKET_X))
     {
     case PACKET_ENABLE:
       packet_format = "X";
@@ -7828,7 +7686,7 @@ remote_kill (struct target_ops *ops)
 static int
 remote_vkill (int pid, struct remote_state *rs)
 {
-  if (remote_protocol_packets[PACKET_vKill].support == PACKET_DISABLE)
+  if (packet_support (PACKET_vKill) == PACKET_DISABLE)
     return -1;
 
   /* Tell the remote target to detach.  */
@@ -7836,13 +7694,18 @@ remote_vkill (int pid, struct remote_state *rs)
   putpkt (rs->buf);
   getpkt (&rs->buf, &rs->buf_size, 0);
 
-  if (packet_ok (rs->buf,
-		 &remote_protocol_packets[PACKET_vKill]) == PACKET_OK)
-    return 0;
-  else if (remote_protocol_packets[PACKET_vKill].support == PACKET_DISABLE)
-    return -1;
-  else
-    return 1;
+  switch (packet_ok (rs->buf,
+		     &remote_protocol_packets[PACKET_vKill]))
+    {
+    case PACKET_OK:
+      return 0;
+    case PACKET_ERROR:
+      return 1;
+    case PACKET_UNKNOWN:
+      return -1;
+    default:
+      internal_error (__FILE__, __LINE__, _("Bad result from packet_ok"));
+    }
 }
 
 static void
@@ -7962,8 +7825,7 @@ extended_remote_mourn (struct target_ops *ops)
 static int
 extended_remote_supports_disable_randomization (struct target_ops *self)
 {
-  return (remote_protocol_packets[PACKET_QDisableRandomization].support
-	  == PACKET_ENABLE);
+  return packet_support (PACKET_QDisableRandomization) == PACKET_ENABLE;
 }
 
 static void
@@ -7990,7 +7852,7 @@ extended_remote_run (char *args)
 
   /* If the user has disabled vRun support, or we have detected that
      support is not available, do not try it.  */
-  if (remote_protocol_packets[PACKET_vRun].support == PACKET_DISABLE)
+  if (packet_support (PACKET_vRun) == PACKET_DISABLE)
     return -1;
 
   strcpy (rs->buf, "vRun;");
@@ -8026,22 +7888,22 @@ extended_remote_run (char *args)
   putpkt (rs->buf);
   getpkt (&rs->buf, &rs->buf_size, 0);
 
-  if (packet_ok (rs->buf, &remote_protocol_packets[PACKET_vRun]) == PACKET_OK)
+  switch (packet_ok (rs->buf, &remote_protocol_packets[PACKET_vRun]))
     {
+    case PACKET_OK:
       /* We have a wait response.  All is well.  */
       return 0;
-    }
-  else if (remote_protocol_packets[PACKET_vRun].support == PACKET_DISABLE)
-    /* It wasn't disabled before, but it is now.  */
-    return -1;
-  else
-    {
+    case PACKET_UNKNOWN:
+      return -1;
+    case PACKET_ERROR:
       if (remote_exec_file[0] == '\0')
 	error (_("Running the default executable on the remote target failed; "
 		 "try \"set remote exec-file\"?"));
       else
 	error (_("Running \"%s\" on the remote target failed"),
 	       remote_exec_file);
+    default:
+      gdb_assert_not_reached (_("bad switch"));
     }
 }
 
@@ -8181,7 +8043,7 @@ remote_insert_breakpoint (struct target_ops *ops,
      fails, and the user has explicitly requested the Z support then
      report an error, otherwise, mark it disabled and go on.  */
 
-  if (remote_protocol_packets[PACKET_Z0].support != PACKET_DISABLE)
+  if (packet_support (PACKET_Z0) != PACKET_DISABLE)
     {
       CORE_ADDR addr = bp_tgt->placed_address;
       struct remote_state *rs;
@@ -8246,7 +8108,7 @@ remote_remove_breakpoint (struct target_ops *ops,
   CORE_ADDR addr = bp_tgt->placed_address;
   struct remote_state *rs = get_remote_state ();
 
-  if (remote_protocol_packets[PACKET_Z0].support != PACKET_DISABLE)
+  if (packet_support (PACKET_Z0) != PACKET_DISABLE)
     {
       char *p = rs->buf;
       char *endbuf = rs->buf + get_remote_packet_size ();
@@ -8303,7 +8165,7 @@ remote_insert_watchpoint (struct target_ops *self,
   char *p;
   enum Z_packet_type packet = watchpoint_to_Z_packet (type);
 
-  if (remote_protocol_packets[PACKET_Z0 + packet].support == PACKET_DISABLE)
+  if (packet_support (PACKET_Z0 + packet) == PACKET_DISABLE)
     return 1;
 
   /* Make sure the remote is pointing at the right process, if
@@ -8353,7 +8215,7 @@ remote_remove_watchpoint (struct target_ops *self,
   char *p;
   enum Z_packet_type packet = watchpoint_to_Z_packet (type);
 
-  if (remote_protocol_packets[PACKET_Z0 + packet].support == PACKET_DISABLE)
+  if (packet_support (PACKET_Z0 + packet) == PACKET_DISABLE)
     return -1;
 
   /* Make sure the remote is pointing at the right process, if
@@ -8466,7 +8328,7 @@ remote_insert_hw_breakpoint (struct target_ops *self, struct gdbarch *gdbarch,
   gdbarch_remote_breakpoint_from_pc
     (gdbarch, &bp_tgt->placed_address, &bp_tgt->placed_size);
 
-  if (remote_protocol_packets[PACKET_Z1].support == PACKET_DISABLE)
+  if (packet_support (PACKET_Z1) == PACKET_DISABLE)
     return -1;
 
   /* Make sure the remote is pointing at the right process, if
@@ -8524,7 +8386,7 @@ remote_remove_hw_breakpoint (struct target_ops *self, struct gdbarch *gdbarch,
   char *p = rs->buf;
   char *endbuf = rs->buf + get_remote_packet_size ();
 
-  if (remote_protocol_packets[PACKET_Z1].support == PACKET_DISABLE)
+  if (packet_support (PACKET_Z1) == PACKET_DISABLE)
     return -1;
 
   /* Make sure the remote is pointing at the right process, if
@@ -9030,7 +8892,7 @@ remote_search_memory (struct target_ops* ops,
   /* If we already know the packet isn't supported, fall back to the simple
      way of searching memory.  */
 
-  if (packet->support == PACKET_DISABLE)
+  if (packet_config_support (packet) == PACKET_DISABLE)
     {
       /* Target doesn't provided special support, fall back and use the
 	 standard support (copy memory and do the search here).  */
@@ -9398,7 +9260,7 @@ static CORE_ADDR
 remote_get_thread_local_address (struct target_ops *ops,
 				 ptid_t ptid, CORE_ADDR lm, CORE_ADDR offset)
 {
-  if (remote_protocol_packets[PACKET_qGetTLSAddr].support != PACKET_DISABLE)
+  if (packet_support (PACKET_qGetTLSAddr) != PACKET_DISABLE)
     {
       struct remote_state *rs = get_remote_state ();
       char *p = rs->buf;
@@ -9445,7 +9307,7 @@ remote_get_thread_local_address (struct target_ops *ops,
 static int
 remote_get_tib_address (struct target_ops *self, ptid_t ptid, CORE_ADDR *addr)
 {
-  if (remote_protocol_packets[PACKET_qGetTIBAddr].support != PACKET_DISABLE)
+  if (packet_support (PACKET_qGetTIBAddr) != PACKET_DISABLE)
     {
       struct remote_state *rs = get_remote_state ();
       char *p = rs->buf;
@@ -9721,7 +9583,7 @@ remote_hostio_send_command (int command_bytes, int which_packet,
   char *attachment_tmp;
 
   if (!rs->remote_desc
-      || remote_protocol_packets[which_packet].support == PACKET_DISABLE)
+      || packet_support (which_packet) == PACKET_DISABLE)
     {
       *remote_errno = FILEIO_ENOSYS;
       return -1;
@@ -10355,8 +10217,8 @@ remote_command (char *args, int from_tty)
 static int
 remote_can_execute_reverse (struct target_ops *self)
 {
-  if (remote_protocol_packets[PACKET_bs].support == PACKET_ENABLE
-      || remote_protocol_packets[PACKET_bc].support == PACKET_ENABLE)
+  if (packet_support (PACKET_bs) == PACKET_ENABLE
+      || packet_support (PACKET_bc) == PACKET_ENABLE)
     return 1;
   else
     return 0;
@@ -10390,65 +10252,50 @@ remote_supports_multi_process (struct target_ops *self)
 static int
 remote_supports_cond_tracepoints (void)
 {
-  struct remote_state *rs = get_remote_state ();
-
-  return rs->cond_tracepoints;
+  return packet_support (PACKET_ConditionalTracepoints) == PACKET_ENABLE;
 }
 
 static int
 remote_supports_cond_breakpoints (struct target_ops *self)
 {
-  struct remote_state *rs = get_remote_state ();
-
-  return rs->cond_breakpoints;
+  return packet_support (PACKET_ConditionalBreakpoints) == PACKET_ENABLE;
 }
 
 static int
 remote_supports_fast_tracepoints (void)
 {
-  struct remote_state *rs = get_remote_state ();
-
-  return rs->fast_tracepoints;
+  return packet_support (PACKET_FastTracepoints) == PACKET_ENABLE;
 }
 
 static int
 remote_supports_static_tracepoints (void)
 {
-  struct remote_state *rs = get_remote_state ();
-
-  return rs->static_tracepoints;
+  return packet_support (PACKET_StaticTracepoints) == PACKET_ENABLE;
 }
 
 static int
 remote_supports_install_in_trace (void)
 {
-  struct remote_state *rs = get_remote_state ();
-
-  return rs->install_in_trace;
+  return packet_support (PACKET_InstallInTrace) == PACKET_ENABLE;
 }
 
 static int
 remote_supports_enable_disable_tracepoint (struct target_ops *self)
 {
-  struct remote_state *rs = get_remote_state ();
-
-  return rs->enable_disable_tracepoints;
+  return (packet_support (PACKET_EnableDisableTracepoints_feature)
+	  == PACKET_ENABLE);
 }
 
 static int
 remote_supports_string_tracing (struct target_ops *self)
 {
-  struct remote_state *rs = get_remote_state ();
-
-  return rs->string_tracing;
+  return packet_support (PACKET_tracenz_feature) == PACKET_ENABLE;
 }
 
 static int
 remote_can_run_breakpoint_commands (struct target_ops *self)
 {
-  struct remote_state *rs = get_remote_state ();
-
-  return rs->breakpoint_commands;
+  return packet_support (PACKET_BreakpointCommands) == PACKET_ENABLE;
 }
 
 static void
@@ -10666,8 +10513,7 @@ remote_download_tracepoint (struct target_ops *self, struct bp_location *loc)
 	}
     }
 
-  if (remote_protocol_packets[PACKET_TracepointSource].support
-      == PACKET_ENABLE)
+  if (packet_support (PACKET_TracepointSource) == PACKET_ENABLE)
     {
       if (b->addr_string)
 	{
@@ -10819,8 +10665,7 @@ remote_trace_set_readonly_regions (struct target_ops *self)
       sec_length = 1 + strlen (tmp1) + 1 + strlen (tmp2);
       if (offset + sec_length + 1 > target_buf_size)
 	{
-	  if (remote_protocol_packets[PACKET_qXfer_traceframe_info].support
-	      != PACKET_ENABLE)
+	  if (packet_support (PACKET_qXfer_traceframe_info) != PACKET_ENABLE)
 	    warning (_("\
 Too many sections for read-only sections definition packet."));
 	  break;
@@ -10857,7 +10702,7 @@ remote_get_trace_status (struct target_ops *self, struct trace_status *ts)
   volatile struct gdb_exception ex;
   enum packet_result result;
 
-  if (remote_protocol_packets[PACKET_qTStatus].support == PACKET_DISABLE)
+  if (packet_support (PACKET_qTStatus) == PACKET_DISABLE)
     return -1;
 
   trace_regblock_size = get_remote_arch_state ()->sizeof_g_packet;
@@ -11134,7 +10979,7 @@ remote_set_disconnected_tracing (struct target_ops *self, int val)
 {
   struct remote_state *rs = get_remote_state ();
 
-  if (rs->disconnected_tracing)
+  if (packet_support (PACKET_DisconnectedTracing_feature) == PACKET_ENABLE)
     {
       char *reply;
 
@@ -11232,8 +11077,7 @@ remote_get_min_fast_tracepoint_insn_len (struct target_ops *self)
 static void
 remote_set_trace_buffer_size (struct target_ops *self, LONGEST val)
 {
-  if (remote_protocol_packets[PACKET_QTBuffer_size].support
-      != PACKET_DISABLE)
+  if (packet_support (PACKET_QTBuffer_size) != PACKET_DISABLE)
     {
       struct remote_state *rs = get_remote_state ();
       char *buf = rs->buf;
@@ -11311,7 +11155,7 @@ remote_set_trace_notes (struct target_ops *self,
 static int
 remote_use_agent (struct target_ops *self, int use)
 {
-  if (remote_protocol_packets[PACKET_QAgent].support != PACKET_DISABLE)
+  if (packet_support (PACKET_QAgent) != PACKET_DISABLE)
     {
       struct remote_state *rs = get_remote_state ();
 
@@ -11333,7 +11177,7 @@ remote_use_agent (struct target_ops *self, int use)
 static int
 remote_can_use_agent (struct target_ops *self)
 {
-  return (remote_protocol_packets[PACKET_QAgent].support != PACKET_DISABLE);
+  return (packet_support (PACKET_QAgent) != PACKET_DISABLE);
 }
 
 struct btrace_target_info
@@ -11347,11 +11191,11 @@ struct btrace_target_info
 static int
 remote_supports_btrace (struct target_ops *self)
 {
-  if (remote_protocol_packets[PACKET_Qbtrace_off].support != PACKET_ENABLE)
+  if (packet_support (PACKET_Qbtrace_off) != PACKET_ENABLE)
     return 0;
-  if (remote_protocol_packets[PACKET_Qbtrace_bts].support != PACKET_ENABLE)
+  if (packet_support (PACKET_Qbtrace_bts) != PACKET_ENABLE)
     return 0;
-  if (remote_protocol_packets[PACKET_qXfer_btrace].support != PACKET_ENABLE)
+  if (packet_support (PACKET_qXfer_btrace) != PACKET_ENABLE)
     return 0;
 
   return 1;
@@ -11368,7 +11212,7 @@ remote_enable_btrace (struct target_ops *self, ptid_t ptid)
   char *buf = rs->buf;
   char *endbuf = rs->buf + get_remote_packet_size ();
 
-  if (packet->support != PACKET_ENABLE)
+  if (packet_config_support (packet) != PACKET_ENABLE)
     error (_("Target does not support branch tracing."));
 
   set_general_thread (ptid);
@@ -11404,7 +11248,7 @@ remote_disable_btrace (struct target_ops *self,
   char *buf = rs->buf;
   char *endbuf = rs->buf + get_remote_packet_size ();
 
-  if (packet->support != PACKET_ENABLE)
+  if (packet_config_support (packet) != PACKET_ENABLE)
     error (_("Target does not support branch tracing."));
 
   set_general_thread (tinfo->ptid);
@@ -11450,7 +11294,7 @@ remote_read_btrace (struct target_ops *self,
   const char *annex;
   char *xml;
 
-  if (packet->support != PACKET_ENABLE)
+  if (packet_config_support (packet) != PACKET_ENABLE)
     error (_("Target does not support branch tracing."));
 
 #if !defined(HAVE_LIBEXPAT)
@@ -11489,9 +11333,8 @@ remote_read_btrace (struct target_ops *self,
 static int
 remote_augmented_libraries_svr4_read (struct target_ops *self)
 {
-  struct remote_state *rs = get_remote_state ();
-
-  return rs->augmented_libraries_svr4_read;
+  return (packet_support (PACKET_augmented_libraries_svr4_read_feature)
+	  == PACKET_ENABLE);
 }
 
 /* Implementation of to_load.  */
@@ -11844,10 +11687,10 @@ set_range_stepping (char *ignore_args, int from_tty,
     {
       if (rs->remote_desc != NULL)
 	{
-	  if (remote_protocol_packets[PACKET_vCont].support == PACKET_SUPPORT_UNKNOWN)
+	  if (packet_support (PACKET_vCont) == PACKET_SUPPORT_UNKNOWN)
 	    remote_vcont_probe (rs);
 
-	  if (remote_protocol_packets[PACKET_vCont].support == PACKET_ENABLE
+	  if (packet_support (PACKET_vCont) == PACKET_ENABLE
 	      && rs->supports_vCont.r)
 	    return;
 	}
diff --git a/gdb/testsuite/gdb.base/cond-eval-mode.exp b/gdb/testsuite/gdb.base/cond-eval-mode.exp
index fd45499..8128fa9 100644
--- a/gdb/testsuite/gdb.base/cond-eval-mode.exp
+++ b/gdb/testsuite/gdb.base/cond-eval-mode.exp
@@ -30,10 +30,10 @@ gdb_test_no_output $test_auto
 
 # If target-side condition evaluation is not supported, this warning will be
 # displayed.
-set warning "warning: Target does not support breakpoint condition evaluation.\r\nUsing host evaluation mode instead.\r\n"
+set warning "warning: Target does not support breakpoint condition evaluation.\r\nUsing host evaluation mode instead."
 
 gdb_test_multiple $test_target $test_target {
-    -re "$warning$gdb_prompt $" {
+    -re "$warning\r\n$gdb_prompt $" {
 	unsupported $test_target
 	return -1
     }
@@ -42,3 +42,13 @@ gdb_test_multiple $test_target $test_target {
 	pass $test_target
     }
 }
+
+# We now know that the target supports target-side conditional
+# evaluation.  Now make sure it doesn't work when we force-disable the
+# ConditionalBreakpoints RSP feature.
+if [gdb_is_target_remote] {
+    gdb_test_no_output "set remote conditional-breakpoints-packet off"
+
+    gdb_test $test_target "$warning" \
+	"set breakpoint condition-evaluation target, with support disabled"
+}
diff --git a/gdb/testsuite/gdb.base/dprintf.exp b/gdb/testsuite/gdb.base/dprintf.exp
index a040580..afd3312 100644
--- a/gdb/testsuite/gdb.base/dprintf.exp
+++ b/gdb/testsuite/gdb.base/dprintf.exp
@@ -153,3 +153,13 @@ if $target_can_dprintf {
 
 gdb_test "set dprintf-style foobar" "Undefined item: \"foobar\"." \
     "Set dprintf style to an unrecognized type"
+
+# Test that force-disabling the BreakpointCommands RSP feature works
+# as expected.  dprintf relies on support for target-side breakpoint
+# commands --- use it as proxy.
+if [gdb_is_target_remote] {
+    gdb_test_no_output "set remote breakpoint-commands-packet off"
+    gdb_test "set dprintf-style agent" \
+	"warning: Target cannot run dprintf commands.*" \
+	"set dprintf-style agent, with feature disabled"
+}
diff --git a/gdb/testsuite/gdb.trace/change-loc.exp b/gdb/testsuite/gdb.trace/change-loc.exp
index 809ff07..b6b6963 100644
--- a/gdb/testsuite/gdb.trace/change-loc.exp
+++ b/gdb/testsuite/gdb.trace/change-loc.exp
@@ -282,8 +282,71 @@ proc tracepoint_change_loc_2 { trace_type } {
     }
 }
 
+# Test that setting a tracepoint while the trace experiment is ongoing
+# doesn't work when we force-disable the InstallInTrace RSP feature.
+
+proc tracepoint_install_in_trace_disabled { trace_type } {
+    with_test_prefix "InstallInTrace disabled: $trace_type" {
+	global testfile
+	global srcfile
+	global pcreg
+	global gdb_prompt
+
+	clean_restart ${testfile}
+	if ![runto_main] {
+	    fail "Can't run to main"
+	    return -1
+	}
+
+	# This test only makes sense with the remote target.
+	if ![gdb_is_target_remote] {
+	    return
+	}
+
+	gdb_test_no_output "delete break 1"
+
+	# Set a tracepoint we'll never meet.  Just to avoid the
+	# complain after `tstart' later.
+	gdb_test "next" ".*"
+	gdb_test "trace main" \
+	    "Tracepoint \[0-9\] at.* file .*$srcfile, line.*" \
+	    "set tracepoint on main"
+
+	gdb_test "break marker" "Breakpoint.*at.* file .*$srcfile, line.*" \
+	    "breakpoint on marker"
+
+	gdb_test_no_output "tstart"
+
+	# Force-disable the InstallInTrace RSP feature.
+	gdb_test_no_output "set remote install-in-trace-packet off"
+
+	# Set a tracepoint while a trace experiment is ongoing.
+	gdb_test "${trace_type} set_tracepoint" \
+	    "racepoint .* at .* set_tracepoint.*" \
+	    "set tracepoint on set_tracepoint"
+
+	gdb_trace_setactions "set action for tracepoint" "" \
+	    "collect \$$pcreg" "^$"
+
+	# Make sure the tracepoint is _not_ installed on the target.
+	gdb_test "info trace" \
+	    "Num     Type\[ \]+Disp Enb Address\[ \]+What.*
+\[0-9\]+\[\t \]+\(|fast \)tracepoint\[ \]+keep y.*installed on target.*\<MULTIPLE\>.*4\.1.* in func4.*not installed on target.*4\.2.* in func4.*not installed on target.*" \
+	    "tracepoint is not installed"
+
+	gdb_test "continue" ".*Breakpoint.*marker.*at.*$srcfile.*" \
+	    "continue to marker"
+
+	gdb_test_no_output "tstop"
+
+	# Nothing should have been collected.
+	gdb_test "tfind" "Target failed to find requested trace frame\\..*"
+    }
+}
+
 tracepoint_change_loc_1 "trace"
 tracepoint_change_loc_2 "trace"
+tracepoint_install_in_trace_disabled "trace"
 
 # Re-compile test case with IPA.
 set libipa [get_in_proc_agent]
@@ -297,3 +360,4 @@ if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile executable \
 
 tracepoint_change_loc_1 "ftrace"
 tracepoint_change_loc_2 "ftrace"
+tracepoint_install_in_trace_disabled "ftrace"
diff --git a/gdb/testsuite/gdb.trace/ftrace.exp b/gdb/testsuite/gdb.trace/ftrace.exp
index 6d9e76e..aa8a660 100644
--- a/gdb/testsuite/gdb.trace/ftrace.exp
+++ b/gdb/testsuite/gdb.trace/ftrace.exp
@@ -159,6 +159,22 @@ proc test_fast_tracepoints {} {
 		"look at collected local, second time"
 
 	}
+
+	# If debugging with the remote target, try force disabling the
+	# fast tracepoints RSP feature, and confirm fast tracepoints
+	# can no longer be downloaded.
+	set test "fast tracepoint could not be downloaded with the feature disabled"
+	if [gdb_is_target_remote] {
+	    gdb_test "set remote fast-tracepoints-packet off"
+
+	    gdb_test_multiple "tstart" $test {
+		-re "warning: Target does not support fast tracepoints, downloading .* as regular tracepoint.*\r\n$gdb_prompt $" {
+		    pass $test
+		}
+	    }
+	} else {
+	    unsupported $test
+	}
     }
 }
 
diff --git a/gdb/testsuite/gdb.trace/qtro.exp b/gdb/testsuite/gdb.trace/qtro.exp
index 8470a0f..e19ff1c 100644
--- a/gdb/testsuite/gdb.trace/qtro.exp
+++ b/gdb/testsuite/gdb.trace/qtro.exp
@@ -32,25 +32,6 @@ if ![runto_main] {
     return -1
 }
 
-# Check whether we're testing with the remote or extended-remote
-# targets, and whether the target supports tracepoints.
-
-proc gdb_is_target_remote { } {
-    global gdb_prompt
-
-    set test "probe for target remote"
-    gdb_test_multiple "maint print target-stack" $test {
-	-re ".*emote serial target in gdb-specific protocol.*$gdb_prompt $" {
-	    pass $test
-	    return 1
-	}
-	-re "$gdb_prompt $" {
-	    pass $test
-	}
-    }
-    return 0
-}
-
 if ![gdb_is_target_remote] {
     return -1
 }
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 73e935a..0770f4d 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -1635,6 +1635,25 @@ proc skip_shlib_tests {} {
     return 1
 }
 
+# Returns true if we're connected with either the remote or the
+# extended-remote target.
+
+proc gdb_is_target_remote { } {
+    global gdb_prompt
+
+    set test "probe for target remote"
+    gdb_test_multiple "maint print target-stack" $test {
+	-re ".*emote serial target in gdb-specific protocol.*$gdb_prompt $" {
+	    pass $test
+	    return 1
+	}
+	-re "$gdb_prompt $" {
+	    pass $test
+	}
+    }
+    return 0
+}
+
 # Test files shall make sure all the test result lines in gdb.sum are
 # unique in a test run, so that comparing the gdb.sum files of two
 # test runs gives correct results.  Test files that exercise
-- 
1.7.11.7



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]