Browse Source

Merge pull request #7001 from electron/debug-wait-connect

Port --debug-brk support to Node 6.3.0
Cheng Zhao 8 years ago
parent
commit
ac9e64cfd4
2 changed files with 7 additions and 5 deletions
  1. 0 5
      atom/browser/javascript_environment.cc
  2. 7 0
      atom/common/node_bindings.cc

+ 0 - 5
atom/browser/javascript_environment.cc

@@ -34,11 +34,6 @@ void JavascriptEnvironment::OnMessageLoopDestroying() {
 
 bool JavascriptEnvironment::Initialize() {
   auto cmd = base::CommandLine::ForCurrentProcess();
-  if (cmd->HasSwitch("debug-brk")) {
-    // Need to be called before v8::Initialize().
-    const char expose_debug_as[] = "--expose_debug_as=v8debug";
-    v8::V8::SetFlagsFromString(expose_debug_as, sizeof(expose_debug_as) - 1);
-  }
 
   // --js-flags.
   std::string js_flags = cmd->GetSwitchValueASCII(switches::kJavaScriptFlags);

+ 7 - 0
atom/common/node_bindings.cc

@@ -185,6 +185,13 @@ node::Environment* NodeBindings::CreateEnvironment(
   base::FilePath helper_exec_path;
   PathService::Get(content::CHILD_PROCESS_EXE, &helper_exec_path);
   process.Set("helperExecPath", helper_exec_path);
+
+  // Set process._debugWaitConnect if --debug-brk was specified to stop
+  // the debugger on the first line
+  if (is_browser_ &&
+      base::CommandLine::ForCurrentProcess()->HasSwitch("debug-brk"))
+    process.Set("_debugWaitConnect", true);
+
   return env;
 }