Lines Matching refs:v8
5 #include "src/inspector/v8-debugger.h"
7 #include "include/v8-container.h"
8 #include "include/v8-context.h"
9 #include "include/v8-function.h"
10 #include "include/v8-microtask-queue.h"
11 #include "include/v8-util.h"
15 #include "src/inspector/v8-debugger-agent-impl.h"
16 #include "src/inspector/v8-inspector-impl.h"
17 #include "src/inspector/v8-inspector-session-impl.h"
18 #include "src/inspector/v8-runtime-agent-impl.h"
19 #include "src/inspector/v8-stack-trace-impl.h"
20 #include "src/inspector/v8-value-utils.h"
40 class MatchPrototypePredicate : public v8::debug::QueryObjectPredicate {
43 v8::Local<v8::Context> context,
44 v8::Local<v8::Object> prototype)
47 bool Filter(v8::Local<v8::Object> object) override {
49 v8::Local<v8::Context> objectContext;
50 if (!v8::debug::GetCreationContext(object).ToLocal(&objectContext)) {
56 for (v8::Local<v8::Value> prototype = object->GetPrototype();
58 prototype = prototype.As<v8::Object>()->GetPrototype()) {
66 v8::Local<v8::Context> m_context;
67 v8::Local<v8::Value> m_prototype;
72 V8Debugger::V8Debugger(v8::Isolate* isolate, V8InspectorImpl* inspector)
82 m_pauseOnExceptionsState(v8::debug::NoBreakOnException) {}
93 v8::HandleScope scope(m_isolate);
94 v8::debug::SetDebugDelegate(m_isolate, this);
96 v8::debug::ChangeBreakOnException(m_isolate, v8::debug::NoBreakOnException);
97 m_pauseOnExceptionsState = v8::debug::NoBreakOnException;
99 v8::debug::TierDownAllModulesPerIsolate(m_isolate);
124 v8::debug::TierUpAllModulesPerIsolate(m_isolate);
126 v8::debug::SetDebugDelegate(m_isolate, nullptr);
141 v8::HandleScope scope(m_isolate);
142 v8::PersistentValueVector<v8::debug::Script> scripts(m_isolate);
143 v8::debug::GetLoadedScripts(m_isolate, scripts);
145 v8::Local<v8::debug::Script> script = scripts.Get(i);
163 v8::debug::SetBreakPointsActive(m_isolate, m_breakpointsActiveCount);
166 v8::debug::ExceptionBreakState V8Debugger::getPauseOnExceptionsState() {
172 v8::debug::ExceptionBreakState pauseOnExceptionsState) {
175 v8::debug::ChangeBreakOnException(m_isolate, pauseOnExceptionsState);
191 v8::debug::SetBreakOnNextFunctionCall(m_isolate);
196 v8::debug::ClearBreakOnNextFunctionCall(m_isolate);
202 return v8::debug::CanBreakProgram(m_isolate);
211 v8::debug::BreakRightNow(m_isolate);
220 [](v8::Isolate* isolate, void*) {
221 v8::debug::BreakRightNow(
223 v8::debug::BreakReasons({v8::debug::BreakReason::kScheduled}));
233 v8::debug::SetTerminateOnResume(m_isolate);
241 if (m_pauseOnExceptionsState == v8::debug::NoBreakOnException) return;
247 v8::debug::BreakRightNow(
248 m_isolate, v8::debug::BreakReasons({v8::debug::BreakReason::kAssert}));
257 v8::debug::PrepareStep(m_isolate, v8::debug::StepInto);
265 v8::debug::PrepareStep(m_isolate, v8::debug::StepOver);
273 v8::debug::PrepareStep(m_isolate, v8::debug::StepOut);
305 void V8Debugger::terminateExecutionCompletedCallback(v8::Isolate* isolate) {
307 static_cast<V8InspectorImpl*>(v8::debug::GetInspector(isolate));
313 v8::Isolate* isolate, void*) {
324 v8::debug::Location v8Location(location->getLineNumber(),
360 v8::debug::RemoveBreakpoint(m_isolate, m_continueToLocationBreakpointId);
367 v8::Local<v8::Context> pausedContext, v8::Local<v8::Value> exception,
368 const std::vector<v8::debug::BreakpointId>& breakpointIds,
369 v8::debug::BreakReasons breakReasons,
370 v8::debug::ExceptionType exceptionType, bool isUncaught) {
376 v8::debug::PrepareStep(m_isolate, v8::debug::StepOut);
385 breakReasons.Add(v8::debug::BreakReason::kAsyncStep);
387 breakReasons.Add(v8::debug::BreakReason::kAgent);
398 breakReasons.contains(v8::debug::BreakReason::kOOM));
411 v8::Context::Scope contextScope(pausedContext);
430 v8::Context::Scope scope(pausedContext);
461 v8::Local<v8::Context> context =
466 [](v8::Isolate* isolate, void*) {
471 v8::debug::BreakRightNow(
472 isolate, v8::debug::BreakReasons({v8::debug::BreakReason::kOOM}));
478 void V8Debugger::ScriptCompiled(v8::Local<v8::debug::Script> script,
485 v8::Isolate* isolate = m_isolate;
502 v8::Local<v8::Context> pausedContext,
503 v8::debug::BreakpointId instrumentationId) {
525 v8::Context::Scope scope(pausedContext);
538 v8::Local<v8::Context> pausedContext,
539 const std::vector<v8::debug::BreakpointId>& break_points_hit,
540 v8::debug::BreakReasons reasons) {
541 handleProgramBreak(pausedContext, v8::Local<v8::Value>(), break_points_hit,
545 void V8Debugger::ExceptionThrown(v8::Local<v8::Context> pausedContext,
546 v8::Local<v8::Value> exception,
547 v8::Local<v8::Value> promise, bool isUncaught,
548 v8::debug::ExceptionType exceptionType) {
549 std::vector<v8::debug::BreakpointId> break_points_hit;
552 v8::debug::BreakReasons({v8::debug::BreakReason::kException}),
556 bool V8Debugger::IsFunctionBlackboxed(v8::Local<v8::debug::Script> script,
557 const v8::debug::Location& start,
558 const v8::debug::Location& end) {
576 bool V8Debugger::ShouldBeSkipped(v8::Local<v8::debug::Script> script, int line,
597 void V8Debugger::AsyncEventOccurred(v8::debug::DebugAsyncActionType type,
603 case v8::debug::kDebugPromiseThen:
607 case v8::debug::kDebugPromiseCatch:
611 case v8::debug::kDebugPromiseFinally:
615 case v8::debug::kDebugWillHandle:
619 case v8::debug::kDebugDidHandle:
623 case v8::debug::kDebugAwait: {
639 v8::MaybeLocal<v8::Value> V8Debugger::getTargetScopes(
640 v8::Local<v8::Context> context, v8::Local<v8::Value> value,
642 v8::Local<v8::Value> scopesValue;
643 std::unique_ptr<v8::debug::ScopeIterator> iterator;
646 iterator = v8::debug::ScopeIterator::CreateForFunction(
647 m_isolate, value.As<v8::Function>());
650 v8::Local<v8::debug::GeneratorObject> generatorObject =
651 v8::debug::GeneratorObject::Cast(value);
652 if (!generatorObject->IsSuspended()) return v8::MaybeLocal<v8::Value>();
654 iterator = v8::debug::ScopeIterator::CreateForGeneratorObject(
655 m_isolate, value.As<v8::Object>());
658 if (!iterator) return v8::MaybeLocal<v8::Value>();
659 v8::Local<v8::Array> result = v8::Array::New(m_isolate);
660 if (!result->SetPrototype(context, v8::Null(m_isolate)).FromMaybe(false)) {
661 return v8::MaybeLocal<v8::Value>();
665 v8::Local<v8::Object> scope = v8::Object::New(m_isolate);
667 return v8::MaybeLocal<v8::Value>();
673 case v8::debug::ScopeIterator::ScopeTypeGlobal:
676 case v8::debug::ScopeIterator::ScopeTypeLocal:
679 case v8::debug::ScopeIterator::ScopeTypeWith:
682 case v8::debug::ScopeIterator::ScopeTypeClosure:
685 case v8::debug::ScopeIterator::ScopeTypeCatch:
688 case v8::debug::ScopeIterator::ScopeTypeBlock:
691 case v8::debug::ScopeIterator::ScopeTypeScript:
694 case v8::debug::ScopeIterator::ScopeTypeEval:
697 case v8::debug::ScopeIterator::ScopeTypeModule:
700 case v8::debug::ScopeIterator::ScopeTypeWasmExpressionStack:
704 v8::Local<v8::Object> object = iterator->GetObject();
713 return v8::MaybeLocal<v8::Value>();
717 v8::MaybeLocal<v8::Value> V8Debugger::functionScopes(
718 v8::Local<v8::Context> context, v8::Local<v8::Function> function) {
722 v8::MaybeLocal<v8::Value> V8Debugger::generatorScopes(
723 v8::Local<v8::Context> context, v8::Local<v8::Value> generator) {
727 v8::MaybeLocal<v8::Array> V8Debugger::collectionsEntries(
728 v8::Local<v8::Context> context, v8::Local<v8::Value> collection) {
729 v8::Isolate* isolate = context->GetIsolate();
730 v8::Local<v8::Array> entries;
732 if (!collection->IsObject() || !collection.As<v8::Object>()
735 return v8::MaybeLocal<v8::Array>();
738 v8::Local<v8::Array> wrappedEntries = v8::Array::New(isolate);
740 if (!wrappedEntries->SetPrototype(context, v8::Null(isolate))
742 return v8::MaybeLocal<v8::Array>();
744 v8::Local<v8::Value> item;
746 v8::Local<v8::Value> value;
748 v8::Local<v8::Object> wrapper = v8::Object::New(isolate);
749 if (!wrapper->SetPrototype(context, v8::Null(isolate)).FromMaybe(false))
766 v8::MaybeLocal<v8::Array> V8Debugger::internalProperties(
767 v8::Local<v8::Context> context, v8::Local<v8::Value> value) {
768 v8::Local<v8::Array> properties;
769 if (!v8::debug::GetInternalProperties(m_isolate, value).ToLocal(&properties))
770 return v8::MaybeLocal<v8::Array>();
771 v8::Local<v8::Array> entries;
778 v8::Local<v8::Value> scopes;
786 v8::Local<v8::Function> function = value.As<v8::Function>();
787 v8::Local<v8::Value> scopes;
797 v8::Local<v8::Array> V8Debugger::queryObjects(v8::Local<v8::Context> context,
798 v8::Local<v8::Object> prototype) {
799 v8::Isolate* isolate = context->GetIsolate();
800 v8::PersistentValueVector<v8::Object> v8Objects(isolate);
802 v8::debug::QueryObjects(context, &predicate, &v8Objects);
804 v8::MicrotasksScope microtasksScope(isolate,
805 v8::MicrotasksScope::kDoNotRunMicrotasks);
806 v8::Local<v8::Array> resultArray = v8::Array::New(
816 v8::Local<v8::StackTrace> v8StackTrace) {
839 v8::debug::SetAsyncEventDelegate(m_isolate,
865 // document https://bit.ly/v8-cheaper-inspector-stack-traces for more
893 v8::HandleScope scope(m_isolate);
910 v8::debug::ClearStepping(m_isolate); // Cancel step into.
933 v8::debug::SetBreakOnNextFunctionCall(m_isolate);
946 v8::debug::ClearBreakOnNextFunctionCall(m_isolate);
974 v8::HandleScope scope(m_isolate);
1032 v8::debug::ClearStepping(m_isolate); // Cancel step into.
1043 v8::debug::SetBreakOnNextFunctionCall(m_isolate);
1051 v8::debug::ClearBreakOnNextFunctionCall(m_isolate);
1097 v8::HandleScope handleScope(m_isolate);
1121 v8::Local<v8::StackFrame> v8Frame) {
1165 bool V8Debugger::addInternalObject(v8::Local<v8::Context> context,
1166 v8::Local<v8::Object> object,