From f11d03cf0937789d8fd7ede4eb29d0a096f4ee5e Mon Sep 17 00:00:00 2001 From: yang-19970325 Date: Fri, 23 Sep 2022 15:15:26 +0800 Subject: [PATCH] add module scope in module compiler mode Issue: #I5S50B Signed-off-by: yang-19970325 Change-Id: Ie97faab016ec14105e373d0039250f1928ae1308 --- tooling/agent/debugger_impl.cpp | 18 ++++++++++++++++++ tooling/agent/debugger_impl.h | 1 + 2 files changed, 19 insertions(+) diff --git a/tooling/agent/debugger_impl.cpp b/tooling/agent/debugger_impl.cpp index 07bdf972..3d941e19 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 8877f0df..87b66c54 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); -- Gitee