Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: src,inspector: add --inspect-silent option #12671

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions src/inspector_io.cc
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,11 @@ void InspectorIo::WaitForDisconnect() {
if (state_ == State::kConnected) {
shutting_down_ = true;
Write(TransportAction::kStop, 0, StringView());
fprintf(stderr, "Waiting for the debugger to disconnect...\n");
fflush(stderr);

if (options_.out() != NULL) {
fprintf(options_.out(), "Waiting for the debugger to disconnect...\n");
fflush(options_.out());
}
parent_env_->inspector_agent()->RunMessageLoop();
}
}
Expand Down Expand Up @@ -257,7 +260,8 @@ void InspectorIo::WorkerRunIO() {
delegate_ = &delegate;
InspectorSocketServer server(&delegate,
options_.host_name(),
options_.port());
options_.port(),
options_.out());
TransportAndIo<Transport> queue_transport(&server, this);
io_thread_req_.data = &queue_transport;
if (!server.Start(&loop)) {
Expand Down Expand Up @@ -337,7 +341,10 @@ void InspectorIo::DispatchMessages() {
CHECK_EQ(session_delegate_, nullptr);
session_id_ = std::get<1>(task);
state_ = State::kConnected;
fprintf(stderr, "Debugger attached.\n");

if (options_.out() != NULL)
fprintf(options_.out(), "Debugger attached.\n");

session_delegate_ = std::unique_ptr<InspectorSessionDelegate>(
new IoSessionDelegate(this));
parent_env_->inspector_agent()->Connect(session_delegate_.get());
Expand Down
7 changes: 6 additions & 1 deletion src/node_debug_options.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ DebugOptions::DebugOptions() : debugger_enabled_(false),
inspector_enabled_(false),
#endif // HAVE_INSPECTOR
wait_connect_(false), http_enabled_(false),
host_name_("127.0.0.1"), port_(-1) { }
host_name_("127.0.0.1"), port_(-1),
out_(stderr) { }

void DebugOptions::EnableDebugAgent(DebugAgentType tool) {
switch (tool) {
Expand Down Expand Up @@ -101,6 +102,10 @@ bool DebugOptions::ParseOption(const std::string& option) {
debugger_enabled_ = true;
enable_inspector = true;
wait_connect_ = true;
} else if (option_name == "--inspect-silent") {
debugger_enabled_ = true;
enable_inspector = true;
out_ = NULL;
} else if ((option_name != "--debug-port" &&
option_name != "--inspect-port") ||
!has_argument) {
Expand Down
4 changes: 4 additions & 0 deletions src/node_debug_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class DebugOptions {
std::string host_name() const { return host_name_; }
int port() const;
void set_port(int port) { port_ = port; }
FILE* out() const { return out_; }

private:
bool debugger_enabled_;
Expand All @@ -44,6 +45,9 @@ class DebugOptions {
bool http_enabled_;
std::string host_name_;
int port_;
#if HAVE_INSPECTOR
FILE* out_;
#endif // HAVE_INSPECTOR
};

} // namespace node
Expand Down