|
From: Tom H. <th...@cy...> - 2004-08-21 11:10:57
|
CVS commit by thughes:
Add support for a --time-stamp option that causes each message output
by valgrind to include a time stamp. This fixes bug #70587.
M +3 -0 coregrind/vg_include.h 1.234
M +4 -0 coregrind/vg_main.c 1.195
M +28 -2 coregrind/vg_messages.c 1.14
M +6 -0 coregrind/docs/coregrind_core.html 1.33
M +1 -0 none/tests/cmdline1.stdout.exp 1.7
M +1 -0 none/tests/cmdline2.stdout.exp 1.7
--- valgrind/coregrind/vg_include.h #1.233:1.234
@@ -205,4 +205,7 @@ extern Int VG_(clo_log_fd);
extern Char* VG_(clo_log_name);
+/* Add timestamps to log messages? default: NO */
+extern Bool VG_(clo_time_stamp);
+
/* The file descriptor to read for input. default: 0 == stdin */
extern Int VG_(clo_input_fd);
--- valgrind/coregrind/vg_main.c #1.194:1.195
@@ -1434,4 +1434,6 @@ Int VG_(clo_log_fd) = 1;
Char* VG_(clo_log_name) = NULL;
+Bool VG_(clo_time_stamp) = False;
+
Int VG_(clo_input_fd) = 0; /* stdin */
Int VG_(clo_n_suppressions) = 0;
@@ -1482,4 +1484,5 @@ void usage ( Bool debug_help )
" --trace-children=no|yes Valgrind-ise child processes? [no]\n"
" --track-fds=no|yes track open file descriptors? [no]\n"
+" --time-stamp=no|yes add timestamps to log messages? [no]\n"
"\n"
" uncommon user options for all Valgrind tools:\n"
@@ -1686,4 +1689,5 @@ static void process_cmd_line_options( UI
else VG_BOOL_CLO("--show-below-main", VG_(clo_show_below_main))
else VG_BOOL_CLO("--single-step", VG_(clo_single_step))
+ else VG_BOOL_CLO("--time-stamp", VG_(clo_time_stamp))
else VG_BOOL_CLO("--track-fds", VG_(clo_track_fds))
else VG_BOOL_CLO("--trace-children", VG_(clo_trace_children))
--- valgrind/coregrind/vg_messages.c #1.13:1.14
@@ -33,4 +33,7 @@
#include "vg_include.h"
+#include <time.h>
+#include <sys/time.h>
+
static char vg_mbuf[M_VG_MSGBUF];
@@ -44,4 +47,22 @@ static void add_to_buf ( Char c )
}
+static void add_timestamp ( Char *buf )
+{
+ struct timeval tv;
+ struct tm tm;
+
+ if ( gettimeofday( &tv, NULL ) == 0 &&
+ localtime_r( &tv.tv_sec, &tm ) == &tm ) {
+ VG_(sprintf)( buf, "%04d-%02d-%02d %02d:%02d:%02d.%03d ",
+ tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
+ tm.tm_hour, tm.tm_min, tm.tm_sec, tv.tv_usec / 1000 );
+ }
+ else {
+ VG_(strcpy)( buf, "" );
+ }
+
+ return;
+}
+
/* Publically visible from here onwards. */
@@ -80,7 +101,12 @@ int VG_(message) ( VgMsgKind kind, Char*
int VG_(start_msg) ( VgMsgKind kind )
{
+ Char ts[32];
Char c;
vg_n_mbuf = 0;
vg_mbuf[vg_n_mbuf] = 0;
+ if (VG_(clo_time_stamp))
+ add_timestamp(ts);
+ else
+ VG_(strcpy)(ts, "");
switch (kind) {
case Vg_UserMsg: c = '='; break;
@@ -90,6 +116,6 @@ int VG_(start_msg) ( VgMsgKind kind )
default: c = '?'; break;
}
- return VG_(add_to_msg)( "%c%c%d%c%c ",
- c,c, VG_(getpid)(), c,c );
+ return VG_(add_to_msg)( "%c%c%s%d%c%c ",
+ c,c, ts, VG_(getpid)(), c,c );
}
--- valgrind/coregrind/docs/coregrind_core.html #1.32:1.33
@@ -558,4 +558,10 @@
see section <a href="#core-comment">2.3</a>.
</li><br><p>
+
+ <li><code>--time-stamp=no</code> [default]<br>
+ <code>--time-stamp=yes</code>
+ <p>Specifies that valgrind should output a timestamp before
+ each message that it outputs.
+ </li><br><p>
</ul>
--- valgrind/none/tests/cmdline1.stdout.exp #1.6:1.7
@@ -10,4 +10,5 @@
--trace-children=no|yes Valgrind-ise child processes? [no]
--track-fds=no|yes track open file descriptors? [no]
+ --time-stamp=no|yes add timestamps to log messages? [no]
uncommon user options for all Valgrind tools:
--- valgrind/none/tests/cmdline2.stdout.exp #1.6:1.7
@@ -10,4 +10,5 @@
--trace-children=no|yes Valgrind-ise child processes? [no]
--track-fds=no|yes track open file descriptors? [no]
+ --time-stamp=no|yes add timestamps to log messages? [no]
uncommon user options for all Valgrind tools:
|