From: Dmitry Kozlov <dmitry_kozlov@mentor.com>
To: <gdb-patches@sourceware.org>
Cc: "'Stan_Shebs@mentor.com'" <Stan_Shebs@mentor.com>,
Vladimir Prus <vladimir@codesourcery.com>
Subject: PATCH fix start-time and stop-time in trace-status
Date: Thu, 27 Sep 2012 12:22:00 -0000 [thread overview]
Message-ID: <506444DD.9040503@mentor.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 499 bytes --]
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
[-- Attachment #2: gdb_dates.diff --]
[-- Type: text/x-patch, Size: 4049 bytes --]
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 <ddk@mentor.com>
+
+ * tracepoint.c (trace_status_command): Fix type of printf arg.
+ (trace_status_mi): Likewise.
+ * remote.c (unpack_ulongest): New.
+
2012-09-24 Siddhesh Poyarekar <siddhesh@redhat.com>
* 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)
next reply other threads:[~2012-09-27 12:22 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-27 12:22 Dmitry Kozlov [this message]
2012-09-27 15:14 ` Tom Tromey
2012-10-01 13:41 ` Dmitry Kozlov
2012-10-15 19:11 ` Tom Tromey
2012-10-16 14:59 ` Dmitry Kozlov
2012-10-16 15:15 ` Pedro Alves
2012-10-16 17:07 ` Stan Shebs
2012-10-16 16:51 ` Tom Tromey
2012-10-08 13:54 ` Dmitry Kozlov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=506444DD.9040503@mentor.com \
--to=dmitry_kozlov@mentor.com \
--cc=Stan_Shebs@mentor.com \
--cc=gdb-patches@sourceware.org \
--cc=vladimir@codesourcery.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox