Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Daniel Jacobowitz <drow@false.org>
To: Joel Brobecker <brobecker@adacore.com>
Cc: Eli Zaretskii <eliz@gnu.org>, gdb-patches@sourceware.org
Subject: Re: [rfa/rfc] Debug output timestamps
Date: Wed, 27 Feb 2008 21:02:00 -0000	[thread overview]
Message-ID: <20080227205144.GB14556@caradoc.them.org> (raw)
In-Reply-To: <20070415080556.GA29271@adacore.com>

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


  reply	other threads:[~2008-02-27 20:52 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-13 13:32 Daniel Jacobowitz
2007-04-13 18:45 ` Eli Zaretskii
2007-04-15 10:19   ` Joel Brobecker
2008-02-27 21:02     ` Daniel Jacobowitz [this message]
2008-02-27 21:58       ` Eli Zaretskii
2008-02-27 22:07         ` Daniel Jacobowitz

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=20080227205144.GB14556@caradoc.them.org \
    --to=drow@false.org \
    --cc=brobecker@adacore.com \
    --cc=eliz@gnu.org \
    --cc=gdb-patches@sourceware.org \
    /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