From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24683 invoked by alias); 11 Apr 2013 06:16:52 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 24673 invoked by uid 89); 11 Apr 2013 06:16:51 -0000 X-Spam-SWARE-Status: No, score=-4.3 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL,TW_CP autolearn=ham version=3.3.1 Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Thu, 11 Apr 2013 06:16:50 +0000 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1UQAoS-0004KR-Uh from Hui_Zhu@mentor.com for gdb-patches@sourceware.org; Wed, 10 Apr 2013 23:16:48 -0700 Received: from SVR-ORW-FEM-03.mgc.mentorg.com ([147.34.97.39]) by SVR-ORW-EXC-10.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Wed, 10 Apr 2013 23:16:49 -0700 Received: from [127.0.0.1] (147.34.91.1) by svr-orw-fem-03.mgc.mentorg.com (147.34.97.39) with Microsoft SMTP Server id 14.1.289.1; Wed, 10 Apr 2013 23:16:47 -0700 Message-ID: <5166554D.2070906@mentor.com> Date: Thu, 11 Apr 2013 08:37:00 -0000 From: Hui Zhu User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:19.0) Gecko/20130126 Thunderbird/19.0 MIME-Version: 1.0 To: gdb-patches ml Subject: [PATCH] store trace default-collect to target [1/6] target, trace and remote References: <51665508.5050706@mentor.com> In-Reply-To: <51665508.5050706@mentor.com> Content-Type: multipart/mixed; boundary="------------030000010107040307020801" X-Virus-Found: No X-SW-Source: 2013-04/txt/msg00310.txt.bz2 --------------030000010107040307020801 Content-Type: text/plain; charset="ISO-8859-1"; format=flowed Content-Transfer-Encoding: 7bit Content-length: 948 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 * 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. --------------030000010107040307020801 Content-Type: text/plain; charset="us-ascii"; name="defc-remote.txt" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="defc-remote.txt" Content-length: 5623 --- 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 */ --------------030000010107040307020801--