Bug 721564 - Get module information for the profiler on Windows; r=BenWa
authorEhsan Akhgari <ehsan@mozilla.com>
Thu, 26 Jan 2012 19:03:42 -0500
changeset 86725 347bd64309233167c13bcb2c44b33db86a98a97a
parent 86724 a82c9700c6730311cd4f5594d43a1f4aac0f913f
child 86728 c07595bee6cf341885c2b8b8497fc7a3e2c6a10e
push id805
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 18:17:35 +0000
treeherdermozilla-aurora@6fb3bf232436 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersBenWa
bugs721564
milestone12.0a1
Bug 721564 - Get module information for the profiler on Windows; r=BenWa
tools/profiler/sps/shared-libraries-win32.cc
--- a/tools/profiler/sps/shared-libraries-win32.cc
+++ b/tools/profiler/sps/shared-libraries-win32.cc
@@ -35,26 +35,31 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include <windows.h>
 #include <tlhelp32.h>
 
 #include "shared-libraries.h"
+#include "nsWindowsHelpers.h"
 
 SharedLibraryInfo SharedLibraryInfo::GetInfoForSelf()
 {
   SharedLibraryInfo sharedLibraryInfo;
 
-  /*
-  HANDLE snap = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, GetCurrentProcessId());
+  nsAutoHandle snap(CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, GetCurrentProcessId()));
 
-  MODULEENTRY32 module;
-  Module32First(snap, &module);
-  do {
-    // process module
-  } while (Module32Next(snap, &module));
-  */
+  MODULEENTRY32 module = {0};
+  module.dwSize = sizeof(MODULEENTRY32);
+  if (Module32First(snap, &module)) {
+    do {
+      SharedLibrary shlib((uintptr_t)module.modBaseAddr,
+                          (uintptr_t)module.modBaseAddr+module.modBaseSize,
+                          0, // DLLs are always mapped at offset 0 on Windows
+                          module.szModule);
+      sharedLibraryInfo.AddSharedLibrary(shlib);
+    } while (Module32Next(snap, &module));
+  }
 
   return sharedLibraryInfo;
 }