[PATCH] store trace default-collect to target [1/6] target, trace and remote

Hui Zhu
2013-04-11T06:16:52Z

[-- Attachment #1: Type: text/plain, Size: 948 bytes --]

Hi,

This is the patch for remote support.
Also add to_download_tracepoint_default_collect as interface for store trace default-collect to target. and call it in start_tracing.

Thanks,
Hui

2013-04-11 Hui Zhu <hui@codesourcery.com>

* remote.c (remote_upload_trace_default_collest): New static.
(remote_start_remote): Call remote_upload_trace_default_collest
and trace_set_default_collect.
(remote_download_tracepoint_default_collect): New.
(remote_can_download_tracepoint): Set
to_download_tracepoint_default_collect.
(remote_upload_trace_default_collest): New.
* target.c (update_current_target): Add
to_download_tracepoint_default_collect.
* target.h (target_ops): to_download_tracepoint_default_collect.
(target_download_tracepoint_default_collect): New.
* tracepoint.c (start_tracing): Call
target_download_tracepoint_default_collect.
(trace_set_default_collect): New.
* tracepoint.h (trace_set_default_collect): New extern.

[-- Attachment #2: defc-remote.txt --]
[-- Type: text/plain, Size: 5623 bytes --]

--- a/remote.c
+++ b/remote.c
@@ -215,6 +215,8 @@ static int remote_get_trace_status (stru
static int remote_upload_tracepoints (struct uploaded_tp **utpp);

static int remote_upload_trace_state_variables (struct uploaded_tsv **utsvp);
+
+static void remote_upload_trace_default_collest (char **collectp);

static void remote_query_supported (void);

@@ -3567,6 +3569,7 @@ remote_start_remote (int from_tty, struc
{
struct uploaded_tp *uploaded_tps = NULL;
struct uploaded_tsv *uploaded_tsvs = NULL;
+ char *uploaded_default_collest = NULL;

if (current_trace_status ()->running)
printf_filtered (_("Trace is already running on the target.\n"));
@@ -3581,6 +3584,10 @@ remote_start_remote (int from_tty, struc
remote_upload_tracepoints (&uploaded_tps);

merge_uploaded_tracepoints (&uploaded_tps);
+
+ remote_upload_trace_default_collest (&uploaded_default_collest);
+
+ trace_set_default_collect (uploaded_default_collest);
}

/* The thread and inferior lists are now synchronized with the
@@ -10567,6 +10574,23 @@ remote_download_tracepoint (struct bp_lo
do_cleanups (old_chain);
}

+static void
+remote_download_tracepoint_default_collect (char *collect)
+{
+ char buf[BUF_SIZE];
+
+ strcpy (buf, "QTDDCsrc:");
+ if (strlen (buf) + strlen (collect) * 2 >= BUF_SIZE)
+ error (_("Source string too long for buffer"));
+ bin2hex (collect, buf + strlen (buf), 0);
+
+ putpkt (buf);
+ remote_get_noisy_reply (&target_buf, &target_buf_size);
+ if (strcmp (target_buf, "OK"))
+ warning (_("\
+Target does not support tracepoint default collect source download."));
+}
+
static int
remote_can_download_tracepoint (void)
{
@@ -11422,6 +11446,8 @@ Specify the serial device it is connecte
remote_ops.to_can_run_breakpoint_commands = remote_can_run_breakpoint_commands;
remote_ops.to_trace_init = remote_trace_init;
remote_ops.to_download_tracepoint = remote_download_tracepoint;
+ remote_ops.to_download_tracepoint_default_collect
+ = remote_download_tracepoint_default_collect;
remote_ops.to_can_download_tracepoint = remote_can_download_tracepoint;
remote_ops.to_download_trace_state_variable
= remote_download_trace_state_variable;
@@ -11644,6 +11670,28 @@ remote_upload_trace_state_variables (str
return 0;
}

+static void
+remote_upload_trace_default_collest (char **collectp)
+{
+ struct remote_state *rs = get_remote_state ();
+ int collect_size;
+
+ putpkt ("qTDC");
+ getpkt (&rs->buf, &rs->buf_size, 0);
+ if (strncmp (rs->buf, "DC", 2))
+ {
+ *collectp = NULL;
+ warning (_("\
+Target does not support tracepoint default collect upload."));
+ return;
+ }
+
+ collect_size = (strlen (rs->buf) - 2) / 2;
+ *collectp = xmalloc (collect_size + 1);
+ hex2bin (rs->buf + 2, *collectp, collect_size);
+ (*collectp)[collect_size] = '\0';
+}
+
void
_initialize_remote (void)
{
--- a/target.c
+++ b/target.c
@@ -706,6 +706,7 @@ update_current_target (void)
INHERIT (to_supports_string_tracing, t);
INHERIT (to_trace_init, t);
INHERIT (to_download_tracepoint, t);
+ INHERIT (to_download_tracepoint_default_collect, t);
INHERIT (to_can_download_tracepoint, t);
INHERIT (to_download_trace_state_variable, t);
INHERIT (to_enable_tracepoint, t);
@@ -890,6 +891,9 @@ update_current_target (void)
de_fault (to_download_tracepoint,
(void (*) (struct bp_location *))
tcomplain);
+ de_fault (to_download_tracepoint_default_collect,
+ (void (*) (char *))
+ tcomplain);
de_fault (to_can_download_tracepoint,
(int (*) (void))
return_zero);
--- a/target.h
+++ b/target.h
@@ -748,6 +748,10 @@ struct target_ops
/* Send full details of a tracepoint location to the target. */
void (*to_download_tracepoint) (struct bp_location *location);

+ /* Send full details of the list of expressions to collect by default
+ to the target. */
+ void (*to_download_tracepoint_default_collect) (char *collect);
+
/* Is the target able to download tracepoint locations in current
state? */
int (*to_can_download_tracepoint) (void);
@@ -1725,6 +1729,9 @@ extern char *target_fileio_read_stralloc
#define target_download_tracepoint(t) \
(*current_target.to_download_tracepoint) (t)

+#define target_download_tracepoint_default_collect(collect) \
+ (*current_target.to_download_tracepoint_default_collect) (collect)
+
#define target_can_download_tracepoint() \
(*current_target.to_can_download_tracepoint) ()

--- a/tracepoint.c
+++ b/tracepoint.c
@@ -1796,6 +1796,8 @@ start_tracing (char *notes)

t->number_on_target = 0;

+ target_download_tracepoint_default_collect (default_collect);
+
for (loc = b->loc; loc; loc = loc->next)
{
/* Since tracepoint locations are never duplicated, `inserted'
@@ -5660,6 +5662,18 @@ traceframe_available_memory (VEC(mem_ran
return 0;
}

+/* Not overwrite default collect If COLLECT is NULL or its size is 0. */
+
+void
+trace_set_default_collect (char *collect)
+{
+ if (collect != NULL && strlen (collect) != 0)
+ {
+ xfree (default_collect);
+ default_collect = collect;
+ }
+}
+
/* Implementation of `sdata' variable. */

static const struct internalvar_funcs sdata_funcs =
--- a/tracepoint.h
+++ b/tracepoint.h
@@ -412,4 +412,6 @@ extern struct traceframe_info *parse_tra
extern int traceframe_available_memory (VEC(mem_range_s) **result,
CORE_ADDR memaddr, ULONGEST len);

+extern void trace_set_default_collect (char *collect);
+
#endif /* TRACEPOINT_H */