]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Add VG_(gettimeofday) such that callgrind can use it without
authorFlorian Krohm <florian@eich-krohm.de>
Thu, 8 Jan 2015 14:43:29 +0000 (14:43 +0000)
committerFlorian Krohm <florian@eich-krohm.de>
Thu, 8 Jan 2015 14:43:29 +0000 (14:43 +0000)
a bloody hack.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14857

callgrind/main.c
coregrind/m_libcproc.c
include/pub_tool_libcproc.h

index 30a0cce17cba83a4a8ef4c82847c4e5fced4d0bb..ad61d459a910971f9862cddd1b7f79ea61f1bac9 100644 (file)
@@ -1706,10 +1706,6 @@ Bool CLG_(handle_client_request)(ThreadId tid, UWord *args, UWord *ret)
 
 /* struct timeval syscalltime[VG_N_THREADS]; */
 #if CLG_MICROSYSTIME
-#include <sys/time.h>
-#include <sys/syscall.h>
-extern Int VG_(do_syscall) ( UInt, ... );
-
 ULong syscalltime[VG_N_THREADS];
 #else
 UInt syscalltime[VG_N_THREADS];
@@ -1722,7 +1718,7 @@ void CLG_(pre_syscalltime)(ThreadId tid, UInt syscallno,
   if (CLG_(clo).collect_systime) {
 #if CLG_MICROSYSTIME
     struct vki_timeval tv_now;
-    VG_(do_syscall)(__NR_gettimeofday, (UInt)&tv_now, (UInt)NULL);
+    VG_(gettimeofday)(&tv_now, NULL);
     syscalltime[tid] = tv_now.tv_sec * 1000000ULL + tv_now.tv_usec;
 #else
     syscalltime[tid] = VG_(read_millisecond_timer)();
@@ -1741,7 +1737,7 @@ void CLG_(post_syscalltime)(ThreadId tid, UInt syscallno,
     struct vki_timeval tv_now;
     ULong diff;
     
-    VG_(do_syscall)(__NR_gettimeofday, (UInt)&tv_now, (UInt)NULL);
+    VG_(gettimeofday)(&tv_now, NULL);
     diff = (tv_now.tv_sec * 1000000ULL + tv_now.tv_usec) - syscalltime[tid];
 #else
     UInt diff = VG_(read_millisecond_timer)() - syscalltime[tid];
@@ -1750,7 +1746,8 @@ void CLG_(post_syscalltime)(ThreadId tid, UInt syscallno,
     /* offset o is for "SysCount", o+1 for "SysTime" */
     o = fullOffset(EG_SYS);
     CLG_ASSERT(o>=0);
-    CLG_DEBUG(0,"   Time (Off %d) for Syscall %d: %ull\n", o, syscallno, diff);
+    CLG_DEBUG(0,"   Time (Off %d) for Syscall %u: %llu\n", o, syscallno,
+              (ULong)diff);
     
     CLG_(current_state).cost[o] ++;
     CLG_(current_state).cost[o+1] += diff;
index a371ce310ee64a20ac84f38f23cf17f76d683138..ec6b0c8b0497b226f8a9e7485132e05ba6c929d1 100644 (file)
@@ -666,6 +666,20 @@ UInt VG_(read_millisecond_timer) ( void )
    return (now - base) / 1000;
 }
 
+Int VG_(gettimeofday)(struct vki_timeval *tv, struct vki_timezone *tz)
+{
+   SysRes res;
+   res = VG_(do_syscall2)(__NR_gettimeofday, (UWord)tv, (UWord)tz);
+
+   if (! sr_isError(res)) return 0;
+
+   /* Make sure, argument values are determinstic upon failure */
+   if (tv) *tv = (struct vki_timeval){ .tv_sec = 0, .tv_usec = 0 };
+   if (tz) *tz = (struct vki_timezone){ .tz_minuteswest = 0, .tz_dsttime = 0 };
+
+   return -1;
+}
+
 
 /* ---------------------------------------------------------------------
    atfork()
index 585cbd7ad7ce4cd7a4e89cd9c75db20c8a9107ec..cbd159f13312027c815af9574bf3534b1a4cb876 100644 (file)
@@ -88,6 +88,7 @@ extern Int VG_(getegid) ( void );
 // (roughly;  it gets initialised partway through Valgrind's initialisation
 // steps).
 extern UInt VG_(read_millisecond_timer) ( void );
+extern Int  VG_(gettimeofday)(struct vki_timeval *tv, struct vki_timezone *tz);
 
 /* ---------------------------------------------------------------------
    atfork