88namespace node {
99
1010namespace {
11- #if HAVE_INSPECTOR
1211const int default_inspector_port = 9229 ;
13- #endif // HAVE_INSPECTOR
1412
1513inline std::string remove_brackets (const std::string& host) {
1614 if (!host.empty () && host.front () == ' [' && host.back () == ' ]' )
@@ -56,14 +54,12 @@ std::pair<std::string, int> split_host_port(const std::string& arg) {
5654} // namespace
5755
5856DebugOptions::DebugOptions () :
59- #if HAVE_INSPECTOR
6057 inspector_enabled_ (false ),
61- # endif // HAVE_INSPECTOR
62- wait_connect_ ( false ), http_enabled_ (false ),
58+ deprecated_debug_ ( false ),
59+ break_first_line_ (false ),
6360 host_name_ (" 127.0.0.1" ), port_(-1 ) { }
6461
6562bool DebugOptions::ParseOption (const char * argv0, const std::string& option) {
66- bool enable_inspector = false ;
6763 bool has_argument = false ;
6864 std::string option_name;
6965 std::string argument;
@@ -81,11 +77,21 @@ bool DebugOptions::ParseOption(const char* argv0, const std::string& option) {
8177 argument.clear ();
8278 }
8379
80+ // Note that --debug-port and --debug-brk in conjuction with --inspect
81+ // work but are undocumented.
82+ // --debug is no longer valid.
83+ // Ref: https://github.com/nodejs/node/issues/12630
84+ // Ref: https://github.com/nodejs/node/pull/12949
8485 if (option_name == " --inspect" ) {
85- enable_inspector = true ;
86+ inspector_enabled_ = true ;
87+ } else if (option_name == " --debug" ) {
88+ deprecated_debug_ = true ;
8689 } else if (option_name == " --inspect-brk" ) {
87- enable_inspector = true ;
88- wait_connect_ = true ;
90+ inspector_enabled_ = true ;
91+ break_first_line_ = true ;
92+ } else if (option_name == " --debug-brk" ) {
93+ break_first_line_ = true ;
94+ deprecated_debug_ = true ;
8995 } else if (option_name == " --debug-port" ||
9096 option_name == " --inspect-port" ) {
9197 if (!has_argument) {
@@ -97,15 +103,14 @@ bool DebugOptions::ParseOption(const char* argv0, const std::string& option) {
97103 return false ;
98104 }
99105
100- if (enable_inspector) {
101- #if HAVE_INSPECTOR
102- inspector_enabled_ = true ;
103- #else
106+ #if !HAVE_INSPECTOR
107+ if (inspector_enabled_) {
104108 fprintf (stderr,
105109 " Inspector support is not available with this Node.js build\n " );
106- return false ;
107- #endif
108110 }
111+ inspector_enabled_ = false ;
112+ return false ;
113+ #endif
109114
110115 // argument can be specified for *any* option to specify host:port
111116 if (has_argument) {
@@ -124,9 +129,7 @@ bool DebugOptions::ParseOption(const char* argv0, const std::string& option) {
124129int DebugOptions::port () const {
125130 int port = port_;
126131 if (port < 0 ) {
127- #if HAVE_INSPECTOR
128132 port = default_inspector_port;
129- #endif // HAVE_INSPECTOR
130133 }
131134 return port;
132135}
0 commit comments