Ver Fonte

cross-platform: Enable GCStress leak report time string

Oguz Bastemur há 9 anos atrás
pai
commit
582782ed8b

+ 1 - 0
bin/GCStress/CMakeLists.txt

@@ -17,6 +17,7 @@ set(LINK_FLAGS ${LINK_FLAGS} "-Wl,-whole-archive")
 
 target_link_libraries (GCStress
   Chakra.Common.Memory
+  Chakra.Runtime.PlatformAgnostic
   Chakra.Common.Common
   Chakra.Common.Core
   Chakra.Common.DataStructures

+ 5 - 2
bin/GCStress/GCStress.vcxproj

@@ -28,9 +28,9 @@
     <Link>
       <AdditionalDependencies>
         $(ChakraCommonMemoryLib);
+        $(ChakraRuntimePlatformAgnostic);
         $(ChakraCommonLinkDependencies);
-        %(AdditionalDependencies);
-      </AdditionalDependencies>
+        %(AdditionalDependencies)</AdditionalDependencies>
       <AdditionalLibraryDirectories>$(OutDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
       <SubSystem>Console</SubSystem>
     </Link>
@@ -57,6 +57,9 @@
     <ProjectReference Include="..\..\lib\Common\Memory\Chakra.Common.Memory.vcxproj">
       <Project>{bb4153ff-ac3e-4734-b562-ff23812df31b}</Project>
     </ProjectReference>
+    <ProjectReference Include="..\..\lib\Runtime\PlatformAgnostic\Chakra.Runtime.PlatformAgnostic.vcxproj">
+      <Project>{129ac184-877c-441f-ac49-a692ce700e62}</Project>
+    </ProjectReference>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="GCStress.h" />

+ 10 - 8
lib/Common/Memory/LeakReport.cpp

@@ -153,17 +153,19 @@ LeakReport::EnsureLeakReportFile()
     Print(_u("================================================================================\n"));
     Print(_u("Chakra Leak Report - PID: %d\n"), ::GetCurrentProcessId());
 
-    // xplat-todo: Make this code cross-platform
-#if _MSC_VER
-    __time64_t time_value = _time64(NULL);
-    char16 time_string[26];
     struct tm local_time;
-    _localtime64_s(&local_time, &time_value);
-    _wasctime_s(time_string, &local_time);
-    Print(time_string);
+    uint64_t time_ms = (uint64_t) PlatformAgnostic::DateTime::HiResTimer::GetSystemTime(); // utc
+    time_t time_sec = time_ms / 1000; // get rid of the milliseconds
+#ifdef _MSC_VER
+    _localtime64_s(&local_time, &time_sec);
+#else
+    localtime_r(&time_sec, &local_time);
 #endif
+    Print(_u("%04d-%02d-%02d %02d:%02d:%02d.%03d\n"),
+           local_time.tm_year + 1900, local_time.tm_mon + 1, local_time.tm_mday,
+           local_time.tm_hour, local_time.tm_min, local_time.tm_sec,
+           time_ms % 1000);
 
-    Print(_u("\n"));
     return true;
 }
 

+ 1 - 1
lib/Runtime/PlatformAgnostic/Platform/Linux/DateTime.cpp

@@ -3,7 +3,7 @@
 // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
 //-------------------------------------------------------------------------------------------------------
 
-#include "Runtime.h"
+#include "Common.h"
 #include <time.h>
 #include <sys/time.h>
 #include "ChakraPlatform.h"

+ 1 - 1
lib/Runtime/PlatformAgnostic/Platform/Linux/HiResTimer.cpp

@@ -3,7 +3,7 @@
 // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
 //-------------------------------------------------------------------------------------------------------
 
-#include "Runtime.h"
+#include "Common.h"
 #include <time.h>
 #include <sys/time.h>
 #include "ChakraPlatform.h"