aboutsummaryrefslogtreecommitdiff
path: root/gdb/gdbserver
diff options
context:
space:
mode:
authorMarkus Metzger <markus.t.metzger@intel.com>2013-11-28 15:44:13 +0100
committerMarkus Metzger <markus.t.metzger@intel.com>2015-02-09 09:38:55 +0100
commitf4abbc168227003a4836dd1a5dd558f40be96372 (patch)
treef35162a46e74f2305cedf76f187f6f61d1e1e257 /gdb/gdbserver
parentaadf7753fd4cc3d9eb1cd0c089fd7a483b58f59e (diff)
downloadgdb-f4abbc168227003a4836dd1a5dd558f40be96372.zip
gdb-f4abbc168227003a4836dd1a5dd558f40be96372.tar.gz
gdb-f4abbc168227003a4836dd1a5dd558f40be96372.tar.bz2
record btrace: add configuration struct
Add a struct to describe the branch trace configuration and use it for enabling branch tracing. The user will be able to set configuration fields for each tracing format to be used for new threads. The actual configuration that is active for a given thread will be shown in the "info record" command. At the moment, the configuration struct only contains a format field that is set to the only available format. The format is the only configuration option that can not be set via set commands. It is given as argument to the "record btrace" command when starting recording. 2015-02-09 Markus Metzger <markus.t.metzger@intel.com> * Makefile.in (XMLFILES): Add btrace-conf.dtd. * x86-linux-nat.c (x86_linux_enable_btrace): Update parameters. (x86_linux_btrace_conf): New. (x86_linux_create_target): Initialize to_btrace_conf. * nat/linux-btrace.c (linux_enable_btrace): Update parameters. Check format. Split into this and ... (linux_enable_bts): ... this. (linux_btrace_conf): New. (perf_event_skip_record): Renamed into ... (perf_event_skip_bts_record): ... this. Updated users. (linux_disable_btrace): Split into this and ... (linux_disable_bts): ... this. (linux_read_btrace): Check format. * nat/linux-btrace.h (linux_enable_btrace): Update parameters. (linux_btrace_conf): New. (btrace_target_info)<ptid>: Moved. (btrace_target_info)<conf>: New. (btrace_target_info): Split into this and ... (btrace_tinfo_bts): ... this. Updated users. * btrace.c (btrace_enable): Update parameters. (btrace_conf, parse_xml_btrace_conf_bts, parse_xml_btrace_conf) (btrace_conf_children, btrace_conf_attributes) (btrace_conf_elements): New. * btrace.h (btrace_enable): Update parameters. (btrace_conf, parse_xml_btrace_conf): New. * common/btrace-common.h (btrace_config): New. * feature/btrace-conf.dtd: New. * record-btrace.c (record_btrace_conf): New. (record_btrace_cmdlist): New. (record_btrace_enable_warn, record_btrace_open): Pass &record_btrace_conf. (record_btrace_info): Print recording format. (cmd_record_btrace_bts_start): New. (cmd_record_btrace_start): Call cmd_record_btrace_bts_start. (_initialize_record_btrace): Add "record btrace bts" subcommand. Add "record bts" alias command. * remote.c (remote_state)<btrace_config>: New. (remote_btrace_reset, PACKET_qXfer_btrace_conf): New. (remote_protocol_features): Add qXfer:btrace-conf:read. (remote_open_1): Call remote_btrace_reset. (remote_xfer_partial): Handle TARGET_OBJECT_BTRACE_CONF. (btrace_target_info)<conf>: New. (btrace_sync_conf, btrace_read_config): New. (remote_enable_btrace): Update parameters. Call btrace_sync_conf and btrace_read_conf. (remote_btrace_conf): New. (init_remote_ops): Initialize to_btrace_conf. (_initialize_remote): Add qXfer:btrace-conf packet. * target.c (target_enable_btrace): Update parameters. (target_btrace_conf): New. * target.h (target_enable_btrace): Update parameters. (target_btrace_conf): New. (target_object)<TARGET_OBJECT_BTRACE_CONF>: New. (target_ops)<to_enable_btrace>: Update parameters and comment. (target_ops)<to_btrace_conf>: New. * target-delegates: Regenerate. * target-debug.h (target_debug_print_const_struct_btrace_config_p) (target_debug_print_const_struct_btrace_target_info_p): New. NEWS: Announce new command and new packet. doc/ * gdb.texinfo (Process Record and Replay): Describe the "record btrace bts" command. (General Query Packets): Describe qXfer:btrace-conf:read packet. (Branch Trace Configuration Format): New. gdbserver/ * linux-low.c (linux_low_enable_btrace): Update parameters. (linux_low_btrace_conf): New. (linux_target_ops)<to_btrace_conf>: Initialize. * server.c (current_btrace_conf): New. (handle_btrace_enable): Rename to ... (handle_btrace_enable_bts): ... this. Pass &current_btrace_conf to target_enable_btrace. Update comment. Update users. (handle_qxfer_btrace_conf): New. (qxfer_packets): Add btrace-conf entry. (handle_query): Report qXfer:btrace-conf:read as supported packet. * target.h (target_ops)<enable_btrace>: Update parameters and comment. (target_ops)<read_btrace_conf>: New. (target_enable_btrace): Update parameters. (target_read_btrace_conf): New. testsuite/ * gdb.btrace/delta.exp: Update "info record" output. * gdb.btrace/enable.exp: Update "info record" output. * gdb.btrace/finish.exp: Update "info record" output. * gdb.btrace/instruction_history.exp: Update "info record" output. * gdb.btrace/next.exp: Update "info record" output. * gdb.btrace/nexti.exp: Update "info record" output. * gdb.btrace/step.exp: Update "info record" output. * gdb.btrace/stepi.exp: Update "info record" output. * gdb.btrace/nohist.exp: Update "info record" output.
Diffstat (limited to 'gdb/gdbserver')
-rw-r--r--gdb/gdbserver/ChangeLog17
-rw-r--r--gdb/gdbserver/linux-low.c35
-rw-r--r--gdb/gdbserver/server.c78
-rw-r--r--gdb/gdbserver/target.h19
4 files changed, 138 insertions, 11 deletions
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog
index 636ad2e..d489ebf 100644
--- a/gdb/gdbserver/ChangeLog
+++ b/gdb/gdbserver/ChangeLog
@@ -1,5 +1,22 @@
2015-02-09 Markus Metzger <markus.t.metzger@intel.com>
+ * linux-low.c (linux_low_enable_btrace): Update parameters.
+ (linux_low_btrace_conf): New.
+ (linux_target_ops)<to_btrace_conf>: Initialize.
+ * server.c (current_btrace_conf): New.
+ (handle_btrace_enable): Rename to ...
+ (handle_btrace_enable_bts): ... this. Pass &current_btrace_conf
+ to target_enable_btrace. Update comment. Update users.
+ (handle_qxfer_btrace_conf): New.
+ (qxfer_packets): Add btrace-conf entry.
+ (handle_query): Report qXfer:btrace-conf:read as supported packet.
+ * target.h (target_ops)<enable_btrace>: Update parameters and comment.
+ (target_ops)<read_btrace_conf>: New.
+ (target_enable_btrace): Update parameters.
+ (target_read_btrace_conf): New.
+
+2015-02-09 Markus Metzger <markus.t.metzger@intel.com>
+
* server.c (handle_btrace_general_set): Remove call to
target_supports_btrace.
(supported_btrace_packets): New.
diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c
index 8bc73a4..b311d4b 100644
--- a/gdb/gdbserver/linux-low.c
+++ b/gdb/gdbserver/linux-low.c
@@ -5938,11 +5938,11 @@ linux_qxfer_libraries_svr4 (const char *annex, unsigned char *readbuf,
/* See to_enable_btrace target method. */
static struct btrace_target_info *
-linux_low_enable_btrace (ptid_t ptid)
+linux_low_enable_btrace (ptid_t ptid, const struct btrace_config *conf)
{
struct btrace_target_info *tinfo;
- tinfo = linux_enable_btrace (ptid);
+ tinfo = linux_enable_btrace (ptid, conf);
if (tinfo != NULL)
{
@@ -6020,6 +6020,35 @@ linux_low_read_btrace (struct btrace_target_info *tinfo, struct buffer *buffer,
btrace_data_fini (&btrace);
return 0;
}
+
+/* See to_btrace_conf target method. */
+
+static int
+linux_low_btrace_conf (const struct btrace_target_info *tinfo,
+ struct buffer *buffer)
+{
+ const struct btrace_config *conf;
+
+ buffer_grow_str (buffer, "<!DOCTYPE btrace-conf SYSTEM \"btrace-conf.dtd\">\n");
+ buffer_grow_str (buffer, "<btrace-conf version=\"1.0\">\n");
+
+ conf = linux_btrace_conf (tinfo);
+ if (conf != NULL)
+ {
+ switch (conf->format)
+ {
+ case BTRACE_FORMAT_NONE:
+ break;
+
+ case BTRACE_FORMAT_BTS:
+ buffer_xml_printf (buffer, "<bts/>\n");
+ break;
+ }
+ }
+
+ buffer_grow_str0 (buffer, "</btrace-conf>\n");
+ return 0;
+}
#endif /* HAVE_LINUX_BTRACE */
static struct target_ops linux_target_ops = {
@@ -6093,11 +6122,13 @@ static struct target_ops linux_target_ops = {
linux_low_enable_btrace,
linux_low_disable_btrace,
linux_low_read_btrace,
+ linux_low_btrace_conf,
#else
NULL,
NULL,
NULL,
NULL,
+ NULL,
#endif
linux_supports_range_stepping,
};
diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c
index 1756a1f..17ee5e1 100644
--- a/gdb/gdbserver/server.c
+++ b/gdb/gdbserver/server.c
@@ -122,6 +122,10 @@ struct vstop_notif
struct target_waitstatus status;
};
+/* The current btrace configuration. This is gdbserver's mirror of GDB's
+ btrace configuration. */
+static struct btrace_config current_btrace_conf;
+
DEFINE_QUEUE_P (notif_event_p);
/* Put a stop reply to the stop reply queue. */
@@ -381,15 +385,17 @@ write_qxfer_response (char *buf, const void *data, int len, int is_more)
PBUFSIZ - 2) + 1;
}
-/* Handle btrace enabling. */
+/* Handle btrace enabling in BTS format. */
static const char *
-handle_btrace_enable (struct thread_info *thread)
+handle_btrace_enable_bts (struct thread_info *thread)
{
if (thread->btrace != NULL)
return "E.Btrace already enabled.";
- thread->btrace = target_enable_btrace (thread->entry.id);
+ current_btrace_conf.format = BTRACE_FORMAT_BTS;
+ thread->btrace = target_enable_btrace (thread->entry.id,
+ &current_btrace_conf);
if (thread->btrace == NULL)
return "E.Could not enable btrace.";
@@ -443,7 +449,7 @@ handle_btrace_general_set (char *own_buf)
err = NULL;
if (strcmp (op, "bts") == 0)
- err = handle_btrace_enable (thread);
+ err = handle_btrace_enable_bts (thread);
else if (strcmp (op, "off") == 0)
err = handle_btrace_disable (thread);
else
@@ -1510,10 +1516,73 @@ handle_qxfer_btrace (const char *annex,
return len;
}
+/* Handle qXfer:btrace-conf:read. */
+
+static int
+handle_qxfer_btrace_conf (const char *annex,
+ gdb_byte *readbuf, const gdb_byte *writebuf,
+ ULONGEST offset, LONGEST len)
+{
+ static struct buffer cache;
+ struct thread_info *thread;
+ int result;
+
+ if (the_target->read_btrace_conf == NULL || writebuf != NULL)
+ return -2;
+
+ if (annex[0] != '\0' || !target_running ())
+ return -1;
+
+ if (ptid_equal (general_thread, null_ptid)
+ || ptid_equal (general_thread, minus_one_ptid))
+ {
+ strcpy (own_buf, "E.Must select a single thread.");
+ return -3;
+ }
+
+ thread = find_thread_ptid (general_thread);
+ if (thread == NULL)
+ {
+ strcpy (own_buf, "E.No such thread.");
+ return -3;
+ }
+
+ if (thread->btrace == NULL)
+ {
+ strcpy (own_buf, "E.Btrace not enabled.");
+ return -3;
+ }
+
+ if (offset == 0)
+ {
+ buffer_free (&cache);
+
+ result = target_read_btrace_conf (thread->btrace, &cache);
+ if (result != 0)
+ {
+ memcpy (own_buf, cache.buffer, cache.used_size);
+ return -3;
+ }
+ }
+ else if (offset > cache.used_size)
+ {
+ buffer_free (&cache);
+ return -3;
+ }
+
+ if (len > cache.used_size - offset)
+ len = cache.used_size - offset;
+
+ memcpy (readbuf, cache.buffer + offset, len);
+
+ return len;
+}
+
static const struct qxfer qxfer_packets[] =
{
{ "auxv", handle_qxfer_auxv },
{ "btrace", handle_qxfer_btrace },
+ { "btrace-conf", handle_qxfer_btrace_conf },
{ "fdpic", handle_qxfer_fdpic},
{ "features", handle_qxfer_features },
{ "libraries", handle_qxfer_libraries },
@@ -1698,6 +1767,7 @@ supported_btrace_packets (char *buf)
strcat (buf, ";Qbtrace:off+");
strcat (buf, ";qXfer:btrace:read+");
+ strcat (buf, ";qXfer:btrace-conf:read+");
}
/* Handle all of the extended 'q' packets. */
diff --git a/gdb/gdbserver/target.h b/gdb/gdbserver/target.h
index ed57886..05feb36 100644
--- a/gdb/gdbserver/target.h
+++ b/gdb/gdbserver/target.h
@@ -357,9 +357,10 @@ struct target_ops
/* Check whether the target supports branch tracing. */
int (*supports_btrace) (struct target_ops *, enum btrace_format);
- /* Enable branch tracing for @ptid and allocate a branch trace target
- information struct for reading and for disabling branch trace. */
- struct btrace_target_info *(*enable_btrace) (ptid_t ptid);
+ /* Enable branch tracing for PTID based on CONF and allocate a branch trace
+ target information struct for reading and for disabling branch trace. */
+ struct btrace_target_info *(*enable_btrace)
+ (ptid_t ptid, const struct btrace_config *conf);
/* Disable branch tracing.
Returns zero on success, non-zero otherwise. */
@@ -371,6 +372,11 @@ struct target_ops
otherwise. */
int (*read_btrace) (struct btrace_target_info *, struct buffer *, int type);
+ /* Read the branch trace configuration into BUFFER.
+ Return 0 on success; print an error message into BUFFER and return -1
+ otherwise. */
+ int (*read_btrace_conf) (const struct btrace_target_info *, struct buffer *);
+
/* Return true if target supports range stepping. */
int (*supports_range_stepping) (void);
};
@@ -493,8 +499,8 @@ int kill_inferior (int);
(the_target->supports_btrace \
? (*the_target->supports_btrace) (the_target, format) : 0)
-#define target_enable_btrace(ptid) \
- (*the_target->enable_btrace) (ptid)
+#define target_enable_btrace(ptid, conf) \
+ (*the_target->enable_btrace) (ptid, conf)
#define target_disable_btrace(tinfo) \
(*the_target->disable_btrace) (tinfo)
@@ -502,6 +508,9 @@ int kill_inferior (int);
#define target_read_btrace(tinfo, buffer, type) \
(*the_target->read_btrace) (tinfo, buffer, type)
+#define target_read_btrace_conf(tinfo, buffer) \
+ (*the_target->read_btrace_conf) (tinfo, buffer)
+
#define target_supports_range_stepping() \
(the_target->supports_range_stepping ? \
(*the_target->supports_range_stepping) () : 0)