This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[rfa/rfc] Debug output timestamps
- From: Daniel Jacobowitz <drow at false dot org>
- To: gdb-patches at sourceware dot org
- Date: Fri, 13 Apr 2007 09:32:09 -0400
- Subject: [rfa/rfc] Debug output timestamps
Does anyone else think this would be useful? I was trying to figure
out how long some operations took during single stepping, in a
relatively unintrusive way. It's not very accurate, but it was still
handy.
--
Daniel Jacobowitz
CodeSourcery
2007-04-13 Daniel Jacobowitz <dan@codesourcery.com>
* utils.c (debug_timestamp): New.
(vfprintf_unfiltered): Print timestamps if requested.
(show_debug_timestamp): New.
(initialize_utils): Register "set debug timestamp".
* NEWS: Mention "set debug timestamp".
* gdb.texinfo (Debugging Output): Document "set debug timestamp".
---
NEWS | 4 ++++
doc/gdb.texinfo | 8 ++++++++
utils.c | 33 +++++++++++++++++++++++++++++++++
3 files changed, 45 insertions(+)
Index: gdb/utils.c
===================================================================
--- gdb.orig/utils.c 2007-04-13 09:01:26.000000000 -0400
+++ gdb/utils.c 2007-04-13 09:07:17.000000000 -0400
@@ -64,6 +64,9 @@
#include "readline/readline.h"
+#include <sys/time.h>
+#include <time.h>
+
#if !HAVE_DECL_MALLOC
extern PTR malloc (); /* OK: PTR */
#endif
@@ -93,6 +96,10 @@ static void prompt_for_continue (void);
static void set_screen_size (void);
static void set_width (void);
+/* A flag indicating whether to timestamp debugging messages. */
+
+static int debug_timestamp = 0;
+
/* Chain of cleanup actions established with make_cleanup,
to be executed if an error happens. */
@@ -2135,6 +2142,16 @@ vfprintf_unfiltered (struct ui_file *str
linebuffer = xstrvprintf (format, args);
old_cleanups = make_cleanup (xfree, linebuffer);
+ if (debug_timestamp && stream == gdb_stdlog)
+ {
+ struct timeval tm;
+ char *timestamp;
+
+ gettimeofday (&tm, NULL);
+ timestamp = xstrprintf ("%ld:%ld ", (long) tm.tv_sec, (long) tm.tv_usec);
+ make_cleanup (xfree, timestamp);
+ fputs_unfiltered (timestamp, stream);
+ }
fputs_unfiltered (linebuffer, stream);
do_cleanups (old_cleanups);
}
@@ -2451,6 +2468,13 @@ pagination_off_command (char *arg, int f
{
pagination_enabled = 0;
}
+
+static void
+show_debug_timestamp (struct ui_file *file, int from_tty,
+ struct cmd_list_element *c, const char *value)
+{
+ fprintf_filtered (file, _("Timestamping debugging messages is %s.\n"), value);
+}
void
@@ -2511,6 +2535,15 @@ Show demangling of C++/ObjC names in dis
NULL,
show_asm_demangle,
&setprintlist, &showprintlist);
+
+ add_setshow_boolean_cmd ("timestamp", class_maintenance,
+ &debug_timestamp, _("\
+Set timestamping of debugging messages."), _("\
+Show timestamping of debugging messages."), _("\
+When set, debugging messages will be marked with seconds and microseconds."),
+ NULL,
+ show_debug_timestamp,
+ &setdebuglist, &showdebuglist);
}
/* Machine specific function to handle SIGWINCH signal. */
Index: gdb/doc/gdb.texinfo
===================================================================
--- gdb.orig/doc/gdb.texinfo 2007-04-13 09:01:26.000000000 -0400
+++ gdb/doc/gdb.texinfo 2007-04-13 09:07:17.000000000 -0400
@@ -16207,6 +16207,14 @@ until the next time you connect to a tar
@item show debug target
Displays the current state of displaying @value{GDBN} target debugging
info.
+@item set debug timestamp
+@cindex timestampping debugging info
+Turns on or off display of timestamps with @value{GDBN} debugging info.
+When enabled, seconds and microseconds are displayed before each debugging
+message.
+@item show debug timestamp
+Displays the current state of displaying timestamps with @value{GDBN}
+debugging info.
@item set debugvarobj
@cindex variable object debugging info
Turns on or off display of @value{GDBN} variable object debugging
Index: gdb/NEWS
===================================================================
--- gdb.orig/NEWS 2007-04-13 09:07:21.000000000 -0400
+++ gdb/NEWS 2007-04-13 09:07:59.000000000 -0400
@@ -61,6 +61,10 @@ show sysroot
general version of "set solib-absolute-prefix", which is now
an alias to "set sysroot".
+set debug timetstamp
+show debug timestamp
+ Display timestamps with GDB debugging output.
+
* New native configurations
OpenBSD/sh sh*-*openbsd*