8
8
namespace node {
9
9
10
10
namespace {
11
- #if HAVE_INSPECTOR
12
11
const int default_inspector_port = 9229 ;
13
- #endif // HAVE_INSPECTOR
14
12
15
13
inline std::string remove_brackets (const std::string& host) {
16
14
if (!host.empty () && host.front () == ' [' && host.back () == ' ]' )
@@ -56,14 +54,12 @@ std::pair<std::string, int> split_host_port(const std::string& arg) {
56
54
} // namespace
57
55
58
56
DebugOptions::DebugOptions () :
59
- #if HAVE_INSPECTOR
60
57
inspector_enabled_ (false ),
61
- # endif // HAVE_INSPECTOR
62
- wait_connect_ ( false ), http_enabled_ (false ),
58
+ deprecated_debug_ ( false ),
59
+ break_first_line_ (false ),
63
60
host_name_ (" 127.0.0.1" ), port_(-1 ) { }
64
61
65
62
bool DebugOptions::ParseOption (const char * argv0, const std::string& option) {
66
- bool enable_inspector = false ;
67
63
bool has_argument = false ;
68
64
std::string option_name;
69
65
std::string argument;
@@ -81,11 +77,21 @@ bool DebugOptions::ParseOption(const char* argv0, const std::string& option) {
81
77
argument.clear ();
82
78
}
83
79
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
84
85
if (option_name == " --inspect" ) {
85
- enable_inspector = true ;
86
+ inspector_enabled_ = true ;
87
+ } else if (option_name == " --debug" ) {
88
+ deprecated_debug_ = true ;
86
89
} 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 ;
89
95
} else if (option_name == " --debug-port" ||
90
96
option_name == " --inspect-port" ) {
91
97
if (!has_argument) {
@@ -97,15 +103,14 @@ bool DebugOptions::ParseOption(const char* argv0, const std::string& option) {
97
103
return false ;
98
104
}
99
105
100
- if (enable_inspector) {
101
- #if HAVE_INSPECTOR
102
- inspector_enabled_ = true ;
103
- #else
106
+ #if !HAVE_INSPECTOR
107
+ if (inspector_enabled_) {
104
108
fprintf (stderr,
105
109
" Inspector support is not available with this Node.js build\n " );
106
- return false ;
107
- #endif
108
110
}
111
+ inspector_enabled_ = false ;
112
+ return false ;
113
+ #endif
109
114
110
115
// argument can be specified for *any* option to specify host:port
111
116
if (has_argument) {
@@ -124,9 +129,7 @@ bool DebugOptions::ParseOption(const char* argv0, const std::string& option) {
124
129
int DebugOptions::port () const {
125
130
int port = port_;
126
131
if (port < 0 ) {
127
- #if HAVE_INSPECTOR
128
132
port = default_inspector_port;
129
- #endif // HAVE_INSPECTOR
130
133
}
131
134
return port;
132
135
}
0 commit comments