* [PATCH] Fix several "set remote foo-packet on/off" commands.
@ 2014-03-31 23:53 Pedro Alves
2014-04-01 8:55 ` Yao Qi
0 siblings, 1 reply; 12+ messages in thread
From: Pedro Alves @ 2014-03-31 23:53 UTC (permalink / raw)
To: gdb-patches
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 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 updates uses of 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 mantained 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 bugfixing and
laying the groundwork).
Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail
without this patch.
gdb/
2014-03-31 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-03-31 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 | 586 +++++++++++-------------------
gdb/testsuite/gdb.base/cond-eval-mode.exp | 14 +-
gdb/testsuite/gdb.base/dprintf.exp | 10 +
gdb/testsuite/gdb.trace/change-loc.exp | 65 ++++
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..1aac5e3 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,13 @@ 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 +1463,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 +1683,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 +1734,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 +2681,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 (¤t_target,
TARGET_OBJECT_THREADS, NULL);
@@ -2831,7 +2813,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 +3339,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 +3356,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 +3390,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 +3406,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 +3639,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 +3660,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 +3798,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 +3840,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 +3851,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 +3870,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 +3899,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 +3910,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 +3976,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 +4195,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 +4359,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 +4380,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 +4394,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 +4639,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 +4745,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 +4882,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 +5944,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 +6207,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 +6235,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 +6432,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 +6661,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 +7685,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 +7693,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 +7824,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 +7851,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 +7887,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 +8042,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 +8107,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 +8164,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 +8214,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 +8327,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 +8385,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 +8891,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 +9259,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 +9306,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 +9582,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 +10216,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 +10251,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 +10512,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 +10664,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 +10701,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 +10978,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 +11076,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 +11154,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 +11176,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 +11190,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 +11211,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 +11247,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 +11293,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 +11332,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 +11686,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..ff6918a 100644
--- a/gdb/testsuite/gdb.trace/change-loc.exp
+++ b/gdb/testsuite/gdb.trace/change-loc.exp
@@ -282,8 +282,72 @@ 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 "3 $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_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.
+ set test "set tracepoint on set_tracepoint"
+ gdb_test_multiple "${trace_type} set_tracepoint" $test {
+ -re "Target returns error code .* too far .*$gdb_prompt $" {
+ if [string equal $trace_type "ftrace"] {
+ # The target was unable to install the fast tracepoint
+ # (e.g., jump pad too far from tracepoint).
+ pass "$test (too far)"
+ } else {
+ fail $test
+ }
+ }
+ -re "\r\n$gdb_prompt $" {
+ pass $test
+ }
+ }
+
+ gdb_trace_setactions "set action for tracepoint" "" \
+ "collect \$$pcreg" "^$"
+
+ # 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.*\<MULTIPLE\>.*3\.1.* in func4.*not installed on target.*3\.2.* in func4.*not installed on target.*" \
+ "tracepoint with two locations"
+ }
+}
+
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 +361,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
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] Fix several "set remote foo-packet on/off" commands.
2014-03-31 23:53 [PATCH] Fix several "set remote foo-packet on/off" commands Pedro Alves
@ 2014-04-01 8:55 ` Yao Qi
2014-04-01 12:07 ` Pedro Alves
0 siblings, 1 reply; 12+ messages in thread
From: Yao Qi @ 2014-04-01 8:55 UTC (permalink / raw)
To: Pedro Alves; +Cc: gdb-patches
On 04/01/2014 07:10 AM, Pedro Alves wrote:
> +/* 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;
> +}
Argument 'rs' is not needed. We can remove it.
However, your patch moves more gdb remote target states from
'struct remote_state' to a global state. I feel that it has
conflict with the multi-target project. Not sure it is part
of your plan to convert the global state to per-target state.
> +# 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 "3 $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_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.
> + set test "set tracepoint on set_tracepoint"
> + gdb_test_multiple "${trace_type} set_tracepoint" $test {
> + -re "Target returns error code .* too far .*$gdb_prompt $" {
> + if [string equal $trace_type "ftrace"] {
> + # The target was unable to install the fast tracepoint
> + # (e.g., jump pad too far from tracepoint).
> + pass "$test (too far)"
A nit here, a fast tracepoint is not installed due to "jump pad too far"
instead of "set remote install-in-trace-packet off". Do we want to emit
a PASS here? IMO, UNSUPPORTED is better. Secondly, if "jump pad too far"
causes fast tracepoint not installed, we should return here to skip the
rest of the test, because the test below can't tell why a fast
tracepoint is not installed, is it caused by
"set remote install-in-trace-packet off" or "jump pad too far".
> + } else {
> + fail $test
> + }
> + }
> + -re "\r\n$gdb_prompt $" {
> + pass $test
> + }
> + }
> +
> + 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.*\<MULTIPLE\>.*3\.1.* in func4.*not installed on target.*3\.2.* in func4.*not installed on target.*" \
> + "tracepoint with two locations"
> + }
> +}
> +
--
Yao (é½å°§)
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] Fix several "set remote foo-packet on/off" commands.
2014-04-01 8:55 ` Yao Qi
@ 2014-04-01 12:07 ` Pedro Alves
2014-04-01 12:25 ` [PATCH v2] " Pedro Alves
2014-04-01 12:48 ` [PATCH] " Yao Qi
0 siblings, 2 replies; 12+ messages in thread
From: Pedro Alves @ 2014-04-01 12:07 UTC (permalink / raw)
To: Yao Qi; +Cc: gdb-patches
Hi Yao,
Thanks for the review.
On 04/01/2014 09:53 AM, Yao Qi wrote:
> On 04/01/2014 07:10 AM, Pedro Alves wrote:
>> +/* 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;
>> +}
>
> Argument 'rs' is not needed. We can remove it.
Yeah. (Though note the parameter was already there, I just moved the
function further below at the same time I reimplemented it.)
> However, your patch moves more gdb remote target states from
> 'struct remote_state' to a global state. I feel that it has
> conflict with the multi-target project.
As part of that project, we'll definitely need to move the
whole remote_protocol_packets global array to remote_state.
This global array already exists. I've just moved a few more manually
managed flags into this array. Note this is listed as a TODO in
the MultiTarget project's wiki page.
Therefore, I'm not really adding any conflict, as that work will
already have to be done. When that is done, we'll likely end up
with passing a 'struct remote_state *' pointer to the new packet_support
function. And with that in mind, it just looks like unnecessary
churn to remove the parameter from remote_multi_process_p now (and
update all callers), only to add it back again. Do you agree?
> Not sure it is part
> of your plan to convert the global state to per-target state.
I don't plan to work on it myself in the near future, but it's
definitely the way to go.
>> +
>> + # 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.
>> + set test "set tracepoint on set_tracepoint"
>> + gdb_test_multiple "${trace_type} set_tracepoint" $test {
>> + -re "Target returns error code .* too far .*$gdb_prompt $" {
>> + if [string equal $trace_type "ftrace"] {
>> + # The target was unable to install the fast tracepoint
>> + # (e.g., jump pad too far from tracepoint).
>> + pass "$test (too far)"
>
> A nit here, a fast tracepoint is not installed due to "jump pad too far"
> instead of "set remote install-in-trace-packet off". Do we want to emit
> a PASS here?
Oh, hmm. Copy-paste from the other function in the file, and I
just didn't think about that part much. It actually makes no sense
to even expect that the target sends back any error code. We've just
disabled installing tracepoints while a trace experiment is running,
so we shouldn't see any response from the target at all.
> IMO, UNSUPPORTED is better.
Agreed, though note you made this a PASS in tracepoint_change_loc_1. ;-)
> Secondly, if "jump pad too far"
> causes fast tracepoint not installed, we should return here to skip the
> rest of the test, because the test below can't tell why a fast
> tracepoint is not installed, is it caused by
> "set remote install-in-trace-packet off" or "jump pad too far".
Even better is to not expect any error at all, and then make sure
that no traceframe was collected.
Here's what I'm folding into v2 of the patch.
---
gdb/remote.c | 1 +
gdb/testsuite/gdb.trace/change-loc.exp | 35 +++++++++++++++++-----------------
2 files changed, 18 insertions(+), 18 deletions(-)
diff --git a/gdb/remote.c b/gdb/remote.c
index 1aac5e3..dcd3cdd 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -1432,6 +1432,7 @@ 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)
{
diff --git a/gdb/testsuite/gdb.trace/change-loc.exp b/gdb/testsuite/gdb.trace/change-loc.exp
index ff6918a..d1a7aee 100644
--- a/gdb/testsuite/gdb.trace/change-loc.exp
+++ b/gdb/testsuite/gdb.trace/change-loc.exp
@@ -286,7 +286,7 @@ proc tracepoint_change_loc_2 { trace_type } {
# doesn't work when we force-disable the InstallInTrace RSP feature.
proc tracepoint_install_in_trace_disabled { trace_type } {
- with_test_prefix "3 $trace_type" {
+ with_test_prefix "InstallInTrace disabled: $trace_type" {
global testfile
global srcfile
global pcreg
@@ -312,27 +312,18 @@ proc tracepoint_install_in_trace_disabled { trace_type } {
"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.
- set test "set tracepoint on set_tracepoint"
- gdb_test_multiple "${trace_type} set_tracepoint" $test {
- -re "Target returns error code .* too far .*$gdb_prompt $" {
- if [string equal $trace_type "ftrace"] {
- # The target was unable to install the fast tracepoint
- # (e.g., jump pad too far from tracepoint).
- pass "$test (too far)"
- } else {
- fail $test
- }
- }
- -re "\r\n$gdb_prompt $" {
- pass $test
- }
- }
+ gdb_test "${trace_type} set_tracepoint" \
+ "racepoint .* at .* set_tracepoint.*" \
+ "set tracepoint on set_tracepoint"
gdb_trace_setactions "set action for tracepoint" "" \
"collect \$$pcreg" "^$"
@@ -340,8 +331,16 @@ proc tracepoint_install_in_trace_disabled { trace_type } {
# 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.*\<MULTIPLE\>.*3\.1.* in func4.*not installed on target.*3\.2.* in func4.*not installed on target.*" \
- "tracepoint with two locations"
+\[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\\..*"
}
}
--
1.7.11.7
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH v2] Fix several "set remote foo-packet on/off" commands.
2014-04-01 12:07 ` Pedro Alves
@ 2014-04-01 12:25 ` Pedro Alves
2014-04-28 19:16 ` Joel Brobecker
2014-04-01 12:48 ` [PATCH] " Yao Qi
1 sibling, 1 reply; 12+ messages in thread
From: Pedro Alves @ 2014-04-01 12:25 UTC (permalink / raw)
To: gdb-patches; +Cc: Yao Qi
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 (¤t_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
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] Fix several "set remote foo-packet on/off" commands.
2014-04-01 12:07 ` Pedro Alves
2014-04-01 12:25 ` [PATCH v2] " Pedro Alves
@ 2014-04-01 12:48 ` Yao Qi
2014-04-25 18:04 ` Pedro Alves
1 sibling, 1 reply; 12+ messages in thread
From: Yao Qi @ 2014-04-01 12:48 UTC (permalink / raw)
To: Pedro Alves; +Cc: gdb-patches
On 04/01/2014 08:06 PM, Pedro Alves wrote:
> As part of that project, we'll definitely need to move the
> whole remote_protocol_packets global array to remote_state.
> This global array already exists. I've just moved a few more manually
> managed flags into this array. Note this is listed as a TODO in
> the MultiTarget project's wiki page.
> Therefore, I'm not really adding any conflict, as that work will
> already have to be done. When that is done, we'll likely end up
> with passing a 'struct remote_state *' pointer to the new packet_support
> function. And with that in mind, it just looks like unnecessary
> churn to remove the parameter from remote_multi_process_p now (and
> update all callers), only to add it back again. Do you agree?
>
Yes, that is fine to keep unused parameter 'rs' remote_multi_process_p.
>> > Not sure it is part
>> > of your plan to convert the global state to per-target state.
> I don't plan to work on it myself in the near future, but it's
> definitely the way to go.
>
OK, got it.
>>> >> +
>>> >> + # 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.
>>> >> + set test "set tracepoint on set_tracepoint"
>>> >> + gdb_test_multiple "${trace_type} set_tracepoint" $test {
>>> >> + -re "Target returns error code .* too far .*$gdb_prompt $" {
>>> >> + if [string equal $trace_type "ftrace"] {
>>> >> + # The target was unable to install the fast tracepoint
>>> >> + # (e.g., jump pad too far from tracepoint).
>>> >> + pass "$test (too far)"
>> >
>> > A nit here, a fast tracepoint is not installed due to "jump pad too far"
>> > instead of "set remote install-in-trace-packet off". Do we want to emit
>> > a PASS here?
> Oh, hmm. Copy-paste from the other function in the file, and I
> just didn't think about that part much. It actually makes no sense
> to even expect that the target sends back any error code. We've just
> disabled installing tracepoints while a trace experiment is running,
> so we shouldn't see any response from the target at all.
>
>> > IMO, UNSUPPORTED is better.
> Agreed, though note you made this a PASS in tracepoint_change_loc_1. ;-)
>
Sorry about that :)
patch v2 looks good to me.
--
Yao (é½å°§)
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] Fix several "set remote foo-packet on/off" commands.
2014-04-01 12:48 ` [PATCH] " Yao Qi
@ 2014-04-25 18:04 ` Pedro Alves
0 siblings, 0 replies; 12+ messages in thread
From: Pedro Alves @ 2014-04-25 18:04 UTC (permalink / raw)
To: Yao Qi; +Cc: gdb-patches
On 04/01/2014 01:46 PM, Yao Qi wrote:
> patch v2 looks good to me.
Thanks Yao. I've pushed this in.
--
Pedro Alves
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v2] Fix several "set remote foo-packet on/off" commands.
2014-04-01 12:25 ` [PATCH v2] " Pedro Alves
@ 2014-04-28 19:16 ` Joel Brobecker
2014-04-29 1:01 ` Pedro Alves
0 siblings, 1 reply; 12+ messages in thread
From: Joel Brobecker @ 2014-04-28 19:16 UTC (permalink / raw)
To: Pedro Alves; +Cc: gdb-patches, Yao Qi
[-- Attachment #1: Type: text/plain, Size: 2976 bytes --]
Hi Pedro,
> gdb/
> 2014-04-01 Pedro Alves <palves@redhat.com>
>
> * remote.c (struct remote_state): Remove multi_process_aware,
[...]
Unfortunately, your patch seems to be introducing a regression,
observable when connecting GDB to QEMU. For instance:
(gdb) set debug remote 1
(gdb) tar rem :4444
Remote debugging using :4444
Sending packet: $qSupported:multiprocess+;qRelocInsn+#2a...Ack
Packet received: PacketSize=1000;qXfer:features:read+
Packet qSupported (supported-packets) is supported
Sending packet: $Hgp0.0#ad...Ack
Packet received: OK
Sending packet: $qXfer:features:read:target.xml:0,ffb#79...Ack
Packet received: [...]
Sending packet: $qXfer:features:read:arm-core.xml:0,ffb#08...Ack
Packet received: [...]
!!! -> Sending packet: $QNonStop:0#8c...Ack
Packet received:
Remote refused setting all-stop mode with:
What happens, here, it seems, is that GDB thinks it's OK to use
the QNonStop even though it wasn't specified in the qSupported
reply. Looking at the code that sets the feature's status when
not seen in the qSupported reply, we see:
/* Handle the defaults for unmentioned features. */
for (i = 0; i < ARRAY_SIZE (remote_protocol_features); i++)
if (!seen[i])
{
const struct protocol_feature *feature;
feature = &remote_protocol_features[i];
feature->func (feature, feature->default_support, NULL);
}
In the case of PACKET_QNonStop, we have the following definition...
{ "QNonStop", PACKET_DISABLE, remote_supported_packet, PACKET_QNonStop },
... so feature->func is remote_supported_packet, which then sets
the feature as:
static void
remote_supported_packet (const struct protocol_feature *feature,
enum packet_support support,
const char *argument)
{
[warning + return if argument not NULL]
remote_protocol_packets[feature->packet].support = support;
}
However, looking at the packet_support function, it basically
relies on packet_config_support, which itself only looks at
the support field of our feature if "detect" was set to AUTO_BOOLEAN_AUTO:
switch (config->detect)
{
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"));
}
However, in the case of this option, it's set to AUTO_BOOLEAN_TRUE.
So the config->support value that we set earlier has no effect.
I worked around the issue by making this package a configurable
packet (diff attached) but I have a feeling that there is either
something I am not getting, or perhaps a hole in the current
design. Or perhaps something else? I am not quite clear on what
should be done, yet.
Thanks!
--
Joel
[-- Attachment #2: remote.c.diff --]
[-- Type: text/x-diff, Size: 554 bytes --]
diff --git a/gdb/remote.c b/gdb/remote.c
index dcd3cdd..14dd8c9 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -11878,6 +11878,9 @@ Show the maximum size of the address (in bits) in a memory packet."), NULL,
add_packet_config_cmd (&remote_protocol_packets[PACKET_QPassSignals],
"QPassSignals", "pass-signals", 0);
+ add_packet_config_cmd (&remote_protocol_packets[PACKET_QNonStop],
+ "QNonStop", "non-stop", 0);
+
add_packet_config_cmd (&remote_protocol_packets[PACKET_QProgramSignals],
"QProgramSignals", "program-signals", 0);
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v2] Fix several "set remote foo-packet on/off" commands.
2014-04-28 19:16 ` Joel Brobecker
@ 2014-04-29 1:01 ` Pedro Alves
2014-04-29 2:10 ` Hui Zhu
2014-04-29 12:53 ` Joel Brobecker
0 siblings, 2 replies; 12+ messages in thread
From: Pedro Alves @ 2014-04-29 1:01 UTC (permalink / raw)
To: Joel Brobecker; +Cc: gdb-patches, Yao Qi
Hi Joel,
Bummer, sorry for the trouble.
On 04/28/2014 08:16 PM, Joel Brobecker wrote:
> I worked around the issue by making this package a configurable
> packet (diff attached) but I have a feeling that there is either
> something I am not getting, or perhaps a hole in the current
> design. Or perhaps something else? I am not quite clear on what
> should be done, yet.
I think the design is sound. See more info in the patch below.
I'd be fine with either:
- restoring things to how they've "always" been immediately.
That is, push the patch below. We can then incrementally add the
missing associated commands, along with corresponding manual and
possibly testsuite changes/additions, as a non-priority task.
- or, adding all the missing commands now, and add an assertion just
like in the patch below, but with no exception list, of course.
(but TBC, I can't offer to work on that myself now.)
Let me know what you think.
-------------
From 37a80ecbfd5cab03a3a88f73d7d06bc6a4f757b9 Mon Sep 17 00:00:00 2001
From: Pedro Alves <palves@redhat.com>
Date: Tue, 29 Apr 2014 01:14:22 +0100
Subject: [PATCH] Fix remote connection to targets that don't support the
QNonStop packet.
... and others. The recent patch that fixed several "set remote
foo-packet on/off" commands introduced a regression, observable when
connecting GDB to QEMU. For instance:
(gdb) set debug remote 1
(gdb) tar rem :4444
Remote debugging using :4444
Sending packet: $qSupported:multiprocess+;qRelocInsn+#2a...Ack
Packet received: PacketSize=1000;qXfer:features:read+
Packet qSupported (supported-packets) is supported
Sending packet: $Hgp0.0#ad...Ack
Packet received: OK
Sending packet: $qXfer:features:read:target.xml:0,ffb#79...Ack
Packet received: [...]
Sending packet: $qXfer:features:read:arm-core.xml:0,ffb#08...Ack
Packet received: [...]
!!! -> Sending packet: $QNonStop:0#8c...Ack
Packet received:
Remote refused setting all-stop mode with:
The "QNonStop" feature is associated with the PACKET_QNonStop packet,
with a default of PACKET_DISABLE, so GDB should not be sending the
packet at all.
The patch that introduced the regression decoupled packet_config's
'detect' and 'support' fields, making the former (an auto_boolean)
purely the associated "set remote foo-packet" command's variable. In
the example above, the packet config's 'supported' field does end up
correctly set to PACKET_DISABLE. However, nothing is presently
initializing packet configs that don't actually have a command
associated. Those configs's 'detect' field then ends up set to
AUTO_BOOLEAN_TRUE, simply because that happens to be 0. This forces
GDB to assume the packet is supported, irrespective of what the target
claims it supports, just like if the user had done "set remote
foo-packet on" (this being the associated command, if there was one).
Ideally, all packet configs would have a command associated. While
that isn't true, make sure all packet configs are initialized, even if
no command is associated, and add an assertion that prevents adding
more packets/features without an associated command.
Tested on x86_64 Fedora 17, against pristine gdbserver, and against a
gdbserver with the QNonStop packet/feature disabled with a local hack.
gdb/
2014-04-29 Pedro Alves <palves@redhat.com>
* remote.c (struct packet_config) <detect>: Extend comment.
(add_packet_config_cmd): Don't set the config's detect or support
fields here.
(init_all_packet_configs): Also initialize the config's 'detect'
field.
(reset_all_packet_configs_support): New function.
(remote_open_1): Call reset_all_packet_configs_support instead of
init_all_packet_configs.
(_initialize_remote): Initialize all packet configs. Assert that
all packets have an associated command, except a few known
outliers.
---
gdb/remote.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++------
1 file changed, 54 insertions(+), 6 deletions(-)
diff --git a/gdb/remote.c b/gdb/remote.c
index dcd3cdd..4177b39 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -1067,7 +1067,8 @@ 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. */
+ 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? */
@@ -1129,8 +1130,6 @@ add_packet_config_cmd (struct packet_config *config, const char *name,
config->name = name;
config->title = title;
- config->detect = AUTO_BOOLEAN_AUTO;
- config->support = PACKET_SUPPORT_UNKNOWN;
set_doc = xstrprintf ("Set use of remote protocol `%s' (%s) packet",
name, title);
show_doc = xstrprintf ("Show current use of remote "
@@ -3632,10 +3631,11 @@ extended_remote_open (char *name, int from_tty)
remote_open_1 (name, from_tty, &extended_remote_ops, 1 /*extended_p */);
}
-/* Generic code for opening a connection to a remote target. */
+/* Reset all packets back to "unknown support". Called when opening a
+ new connection to a remote target. */
static void
-init_all_packet_configs (void)
+reset_all_packet_configs_support (void)
{
int i;
@@ -3643,6 +3643,20 @@ init_all_packet_configs (void)
remote_protocol_packets[i].support = PACKET_SUPPORT_UNKNOWN;
}
+/* Initialize all packet configs. */
+
+static void
+init_all_packet_configs (void)
+{
+ int i;
+
+ for (i = 0; i < PACKET_MAX; i++)
+ {
+ remote_protocol_packets[i].detect = AUTO_BOOLEAN_AUTO;
+ remote_protocol_packets[i].support = PACKET_SUPPORT_UNKNOWN;
+ }
+}
+
/* Symbol look-up. */
static void
@@ -4192,7 +4206,7 @@ remote_open_1 (char *name, int from_tty,
/* Reset the target state; these things will be queried either by
remote_query_supported or as they are needed. */
- init_all_packet_configs ();
+ reset_all_packet_configs_support ();
rs->cached_wait_status = 0;
rs->explicit_packet_size = 0;
rs->noack_mode = 0;
@@ -11869,6 +11883,8 @@ Show the maximum size of the address (in bits) in a memory packet."), NULL,
NULL, /* FIXME: i18n: */
&setlist, &showlist);
+ init_all_packet_configs ();
+
add_packet_config_cmd (&remote_protocol_packets[PACKET_X],
"X", "binary-download", 1);
@@ -12052,6 +12068,38 @@ Show the maximum size of the address (in bits) in a memory packet."), NULL,
add_packet_config_cmd (&remote_protocol_packets[PACKET_qXfer_btrace],
"qXfer:btrace", "read-btrace", 0);
+ /* Assert that we've registered commands for all packet configs. */
+ {
+ int i;
+
+ for (i = 0; i < PACKET_MAX; i++)
+ {
+ /* Ideally all configs would have a command associated. Some
+ still don't though. */
+ int excepted;
+
+ switch (i)
+ {
+ case PACKET_QNonStop:
+ case PACKET_multiprocess_feature:
+ case PACKET_EnableDisableTracepoints_feature:
+ case PACKET_tracenz_feature:
+ case PACKET_DisconnectedTracing_feature:
+ case PACKET_augmented_libraries_svr4_read_feature:
+ /* Additions to this list need to be well justified. */
+ excepted = 1;
+ break;
+ default:
+ excepted = 0;
+ break;
+ }
+
+ /* This catches both forgetting to add a config command, and
+ forgetting to remove a packet from the exception list. */
+ gdb_assert (excepted == (remote_protocol_packets[i].name == NULL));
+ }
+ }
+
/* Keep the old ``set remote Z-packet ...'' working. Each individual
Z sub-packet has its own set and show commands, but users may
have sets to this variable in their .gdbinit files (or in their
--
1.7.11.7
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v2] Fix several "set remote foo-packet on/off" commands.
2014-04-29 1:01 ` Pedro Alves
@ 2014-04-29 2:10 ` Hui Zhu
2014-04-29 12:53 ` Joel Brobecker
1 sibling, 0 replies; 12+ messages in thread
From: Hui Zhu @ 2014-04-29 2:10 UTC (permalink / raw)
To: gdb-patches
On 04/29/14 09:01, Pedro Alves wrote:
> Hi Joel,
>
> Bummer, sorry for the trouble.
>
> On 04/28/2014 08:16 PM, Joel Brobecker wrote:
>
>> I worked around the issue by making this package a configurable
>> packet (diff attached) but I have a feeling that there is either
>> something I am not getting, or perhaps a hole in the current
>> design. Or perhaps something else? I am not quite clear on what
>> should be done, yet.
>
> I think the design is sound. See more info in the patch below.
>
> I'd be fine with either:
>
> - restoring things to how they've "always" been immediately.
> That is, push the patch below. We can then incrementally add the
> missing associated commands, along with corresponding manual and
> possibly testsuite changes/additions, as a non-priority task.
This patch fixed my issue with qemu that donn't support qnonstop.
Thanks,
Hui
>
> - or, adding all the missing commands now, and add an assertion just
> like in the patch below, but with no exception list, of course.
> (but TBC, I can't offer to work on that myself now.)
>
> Let me know what you think.
>
> -------------
> From 37a80ecbfd5cab03a3a88f73d7d06bc6a4f757b9 Mon Sep 17 00:00:00 2001
> From: Pedro Alves <palves@redhat.com>
> Date: Tue, 29 Apr 2014 01:14:22 +0100
> Subject: [PATCH] Fix remote connection to targets that don't support the
> QNonStop packet.
>
> ... and others. The recent patch that fixed several "set remote
> foo-packet on/off" commands introduced a regression, observable when
> connecting GDB to QEMU. For instance:
>
> (gdb) set debug remote 1
> (gdb) tar rem :4444
> Remote debugging using :4444
> Sending packet: $qSupported:multiprocess+;qRelocInsn+#2a...Ack
> Packet received: PacketSize=1000;qXfer:features:read+
> Packet qSupported (supported-packets) is supported
> Sending packet: $Hgp0.0#ad...Ack
> Packet received: OK
> Sending packet: $qXfer:features:read:target.xml:0,ffb#79...Ack
> Packet received: [...]
> Sending packet: $qXfer:features:read:arm-core.xml:0,ffb#08...Ack
> Packet received: [...]
> !!! -> Sending packet: $QNonStop:0#8c...Ack
> Packet received:
> Remote refused setting all-stop mode with:
>
> The "QNonStop" feature is associated with the PACKET_QNonStop packet,
> with a default of PACKET_DISABLE, so GDB should not be sending the
> packet at all.
>
> The patch that introduced the regression decoupled packet_config's
> 'detect' and 'support' fields, making the former (an auto_boolean)
> purely the associated "set remote foo-packet" command's variable. In
> the example above, the packet config's 'supported' field does end up
> correctly set to PACKET_DISABLE. However, nothing is presently
> initializing packet configs that don't actually have a command
> associated. Those configs's 'detect' field then ends up set to
> AUTO_BOOLEAN_TRUE, simply because that happens to be 0. This forces
> GDB to assume the packet is supported, irrespective of what the target
> claims it supports, just like if the user had done "set remote
> foo-packet on" (this being the associated command, if there was one).
>
> Ideally, all packet configs would have a command associated. While
> that isn't true, make sure all packet configs are initialized, even if
> no command is associated, and add an assertion that prevents adding
> more packets/features without an associated command.
>
> Tested on x86_64 Fedora 17, against pristine gdbserver, and against a
> gdbserver with the QNonStop packet/feature disabled with a local hack.
>
> gdb/
> 2014-04-29 Pedro Alves <palves@redhat.com>
>
> * remote.c (struct packet_config) <detect>: Extend comment.
> (add_packet_config_cmd): Don't set the config's detect or support
> fields here.
> (init_all_packet_configs): Also initialize the config's 'detect'
> field.
> (reset_all_packet_configs_support): New function.
> (remote_open_1): Call reset_all_packet_configs_support instead of
> init_all_packet_configs.
> (_initialize_remote): Initialize all packet configs. Assert that
> all packets have an associated command, except a few known
> outliers.
> ---
> gdb/remote.c | 60
++++++++++++++++++++++++++++++++++++++++++++++++++++++------
> 1 file changed, 54 insertions(+), 6 deletions(-)
>
> diff --git a/gdb/remote.c b/gdb/remote.c
> index dcd3cdd..4177b39 100644
> --- a/gdb/remote.c
> +++ b/gdb/remote.c
> @@ -1067,7 +1067,8 @@ 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. */
> + 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? */
> @@ -1129,8 +1130,6 @@ add_packet_config_cmd (struct packet_config
*config, const char *name,
>
> config->name = name;
> config->title = title;
> - config->detect = AUTO_BOOLEAN_AUTO;
> - config->support = PACKET_SUPPORT_UNKNOWN;
> set_doc = xstrprintf ("Set use of remote protocol `%s' (%s) packet",
> name, title);
> show_doc = xstrprintf ("Show current use of remote "
> @@ -3632,10 +3631,11 @@ extended_remote_open (char *name, int from_tty)
> remote_open_1 (name, from_tty, &extended_remote_ops, 1
/*extended_p */);
> }
>
> -/* Generic code for opening a connection to a remote target. */
> +/* Reset all packets back to "unknown support". Called when opening a
> + new connection to a remote target. */
>
> static void
> -init_all_packet_configs (void)
> +reset_all_packet_configs_support (void)
> {
> int i;
>
> @@ -3643,6 +3643,20 @@ init_all_packet_configs (void)
> remote_protocol_packets[i].support = PACKET_SUPPORT_UNKNOWN;
> }
>
> +/* Initialize all packet configs. */
> +
> +static void
> +init_all_packet_configs (void)
> +{
> + int i;
> +
> + for (i = 0; i < PACKET_MAX; i++)
> + {
> + remote_protocol_packets[i].detect = AUTO_BOOLEAN_AUTO;
> + remote_protocol_packets[i].support = PACKET_SUPPORT_UNKNOWN;
> + }
> +}
> +
> /* Symbol look-up. */
>
> static void
> @@ -4192,7 +4206,7 @@ remote_open_1 (char *name, int from_tty,
>
> /* Reset the target state; these things will be queried either by
> remote_query_supported or as they are needed. */
> - init_all_packet_configs ();
> + reset_all_packet_configs_support ();
> rs->cached_wait_status = 0;
> rs->explicit_packet_size = 0;
> rs->noack_mode = 0;
> @@ -11869,6 +11883,8 @@ Show the maximum size of the address (in
bits) in a memory packet."), NULL,
> NULL, /* FIXME: i18n: */
> &setlist, &showlist);
>
> + init_all_packet_configs ();
> +
> add_packet_config_cmd (&remote_protocol_packets[PACKET_X],
> "X", "binary-download", 1);
>
> @@ -12052,6 +12068,38 @@ Show the maximum size of the address (in
bits) in a memory packet."), NULL,
> add_packet_config_cmd (&remote_protocol_packets[PACKET_qXfer_btrace],
> "qXfer:btrace", "read-btrace", 0);
>
> + /* Assert that we've registered commands for all packet configs. */
> + {
> + int i;
> +
> + for (i = 0; i < PACKET_MAX; i++)
> + {
> + /* Ideally all configs would have a command associated. Some
> + still don't though. */
> + int excepted;
> +
> + switch (i)
> + {
> + case PACKET_QNonStop:
> + case PACKET_multiprocess_feature:
> + case PACKET_EnableDisableTracepoints_feature:
> + case PACKET_tracenz_feature:
> + case PACKET_DisconnectedTracing_feature:
> + case PACKET_augmented_libraries_svr4_read_feature:
> + /* Additions to this list need to be well justified. */
> + excepted = 1;
> + break;
> + default:
> + excepted = 0;
> + break;
> + }
> +
> + /* This catches both forgetting to add a config command, and
> + forgetting to remove a packet from the exception list. */
> + gdb_assert (excepted == (remote_protocol_packets[i].name == NULL));
> + }
> + }
> +
> /* Keep the old ``set remote Z-packet ...'' working. Each individual
> Z sub-packet has its own set and show commands, but users may
> have sets to this variable in their .gdbinit files (or in their
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v2] Fix several "set remote foo-packet on/off" commands.
2014-04-29 1:01 ` Pedro Alves
2014-04-29 2:10 ` Hui Zhu
@ 2014-04-29 12:53 ` Joel Brobecker
2014-04-29 13:07 ` Pedro Alves
1 sibling, 1 reply; 12+ messages in thread
From: Joel Brobecker @ 2014-04-29 12:53 UTC (permalink / raw)
To: Pedro Alves; +Cc: gdb-patches, Yao Qi
Hi Pedro,
> Bummer, sorry for the trouble.
No problem at all!
> I think the design is sound. See more info in the patch below.
>
> I'd be fine with either:
>
> - restoring things to how they've "always" been immediately.
> That is, push the patch below. We can then incrementally add the
> missing associated commands, along with corresponding manual and
> possibly testsuite changes/additions, as a non-priority task.
>
> - or, adding all the missing commands now, and add an assertion just
> like in the patch below, but with no exception list, of course.
> (but TBC, I can't offer to work on that myself now.)
Either approach would be fine with me too. I could even see a two-step
approach where we apply your first patch as a stop-gap, and then
implement everything as a setting (I think having the setting for
every packet could prove useful to interact with difficult remote
stubs).
Thanks!
--
Joel
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v2] Fix several "set remote foo-packet on/off" commands.
2014-04-29 12:53 ` Joel Brobecker
@ 2014-04-29 13:07 ` Pedro Alves
2014-04-29 14:05 ` Joel Brobecker
0 siblings, 1 reply; 12+ messages in thread
From: Pedro Alves @ 2014-04-29 13:07 UTC (permalink / raw)
To: Joel Brobecker; +Cc: gdb-patches, Yao Qi
On 04/29/2014 01:53 PM, Joel Brobecker wrote:
> Hi Pedro,
>
>> Bummer, sorry for the trouble.
>
> No problem at all!
>
>> I think the design is sound. See more info in the patch below.
>>
>> I'd be fine with either:
>>
>> - restoring things to how they've "always" been immediately.
>> That is, push the patch below. We can then incrementally add the
>> missing associated commands, along with corresponding manual and
>> possibly testsuite changes/additions, as a non-priority task.
>>
>> - or, adding all the missing commands now, and add an assertion just
>> like in the patch below, but with no exception list, of course.
>> (but TBC, I can't offer to work on that myself now.)
>
> Either approach would be fine with me too. I could even see a two-step
> approach where we apply your first patch as a stop-gap, and then
> implement everything as a setting (I think having the setting for
> every packet could prove useful to interact with difficult remote
> stubs).
Alright, so I just went ahead and pushed the patch in.
Thanks,
--
Pedro Alves
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v2] Fix several "set remote foo-packet on/off" commands.
2014-04-29 13:07 ` Pedro Alves
@ 2014-04-29 14:05 ` Joel Brobecker
0 siblings, 0 replies; 12+ messages in thread
From: Joel Brobecker @ 2014-04-29 14:05 UTC (permalink / raw)
To: Pedro Alves; +Cc: gdb-patches, Yao Qi
> >> I'd be fine with either:
> >>
> >> - restoring things to how they've "always" been immediately.
> >> That is, push the patch below. We can then incrementally add the
> >> missing associated commands, along with corresponding manual and
> >> possibly testsuite changes/additions, as a non-priority task.
> >>
> >> - or, adding all the missing commands now, and add an assertion just
> >> like in the patch below, but with no exception list, of course.
> >> (but TBC, I can't offer to work on that myself now.)
> >
> > Either approach would be fine with me too. I could even see a two-step
> > approach where we apply your first patch as a stop-gap, and then
> > implement everything as a setting (I think having the setting for
> > every packet could prove useful to interact with difficult remote
> > stubs).
>
> Alright, so I just went ahead and pushed the patch in.
Thanks, Pedro!
--
Joel
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2014-04-29 14:05 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-31 23:53 [PATCH] Fix several "set remote foo-packet on/off" commands Pedro Alves
2014-04-01 8:55 ` Yao Qi
2014-04-01 12:07 ` Pedro Alves
2014-04-01 12:25 ` [PATCH v2] " Pedro Alves
2014-04-28 19:16 ` Joel Brobecker
2014-04-29 1:01 ` Pedro Alves
2014-04-29 2:10 ` Hui Zhu
2014-04-29 12:53 ` Joel Brobecker
2014-04-29 13:07 ` Pedro Alves
2014-04-29 14:05 ` Joel Brobecker
2014-04-01 12:48 ` [PATCH] " Yao Qi
2014-04-25 18:04 ` Pedro Alves
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox