diff --git a/tooling/agent/debugger_impl.cpp b/tooling/agent/debugger_impl.cpp index e61c2816613e1c1fee7c0bd90736d20e0e7c2464..cd1108f6edc7422298aba565b045f9ce6fd6edf7 100644 --- a/tooling/agent/debugger_impl.cpp +++ b/tooling/agent/debugger_impl.cpp @@ -957,7 +957,7 @@ bool DebuggerImpl::GenerateCallFrame(CallFrame *callFrame, std::vector> scopeChain; scopeChain.emplace_back(GetLocalScopeChain(frameHandler, &thisObj)); - if (jsPandaFile != nullptr && !jsPandaFile->IsBundlePack()) { + if (jsPandaFile != nullptr && !jsPandaFile->IsBundlePack() && jsPandaFile->IsNewVersion()) { scopeChain.emplace_back(GetModuleScopeChain()); } scopeChain.emplace_back(GetGlobalScopeChain()); @@ -1037,7 +1037,9 @@ std::unique_ptr DebuggerImpl::GetModuleScopeChain() 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); + JSHandle currentModule = JSHandle(thread, DebuggerApi::GetCurrentModule(vm_)); + DebuggerApi::GetExportVariables(vm_, moduleObj, currentModule.GetTaggedValue()); + DebuggerApi::GetImportVariables(vm_, moduleObj, currentModule.GetTaggedValue()); return moduleScope; } diff --git a/tooling/backend/debugger_executor.cpp b/tooling/backend/debugger_executor.cpp index b1ae45a247dbc13853c53993cc1fd66439fa845c..d753f99d29958948a6d5090e88f36ad87c9fa5ba 100644 --- a/tooling/backend/debugger_executor.cpp +++ b/tooling/backend/debugger_executor.cpp @@ -205,7 +205,14 @@ Local DebuggerExecutor::GetModuleValue(const EcmaVM *vm, const Frame { Local result; std::string varName = name->ToString(); - result = DebuggerApi::GetModuleValue(vm, frameHandler, varName); + Method *method = DebuggerApi::GetMethod(frameHandler); + const JSPandaFile *jsPandaFile = method->GetJSPandaFile(); + if (jsPandaFile != nullptr && (jsPandaFile->IsBundlePack() || !jsPandaFile->IsNewVersion())) { + return result; + } + + JSTaggedValue currentModule = DebuggerApi::GetCurrentModule(vm); + result = DebuggerApi::GetModuleValue(vm, currentModule, varName); return result; } @@ -213,7 +220,14 @@ bool DebuggerExecutor::SetModuleValue(const EcmaVM *vm, const FrameHandler *fram Local name, Local value) { std::string varName = name->ToString(); - DebuggerApi::SetModuleValue(vm, frameHandler, varName, value); + Method *method = DebuggerApi::GetMethod(frameHandler); + const JSPandaFile *jsPandaFile = method->GetJSPandaFile(); + if (jsPandaFile != nullptr && (jsPandaFile->IsBundlePack() || !jsPandaFile->IsNewVersion())) { + return false; + } + + JSTaggedValue currentModule = DebuggerApi::GetCurrentModule(vm); + DebuggerApi::SetModuleValue(vm, currentModule, varName, value); return true; } } // namespace panda::ecmascript::tooling diff --git a/tooling/test/testcases/js_module_variable_test.h b/tooling/test/testcases/js_module_variable_test.h index 45be22597e46923d901651e826ab49ddfcd2090d..7243cbe2a11934b0c2d99f264e8e5cd6f1035bbf 100644 --- a/tooling/test/testcases/js_module_variable_test.h +++ b/tooling/test/testcases/js_module_variable_test.h @@ -111,7 +111,7 @@ private: auto frame = paused->GetCallFrames()->at(0).get(); ASSERT_EQ(frame->GetFunctionName(), "foo"); auto scopes = frame->GetScopeChain(); - ASSERT_EQ(scopes->size(), 3U); // 2: contain local and global + ASSERT_EQ(scopes->size(), 3U); // 3: contain local module and global for (uint32_t i = 0; i < scopes->size(); i++) { auto scope = scopes->at(i).get(); if (scope->GetType() != Scope::Type::Module()) {