This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [rfa/rfc] Debug output timestamps


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]