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

inspector: listen on process.debugPort #8386

Merged
merged 1 commit into from
Sep 14, 2016
Merged
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
16 changes: 5 additions & 11 deletions src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,6 @@ static bool use_debug_agent = false;
static bool debug_wait_connect = false;
static std::string* debug_host; // coverity[leaked_storage]
static int debug_port = 5858;
static std::string* inspector_host; // coverity[leaked_storage]
static int inspector_port = 9229;
static const int v8_default_thread_pool_size = 4;
static int v8_thread_pool_size = v8_default_thread_pool_size;
static bool prof_process = false;
Expand Down Expand Up @@ -3473,15 +3471,12 @@ static bool ParseDebugOpt(const char* arg) {
return true;
}

std::string** const the_host = use_inspector ? &inspector_host : &debug_host;
int* const the_port = use_inspector ? &inspector_port : &debug_port;

// FIXME(bnoordhuis) Move IPv6 address parsing logic to lib/net.js.
// It seems reasonable to support [address]:port notation
// in net.Server#listen() and net.Socket#connect().
const size_t port_len = strlen(port);
if (port[0] == '[' && port[port_len - 1] == ']') {
*the_host = new std::string(port + 1, port_len - 2);
debug_host = new std::string(port + 1, port_len - 2);
return true;
}

Expand All @@ -3491,13 +3486,13 @@ static bool ParseDebugOpt(const char* arg) {
// if it's not all decimal digits, it's a host name.
for (size_t n = 0; port[n] != '\0'; n += 1) {
if (port[n] < '0' || port[n] > '9') {
*the_host = new std::string(port);
debug_host = new std::string(port);
return true;
}
}
} else {
const bool skip = (colon > port && port[0] == '[' && colon[-1] == ']');
*the_host = new std::string(port + skip, colon - skip);
debug_host = new std::string(port + skip, colon - skip);
}

char* endptr;
Expand All @@ -3510,7 +3505,7 @@ static bool ParseDebugOpt(const char* arg) {
exit(12);
}

*the_port = static_cast<int>(result);
debug_port = static_cast<int>(result);

return true;
}
Expand Down Expand Up @@ -3770,8 +3765,7 @@ static void DispatchMessagesDebugAgentCallback(Environment* env) {
static void StartDebug(Environment* env, const char* path, bool wait) {
CHECK(!debugger_running);
if (use_inspector) {
debugger_running = v8_platform.StartInspector(env, path, inspector_port,
wait);
debugger_running = v8_platform.StartInspector(env, path, debug_port, wait);
} else {
env->debugger_agent()->set_dispatch_handler(
DispatchMessagesDebugAgentCallback);
Expand Down