Bug 1460022: Part 13 - Update profiler to use revised DLL interceptor interface; r=njn
☠☠ backed out by 3a415f165864 ☠ ☠
authorAaron Klotz <aklotz@mozilla.com>
Wed, 27 Jun 2018 14:23:29 -0600
changeset 480041 0734142a3f358117ac8baddd994dc5526d124593
parent 480040 18fbfa7ca68556a5fb6de2c85eab23e796bb1ce8
child 480042 3a415f165864dc3c17ea1e49d66d34245d660fd4
push id9719
push userffxbld-merge
push dateFri, 24 Aug 2018 17:49:46 +0000
treeherdermozilla-beta@719ec98fba77 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnjn
bugs1460022
milestone63.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1460022: Part 13 - Update profiler to use revised DLL interceptor interface; r=njn
tools/profiler/core/platform-win32.cpp
--- a/tools/profiler/core/platform-win32.cpp
+++ b/tools/profiler/core/platform-win32.cpp
@@ -298,32 +298,34 @@ Registers::SyncPopulate()
   PopulateRegsFromContext(*this, &context);
 }
 #endif
 
 #if defined(GP_PLAT_amd64_windows)
 static WindowsDllInterceptor NtDllIntercept;
 
 typedef NTSTATUS (NTAPI *LdrUnloadDll_func)(HMODULE module);
-static LdrUnloadDll_func stub_LdrUnloadDll;
+static WindowsDllInterceptor::FuncHookType<LdrUnloadDll_func>
+  stub_LdrUnloadDll;
 
 static NTSTATUS NTAPI
 patched_LdrUnloadDll(HMODULE module)
 {
   // Prevent the stack walker from suspending this thread when LdrUnloadDll
   // holds the RtlLookupFunctionEntry lock.
   AutoSuppressStackWalking suppress;
   return stub_LdrUnloadDll(module);
 }
 
 // These pointers are disguised as PVOID to avoid pulling in obscure headers
 typedef PVOID (WINAPI *LdrResolveDelayLoadedAPI_func)(PVOID ParentModuleBase,
   PVOID DelayloadDescriptor, PVOID FailureDllHook, PVOID FailureSystemHook,
   PVOID ThunkAddress, ULONG Flags);
-static LdrResolveDelayLoadedAPI_func stub_LdrResolveDelayLoadedAPI;
+static WindowsDllInterceptor::FuncHookType<LdrResolveDelayLoadedAPI_func>
+  stub_LdrResolveDelayLoadedAPI;
 
 static PVOID WINAPI
 patched_LdrResolveDelayLoadedAPI(PVOID ParentModuleBase,
   PVOID DelayloadDescriptor, PVOID FailureDllHook, PVOID FailureSystemHook,
   PVOID ThunkAddress, ULONG Flags)
 {
   // Prevent the stack walker from suspending this thread when
   // LdrResolveDelayLoadAPI holds the RtlLookupFunctionEntry lock.
@@ -331,26 +333,18 @@ patched_LdrResolveDelayLoadedAPI(PVOID P
   return stub_LdrResolveDelayLoadedAPI(ParentModuleBase, DelayloadDescriptor,
                                        FailureDllHook, FailureSystemHook,
                                        ThunkAddress, Flags);
 }
 
 void
 InitializeWin64ProfilerHooks()
 {
-  static bool initialized = false;
-  if (initialized) {
-    return;
-  }
-  initialized = true;
-
   NtDllIntercept.Init("ntdll.dll");
-  NtDllIntercept.AddHook("LdrUnloadDll",
-                         reinterpret_cast<intptr_t>(patched_LdrUnloadDll),
-                         (void**)&stub_LdrUnloadDll);
+  stub_LdrUnloadDll.Set(NtDllIntercept, "LdrUnloadDll", &patched_LdrUnloadDll);
   if (IsWin8OrLater()) { // LdrResolveDelayLoadedAPI was introduced in Win8
-    NtDllIntercept.AddHook("LdrResolveDelayLoadedAPI",
-                           reinterpret_cast<intptr_t>(patched_LdrResolveDelayLoadedAPI),
-                           (void**)&stub_LdrResolveDelayLoadedAPI);
+    stub_LdrResolveDelayLoadedAPI.Set(NtDllIntercept,
+                                      "LdrResolveDelayLoadedAPI",
+                                      &patched_LdrResolveDelayLoadedAPI);
   }
 }
 #endif // defined(GP_PLAT_amd64_windows)