@@ -131,7 +131,8 @@ class AgentImpl {
131
131
explicit AgentImpl (node::Environment* env);
132
132
133
133
// Start the inspector agent thread
134
- bool Start (v8::Platform* platform, const char * path, int port, bool wait);
134
+ bool Start (v8::Platform* platform, const char * path,
135
+ const DebugOptions& options);
135
136
// Stop the inspector agent
136
137
void Stop ();
137
138
@@ -168,15 +169,14 @@ class AgentImpl {
168
169
void NotifyMessageReceived ();
169
170
State ToState (State state);
170
171
172
+ DebugOptions options_;
171
173
uv_sem_t start_sem_;
172
174
ConditionVariable incoming_message_cond_;
173
175
Mutex state_lock_;
174
176
uv_thread_t thread_;
175
177
uv_loop_t child_loop_;
176
178
177
179
InspectorAgentDelegate* delegate_;
178
-
179
- int port_;
180
180
bool wait_;
181
181
bool shutting_down_;
182
182
State state_;
@@ -192,6 +192,8 @@ class AgentImpl {
192
192
InspectorSocketServer* server_;
193
193
194
194
std::string script_name_;
195
+ std::string script_path_;
196
+ const std::string id_;
195
197
196
198
friend class ChannelImpl ;
197
199
friend class DispatchOnInspectorBackendTask ;
@@ -316,7 +318,6 @@ class V8NodeInspector : public v8_inspector::V8InspectorClient {
316
318
};
317
319
318
320
AgentImpl::AgentImpl (Environment* env) : delegate_(nullptr ),
319
- port_(0 ),
320
321
wait_(false ),
321
322
shutting_down_(false ),
322
323
state_(State::kNew ),
@@ -396,7 +397,10 @@ void InspectorWrapConsoleCall(const v8::FunctionCallbackInfo<v8::Value>& args) {
396
397
}
397
398
398
399
bool AgentImpl::Start (v8::Platform* platform, const char * path,
399
- int port, bool wait) {
400
+ const DebugOptions& options) {
401
+ options_ = options;
402
+ wait_ = options.wait_for_connect ();
403
+
400
404
auto env = parent_env_;
401
405
inspector_ = new V8NodeInspector (this , env, platform);
402
406
platform_ = platform;
@@ -408,9 +412,6 @@ bool AgentImpl::Start(v8::Platform* platform, const char* path,
408
412
int err = uv_loop_init (&child_loop_);
409
413
CHECK_EQ (err, 0 );
410
414
411
- port_ = port;
412
- wait_ = wait;
413
-
414
415
err = uv_thread_create (&thread_, AgentImpl::ThreadCbIO, this );
415
416
CHECK_EQ (err, 0 );
416
417
uv_sem_wait (&start_sem_);
@@ -420,7 +421,7 @@ bool AgentImpl::Start(v8::Platform* platform, const char* path,
420
421
return false ;
421
422
}
422
423
state_ = State::kAccepting ;
423
- if (wait ) {
424
+ if (options_. wait_for_connect () ) {
424
425
DispatchMessages ();
425
426
}
426
427
return true ;
@@ -548,7 +549,7 @@ void AgentImpl::WorkerRunIO() {
548
549
}
549
550
InspectorAgentDelegate delegate (this , script_path, script_name_, wait_);
550
551
delegate_ = &delegate;
551
- InspectorSocketServer server (&delegate, port_ );
552
+ InspectorSocketServer server (&delegate, options_. port () );
552
553
if (!server.Start (&child_loop_)) {
553
554
fprintf (stderr, " Unable to open devtools socket: %s\n " , uv_strerror (err));
554
555
state_ = State::kError ; // Safe, main thread is waiting on semaphore
@@ -666,8 +667,8 @@ Agent::~Agent() {
666
667
}
667
668
668
669
bool Agent::Start (v8::Platform* platform, const char * path,
669
- int port, bool wait ) {
670
- return impl->Start (platform, path, port, wait );
670
+ const DebugOptions& options ) {
671
+ return impl->Start (platform, path, options );
671
672
}
672
673
673
674
void Agent::Stop () {
0 commit comments