From 7b5a1b06ba40e2faa11b2be48af2c1856bd2fad7 Mon Sep 17 00:00:00 2001 From: Robo Date: Thu, 22 Oct 2015 16:20:48 +0530 Subject: [PATCH] debugger: expose v8debug --- atom/browser/javascript_environment.cc | 7 +++++++ atom/browser/node_debugger.cc | 8 +------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/atom/browser/javascript_environment.cc b/atom/browser/javascript_environment.cc index 4e825e38142d..cc06bb6ff9c2 100644 --- a/atom/browser/javascript_environment.cc +++ b/atom/browser/javascript_environment.cc @@ -4,6 +4,7 @@ #include "atom/browser/javascript_environment.h" +#include "base/command_line.h" #include "gin/array_buffer.h" #include "gin/v8_initializer.h" @@ -20,6 +21,12 @@ JavascriptEnvironment::JavascriptEnvironment() } 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); + } gin::IsolateHolder::Initialize(gin::IsolateHolder::kNonStrictMode, gin::ArrayBufferAllocator::SharedInstance()); return true; diff --git a/atom/browser/node_debugger.cc b/atom/browser/node_debugger.cc index da5602a88137..2cfcdb222aea 100644 --- a/atom/browser/node_debugger.cc +++ b/atom/browser/node_debugger.cc @@ -35,17 +35,14 @@ NodeDebugger::NodeDebugger(v8::Isolate* isolate) weak_factory_(this) { bool use_debug_agent = false; int port = 5858; - bool wait_for_connection = false; std::string port_str; base::CommandLine* cmd = base::CommandLine::ForCurrentProcess(); if (cmd->HasSwitch("debug")) { use_debug_agent = true; port_str = cmd->GetSwitchValueASCII("debug"); - } - if (cmd->HasSwitch("debug-brk")) { + } else if (cmd->HasSwitch("debug-brk")) { use_debug_agent = true; - wait_for_connection = true; port_str = cmd->GetSwitchValueASCII("debug-brk"); } @@ -56,9 +53,6 @@ NodeDebugger::NodeDebugger(v8::Isolate* isolate) isolate_->SetData(kIsolateSlot, this); v8::Debug::SetMessageHandler(DebugMessageHandler); - if (wait_for_connection) - v8::Debug::DebugBreak(isolate_); - uv_async_init(uv_default_loop(), &weak_up_ui_handle_, ProcessMessageInUI); // Start a new IO thread.