| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 06a29f8 commit 3fe59ba
25 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -100,6 +100,12 @@ experimental domain NodeWorker | |||
| 100 | 100 | ||
| 101 | 101 | # Support for inspecting node process state. | |
| 102 | 102 | experimental domain NodeRuntime | |
| 103 | + # Enable the NodeRuntime events except by `NodeRuntime.waitingForDisconnect`. | ||
| 104 | + command enable | ||
| 105 | + | ||
| 106 | + # Disable NodeRuntime events | ||
| 107 | + command disable | ||
| 108 | + | ||
| 103 | 109 | # Enable the `NodeRuntime.waitingForDisconnect`. | |
| 104 | 110 | command notifyWhenWaitingForDisconnect | |
| 105 | 111 | parameters | |
@@ -110,3 +116,7 @@ experimental domain NodeRuntime | |||
| 110 | 116 | # It is fired when the Node process finished all code execution and is | |
| 111 | 117 | # waiting for all frontends to disconnect. | |
| 112 | 118 | event waitingForDisconnect | |
| 119 | + | ||
| 120 | + # This event is fired when the runtime is waiting for the debugger. For | ||
| 121 | + # example, when inspector.waitingForDebugger is called | ||
| 122 | + event waitingForDebugger | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -8,7 +8,9 @@ namespace inspector { | |||
| 8 | 8 | namespace protocol { | |
| 9 | 9 | ||
| 10 | 10 | RuntimeAgent::RuntimeAgent() | |
| 11 | - : notify_when_waiting_for_disconnect_(false) {} | ||
| 11 | + : notify_when_waiting_for_disconnect_(false), | ||
| 12 | + enabled_(false), | ||
| 13 | + is_waiting_for_debugger_(false) {} | ||
| 12 | 14 | ||
| 13 | 15 | void RuntimeAgent::Wire(UberDispatcher* dispatcher) { | |
| 14 | 16 | frontend_ = std::make_unique<NodeRuntime::Frontend>(dispatcher->channel()); | |
@@ -20,6 +22,30 @@ DispatchResponse RuntimeAgent::notifyWhenWaitingForDisconnect(bool enabled) { | |||
| 20 | 22 | return DispatchResponse::OK(); | |
| 21 | 23 | } | |
| 22 | 24 | ||
| 25 | + DispatchResponse RuntimeAgent::enable() { | ||
| 26 | + enabled_ = true; | ||
| 27 | + if (is_waiting_for_debugger_) { | ||
| 28 | + frontend_->waitingForDebugger(); | ||
| 29 | + } | ||
| 30 | + return DispatchResponse::OK(); | ||
| 31 | + } | ||
| 32 | + | ||
| 33 | + DispatchResponse RuntimeAgent::disable() { | ||
| 34 | + enabled_ = false; | ||
| 35 | + return DispatchResponse::OK(); | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + void RuntimeAgent::setWaitingForDebugger() { | ||
| 39 | + is_waiting_for_debugger_ = true; | ||
| 40 | + if (enabled_) { | ||
| 41 | + frontend_->waitingForDebugger(); | ||
| 42 | + } | ||
| 43 | + } | ||
| 44 | + | ||
| 45 | + void RuntimeAgent::unsetWaitingForDebugger() { | ||
| 46 | + is_waiting_for_debugger_ = false; | ||
| 47 | + } | ||
| 48 | + | ||
| 23 | 49 | bool RuntimeAgent::notifyWaitingForDisconnect() { | |
| 24 | 50 | if (notify_when_waiting_for_disconnect_) { | |
| 25 | 51 | frontend_->waitingForDisconnect(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -18,11 +18,21 @@ class RuntimeAgent : public NodeRuntime::Backend { | |||
| 18 | 18 | ||
| 19 | 19 | DispatchResponse notifyWhenWaitingForDisconnect(bool enabled) override; | |
| 20 | 20 | ||
| 21 | + DispatchResponse enable() override; | ||
| 22 | + | ||
| 23 | + DispatchResponse disable() override; | ||
| 24 | + | ||
| 21 | 25 | bool notifyWaitingForDisconnect(); | |
| 22 | 26 | ||
| 27 | + void setWaitingForDebugger(); | ||
| 28 | + | ||
| 29 | + void unsetWaitingForDebugger(); | ||
| 30 | + | ||
| 23 | 31 | private: | |
| 24 | 32 | std::shared_ptr<NodeRuntime::Frontend> frontend_; | |
| 25 | 33 | bool notify_when_waiting_for_disconnect_; | |
| 34 | + bool enabled_; | ||
| 35 | + bool is_waiting_for_debugger_; | ||
| 26 | 36 | }; | |
| 27 | 37 | } // namespace protocol | |
| 28 | 38 | } // namespace inspector | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -278,6 +278,10 @@ class ChannelImpl final : public v8_inspector::V8Inspector::Channel, | |||
| 278 | 278 | return retaining_context_; | |
| 279 | 279 | } | |
| 280 | 280 | ||
| 281 | + void setWaitingForDebugger() { runtime_agent_->setWaitingForDebugger(); } | ||
| 282 | + | ||
| 283 | + void unsetWaitingForDebugger() { runtime_agent_->unsetWaitingForDebugger(); } | ||
| 284 | + | ||
| 281 | 285 | bool retainingContext() { | |
| 282 | 286 | return retaining_context_; | |
| 283 | 287 | } | |
@@ -418,6 +422,9 @@ class NodeInspectorClient : public V8InspectorClient { | |||
| 418 | 422 | ||
| 419 | 423 | void waitForFrontend() { | |
| 420 | 424 | waiting_for_frontend_ = true; | |
| 425 | + for (const auto& id_channel : channels_) { | ||
| 426 | + id_channel.second->setWaitingForDebugger(); | ||
| 427 | + } | ||
| 421 | 428 | runMessageLoop(); | |
| 422 | 429 | } | |
| 423 | 430 | ||
@@ -465,6 +472,9 @@ class NodeInspectorClient : public V8InspectorClient { | |||
| 465 | 472 | ||
| 466 | 473 | void runIfWaitingForDebugger(int context_group_id) override { | |
| 467 | 474 | waiting_for_frontend_ = false; | |
| 475 | + for (const auto& id_channel : channels_) { | ||
| 476 | + id_channel.second->unsetWaitingForDebugger(); | ||
| 477 | + } | ||
| 468 | 478 | } | |
| 469 | 479 | ||
| 470 | 480 | int connectFrontend(std::unique_ptr<InspectorSessionDelegate> delegate, | |
@@ -476,6 +486,9 @@ class NodeInspectorClient : public V8InspectorClient { | |||
| 476 | 486 | std::move(delegate), | |
| 477 | 487 | getThreadHandle(), | |
| 478 | 488 | prevent_shutdown); | |
| 489 | + if (waiting_for_frontend_) { | ||
| 490 | + channels_[session_id]->setWaitingForDebugger(); | ||
| 491 | + } | ||
| 479 | 492 | return session_id; | |
| 480 | 493 | } | |
| 481 | 494 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -303,6 +303,9 @@ class InspectorSession { | |||
| 303 | 303 | console.log('[test]', 'Verify node waits for the frontend to disconnect'); | |
| 304 | 304 | await this.send({ 'method': 'Debugger.resume' }); | |
| 305 | 305 | await this.waitForNotification((notification) => { | |
| 306 | + if (notification.method === 'Debugger.paused') { | ||
| 307 | + this.send({ 'method': 'Debugger.resume' }); | ||
| 308 | + } | ||
| 306 | 309 | return notification.method === 'Runtime.executionContextDestroyed' && | |
| 307 | 310 | notification.params.executionContextId === 1; | |
| 308 | 311 | }); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -54,7 +54,6 @@ async function runTests() { | |||
| 54 | 54 | 'params': { 'maxDepth': 10 } }, | |
| 55 | 55 | { 'method': 'Debugger.setBlackboxPatterns', | |
| 56 | 56 | 'params': { 'patterns': [] } }, | |
| 57 | - { 'method': 'Runtime.runIfWaitingForDebugger' }, | ||
| 58 | 57 | ]); | |
| 59 | 58 | ||
| 60 | 59 | await waitForInitialSetup(session); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -30,6 +30,8 @@ async function checkAsyncStackTrace(session) { | |||
| 30 | 30 | async function runTests() { | |
| 31 | 31 | const instance = new NodeInstance(undefined, script); | |
| 32 | 32 | const session = await instance.connectInspectorSession(); | |
| 33 | + await session.send({ method: 'NodeRuntime.enable' }); | ||
| 34 | + await session.waitForNotification('NodeRuntime.waitingForDebugger'); | ||
| 33 | 35 | await session.send([ | |
| 34 | 36 | { 'method': 'Runtime.enable' }, | |
| 35 | 37 | { 'method': 'Debugger.enable' }, | |
@@ -39,6 +41,7 @@ async function runTests() { | |||
| 39 | 41 | 'params': { 'patterns': [] } }, | |
| 40 | 42 | { 'method': 'Runtime.runIfWaitingForDebugger' }, | |
| 41 | 43 | ]); | |
| 44 | + await session.send({ method: 'NodeRuntime.disable' }); | ||
| 42 | 45 | await skipBreakpointAtStart(session); | |
| 43 | 46 | await checkAsyncStackTrace(session); | |
| 44 | 47 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -69,7 +69,6 @@ async function runTests() { | |||
| 69 | 69 | 'params': { 'maxDepth': 10 } }, | |
| 70 | 70 | { 'method': 'Debugger.setBlackboxPatterns', | |
| 71 | 71 | 'params': { 'patterns': [] } }, | |
| 72 | - { 'method': 'Runtime.runIfWaitingForDebugger' }, | ||
| 73 | 72 | ]); | |
| 74 | 73 | ||
| 75 | 74 | await waitForInitialSetup(session); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -20,6 +20,8 @@ function runTest() { | |||
| 20 | 20 | async function runTests() { | |
| 21 | 21 | const instance = new NodeInstance(undefined, script); | |
| 22 | 22 | const session = await instance.connectInspectorSession(); | |
| 23 | + await session.send({ method: 'NodeRuntime.enable' }); | ||
| 24 | + await session.waitForNotification('NodeRuntime.waitingForDebugger'); | ||
| 23 | 25 | await session.send([ | |
| 24 | 26 | { 'method': 'Runtime.enable' }, | |
| 25 | 27 | { 'method': 'Debugger.enable' }, | |
@@ -29,6 +31,7 @@ async function runTests() { | |||
| 29 | 31 | 'params': { 'patterns': [] } }, | |
| 30 | 32 | { 'method': 'Runtime.runIfWaitingForDebugger' }, | |
| 31 | 33 | ]); | |
| 34 | + session.send({ method: 'NodeRuntime.disable' }); | ||
| 32 | 35 | ||
| 33 | 36 | await session.waitForBreakOnLine(0, '[eval]'); | |
| 34 | 37 | await session.send({ 'method': 'Debugger.resume' }); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -26,6 +26,8 @@ async function checkAsyncStackTrace(session) { | |||
| 26 | 26 | async function runTests() { | |
| 27 | 27 | const instance = new NodeInstance(undefined, script); | |
| 28 | 28 | const session = await instance.connectInspectorSession(); | |
| 29 | + await session.send({ method: 'NodeRuntime.enable' }); | ||
| 30 | + await session.waitForNotification('NodeRuntime.waitingForDebugger'); | ||
| 29 | 31 | await session.send([ | |
| 30 | 32 | { 'method': 'Runtime.enable' }, | |
| 31 | 33 | { 'method': 'Debugger.enable' }, | |
@@ -35,6 +37,7 @@ async function runTests() { | |||
| 35 | 37 | 'params': { 'patterns': [] } }, | |
| 36 | 38 | { 'method': 'Runtime.runIfWaitingForDebugger' }, | |
| 37 | 39 | ]); | |
| 40 | + await session.send({ method: 'NodeRuntime.disable' }); | ||
| 38 | 41 | ||
| 39 | 42 | await skipFirstBreakpoint(session); | |
| 40 | 43 | await checkAsyncStackTrace(session); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments