|
From: <sv...@va...> - 2005-11-08 19:01:51
|
Author: sewardj
Date: 2005-11-08 19:01:44 +0000 (Tue, 08 Nov 2005)
New Revision: 5042
Log:
Reinstate timestamping, sort-of, having trashed VG_(ctime) as part of
the glibc-removal process. Timestamps are now printed in terms of
elapsed wallclock time since startup, shown as days, hours, minutes,
seconds and milliseconds. The arithmetic is done with 32-bit unsigned
ints, so people doing Valgrind runs that last longer than 49.71 days
are going to see some funny results :-)
Modified:
trunk/coregrind/m_libcprint.c
trunk/coregrind/m_main.c
trunk/coregrind/pub_core_libcprint.h
trunk/docs/xml/manual-core.xml
Modified: trunk/coregrind/m_libcprint.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/m_libcprint.c 2005-11-08 16:51:55 UTC (rev 5041)
+++ trunk/coregrind/m_libcprint.c 2005-11-08 19:01:44 UTC (rev 5042)
@@ -32,9 +32,9 @@
#include "pub_core_debuglog.h"
#include "pub_core_libcbase.h"
#include "pub_core_libcassert.h"
-#include "pub_core_libcfile.h" // For VG_(write)(), VG_(write_socket)(=
)
+#include "pub_core_libcfile.h" // VG_(write)(), VG_(write_socket)()
#include "pub_core_libcprint.h"
-#include "pub_core_libcproc.h" // For VG_(getpid)()
+#include "pub_core_libcproc.h" // VG_(getpid)(), VG_(read_millisecond_=
timer()
#include "pub_core_options.h"
#include "valgrind.h" // For RUNNING_ON_VALGRIND
=20
@@ -252,28 +252,35 @@
=20
=20
/* ---------------------------------------------------------------------
- ctime()
+ elapsed_wallclock_time()
------------------------------------------------------------------ */
=20
-/* BUF must be at least 25 characters long. This is unchecked. */
+/* Get the elapsed wallclock time since startup into buf, which must
+ 16 chars long. This is unchecked. It also relies on the
+ millisecond timer having been set to zero by an initial read in
+ m_main during startup. */
=20
-void VG_(ctime) ( /*OUT*/HChar* buf )
+void VG_(elapsed_wallclock_time) ( /*OUT*/HChar* buf )
{
-#if 0
- struct timeval tv;
- struct tm tm;
- buf[0] =3D 0;
- if ( gettimeofday( &tv, NULL ) =3D=3D 0
- && localtime_r( &tv.tv_sec, &tm ) =3D=3D &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, "VG_(ctime) HACK!");
-#endif
+ UInt t, ms, s, mins, hours, days;
+
+ t =3D VG_(read_millisecond_timer)(); /* milliseconds */
+
+ ms =3D t % 1000;
+ t /=3D 1000; /* now in seconds */
+
+ s =3D t % 60;
+ t /=3D 60; /* now in minutes */
+
+ mins =3D t % 60;
+ t /=3D 60; /* now in hours */
+
+ hours =3D t % 24;
+ t /=3D 24; /* now in days */
+
+ days =3D t;
+
+ VG_(sprintf)(buf, "%02u:%02u:%02u:%02u.%03u", days, hours, mins, s, m=
s);
}
=20
=20
@@ -307,7 +314,7 @@
=20
if (VG_(clo_time_stamp)) {
HChar buf[50];
- VG_(ctime)(buf);
+ VG_(elapsed_wallclock_time)(buf);
count +=3D VG_(printf)( "%s ", buf);
}
=20
Modified: trunk/coregrind/m_main.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/m_main.c 2005-11-08 16:51:55 UTC (rev 5041)
+++ trunk/coregrind/m_main.c 2005-11-08 19:01:44 UTC (rev 5042)
@@ -2234,6 +2234,12 @@
logging_to_fd =3D process_cmd_line_options(client_auxv, toolname);
=20
//--------------------------------------------------------------
+ // Zeroise the millisecond counter by doing a first read of it.
+ // p: none
+ //--------------------------------------------------------------
+ (void) VG_(read_millisecond_timer)();
+
+ //--------------------------------------------------------------
// Print the preamble
// p: tl_pre_clo_init [for 'VG_(details).name' and frien=
ds]
// p: process_cmd_line_options() [for VG_(clo_verbosity), VG_(clo_x=
ml),
@@ -2494,7 +2500,7 @@
=20
if (VG_(clo_xml)) {
HChar buf[50];
- VG_(ctime)(buf);
+ VG_(elapsed_wallclock_time)(buf);
VG_(message)(Vg_UserMsg, "<status>\n"
" <state>RUNNING</state>\n"
" <time>%t</time>\n"
@@ -2565,7 +2571,7 @@
VG_(show_error_counts_as_XML)();
VG_(message)(Vg_UserMsg, "");
}
- VG_(ctime)(buf);
+ VG_(elapsed_wallclock_time)(buf);
VG_(message)(Vg_UserMsg, "<status>\n"
" <state>FINISHED</state>\n"
" <time>%t</time>\n"
Modified: trunk/coregrind/pub_core_libcprint.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/pub_core_libcprint.h 2005-11-08 16:51:55 UTC (rev 504=
1)
+++ trunk/coregrind/pub_core_libcprint.h 2005-11-08 19:01:44 UTC (rev 504=
2)
@@ -42,9 +42,11 @@
descriptor or a socket descriptor. */
extern Bool VG_(logging_to_socket);
=20
-/* Get a human-readable representation of the local time into BUF,
- which must be at least 25 characters long. This is unchecked. */
-extern void VG_(ctime) ( /*OUT*/HChar* buf );
+/* Get the elapsed wallclock time since startup into buf, which must
+ 16 chars long. This is unchecked. It also relies on the
+ millisecond timer having been set to zero by an initial read in
+ m_main during startup. */
+void VG_(elapsed_wallclock_time) ( /*OUT*/HChar* buf );
=20
#endif // __PUB_CORE_LIBCPRINT_H
=20
Modified: trunk/docs/xml/manual-core.xml
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/docs/xml/manual-core.xml 2005-11-08 16:51:55 UTC (rev 5041)
+++ trunk/docs/xml/manual-core.xml 2005-11-08 19:01:44 UTC (rev 5042)
@@ -647,8 +647,10 @@
<listitem id=3D"time_stamp">
<para><computeroutput>--time-stamp=3Dno</computeroutput> [default]</=
para>
<para><computeroutput>--time-stamp=3Dyes</computeroutput></para>
- <para>When enabled, Valgrind will precede each message with the
- current time and date.</para>
+ <para>When enabled, Valgrind will precede each message with=20
+ an indication of the elapsed wallclock time since startup,
+ expressed as days, hours, minutes, seconds and milliseconds.
+ </para>
</listitem>
=20
<listitem id=3D"log2fd">
|