static int remote_can_run_breakpoint_commands (struct target_ops *self);
+static void remote_btrace_reset (void);
+
/* For "remote". */
static struct cmd_list_element *remote_cmdlist;
/* The state of remote notification. */
struct remote_notif_state *notif_state;
+
+ /* The branch trace configuration. */
+ struct btrace_config btrace_config;
};
/* Private data that we'll store in (struct thread_info)->private. */
/* Support for qXfer:libraries-svr4:read with a non-empty annex. */
PACKET_augmented_libraries_svr4_read_feature,
+ /* Support for the qXfer:btrace-conf:read packet. */
+ PACKET_qXfer_btrace_conf,
+
PACKET_MAX
};
{ "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,
- PACKET_qXfer_btrace }
+ PACKET_qXfer_btrace },
+ { "qXfer:btrace-conf:read", PACKET_DISABLE, remote_supported_packet,
+ PACKET_qXfer_btrace_conf }
};
static char *remote_support_xml;
}
}
+ remote_btrace_reset ();
+
if (target_async_permitted)
wait_forever_enabled_p = 1;
}
xfered_len,
&remote_protocol_packets[PACKET_qXfer_btrace]);
+ case TARGET_OBJECT_BTRACE_CONF:
+ return remote_read_qxfer (ops, "btrace-conf", annex, readbuf, offset,
+ len, xfered_len,
+ &remote_protocol_packets[PACKET_qXfer_btrace_conf]);
+
default:
return TARGET_XFER_E_IO;
}
{
/* The ptid of the traced thread. */
ptid_t ptid;
+
+ /* The obtained branch trace configuration. */
+ struct btrace_config conf;
};
+/* Reset our idea of our target's btrace configuration. */
+
+static void
+remote_btrace_reset (void)
+{
+ struct remote_state *rs = get_remote_state ();
+
+ memset (&rs->btrace_config, 0, sizeof (rs->btrace_config));
+}
+
/* Check whether the target supports branch tracing. */
static int
internal_error (__FILE__, __LINE__, _("Unknown branch trace format"));
}
+/* Synchronize the configuration with the target. */
+
+static void
+btrace_sync_conf (const struct btrace_config *conf)
+{
+ /* Nothing to do for now. */
+}
+
+/* Read the current thread's btrace configuration from the target and
+ store it into CONF. */
+
+static void
+btrace_read_config (struct btrace_config *conf)
+{
+ char *xml;
+
+ xml = target_read_stralloc (¤t_target,
+ TARGET_OBJECT_BTRACE_CONF, "");
+ if (xml != NULL)
+ {
+ struct cleanup *cleanup;
+
+ cleanup = make_cleanup (xfree, xml);
+ parse_xml_btrace_conf (conf, xml);
+ do_cleanups (cleanup);
+ }
+}
+
/* Enable branch tracing. */
static struct btrace_target_info *
-remote_enable_btrace (struct target_ops *self, ptid_t ptid)
+remote_enable_btrace (struct target_ops *self, ptid_t ptid,
+ const struct btrace_config *conf)
{
struct btrace_target_info *tinfo = NULL;
struct packet_config *packet = &remote_protocol_packets[PACKET_Qbtrace_bts];
struct remote_state *rs = get_remote_state ();
char *buf = rs->buf;
char *endbuf = rs->buf + get_remote_packet_size ();
+ volatile struct gdb_exception err;
if (packet_config_support (packet) != PACKET_ENABLE)
error (_("Target does not support branch tracing."));
+ btrace_sync_conf (conf);
+
set_general_thread (ptid);
buf += xsnprintf (buf, endbuf - buf, "%s", packet->name);
tinfo = xzalloc (sizeof (*tinfo));
tinfo->ptid = ptid;
+ /* If we fail to read the configuration, we lose some information, but the
+ tracing itself is not impacted. */
+ TRY_CATCH (err, RETURN_MASK_ERROR)
+ btrace_read_config (&tinfo->conf);
+
+ if (err.message != NULL)
+ warning ("%s", err.message);
+
return tinfo;
}
return BTRACE_ERR_NONE;
}
+static const struct btrace_config *
+remote_btrace_conf (struct target_ops *self,
+ const struct btrace_target_info *tinfo)
+{
+ return &tinfo->conf;
+}
+
static int
remote_augmented_libraries_svr4_read (struct target_ops *self)
{
remote_ops.to_disable_btrace = remote_disable_btrace;
remote_ops.to_teardown_btrace = remote_teardown_btrace;
remote_ops.to_read_btrace = remote_read_btrace;
+ remote_ops.to_btrace_conf = remote_btrace_conf;
remote_ops.to_augmented_libraries_svr4_read =
remote_augmented_libraries_svr4_read;
}
add_packet_config_cmd (&remote_protocol_packets[PACKET_qXfer_btrace],
"qXfer:btrace", "read-btrace", 0);
+ add_packet_config_cmd (&remote_protocol_packets[PACKET_qXfer_btrace_conf],
+ "qXfer:btrace-conf", "read-btrace-conf", 0);
+
/* Assert that we've registered commands for all packet configs. */
{
int i;