60 return std::unique_ptr<V8Inspector>(
new V8InspectorImpl(isolate, client));
99 .ToLocal(&unboundScript))
104 return unboundScript->BindToCurrentContext()->Run(context);
125 int contextGroupId) {
129 .insert(std::make_pair(
131 std::unique_ptr<V8ConsoleMessageStorage>(
134 return storageIt->second.get();
144 return m_debugger->createStackTrace(stackTrace);
151 std::shared_ptr<V8DebuggerBarrier> debuggerBarrier;
158 debuggerBarrier = it->second.lock();
165 std::unique_ptr<V8InspectorSessionImpl> session =
167 state, client_trust_level,
168 std::move(debuggerBarrier));
170 return std::move(session);
183 int contextId)
const {
184 if (!groupId || !contextId)
return nullptr;
186 auto contextGroupIt =
m_contexts.find(groupId);
187 if (contextGroupIt ==
m_contexts.end())
return nullptr;
189 auto contextIt = contextGroupIt->second->find(contextId);
190 if (contextIt == contextGroupIt->second->end())
return nullptr;
192 return contextIt->second.get();
207 if (context) unique_id =
m_debugger->debuggerIdFor(context->contextGroupId());
224 std::make_pair(context->uniqueId().pair(), contextId));
226 auto contextIt =
m_contexts.find(info.contextGroupId);
229 .insert(std::make_pair(
236 (*contextById)[contextId].reset(context);
239 session->runtimeAgent()->addBindings(context);
240 session->runtimeAgent()->reportExecutionContextCreated(context);
255 storageIt->second->contextDestroyed(contextId);
258 if (!inspectedContext)
return;
272 for (
const auto& map_entry : *contextsIt->second)
287 unsigned lineNumber,
unsigned columnNumber,
288 std::unique_ptr<V8StackTrace> stackTrace,
int scriptId) {
291 std::unique_ptr<V8StackTraceImpl> stackTraceImpl(
294 std::unique_ptr<V8ConsoleMessage> consoleMessage =
297 toString16(url), lineNumber, columnNumber, std::move(stackTraceImpl),
305 unsigned exceptionId,
308 if (!groupId)
return;
310 std::unique_ptr<V8ConsoleMessage> consoleMessage =
318 return m_debugger->captureStackTrace(fullStack);
322 return m_debugger->storeCurrentStackTrace(description);
330 m_debugger->externalAsyncTaskFinished(parent);
336 m_debugger->asyncTaskScheduled(taskName, task, recurring);
383 if (!context)
return;
393 auto it2 = it->second.find(sessionId);
394 return it2 == it->second.end() ?
nullptr : it2->second;
407 std::vector<int> ids;
408 ids.reserve(it->second->size());
409 for (
auto& contextIt : *(it->second)) ids.push_back(contextIt.first);
412 for (
auto& contextId : ids) {
415 auto contextIt = it->second->find(contextId);
416 if (contextIt != it->second->end())
callback(contextIt->second.get());
425 std::vector<int> ids;
426 ids.reserve(it->second.size());
427 for (
auto& sessionIt : it->second) ids.push_back(sessionIt.first);
430 for (
auto& sessionId : ids) {
433 auto sessionIt = it->second.find(sessionId);
434 if (sessionIt != it->second.end())
callback(sessionIt->second);
447 : m_scope(scope),
m_isolate(scope.inspector()->isolate()) {}
451 bool m_canceled =
false;
455 if (m_scope.tryCatch().HasTerminated()) {
456 m_scope.inspector()->debugger()->reportTermination();
460 m_cancelToken->m_canceled =
true;
474 if (m_token->m_canceled)
return;
485 return protocol::Response::ServerError(
"Execution was terminated");
490 std::make_unique<TerminateTask>(
m_isolate, m_cancelToken), timeout);
491 return protocol::Response::Success();
498 if (!exception->IsObject()) {
521 CHECK(object->IsObject());
528 if (!exception->IsObject()) {
538 auto entry = map->Get(
m_isolate, exception);
540 if (!entry.ToLocal(&
object) || !object->IsObject())
542 return scope.
Escape(
object.As<v8::Object>());
545std::unique_ptr<protocol::DictionaryValue>
550 if (!maybeData.
ToLocal(&data))
return nullptr;
559 std::unique_ptr<protocol::DictionaryValue> jsonObject;
union v8::internal::@341::BuiltinMetadata::KindSpecificData data
static Local< Context > New(Isolate *isolate, ExtensionConfiguration *extensions=nullptr, MaybeLocal< ObjectTemplate > global_template=MaybeLocal< ObjectTemplate >(), MaybeLocal< Value > global_object=MaybeLocal< Value >(), DeserializeInternalFieldsCallback internal_fields_deserializer=DeserializeInternalFieldsCallback(), MicrotaskQueue *microtask_queue=nullptr, DeserializeContextDataCallback context_data_deserializer=DeserializeContextDataCallback(), DeserializeAPIWrapperCallback api_wrapper_deserializer=DeserializeAPIWrapperCallback())
V8_INLINE Local< T > Escape(Local< T > value)
void CancelTerminateExecution()
void SetIdle(bool is_idle)
void TerminateExecution()
bool IsExecutionTerminating()
V8_WARN_UNUSED_RESULT V8_INLINE bool ToLocal(Local< S > *out) const
V8_INLINE Local< T > ToLocalChecked()
V8_INLINE bool IsEmpty() const
V8_INLINE T FromMaybe(const T &default_value) const
static Local< Object > New(Isolate *isolate)
V8_INLINE Local< T > Get(Isolate *isolate) const
static V8_WARN_UNUSED_RESULT MaybeLocal< Script > Compile(Local< Context > context, Source *source, CompileOptions options=kNoCompileOptions, NoCacheReason no_cache_reason=kNoCacheNoReason)
V8_INLINE bool IsEmpty() const
static V8_EXPORT_PRIVATE Local< EphemeronTable > New(v8::Isolate *isolate)
void addMessage(std::unique_ptr< V8ConsoleMessage >)
static std::unique_ptr< V8ConsoleMessage > createForRevokedException(double timestamp, const String16 &message, unsigned revokedExceptionId)
static std::unique_ptr< V8ConsoleMessage > createForException(double timestamp, const String16 &detailedMessage, const String16 &url, unsigned lineNumber, unsigned columnNumber, std::unique_ptr< V8StackTraceImpl >, int scriptId, v8::Isolate *, const String16 &message, int contextId, v8::Local< v8::Value > exception, unsigned exceptionId)
virtual double currentTimeMS()
virtual int64_t generateUniqueId()
std::shared_ptr< CancelToken > m_token
TerminateTask(v8::Isolate *isolate, std::shared_ptr< CancelToken > token)
EvaluateScope(const InjectedScript::Scope &scope)
protocol::Response setTimeout(double timeout)
MuteExceptionsMap m_muteExceptionsMap
void externalAsyncTaskFinished(const V8StackTraceId &parent) override
int64_t generateUniqueId()
V8_EXPORT_PRIVATE V8InspectorImpl(v8::Isolate *, V8InspectorClient *)
void asyncTaskStarted(void *task) override
std::unique_ptr< V8Console > m_console
V8InspectorClient * m_client
V8ConsoleMessageStorage * ensureConsoleMessageStorage(int contextGroupId)
void disconnect(V8InspectorSessionImpl *)
v8::MaybeLocal< v8::Context > contextById(int contextId) override
std::unique_ptr< V8InspectorSession > connect(int contextGroupId, V8Inspector::Channel *, StringView state, ClientTrustLevel, SessionPauseState) override
std::unique_ptr< protocol::DictionaryValue > getAssociatedExceptionDataForProtocol(v8::Local< v8::Value > exception)
v8::MaybeLocal< v8::Value > compileAndRunInternalScript(v8::Local< v8::Context >, v8::Local< v8::String >)
v8::MaybeLocal< v8::Script > compileScript(v8::Local< v8::Context >, const String16 &code, const String16 &fileName)
ContextsByGroupMap m_contexts
void contextCollected(int contextGroupId, int contextId)
V8DebuggerId uniqueDebuggerId(int contextId) override
std::unique_ptr< V8StackTrace > createStackTrace(v8::Local< v8::StackTrace >) override
v8::Global< v8::Context > m_regexContext
void idleFinished() override
void asyncTaskScheduled(StringView taskName, void *task, bool recurring) override
v8::MaybeLocal< v8::Context > regexContext()
InspectedContext * getContext(int groupId, int contextId) const
void contextCreated(const V8ContextInfo &) override
V8_EXPORT_PRIVATE bool associateExceptionData(v8::Local< v8::Context >, v8::Local< v8::Value > exception, v8::Local< v8::Name > key, v8::Local< v8::Value > value) override
void discardInspectedContext(int contextGroupId, int contextId)
void unmuteExceptions(int contextGroupId)
bool hasConsoleMessageStorage(int contextGroupId)
V8_EXPORT_PRIVATE V8Console * console()
uint64_t isolateId() override
int resolveUniqueContextId(internal::V8DebuggerId uniqueId) const
std::unordered_map< int, int > m_contextIdToGroupIdMap
v8::Global< v8::debug::EphemeronTable > m_exceptionMetaData
std::unordered_map< int, std::weak_ptr< V8DebuggerBarrier > > m_debuggerBarriers
V8_EXPORT_PRIVATE v8::MaybeLocal< v8::Object > getAssociatedExceptionData(v8::Local< v8::Value > exception)
void resetContextGroup(int contextGroupId) override
~V8InspectorImpl() override
void allAsyncTasksCanceled() override
V8StackTraceId storeCurrentStackTrace(StringView description) override
v8::MaybeLocal< v8::Context > exceptionMetaDataContext()
std::unique_ptr< V8StackTrace > captureStackTrace(bool fullStack) override
v8::Global< v8::Context > m_exceptionMetaDataContext
void forEachSession(int contextGroupId, const std::function< void(V8InspectorSessionImpl *)> &callback)
unsigned nextExceptionId()
std::map< std::pair< int64_t, int64_t >, int > m_uniqueIdToContextId
void asyncTaskFinished(void *task) override
void exceptionRevoked(v8::Local< v8::Context >, unsigned exceptionId, StringView message) override
void externalAsyncTaskStarted(const V8StackTraceId &parent) override
int contextGroupId(v8::Local< v8::Context >) const
ConsoleStorageMap m_consoleStorageMap
V8InspectorSessionImpl * sessionById(int contextGroupId, int sessionId)
void contextDestroyed(v8::Local< v8::Context >) override
void forEachContext(int contextGroupId, const std::function< void(InspectedContext *)> &callback)
void muteExceptions(int contextGroupId)
unsigned exceptionThrown(v8::Local< v8::Context >, StringView message, v8::Local< v8::Value > exception, StringView detailedMessage, StringView url, unsigned lineNumber, unsigned columnNumber, std::unique_ptr< V8StackTrace >, int scriptId) override
std::unordered_map< int, std::map< int, V8InspectorSessionImpl * > > m_sessions
void asyncTaskCanceled(void *task) override
std::unordered_map< int, std::unique_ptr< InspectedContext > > ContextByIdMap
void idleStarted() override
std::unique_ptr< V8Debugger > m_debugger
static std::unique_ptr< V8InspectorSessionImpl > create(V8InspectorImpl *, int contextGroupId, int sessionId, V8Inspector::Channel *, StringView state, v8_inspector::V8Inspector::ClientTrustLevel, std::shared_ptr< V8DebuggerBarrier >)
V8RuntimeAgentImpl * runtimeAgent()
int contextGroupId() const
static std::unique_ptr< V8Inspector > create(v8::Isolate *, V8InspectorClient *)
void reportExecutionContextDestroyed(InspectedContext *)
std::pair< int64_t, int64_t > pair() const
v8_inspector::V8DebuggerId toV8DebuggerId() const
refactor address components for immediate indexing make OptimizeMaglevOnNextCall optimize to turbofan instead of maglev filter for tracing turbofan compilation nullptr
ZoneVector< RpoNumber > & result
InstructionOperand source
MaybeLocal< UnboundScript > CompileInspectorScript(Isolate *v8_isolate, Local< String > source)
void SetConsoleDelegate(Isolate *v8_isolate, ConsoleDelegate *delegate)
void SetIsolateId(v8::Isolate *v8_isolate, uint64_t id)
int64_t GetNextRandomInt64(v8::Isolate *v8_isolate)
Platform * GetCurrentPlatform()
void SetInspector(Isolate *isolate, v8_inspector::V8Inspector *inspector)
uint64_t GetIsolateId(v8::Isolate *v8_isolate)
Response objectToProtocolValue(v8::Local< v8::Context > context, v8::Local< v8::Object > object, int maxDepth, std::unique_ptr< protocol::DictionaryValue > *result)
v8::Local< v8::String > toV8String(v8::Isolate *isolate, const String16 &string)
String16 toString16(const StringView &string)
V8_INLINE Local< Primitive > Null(Isolate *isolate)
#define DCHECK(condition)
std::unique_ptr< ValueMirror > key