-
Notifications
You must be signed in to change notification settings - Fork 30.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[wip] src, inspector: support opted-in VM contexts #14231
Closed
Closed
Changes from 3 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
ff88cf4
src: refactor contextify
TimothyGu 9f12ee8
[WIP] src, inspector: support opted-in VM contexts
TimothyGu a08b03e
ignore already tracked contexts
TimothyGu 2d9272c
src: add a macro for debugging inspector WS
TimothyGu f1ca818
test: add some tools to common
TimothyGu a8ebfb5
bug fixes
TimothyGu fe7c4a5
tests
TimothyGu 0352a48
contextAttached
TimothyGu 06f635b
contextAttached tests
TimothyGu fc7d408
auto attachment from runInContext
TimothyGu a0c6f68
Add docs
TimothyGu 15a8ff8
vm: support binding a script to a context
TimothyGu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,13 +2,15 @@ | |
#define SRC_INSPECTOR_AGENT_H_ | ||
|
||
#include <memory> | ||
#include <vector> | ||
|
||
#include <stddef.h> | ||
|
||
#if !HAVE_INSPECTOR | ||
#error("This header can only be used when inspector is enabled") | ||
#endif | ||
|
||
#include "v8.h" | ||
#include "node_debug_options.h" | ||
|
||
// Forward declaration to break recursive dependency chain with src/env.h. | ||
|
@@ -46,6 +48,35 @@ class InspectorSessionDelegate { | |
class InspectorIo; | ||
class NodeInspectorClient; | ||
|
||
class ContextInfo { | ||
public: | ||
explicit ContextInfo(v8::Local<v8::Context> context, const int group_id, | ||
const char* name, const char* origin = nullptr, | ||
const char* aux_data = nullptr) | ||
: group_id_(group_id), | ||
name_(name), | ||
origin_(origin), | ||
aux_data_(aux_data) { | ||
context_.Reset(context->GetIsolate(), context); | ||
} | ||
|
||
inline v8::Local<v8::Context> context(v8::Isolate* isolate) const { | ||
return context_.Get(isolate); | ||
} | ||
|
||
int group_id() const { return group_id_; } | ||
const char* name() const { return name_; } | ||
const char* origin() const { return origin_; } | ||
const char* aux_data() const { return aux_data_; } | ||
|
||
private: | ||
v8::Persistent<v8::Context> context_; | ||
const int group_id_; | ||
const char* name_; | ||
const char* origin_; | ||
const char* aux_data_; | ||
}; | ||
|
||
class Agent { | ||
public: | ||
explicit Agent(node::Environment* env); | ||
|
@@ -57,6 +88,9 @@ class Agent { | |
// Stop and destroy io_ | ||
void Stop(); | ||
|
||
bool ContextCreated(const node::inspector::ContextInfo* info); | ||
void ContextDestroyed(v8::Local<v8::Context> context); | ||
|
||
bool IsStarted() { return !!client_; } | ||
|
||
// IO thread started, and client connected | ||
|
@@ -102,6 +136,7 @@ class Agent { | |
std::unique_ptr<NodeInspectorClient> client_; | ||
std::unique_ptr<InspectorIo> io_; | ||
v8::Platform* platform_; | ||
std::vector<const node::inspector::ContextInfo*> contexts_; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please move this to NodeInspectorClient |
||
bool enabled_; | ||
std::string path_; | ||
DebugOptions debug_options_; | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've you just moved this line, but maybe do
const double NANOS_PER_MSEC = 1E6;
since AFAICT it's only used for double arithmetic.