by valgrind to include a time stamp. This fixes bug #70587.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2594
<code>valgrind-listener</code> program. For further details,
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>
<h4>Error-related options</h4>
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);
/* The number of suppression files specified. */
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;
Char* VG_(clo_suppressions)[VG_CLO_MAX_SFILES];
" -v --verbose be more verbose, incl counts of errors\n"
" --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"
" --run-libc-freeres=no|yes free up glibc memory at exit? [yes]\n"
else VG_BOOL_CLO("--run-libc-freeres", VG_(clo_run_libc_freeres))
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))
else VG_BOOL_CLO("--trace-sched", VG_(clo_trace_sched))
#include "vg_include.h"
+#include <time.h>
+#include <sys/time.h>
+
static char vg_mbuf[M_VG_MSGBUF];
static int vg_n_mbuf;
vg_mbuf[vg_n_mbuf] = 0;
}
+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. */
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;
case Vg_DebugMsg: c = '-'; break;
case Vg_ClientMsg: c = '*'; break;
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 );
}
-v --verbose be more verbose, incl counts of errors
--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:
--run-libc-freeres=no|yes free up glibc memory at exit? [yes]
-v --verbose be more verbose, incl counts of errors
--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:
--run-libc-freeres=no|yes free up glibc memory at exit? [yes]