diff --git a/tooling/agent/debugger_impl.cpp b/tooling/agent/debugger_impl.cpp index 07bdf97212ee5fa27f318d71bb5a1454a1a2e902..3d941e195709dbb6752a49fed94e9f174d83723e 100644 --- a/tooling/agent/debugger_impl.cpp +++ b/tooling/agent/debugger_impl.cpp @@ -935,6 +935,7 @@ bool DebuggerImpl::GenerateCallFrame(CallFrame *callFrame, std::vector> scopeChain; scopeChain.emplace_back(GetLocalScopeChain(frameHandler, &thisObj)); + scopeChain.emplace_back(GetModuleScopeChain()); scopeChain.emplace_back(GetGlobalScopeChain()); callFrame->SetCallFrameId(callFrameId) @@ -997,6 +998,23 @@ std::unique_ptr DebuggerImpl::GetLocalScopeChain(const FrameHandler *fram return localScope; } +std::unique_ptr DebuggerImpl::GetModuleScopeChain() +{ + auto moduleScope = std::make_unique(); + + std::unique_ptr module = std::make_unique(); + Local moduleObj = ObjectRef::New(vm_); + module->SetType(ObjectType::Object) + .SetObjectId(runtime_->curObjectId_) + .SetClassName(ObjectClassName::Object) + .SetDescription(RemoteObject::ObjectDescription); + moduleScope->SetType(Scope::Type::Module()).SetObject(std::move(module)); + runtime_->properties_[runtime_->curObjectId_++] = Global(vm_, moduleObj); + JSThread *thread = vm_->GetJSThread(); + DebuggerApi::GetModuleVariables(vm_, moduleObj, thread); + return moduleScope; +} + void DebuggerImpl::GetLocalVariables(const FrameHandler *frameHandler, panda_file::File::EntityId methodId, const JSPandaFile *jsPandaFile, Local &thisVal, Local &localObj) { diff --git a/tooling/agent/debugger_impl.h b/tooling/agent/debugger_impl.h index 8877f0df11b2642226f92506c6e6869f6bd50185..87b66c5439db0bdc6ec8c57c15c87e992e3b3226 100644 --- a/tooling/agent/debugger_impl.h +++ b/tooling/agent/debugger_impl.h @@ -146,6 +146,7 @@ private: void SaveCallFrameHandler(const FrameHandler *frameHandler); std::unique_ptr GetLocalScopeChain(const FrameHandler *frameHandler, std::unique_ptr *thisObj); + std::unique_ptr GetModuleScopeChain(); std::unique_ptr GetGlobalScopeChain(); void GetLocalVariables(const FrameHandler *frameHandler, panda_file::File::EntityId methodId, const JSPandaFile *jsPandaFile, Local &thisVal, Local &localObj);