Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [rfa/rfc] Debug output timestamps
@ 2007-04-13 13:32 Daniel Jacobowitz
  2007-04-13 18:45 ` Eli Zaretskii
  0 siblings, 1 reply; 6+ messages in thread
From: Daniel Jacobowitz @ 2007-04-13 13:32 UTC (permalink / raw)
  To: gdb-patches

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);
+}
 \f
 
 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*


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [rfa/rfc] Debug output timestamps
  2007-04-13 13:32 [rfa/rfc] Debug output timestamps Daniel Jacobowitz
@ 2007-04-13 18:45 ` Eli Zaretskii
  2007-04-15 10:19   ` Joel Brobecker
  0 siblings, 1 reply; 6+ messages in thread
From: Eli Zaretskii @ 2007-04-13 18:45 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: gdb-patches

> Date: Fri, 13 Apr 2007 09:32:09 -0400
> From: Daniel Jacobowitz <drow@false.org>
> 
> 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.

Sounds like a good idea to me.

The doco patch is okay, if we decide to commit this.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [rfa/rfc] Debug output timestamps
  2007-04-13 18:45 ` Eli Zaretskii
@ 2007-04-15 10:19   ` Joel Brobecker
  2008-02-27 21:02     ` Daniel Jacobowitz
  0 siblings, 1 reply; 6+ messages in thread
From: Joel Brobecker @ 2007-04-15 10:19 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Daniel Jacobowitz, gdb-patches

> > 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.
> 
> Sounds like a good idea to me.

Me too!

-- 
Joel


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [rfa/rfc] Debug output timestamps
  2007-04-15 10:19   ` Joel Brobecker
@ 2008-02-27 21:02     ` Daniel Jacobowitz
  2008-02-27 21:58       ` Eli Zaretskii
  0 siblings, 1 reply; 6+ messages in thread
From: Daniel Jacobowitz @ 2008-02-27 21:02 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: Eli Zaretskii, gdb-patches

On Sun, Apr 15, 2007 at 12:05:56PM +0400, Joel Brobecker wrote:
> > > 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.
> > 
> > Sounds like a good idea to me.
> 
> Me too!

I have very belatedly checked this in.  (No, there wasn't any good
reason; I forgot.)

I started a new NEWS section on trunk for post-GDB-6.8, since the
branch date has passed.

-- 
Daniel Jacobowitz
CodeSourcery

2008-02-27  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".  Add GDB 6.8 section.

2008-02-27  Daniel Jacobowitz  <dan@codesourcery.com>

	* gdb.texinfo (Debugging Output): Document "set debug timestamp".

Index: NEWS
===================================================================
RCS file: /cvs/src/src/gdb/NEWS,v
retrieving revision 1.259
diff -u -p -r1.259 NEWS
--- NEWS	19 Feb 2008 18:20:45 -0000	1.259
+++ NEWS	27 Feb 2008 20:46:03 -0000
@@ -1,7 +1,15 @@
 		What has changed in GDB?
 	     (Organized release by release)
 
-*** Changes since GDB 6.7
+*** Changes since GDB 6.8
+
+* New commands
+
+set debug timetstamp
+show debug timestamp
+  Display timestamps with GDB debugging output.
+
+*** Changes in GDB 6.8
 
 * New native configurations
 
Index: utils.c
===================================================================
RCS file: /cvs/src/src/gdb/utils.c,v
retrieving revision 1.184
diff -u -p -r1.184 utils.c
--- utils.c	1 Jan 2008 22:53:13 -0000	1.184
+++ utils.c	27 Feb 2008 20:46:04 -0000
@@ -63,6 +63,9 @@
 
 #include "readline/readline.h"
 
+#include <sys/time.h>
+#include <time.h>
+
 #if !HAVE_DECL_MALLOC
 extern PTR malloc ();		/* OK: PTR */
 #endif
@@ -92,6 +95,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.  */
 
@@ -2121,6 +2128,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);
 }
@@ -2437,6 +2454,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);
+}
 \f
 
 void
@@ -2497,6 +2521,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: doc/gdb.texinfo
===================================================================
RCS file: /cvs/src/src/gdb/doc/gdb.texinfo,v
retrieving revision 1.469
diff -u -p -r1.469 gdb.texinfo
--- doc/gdb.texinfo	25 Feb 2008 20:34:40 -0000	1.469
+++ doc/gdb.texinfo	27 Feb 2008 20:46:06 -0000
@@ -16387,6 +16387,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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [rfa/rfc] Debug output timestamps
  2008-02-27 21:02     ` Daniel Jacobowitz
@ 2008-02-27 21:58       ` Eli Zaretskii
  2008-02-27 22:07         ` Daniel Jacobowitz
  0 siblings, 1 reply; 6+ messages in thread
From: Eli Zaretskii @ 2008-02-27 21:58 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: brobecker, gdb-patches

> Date: Wed, 27 Feb 2008 15:51:44 -0500
> From: Daniel Jacobowitz <drow@false.org>
> Cc: Eli Zaretskii <eliz@gnu.org>, gdb-patches@sourceware.org
> 
> 	* NEWS: Mention "set debug timestamp".  Add GDB 6.8 section.
> 
> 2008-02-27  Daniel Jacobowitz  <dan@codesourcery.com>
> 
> 	* gdb.texinfo (Debugging Output): Document "set debug timestamp".

This is okay, but wouldn't it be better to also show hours and
minutes?  That's what I'd expect when I read the word ``timestamp'' in
the docs.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [rfa/rfc] Debug output timestamps
  2008-02-27 21:58       ` Eli Zaretskii
@ 2008-02-27 22:07         ` Daniel Jacobowitz
  0 siblings, 0 replies; 6+ messages in thread
From: Daniel Jacobowitz @ 2008-02-27 22:07 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: brobecker, gdb-patches

On Wed, Feb 27, 2008 at 11:28:52PM +0200, Eli Zaretskii wrote:
> This is okay, but wouldn't it be better to also show hours and
> minutes?  That's what I'd expect when I read the word ``timestamp'' in
> the docs.

Maybe - I only use it to calculate elapsed time, so seconds were most
convenient.  It probably depends on the individual reading
(e.g. strace has options to do it both ways).

-- 
Daniel Jacobowitz
CodeSourcery


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2008-02-27 21:58 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-04-13 13:32 [rfa/rfc] Debug output timestamps Daniel Jacobowitz
2007-04-13 18:45 ` Eli Zaretskii
2007-04-15 10:19   ` Joel Brobecker
2008-02-27 21:02     ` Daniel Jacobowitz
2008-02-27 21:58       ` Eli Zaretskii
2008-02-27 22:07         ` Daniel Jacobowitz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox