diff options
Diffstat (limited to 'gdb/remote.c')
-rw-r--r-- | gdb/remote.c | 85 |
1 files changed, 83 insertions, 2 deletions
diff --git a/gdb/remote.c b/gdb/remote.c index 61420ec..0226f3f 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -221,6 +221,8 @@ static int remote_supports_cond_breakpoints (struct target_ops *self); 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; @@ -371,6 +373,9 @@ struct remote_state /* 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. */ @@ -1327,6 +1332,9 @@ enum { /* 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 }; @@ -4010,7 +4018,9 @@ static const struct protocol_feature remote_protocol_features[] = { { "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; @@ -4358,6 +4368,8 @@ remote_open_1 (const char *name, int from_tty, } } + remote_btrace_reset (); + if (target_async_permitted) wait_forever_enabled_p = 1; } @@ -8945,6 +8957,11 @@ remote_xfer_partial (struct target_ops *ops, enum target_object object, 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; } @@ -11319,8 +11336,21 @@ struct btrace_target_info { /* 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 @@ -11343,20 +11373,52 @@ remote_supports_btrace (struct target_ops *self, enum btrace_format format) 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); @@ -11376,6 +11438,14 @@ remote_enable_btrace (struct target_ops *self, ptid_t ptid) 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; } @@ -11472,6 +11542,13 @@ remote_read_btrace (struct target_ops *self, 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) { @@ -11608,6 +11685,7 @@ Specify the serial device it is connected to\n\ 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; } @@ -12206,6 +12284,9 @@ 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); + 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; |