2015-08-27 04:25:28 +00:00
|
|
|
// Copyright (c) 2014 GitHub, Inc.
|
|
|
|
// Use of this source code is governed by the MIT license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2019-06-19 20:46:59 +00:00
|
|
|
#include "shell/browser/node_debugger.h"
|
2015-08-27 04:25:28 +00:00
|
|
|
|
2018-09-18 00:48:10 +00:00
|
|
|
#include <memory>
|
2018-08-27 17:50:23 +00:00
|
|
|
#include <string>
|
2018-09-18 00:48:10 +00:00
|
|
|
#include <vector>
|
2018-08-27 17:50:23 +00:00
|
|
|
|
2015-08-27 04:25:28 +00:00
|
|
|
#include "base/command_line.h"
|
2018-09-18 00:48:10 +00:00
|
|
|
#include "base/logging.h"
|
2018-11-29 03:01:09 +00:00
|
|
|
#include "base/strings/string_util.h"
|
2017-05-15 18:16:32 +00:00
|
|
|
#include "base/strings/utf_string_conversions.h"
|
2017-05-15 16:30:55 +00:00
|
|
|
#include "libplatform/libplatform.h"
|
2019-12-05 09:46:34 +00:00
|
|
|
#include "shell/common/gin_helper/dictionary.h"
|
2019-06-19 20:46:59 +00:00
|
|
|
#include "shell/common/node_includes.h"
|
2017-06-12 18:53:11 +00:00
|
|
|
|
2019-06-19 21:23:04 +00:00
|
|
|
namespace electron {
|
2015-08-27 04:25:28 +00:00
|
|
|
|
2018-04-18 01:55:30 +00:00
|
|
|
NodeDebugger::NodeDebugger(node::Environment* env) : env_(env) {}
|
2015-08-27 04:25:28 +00:00
|
|
|
|
2019-09-16 22:12:00 +00:00
|
|
|
NodeDebugger::~NodeDebugger() = default;
|
2015-08-27 04:25:28 +00:00
|
|
|
|
2018-09-04 09:15:17 +00:00
|
|
|
void NodeDebugger::Start() {
|
2018-04-17 22:41:47 +00:00
|
|
|
auto* inspector = env_->inspector_agent();
|
2017-05-15 16:30:55 +00:00
|
|
|
if (inspector == nullptr)
|
2015-08-27 04:25:28 +00:00
|
|
|
return;
|
|
|
|
|
2020-02-09 18:42:02 +00:00
|
|
|
// DebugOptions will already have been set by ProcessGlobalArgs,
|
|
|
|
// so just pull the ones from there to pass to the InspectorAgent
|
|
|
|
const auto debug_options = env_->options()->debug_options();
|
|
|
|
if (inspector->Start(
|
|
|
|
"" /* path */, debug_options,
|
|
|
|
std::make_shared<node::HostPort>(debug_options.host_port),
|
|
|
|
true /* is_main */))
|
2018-11-09 03:44:31 +00:00
|
|
|
DCHECK(env_->inspector_agent()->IsListening());
|
2015-08-27 04:25:28 +00:00
|
|
|
}
|
|
|
|
|
2019-04-30 22:44:40 +00:00
|
|
|
void NodeDebugger::Stop() {
|
|
|
|
auto* inspector = env_->inspector_agent();
|
2019-07-23 21:56:22 +00:00
|
|
|
if (inspector && inspector->IsListening()) {
|
|
|
|
inspector->WaitForDisconnect();
|
2019-04-30 22:44:40 +00:00
|
|
|
inspector->Stop();
|
2019-07-23 21:56:22 +00:00
|
|
|
}
|
2019-04-30 22:44:40 +00:00
|
|
|
}
|
|
|
|
|
2019-06-19 21:23:04 +00:00
|
|
|
} // namespace electron
|