From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21681 invoked by alias); 13 Apr 2007 13:32:18 -0000 Received: (qmail 21670 invoked by uid 22791); 13 Apr 2007 13:32:17 -0000 X-Spam-Check-By: sourceware.org Received: from return.false.org (HELO return.false.org) (66.207.162.98) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 13 Apr 2007 14:32:13 +0100 Received: from return.false.org (localhost [127.0.0.1]) by return.false.org (Postfix) with ESMTP id 81EAD4B267 for ; Fri, 13 Apr 2007 08:32:12 -0500 (CDT) Received: from caradoc.them.org (dsl093-172-095.pit1.dsl.speakeasy.net [66.93.172.95]) by return.false.org (Postfix) with ESMTP id 375A04B262 for ; Fri, 13 Apr 2007 08:32:12 -0500 (CDT) Received: from drow by caradoc.them.org with local (Exim 4.63) (envelope-from ) id 1HcLso-0002vb-Ak for gdb-patches@sourceware.org; Fri, 13 Apr 2007 09:32:10 -0400 Date: Fri, 13 Apr 2007 13:32:00 -0000 From: Daniel Jacobowitz To: gdb-patches@sourceware.org Subject: [rfa/rfc] Debug output timestamps Message-ID: <20070413133209.GA11212@caradoc.them.org> Mail-Followup-To: gdb-patches@sourceware.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.15 (2007-04-09) X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2007-04/txt/msg00193.txt.bz2 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 * 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 +#include + #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*