| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 33af09f commit e30e307
8 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -159,6 +159,7 @@ | |||
| 159 | 159 | 'src/node_config.cc', | |
| 160 | 160 | 'src/node_constants.cc', | |
| 161 | 161 | 'src/node_contextify.cc', | |
| 162 | + 'src/node_debug_options.cc', | ||
| 162 | 163 | 'src/node_file.cc', | |
| 163 | 164 | 'src/node_http_parser.cc', | |
| 164 | 165 | 'src/node_javascript.cc', | |
@@ -201,6 +202,7 @@ | |||
| 201 | 202 | 'src/node.h', | |
| 202 | 203 | 'src/node_buffer.h', | |
| 203 | 204 | 'src/node_constants.h', | |
| 205 | + 'src/node_debug_options.h', | ||
| 204 | 206 | 'src/node_file.h', | |
| 205 | 207 | 'src/node_http_parser.h', | |
| 206 | 208 | 'src/node_internals.h', | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -50,7 +50,6 @@ using v8::Value; | |||
| 50 | 50 | ||
| 51 | 51 | ||
| 52 | 52 | Agent::Agent(Environment* env) : state_(kNone), | |
| 53 | - port_(5858), | ||
| 54 | 53 | wait_(false), | |
| 55 | 54 | parent_env_(env), | |
| 56 | 55 | child_env_(nullptr), | |
@@ -69,7 +68,7 @@ Agent::~Agent() { | |||
| 69 | 68 | } | |
| 70 | 69 | ||
| 71 | 70 | ||
| 72 | - bool Agent::Start(const char* host, int port, bool wait) { | ||
| 71 | + bool Agent::Start(const DebugOptions& options) { | ||
| 73 | 72 | int err; | |
| 74 | 73 | ||
| 75 | 74 | if (state_ == kRunning) | |
@@ -85,9 +84,8 @@ bool Agent::Start(const char* host, int port, bool wait) { | |||
| 85 | 84 | goto async_init_failed; | |
| 86 | 85 | uv_unref(reinterpret_cast<uv_handle_t*>(&child_signal_)); | |
| 87 | 86 | ||
| 88 | - host_ = host; | ||
| 89 | - port_ = port; | ||
| 90 | - wait_ = wait; | ||
| 87 | + options_ = options; | ||
| 88 | + wait_ = options_.wait_for_connect(); | ||
| 91 | 89 | ||
| 92 | 90 | err = uv_thread_create(&thread_, | |
| 93 | 91 | reinterpret_cast<uv_thread_cb>(ThreadCb), | |
@@ -210,9 +208,11 @@ void Agent::InitAdaptor(Environment* env) { | |||
| 210 | 208 | ||
| 211 | 209 | api->Set(String::NewFromUtf8(isolate, "host", | |
| 212 | 210 | NewStringType::kNormal).ToLocalChecked(), | |
| 213 | - String::NewFromUtf8(isolate, host_.data(), NewStringType::kNormal, | ||
| 214 | - host_.size()).ToLocalChecked()); | ||
| 215 | - api->Set(String::NewFromUtf8(isolate, "port"), Integer::New(isolate, port_)); | ||
| 211 | + String::NewFromUtf8(isolate, options_.host_name().data(), | ||
| 212 | + NewStringType::kNormal, | ||
| 213 | + options_.host_name().size()).ToLocalChecked()); | ||
| 214 | + api->Set(String::NewFromUtf8(isolate, "port"), | ||
| 215 | + Integer::New(isolate, options_.port())); | ||
| 216 | 216 | ||
| 217 | 217 | env->process_object()->Set(String::NewFromUtf8(isolate, "_debugAPI"), api); | |
| 218 | 218 | api_.Reset(env->isolate(), api); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -25,6 +25,7 @@ | |||
| 25 | 25 | #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS | |
| 26 | 26 | ||
| 27 | 27 | #include "node_mutex.h" | |
| 28 | + #include "node_debug_options.h" | ||
| 28 | 29 | #include "util.h" | |
| 29 | 30 | #include "util-inl.h" | |
| 30 | 31 | #include "uv.h" | |
@@ -76,7 +77,7 @@ class Agent { | |||
| 76 | 77 | typedef void (*DispatchHandler)(node::Environment* env); | |
| 77 | 78 | ||
| 78 | 79 | // Start the debugger agent thread | |
| 79 | - bool Start(const char* host, int port, bool wait); | ||
| 80 | + bool Start(const DebugOptions& options); | ||
| 80 | 81 | // Listen for debug events | |
| 81 | 82 | void Enable(); | |
| 82 | 83 | // Stop the debugger agent | |
@@ -114,9 +115,8 @@ class Agent { | |||
| 114 | 115 | }; | |
| 115 | 116 | ||
| 116 | 117 | State state_; | |
| 118 | + DebugOptions options_; | ||
| 117 | 119 | ||
| 118 | - std::string host_; | ||
| 119 | - int port_; | ||
| 120 | 120 | bool wait_; | |
| 121 | 121 | ||
| 122 | 122 | uv_sem_t start_sem_; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -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() { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7,6 +7,8 @@ | |||
| 7 | 7 | #error("This header can only be used when inspector is enabled") | |
| 8 | 8 | #endif | |
| 9 | 9 | ||
| 10 | + #include "node_debug_options.h" | ||
| 11 | + | ||
| 10 | 12 | // Forward declaration to break recursive dependency chain with src/env.h. | |
| 11 | 13 | namespace node { | |
| 12 | 14 | class Environment; | |
@@ -31,7 +33,8 @@ class Agent { | |||
| 31 | 33 | ~Agent(); | |
| 32 | 34 | ||
| 33 | 35 | // Start the inspector agent thread | |
| 34 | - bool Start(v8::Platform* platform, const char* path, int port, bool wait); | ||
| 36 | + bool Start(v8::Platform* platform, const char* path, | ||
| 37 | + const DebugOptions& options); | ||
| 35 | 38 | // Stop the inspector agent | |
| 36 | 39 | void Stop(); | |
| 37 | 40 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments