Bug 1274041 - Initialize jprof in child process. r?jesup draft
authorL. David Baron <dbaron@dbaron.org>
Wed, 18 May 2016 14:06:46 -0700
changeset 368478 7c18786ab97b469df9b1b7bdaf9e09100c907cf2
parent 368477 eb17152555363e37a96a7d08390f1b392a0b1984
child 368479 d329305ea93830a455008691bbc7d8f917f7ba84
push id18549
push userdbaron@mozilla.com
push dateWed, 18 May 2016 21:06:58 +0000
reviewersjesup
bugs1274041
milestone49.0a1
Bug 1274041 - Initialize jprof in child process. r?jesup This makes a function call in XRE_InitChildProcess for the child process that currently exists in XREMain::XRE_mainStartup for the parent process. This allows signals that jprof uses to be sent to a child process to profile that child process. MozReview-Commit-ID: CeWnYl4LJyA
toolkit/xre/nsEmbedFunctions.cpp
--- a/toolkit/xre/nsEmbedFunctions.cpp
+++ b/toolkit/xre/nsEmbedFunctions.cpp
@@ -90,16 +90,20 @@
 using mozilla::_ipdltest::IPDLUnitTestProcessChild;
 #endif  // ifdef MOZ_IPDL_TESTS
 
 #ifdef MOZ_B2G_LOADER
 #include "nsLocalFile.h"
 #include "nsXREAppData.h"
 #endif
 
+#ifdef MOZ_JPROF
+#include "jprof.h"
+#endif
+
 using namespace mozilla;
 
 using mozilla::ipc::BrowserProcessSubThread;
 using mozilla::ipc::GeckoChildProcessHost;
 using mozilla::ipc::IOThreadChild;
 using mozilla::ipc::ProcessChild;
 using mozilla::ipc::ScopedXREEmbed;
 
@@ -302,16 +306,21 @@ XRE_InitChildProcess(int aArgc,
   NS_ENSURE_ARG_MIN(aArgc, 2);
   NS_ENSURE_ARG_POINTER(aArgv);
   NS_ENSURE_ARG_POINTER(aArgv[0]);
 
 #ifdef HAS_DLL_BLOCKLIST
   DllBlocklist_Initialize();
 #endif
 
+#ifdef MOZ_JPROF
+  // Call the code to install our handler
+  setupProfilingStuff();
+#endif
+
   // This is needed by Telemetry to initialize histogram collection.
   UniquePtr<base::StatisticsRecorder> statisticsRecorder =
     MakeUnique<base::StatisticsRecorder>();
 
 #if !defined(MOZ_WIDGET_ANDROID) && !defined(MOZ_WIDGET_GONK)
   // On non-Fennec Gecko, the GMPLoader code resides in plugin-container,
   // and we must forward it through to the GMP code here.
   GMPProcessChild::SetGMPLoader(aGMPLoader);