Home
About
Blog
Products
Forum
Support
Contact
Sunbelt Computer Software
PL/B Language Development and Support
Home
About
Blog
Products
Forum
Support
Contact
node/src/inspector_agent.h at main · inoway46/node · GitHub
Skip to content
Navigation Menu
Sign in
Appearance settings
Platform
AI CODE CREATION
GitHub Copilot
Write better code with AI
GitHub Copilot app
Direct agents from issue to merge
MCP Registry
Integrate external tools
DEVELOPER WORKFLOWS
Actions
Automate any workflow
Codespaces
Instant dev environments
Issues
Plan and track work
Code Review
Manage code changes
Code Quality
Enforce quality at merge
APPLICATION SECURITY
GitHub Advanced Security
Find and fix vulnerabilities
Code security
Secure your code as you build
Secret protection
Stop leaks before they start
EXPLORE
Why GitHub
Documentation
Blog
Changelog
Marketplace
View all features
Solutions
BY COMPANY SIZE
Enterprises
Small and medium teams
Startups
Nonprofits
BY USE CASE
App Modernization
DevSecOps
DevOps
CI/CD
View all use cases
BY INDUSTRY
Healthcare
Financial services
Manufacturing
Government
See all industries
View all solutions
Resources
EXPLORE BY TOPIC
AI
Software Development
DevOps
Security
View all topics
EXPLORE BY TYPE
Customer stories
Events & webinars
Ebooks & reports
Business insights
GitHub Skills
SUPPORT & SERVICES
Documentation
Customer support
Community forum
Trust center
Partners
View all resources
Open Source
COMMUNITY
GitHub Sponsors
Fund open source developers
PROGRAMS
Security Lab
Maintainer Community
GitHub Stars
Archive Program
REPOSITORIES
Topics
Trending
Collections
Enterprise
ENTERPRISE SOLUTIONS
Enterprise platform
AI-powered developer platform
AVAILABLE ADD-ONS
GitHub Advanced Security
Enterprise-grade security features
Copilot for Business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
inoway46
node
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
More
items
Files
Expand file tree
main
Breadcrumbs
node
/
src
/
inspector_agent.h
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
176 lines (140 loc) · 6.21 KB
main
Breadcrumbs
node
/
src
/
inspector_agent.h
Copy path
Top
File metadata and controls
Code
Blame
176 lines (140 loc) · 6.21 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
#
pragma
once
#
include
"
inspector/network_resource_manager.h
"
#
if
defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
#
if
!HAVE_INSPECTOR
#
error
("This header can only be used when inspector is enabled")
#
endif
#
include
"
node_options.h
"
#
include
"
uv.h
"
#
include
"
v8.h
"
#
include
<
cstddef
>
#
include
<
memory
>
namespace
v8_inspector
{
class
StringView
;
}
//
namespace v8_inspector
namespace
node
{
//
Forward declaration to break recursive dependency chain with src/env.h.
class
Environment
;
struct
ContextInfo
;
namespace
inspector
{
class
InspectorIo
;
class
ParentInspectorHandle
;
class
NodeInspectorClient
;
class
WorkerManager
;
class
InspectorSession
{
public:
virtual
~InspectorSession
() =
default
;
virtual
void
Dispatch
(
const
v8_inspector::StringView& message) = 0;
};
class
InspectorSessionDelegate
{
public:
virtual
~InspectorSessionDelegate
() =
default
;
virtual
void
SendMessageToFrontend
(
const
v8_inspector::StringView& message)
= 0;
};
class
Agent
{
public:
explicit
Agent
(node::Environment* env);
~Agent
();
//
Create client_, may create io_ if option enabled
bool
Start
(
const
std::string& path,
const
DebugOptions& options,
std::shared_ptr<ExclusiveAccess<HostPort>> host_port,
bool
is_main);
//
Stop and destroy io_
void
Stop
();
bool
IsListening
() {
return
io_ !=
nullptr
; }
//
Returns true if the Node inspector is actually in use. It will be true
//
if either the user explicitly opted into inspector (e.g. with the
//
--inspect command line flag) or if inspector JS API had been used.
bool
IsActive
();
//
Blocks till frontend connects and sends "runIfWaitingForDebugger"
void
WaitForConnect
();
bool
WaitForConnectByOptions
();
void
StopIfWaitingForConnect
();
//
Blocks till all the sessions with "WaitForDisconnectOnShutdown" disconnect
void
WaitForDisconnect
();
void
ReportUncaughtException
(v8::Local<v8::Value> error,
v8::Local<v8::Message> message);
void
EmitProtocolEvent
(v8::Local<v8::Context> context,
const
v8_inspector::StringView& event,
v8::Local<v8::Object> params);
void
SetupNetworkTracking
(v8::Local<v8::Function> enable_function,
v8::Local<v8::Function> disable_function);
void
EnableNetworkTracking
();
void
DisableNetworkTracking
();
//
Async stack traces instrumentation.
void
AsyncTaskScheduled
(
const
v8_inspector::StringView& taskName,
void
* task,
bool
recurring);
void
AsyncTaskCanceled
(
void
* task);
void
AsyncTaskStarted
(
void
* task);
void
AsyncTaskFinished
(
void
* task);
void
AllAsyncTasksCanceled
();
void
RegisterAsyncHook
(v8::Isolate* isolate,
v8::Local<v8::Function> enable_function,
v8::Local<v8::Function> disable_function);
void
SetAsyncHookTrackingEnabled
(
bool
enabled);
void
SetParentHandle
(std::unique_ptr<ParentInspectorHandle> parent_handle);
std::unique_ptr<ParentInspectorHandle>
GetParentHandle
(
uint64_t
thread_id,
std::string_view url,
std::string_view name);
//
Called to create inspector sessions that can be used from the same thread.
//
The inspector responds by using the delegate to send messages back.
std::unique_ptr<InspectorSession>
Connect
(
std::unique_ptr<InspectorSessionDelegate> delegate,
bool
prevent_shutdown);
//
Called from the worker to create inspector sessions that is connected
//
to the main thread.
//
The inspector responds by using the delegate to send messages back.
std::unique_ptr<InspectorSession>
ConnectToMainThread
(
std::unique_ptr<InspectorSessionDelegate> delegate,
bool
prevent_shutdown);
void
PauseOnNextJavascriptStatement
(
const
std::string& reason);
std::string
GetWsUrl
()
const
;
//
Can only be called from the main thread.
bool
StartIoThread
();
//
Calls StartIoThread() from off the main thread. Only valid while the
//
Environment owns the inspector and has not started cleanup.
void
RequestIoThreadStart
();
const
DebugOptions&
options
() {
return
debug_options_; }
std::shared_ptr<ExclusiveAccess<HostPort>>
host_port
() {
return
host_port_; }
void
ContextCreated
(v8::Local<v8::Context> context,
const
ContextInfo& info);
//
Interface for interacting with inspectors in worker threads
std::shared_ptr<WorkerManager>
GetWorkerManager
();
inline
Environment*
env
()
const
{
return
parent_env_; }
std::shared_ptr<NetworkResourceManager>
GetNetworkResourceManager
();
private:
void
SyncAsyncHookState
();
void
ToggleNetworkTracking
(v8::Isolate* isolate, v8::Local<v8::Function> fn);
node::Environment* parent_env_;
//
Encapsulates majority of the Inspector functionality
std::shared_ptr<NodeInspectorClient> client_;
//
Interface for transports, e.g. WebSocket server
std::unique_ptr<InspectorIo> io_;
std::unique_ptr<ParentInspectorHandle> parent_handle_;
std::string path_;
//
This is a copy of the debug options parsed from CLI in the Environment.
//
Do not use the host_port in that, instead manipulate the shared host_port_
//
pointer which is meant to store the actual host and port of the inspector
//
server.
DebugOptions debug_options_;
std::shared_ptr<ExclusiveAccess<HostPort>> host_port_;
//
The state of the async hook used for async stack traces that the protocol
//
last requested, and the state JS currently has. SyncAsyncHookState()
//
reconciles the two when it is possible and safe to call into JS.
bool
async_hook_wanted_ =
false
;
bool
async_hook_enabled_ =
false
;
bool
syncing_async_hook_state_ =
false
;
//
Woken by the SIGUSR1 watchdog; closed by the cleanup hook or ~Agent(),
//
whichever runs first, and freed by its close callback.
uv_async_t
* start_io_thread_async_ =
nullptr
;
void
StopAcceptingIoThreadStarts
();
static
void
StopAcceptingIoThreadStartsHook
(
void
* agent);
bool
network_tracking_enabled_ =
false
;
bool
pending_enable_network_tracking =
false
;
bool
pending_disable_network_tracking =
false
;
std::shared_ptr<NetworkResourceManager> network_resource_manager_;
};
}
//
namespace inspector
}
//
namespace node
#
endif
//
defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
You can’t perform that action at this time.