]> khamidou — GitHub mirrors - electron.git/commitdiff
win: Only install breakpad hook when crash-reporter is used
authorCheng Zhao <zcbenz@gmail.com>
Thu, 15 Oct 2015 10:25:07 +0000 (18:25 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Thu, 15 Oct 2015 10:25:07 +0000 (18:25 +0800)
atom/app/atom_main_delegate.cc
atom/common/crash_reporter/crash_reporter_win.cc
atom/common/crash_reporter/crash_reporter_win.h

index 1c35bced3e6c4a87c0d7003355d64959b05ac071..44f2048c091fff09efe63cd277a5cae7e02fe186 100644 (file)
 #include "content/public/common/content_switches.h"
 #include "ui/base/resource/resource_bundle.h"
 
-#if defined(OS_WIN)
-#include "atom/common/crash_reporter/crash_reporter_win.h"
-#endif
-
 namespace atom {
 
 namespace {
@@ -73,10 +69,6 @@ bool AtomMainDelegate::BasicStartupComplete(int* exit_code) {
   // Logging with pid and timestamp.
   logging::SetLogItems(true, false, true, false);
 
-#if defined(OS_WIN)
-  crash_reporter::SetupV8CodeRangeHook();
-#endif
-
 #if defined(DEBUG) && defined(OS_LINUX)
   // Enable convient stack printing.
   base::debug::EnableInProcessStackDumping();
index 8ea5b6689cfb2f07eb5b5ce5b36ed58cd2ad3fab..78bd196f6cceb14343df77ce8564166e29213b0f 100644 (file)
@@ -133,11 +133,6 @@ void UnregisterNonABICompliantCodeRange(void* start) {
 
 }  // namespace
 
-void SetupV8CodeRangeHook() {
-  gin::Debug::SetCodeRangeCreatedCallback(RegisterNonABICompliantCodeRange);
-  gin::Debug::SetCodeRangeDeletedCallback(UnregisterNonABICompliantCodeRange);
-}
-
 CrashReporterWin::CrashReporterWin() {
 }
 
@@ -187,6 +182,20 @@ void CrashReporterWin::InitBreakpad(const std::string& product_name,
 
   if (!breakpad_->IsOutOfProcess())
     LOG(ERROR) << "Cannot initialize out-of-process crash handler";
+
+#ifdef _WIN64
+  // Hook up V8 to breakpad.
+  {
+    // gin::Debug::SetCodeRangeCreatedCallback only runs the callback when
+    // Isolate is just created, so we have to manually run following code here.
+    void* code_range = nullptr;
+    size_t size = 0;
+    v8::Isolate::GetCurrent()->GetCodeRange(&code_range, &size);
+    if (code_range && size)
+      RegisterNonABICompliantCodeRange(code_range, size);
+  }
+  gin::Debug::SetCodeRangeDeletedCallback(UnregisterNonABICompliantCodeRange);
+#endif
 }
 
 void CrashReporterWin::SetUploadParameters() {
index 1725ca3283105cf427209f61c16582f4cccb411b..09c7ff4eaad66084ebf82835df5aa8d40069326a 100644 (file)
@@ -17,9 +17,6 @@ template <typename T> struct DefaultSingletonTraits;
 
 namespace crash_reporter {
 
-// Hook up V8 to breakpad.
-void SetupV8CodeRangeHook();
-
 class CrashReporterWin : public CrashReporter {
  public:
   static CrashReporterWin* GetInstance();