summaryrefslogtreecommitdiff
path: root/gdb/gdbserver/server.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/gdbserver/server.c')
-rw-r--r--gdb/gdbserver/server.c78
1 files changed, 74 insertions, 4 deletions
diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c
index 1756a1f0686..17ee5e1e902 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. */