*** Changes since GDB 15
+* GDB now supports printing of asynchronous events from the Intel Processor
+ Trace during 'record instruction-history', 'record function-call-history'
+ and all stepping commands. This can be controlled with the new
+ "set record btrace pt event-tracing" command.
+
* GDB now supports printing of ptwrite payloads from the Intel Processor
Trace during 'record instruction-history', 'record function-call-history'
and all stepping commands. The payload is also accessible in Python as a
Show the current setting of the requested ring buffer size for branch
tracing in Intel Processor Trace format.
+@item set record btrace pt event-tracing
+Enable or disable event tracing for branch tracing in Intel Processor
+Trace format. When enabled, events are recorded during execution as
+auxiliary information and will be printed during stepping commands and
+commands displaying the execution history. Changing this setting has no
+effect on an active recording. The default is off.
+
+@item show record btrace pt event-tracing
+Show the current setting of Intel Processor Trace event tracing.
+
@kindex info record
@item info record
Show various statistics about the recording depending on the recording
@tab @samp{-}
@tab Yes
+@item @samp{Qbtrace-conf:pt:event-tracing}
+@tab Yes
+@tab @samp{-}
+@tab Yes
+
@item @samp{QNonStop}
@tab No
@tab @samp{-}
@item Qbtrace-conf:pt:ptwrite
The remote stub understands the @samp{Qbtrace-conf:pt:ptwrite} packet.
+@item Qbtrace-conf:pt:event-tracing
+The remote stub understands the @samp{Qbtrace-conf:pt:event-tracing} packet.
+
@item swbreak
The remote stub reports the @samp{swbreak} stop reason for memory
breakpoints.
A badly formed request or an error was encountered.
@end table
+@item Qbtrace-conf:pt:event-tracing=@var{(yes|no)}
+Indicate support for event-tracing packets. This allows for backwards
+compatibility.
+
+Reply:
+@table @samp
+@item OK
+The event-tracing config parameter has been set.
+@item E.errtext
+A badly formed request or an error was encountered.
+@end table
+
@end table
@node Architecture-Specific Protocol Details
The formal DTD for the branch trace configuration format is given below:
@smallexample
-<!ELEMENT btrace-conf (bts?, pt?)>
-<!ATTLIST btrace-conf version CDATA #FIXED "1.0">
+<!ELEMENT btrace-conf (bts?, pt?)>
+<!ATTLIST btrace-conf version CDATA #FIXED "1.0">
<!ELEMENT bts EMPTY>
-<!ATTLIST bts size CDATA #IMPLIED>
+<!ATTLIST bts size CDATA #IMPLIED>
<!ELEMENT pt EMPTY>
-<!ATTLIST pt size CDATA #IMPLIED>
-<!ATTLIST pt ptwrite (yes | no) #IMPLIED>
+<!ATTLIST pt size CDATA #IMPLIED>
+<!ATTLIST pt ptwrite (yes | no) #IMPLIED>
+<!ATTLIST pt event-tracing (yes | no) #IMPLIED>
@end smallexample
@include agentexpr.texi
<!ELEMENT pt EMPTY>
<!ATTLIST pt size CDATA #IMPLIED>
<!ATTLIST pt ptwrite (yes | no) #IMPLIED>
+<!ATTLIST pt event-tracing (yes | no) #IMPLIED>
tinfo->conf.pt.ptwrite = true;
}
+ if (conf->event_tracing)
+ {
+ if (linux_supports_pt_feature ("event_trace"))
+ {
+ tinfo->attr.config |= linux_read_pt_config_bitmask ("event");
+ tinfo->conf.pt.event_tracing = true;
+ }
+ else
+ error (_("Event tracing for record btrace pt is not supported."));
+ }
+
errno = 0;
scoped_fd fd (syscall (SYS_perf_event_open, &tinfo->attr, pid, -1, -1, 0));
if (fd.get () < 0)
value);
}
+
+static bool event_tracing = false;
+
+/* The "record pt event-tracing" show value function. */
+
+static void
+show_record_pt_event_tracing_value (struct ui_file *file, int from_tty,
+ struct cmd_list_element *c,
+ const char *value)
+{
+#if (LIBIPT_VERSION >= 0x201)
+ gdb_printf (file, _("record pt event-tracing is %s.\n"), value);
+#else
+ gdb_printf (_("Event-tracing is not supported by GDB.\n"));
+#endif /* defined (LIBIPT_VERSION >= 0x201) */
+}
+
+/* The "record pt event-tracing" set value function. */
+
+static void
+set_record_pt_event_tracing_value (const char *args, int from_tty,
+ cmd_list_element *c)
+{
+#if (LIBIPT_VERSION >= 0x201)
+ record_btrace_conf.pt.event_tracing = event_tracing;
+#else
+ gdb_printf (_("Event-tracing is not supported by GDB.\n"));
+#endif /* defined (LIBIPT_VERSION >= 0x201) */
+}
+
/* Initialize btrace commands. */
void _initialize_record_btrace ();
&set_record_btrace_pt_cmdlist,
&show_record_btrace_pt_cmdlist);
+ add_setshow_boolean_cmd ("event-tracing", no_class, &event_tracing,
+ _("Set event-tracing for record pt."),
+ _("Show event-tracing for record pt."),
+ _("\
+Use \"on\" to enable event tracing for recordings with Intel Processor Trace, \
+and \"off\" to disable it.\n\
+Without an argument, event tracing is enabled. Changing this setting has no\
+effect on an active recording."),
+ set_record_pt_event_tracing_value,
+ show_record_pt_event_tracing_value,
+ &set_record_btrace_pt_cmdlist,
+ &show_record_btrace_pt_cmdlist);
+
add_target (record_btrace_target_info, record_btrace_target_open);
bfcache = htab_create_alloc (50, bfcache_hash, bfcache_eq, NULL,
#else
record_btrace_conf.pt.ptwrite = false;
#endif
+ record_btrace_conf.pt.event_tracing = false;
}
/* Support for the Qbtrace-conf:pt:ptwrite packet. */
PACKET_Qbtrace_conf_pt_ptwrite,
+ /* Support for the Qbtrace-conf:pt:event-tracing packet. */
+ PACKET_Qbtrace_conf_pt_event_tracing,
+
/* Support for exec events. */
PACKET_exec_event_feature,
PACKET_Qbtrace_conf_pt_size },
{ "Qbtrace-conf:pt:ptwrite", PACKET_DISABLE, remote_supported_packet,
PACKET_Qbtrace_conf_pt_ptwrite },
+ { "Qbtrace-conf:pt:event-tracing", PACKET_DISABLE, remote_supported_packet,
+ PACKET_Qbtrace_conf_pt_event_tracing },
{ "vContSupported", PACKET_DISABLE, remote_supported_packet, PACKET_vContSupported },
{ "QThreadEvents", PACKET_DISABLE, remote_supported_packet, PACKET_QThreadEvents },
{ "QThreadOptions", PACKET_DISABLE, remote_supported_thread_options,
std::vector<gdb_xml_value> &attributes)
{
struct btrace_config *conf;
- struct gdb_xml_value *size, *ptwrite;
+ struct gdb_xml_value *size, *ptwrite, *event_tracing;
conf = (struct btrace_config *) user_data;
conf->format = BTRACE_FORMAT_PT;
ptwrite = xml_find_attribute (attributes, "ptwrite");
if (ptwrite != nullptr)
conf->pt.ptwrite = (bool) *(ULONGEST *) ptwrite->value.get ();
+
+ event_tracing = xml_find_attribute (attributes, "event-tracing");
+ if (event_tracing != nullptr)
+ conf->pt.event_tracing = (bool) *(ULONGEST *) event_tracing->value.get ();
}
static const struct gdb_xml_attribute btrace_conf_pt_attributes[] = {
{ "size", GDB_XML_AF_OPTIONAL, gdb_xml_parse_attr_ulongest, NULL },
{ "ptwrite", GDB_XML_AF_OPTIONAL, gdb_xml_parse_attr_enum,
gdb_xml_enums_boolean },
+ { "event-tracing", GDB_XML_AF_OPTIONAL, gdb_xml_parse_attr_enum,
+ gdb_xml_enums_boolean },
{ NULL, GDB_XML_AF_NONE, NULL, NULL }
};
rs->btrace_config.pt.ptwrite = conf->pt.ptwrite;
}
+
+ /* Event tracing is a user setting, warn if it is set but the target
+ doesn't support it. */
+ if ((m_features.packet_support (PACKET_Qbtrace_conf_pt_event_tracing)
+ != PACKET_ENABLE)
+ && conf->pt.event_tracing)
+ warning (_("Target does not support event-tracing."));
+
+ if ((m_features.packet_support (PACKET_Qbtrace_conf_pt_event_tracing)
+ == PACKET_ENABLE)
+ && conf->pt.event_tracing != rs->btrace_config.pt.event_tracing)
+ {
+ pos = buf;
+ const char *event_tracing = conf->pt.event_tracing ? "yes" : "no";
+ const char *name
+ = packets_descriptions[PACKET_Qbtrace_conf_pt_event_tracing].name;
+ pos += xsnprintf (pos, endbuf - pos, "%s=\"%s\"", name, event_tracing);
+
+ putpkt (buf);
+ getpkt (&rs->buf, 0);
+
+ packet_result result
+ = m_features.packet_ok (buf, PACKET_Qbtrace_conf_pt_event_tracing);
+ if (result.status () == PACKET_ERROR)
+ {
+ if (buf[0] == 'E' && buf[1] == '.')
+ error (_("Failed to sync event-tracing config: %s"), buf + 2);
+ else
+ error (_("Failed to sync event-tracing config."));
+ }
+
+ rs->btrace_config.pt.event_tracing = conf->pt.event_tracing;
+ }
}
/* Read TP's btrace configuration from the target and store it into CONF. */
add_packet_config_cmd (PACKET_Qbtrace_conf_pt_ptwrite, "Qbtrace-conf:pt:ptwrite",
"btrace-conf-pt-ptwrite", 0);
+ add_packet_config_cmd (PACKET_Qbtrace_conf_pt_event_tracing,
+ "Qbtrace-conf:pt:event-tracing",
+ "btrace-conf-pt-event-tracing", 0);
+
add_packet_config_cmd (PACKET_vContSupported, "vContSupported",
"verbose-resume-supported", 0);
string_xml_appendf (*buffer, "/>\n");
string_xml_appendf (*buffer, " ptwrite=\"%s\"",
conf->pt.ptwrite ? "yes" : "no");
+ string_xml_appendf (*buffer, " event-tracing=\"%s\"",
+ conf->pt.event_tracing ? "yes" : "no");
string_xml_appendf (*buffer, "/>\n");
break;
}
return -1;
}
}
+ else if (strncmp (op, "pt:event-tracing=", strlen ("pt:event-tracing=")) == 0)
+ {
+ op += strlen ("pt:event-tracing=");
+ if (strncmp (op, "\"yes\"", strlen ("\"yes\"")) == 0)
+ current_btrace_conf.pt.event_tracing = true;
+ else if (strncmp (op, "\"no\"", strlen ("\"no\"")) == 0)
+ current_btrace_conf.pt.event_tracing = false;
+ else
+ {
+ strcpy (own_buf, "E.Bad event-tracing value.");
+ return -1;
+ }
+ }
else
{
strcpy (own_buf, "E.Bad Qbtrace configuration option.");
strcat (buf, ";Qbtrace:pt+");
strcat (buf, ";Qbtrace-conf:pt:size+");
strcat (buf, ";Qbtrace-conf:pt:ptwrite+");
+ strcat (buf, ";Qbtrace-conf:pt:event-tracing+");
strcat (buf, ";Qbtrace:off+");
strcat (buf, ";qXfer:btrace:read+");
strcat (buf, ";qXfer:btrace-conf:read+");
If both gdb and gdbserver support this, gdb will try to enable ptwrite
packets when tracing is started. */
bool ptwrite;
+
+ /* Event tracing setting. */
+ bool event_tracing;
};
/* A branch tracing configuration.