From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14676 invoked by alias); 8 Oct 2012 19:14:34 -0000 Received: (qmail 14645 invoked by uid 22791); 8 Oct 2012 19:14:31 -0000 X-SWARE-Spam-Status: No, hits=-4.5 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL X-Spam-Check-By: sourceware.org Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 08 Oct 2012 19:14:25 +0000 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1TLImX-0001jI-7B from Dmitry_Kozlov@mentor.com for gdb-patches@sourceware.org; Mon, 08 Oct 2012 12:14:25 -0700 Received: from SVR-IES-FEM-01.mgc.mentorg.com ([137.202.0.104]) by SVR-ORW-EXC-10.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Mon, 8 Oct 2012 12:14:24 -0700 Received: from [127.0.0.1] (137.202.0.76) by SVR-IES-FEM-01.mgc.mentorg.com (137.202.0.104) with Microsoft SMTP Server id 14.1.289.1; Mon, 8 Oct 2012 20:14:23 +0100 Message-ID: <5073260C.2010809@mentor.com> Date: Mon, 08 Oct 2012 19:14:00 -0000 From: Dmitry Kozlov User-Agent: Mozilla/5.0 (X11; Linux i686; rv:15.0) Gecko/20120912 Thunderbird/15.0.1 MIME-Version: 1.0 To: Yao Qi CC: , "'Stan_Shebs@mentor.com'" , Vladimir Prus Subject: Re: [PATCH] Extend tsave: save start time, stop time, user and notes References: <506C4719.3030900@mentor.com> <5072CB78.8030908@codesourcery.com> In-Reply-To: <5072CB78.8030908@codesourcery.com> Content-Type: multipart/mixed; boundary="------------000505040104070807050204" 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 X-SW-Source: 2012-10/txt/msg00134.txt.bz2 --------------000505040104070807050204 Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit Content-length: 2777 Hello Yao, thank you for review, I have updated patch based on your recommendations. Please see attached file. And you are right this patch depends on my previous patch PATCH fix start-time and stop-time in trace-status http://sourceware.org/ml/gdb-patches/2012-09/msg00621.htm Thank you, Dmitry On 10/08/2012 04:47 PM, Yao Qi wrote: > On 10/03/2012 10:09 PM, Dmitry Kozlov wrote: > > In general, I think it is useful to include these attributes in > tracefile saved by command 'tsave'. > >> 2012-10-03 Dmitry Kozlov >> >> * tracepoint.c (trace_save): Add saving starttime, stoptime, user >> and notes. >> >> diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c >> index 0f94150..f7e96eb 100644 >> --- a/gdb/tracepoint.c >> +++ b/gdb/tracepoint.c >> @@ -3036,6 +3036,24 @@ trace_save (const char *filename, int >> target_does_save) >> fprintf (fp, ";disconn:%x", ts->disconnected_tracing); >> if (ts->circular_buffer) >> fprintf (fp, ";circular:%x", ts->circular_buffer); >> + if (ts->start_time) >> + fprintf (fp, ";starttime:%ld%06ld", (long int) (ts->start_time / >> 1000000), (long int) (ts->start_time % 1000000)); > > This line is too long... > >> + if (ts->stop_time) >> + fprintf (fp, ";stoptime:%ld%06ld", (long int) (ts->stop_time / >> 1000000), (long int) (ts->stop_time % 1000000)); > > and this line. > >> + if (ts->notes) > > ts->notes will never be NULL, because GDBserver will always send > "notes:" in qTStatus packet (See gdbserver/tracepoint.c:cmd_qtstatus), > but other stubs may don't include "notes:" in qTStatus packet, so we > may do the check here like this, > > if (ts->notes && ts->notes[0] != 0) > >> + { >> + char *buf = (char *) alloca (strlen (ts->notes) * 2 + 1); > > We need a blank line here. Looks 'alloca' is not encouraged to use, > and it should be replaced with xmalloc/xfree. > > [PATCH] Replace potentially unsafe alloca with xmalloc/xfree in > value_concat > http://sourceware.org/ml/gdb-patches/2012-09/msg00274.html > >> + bin2hex ((gdb_byte *) ts->notes, buf, 0); >> + fprintf (fp, ";notes:%s", buf); >> + >> + } >> + if (ts->user_name) >> + { >> + char *buf = (char *) alloca (strlen (ts->user_name) * 2 + 1); > > Likewise. > >> + bin2hex ((gdb_byte *) ts->user_name, buf, 0); >> + fprintf (fp, ";username:%s", buf); >> + >> + } >> fprintf (fp, "\n"); >> >> /* Note that we want to upload tracepoints and save those, rather > > Logically, this patch depends on your previous patch > > PATCH fix start-time and stop-time in trace-status > http://sourceware.org/ml/gdb-patches/2012-09/msg00621.html > > otherwise, we generate start-time and stop-time in trace file in > decimal format, while gdb still interprets it as hex. --------------000505040104070807050204 Content-Type: text/x-patch; name="gdb_tsave_v2.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="gdb_tsave_v2.diff" Content-length: 2209 commit e150b4b622d5f4ebf4e1d7c1f35510fd17c0ec8b Author: Dmitry Kozlov Date: Thu Oct 4 13:06:38 2012 +0400 Extend tsave to save trace start time, stop time and notes. diff --git a/gdb/ChangeLog b/gdb/ChangeLog index fe3728b..135f566 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,9 @@ 2012-10-04 Dmitry Kozlov + * tracepoint.c (trace_save): Add saving starttime, stoptime, user and notes. + +2012-10-04 Dmitry Kozlov + * tracepoint.c (trace_status_command): Fix type of printf arg. (trace_status_mi): Likewise. diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c index 0f94150..0e44316 100644 --- a/gdb/tracepoint.c +++ b/gdb/tracepoint.c @@ -3018,7 +3018,7 @@ trace_save (const char *filename, int target_does_save) (ts->running ? '1' : '0'), stop_reason_names[ts->stop_reason]); if (ts->stop_reason == tracepoint_error) { - char *buf = (char *) alloca (strlen (ts->stop_desc) * 2 + 1); + char *buf = (char *) xmalloc (strlen (ts->stop_desc) * 2 + 1); bin2hex ((gdb_byte *) ts->stop_desc, buf, 0); fprintf (fp, ":%s", buf); @@ -3036,6 +3036,33 @@ trace_save (const char *filename, int target_does_save) fprintf (fp, ";disconn:%x", ts->disconnected_tracing); if (ts->circular_buffer) fprintf (fp, ";circular:%x", ts->circular_buffer); + if (ts->start_time) + { + fprintf (fp, ";starttime:%ld%06ld", + (long int) (ts->start_time / 1000000), + (long int) (ts->start_time % 1000000)); + } + if (ts->stop_time) + { + fprintf (fp, ";stoptime:%ld%06ld", + (long int) (ts->stop_time / 1000000), + (long int) (ts->stop_time % 1000000)); + } + if (ts->notes && ts->notes[0] != 0 ) + { + char *buf = (char *) xmalloc (strlen (ts->notes) * 2 + 1); + + bin2hex ((gdb_byte *) ts->notes, buf, 0); + fprintf (fp, ";notes:%s", buf); + } + if (ts->user_name) + { + char *buf = (char *) xmalloc (strlen (ts->user_name) * 2 + 1); + + bin2hex ((gdb_byte *) ts->user_name, buf, 0); + fprintf (fp, ";username:%s", buf); + } + fprintf (fp, "\n"); /* Note that we want to upload tracepoints and save those, rather --------------000505040104070807050204--