From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30486 invoked by alias); 27 Sep 2012 12:22:06 -0000 Received: (qmail 30472 invoked by uid 22791); 27 Sep 2012 12:22:03 -0000 X-SWARE-Spam-Status: No, hits=-3.4 required=5.0 tests=BAYES_00,KHOP_RCVD_UNTRUST,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL,TW_XS 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; Thu, 27 Sep 2012 12:21:56 +0000 Received: from svr-orw-fem-01.mgc.mentorg.com ([147.34.98.93]) by relay1.mentorg.com with esmtp id 1THD6I-0000yq-Fq from Dmitry_Kozlov@mentor.com for gdb-patches@sourceware.org; Thu, 27 Sep 2012 05:21:54 -0700 Received: from SVR-IES-FEM-01.mgc.mentorg.com ([137.202.0.104]) by svr-orw-fem-01.mgc.mentorg.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Thu, 27 Sep 2012 05:21:54 -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; Thu, 27 Sep 2012 13:21:51 +0100 Message-ID: <506444DD.9040503@mentor.com> Date: Thu, 27 Sep 2012 12:22:00 -0000 From: Dmitry Kozlov User-Agent: Mozilla/5.0 (X11; Linux i686; rv:15.0) Gecko/20120827 Thunderbird/15.0 MIME-Version: 1.0 To: CC: "'Stan_Shebs@mentor.com'" , Vladimir Prus Subject: PATCH fix start-time and stop-time in trace-status Content-Type: multipart/mixed; boundary="------------050900080908070405030805" 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-09/txt/msg00621.txt.bz2 --------------050900080908070405030805 Content-Type: text/plain; charset="ISO-8859-1"; format=flowed Content-Transfer-Encoding: 7bit Content-length: 499 Hello, I noticed that trace-status MI command reports incorrect start-time and stop-time, sometimes even negative. Investigation showed that gdbserver reports start-time and stop-time in decimal format, while gdb tries to interpret it as hex adn then broke it during type conversion. I think keeping decimal format for communication is useful because itis human-readable in remote log, so the attached patch fixes this problem on the gdb side. Please consider applying it. Thank you, Dmitry --------------050900080908070405030805 Content-Type: text/x-patch; name="gdb_dates.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="gdb_dates.diff" Content-length: 4049 diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 0a1ccdf..b43928d 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2012-09-25 Dmitry Kozlov + + * tracepoint.c (trace_status_command): Fix type of printf arg. + (trace_status_mi): Likewise. + * remote.c (unpack_ulongest): New. + 2012-09-24 Siddhesh Poyarekar * m2-typeprint.c (m2_enum): Expand LASTVAL to LONGEST. diff --git a/gdb/remote.c b/gdb/remote.c index 1750bee..cc871e5 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -1892,6 +1892,8 @@ struct gdb_ext_thread_info char *unpack_varlen_hex (char *buff, ULONGEST *result); +char *unpack_ulongest (char *buff, ULONGEST *result); + static char *unpack_nibble (char *buf, int *val); static char *pack_nibble (char *buf, int nibble); @@ -2079,6 +2081,21 @@ stub_unpack_int (char *buff, int fieldlength) } char * +unpack_ulongest (char *buff, ULONGEST *result) +{ + ULONGEST retval = 0; + + while (isdigit (*buff)) + { + retval *= 10; + retval += *buff - '0'; + buff++; + } + *result = retval; + return buff; +} + +char * unpack_varlen_hex (char *buff, /* packet to parse */ ULONGEST *result) { diff --git a/gdb/remote.h b/gdb/remote.h index 3adc54e..7dbe263 100644 --- a/gdb/remote.h +++ b/gdb/remote.h @@ -39,6 +39,8 @@ extern int putpkt (char *buf); extern char *unpack_varlen_hex (char *buff, ULONGEST *result); +extern char *unpack_ulongest (char *buff, ULONGEST *result); + extern void async_remote_interrupt_twice (void *arg); void register_remote_g_packet_guess (struct gdbarch *gdbarch, int bytes, diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c index bdd6f50..6ff3a2f 100644 --- a/gdb/tracepoint.c +++ b/gdb/tracepoint.c @@ -2039,20 +2039,20 @@ trace_status_command (char *args, int from_tty) /* Reporting a run time is more readable than two long numbers. */ printf_filtered (_("Trace started at %ld.%06ld secs, stopped %ld.%06ld secs later.\n"), - (long int) ts->start_time / 1000000, - (long int) ts->start_time % 1000000, - (long int) run_time / 1000000, - (long int) run_time % 1000000); + (long int) (ts->start_time / 1000000), + (long int) (ts->start_time % 1000000), + (long int) (run_time / 1000000), + (long int) (run_time % 1000000)); } else printf_filtered (_("Trace started at %ld.%06ld secs.\n"), - (long int) ts->start_time / 1000000, - (long int) ts->start_time % 1000000); + (long int) (ts->start_time / 1000000), + (long int) (ts->start_time % 1000000)); } else if (ts->stop_time) printf_filtered (_("Trace stopped at %ld.%06ld secs.\n"), - (long int) ts->stop_time / 1000000, - (long int) ts->stop_time % 1000000); + (long int) (ts->stop_time / 1000000), + (long int) (ts->stop_time % 1000000)); /* Now report any per-tracepoint status available. */ tp_vec = all_tracepoints (); @@ -2167,12 +2167,12 @@ trace_status_mi (int on_stop) char buf[100]; xsnprintf (buf, sizeof buf, "%ld.%06ld", - (long int) ts->start_time / 1000000, - (long int) ts->start_time % 1000000); + (long int) (ts->start_time / 1000000), + (long int) (ts->start_time % 1000000)); ui_out_field_string (uiout, "start-time", buf); xsnprintf (buf, sizeof buf, "%ld.%06ld", - (long int) ts->stop_time / 1000000, - (long int) ts->stop_time % 1000000); + (long int) (ts->stop_time / 1000000), + (long int) (ts->stop_time % 1000000)); ui_out_field_string (uiout, "stop-time", buf); } } @@ -3938,12 +3938,12 @@ Status line: '%s'\n"), p, line); } else if (strncmp (p, "starttime", p1 - p) == 0) { - p = unpack_varlen_hex (++p1, &val); + p = unpack_ulongest (++p1, &val); ts->start_time = val; } else if (strncmp (p, "stoptime", p1 - p) == 0) { - p = unpack_varlen_hex (++p1, &val); + p = unpack_ulongest (++p1, &val); ts->stop_time = val; } else if (strncmp (p, "username", p1 - p) == 0) --------------050900080908070405030805--