From 056e5b951bb47a33793ffef8315cefe3363945ab Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Fri, 26 Aug 2016 12:06:15 -0700 Subject: [PATCH 1/3] Set process._debugWaitConnect with --debug-brk is specified --- atom/common/node_bindings.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/atom/common/node_bindings.cc b/atom/common/node_bindings.cc index d1db83b70850..36b125fefb6e 100644 --- a/atom/common/node_bindings.cc +++ b/atom/common/node_bindings.cc @@ -185,6 +185,10 @@ node::Environment* NodeBindings::CreateEnvironment( base::FilePath helper_exec_path; PathService::Get(content::CHILD_PROCESS_EXE, &helper_exec_path); process.Set("helperExecPath", helper_exec_path); + + if (base::CommandLine::ForCurrentProcess()->HasSwitch("debug-brk")) + process.Set("_debugWaitConnect", true); + return env; } From a2f0111205c113b573da81f891cfc7ac0103749e Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Fri, 26 Aug 2016 12:08:18 -0700 Subject: [PATCH 2/3] Remove v8debug flag no longer supported by node --- atom/browser/javascript_environment.cc | 5 ----- 1 file changed, 5 deletions(-) diff --git a/atom/browser/javascript_environment.cc b/atom/browser/javascript_environment.cc index 0f87a2ca32fd..3cdd2c771ee6 100644 --- a/atom/browser/javascript_environment.cc +++ b/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); From 7dd1a7e6f4ff6003999929bd12c54afee011104d Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Fri, 26 Aug 2016 12:30:27 -0700 Subject: [PATCH 3/3] Only set _debugWaitConnect in main process --- atom/common/node_bindings.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/atom/common/node_bindings.cc b/atom/common/node_bindings.cc index 36b125fefb6e..f8e2573e0a14 100644 --- a/atom/common/node_bindings.cc +++ b/atom/common/node_bindings.cc @@ -186,7 +186,10 @@ node::Environment* NodeBindings::CreateEnvironment( PathService::Get(content::CHILD_PROCESS_EXE, &helper_exec_path); process.Set("helperExecPath", helper_exec_path); - if (base::CommandLine::ForCurrentProcess()->HasSwitch("debug-brk")) + // 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;