diff --git a/tooling/agent/debugger_impl.cpp b/tooling/agent/debugger_impl.cpp index a72cde9cdec7fa29c2f6d1c694e474bb2cb42239..06da8c3eea52dba5d9b5bef64b7516fe604446be 100644 --- a/tooling/agent/debugger_impl.cpp +++ b/tooling/agent/debugger_impl.cpp @@ -70,9 +70,9 @@ bool DebuggerImpl::NotifyScriptParsed(ScriptId scriptId, const std::string &file } #endif - const JSPandaFile *jsPandaFile = nullptr; + std::shared_ptr jsPandaFile; JSPandaFileManager::GetInstance()->EnumerateJSPandaFiles([&jsPandaFile, &fileName]( - const panda::ecmascript::JSPandaFile *pandaFile) { + const std::shared_ptr &pandaFile) { if (fileName == pandaFile->GetJSPandaFileDesc().c_str()) { jsPandaFile = pandaFile; return false; @@ -152,7 +152,7 @@ bool DebuggerImpl::NotifySingleStep(const JSPtLocation &location) bool DebuggerImpl::IsSkipLine(const JSPtLocation &location) { DebugInfoExtractor *extractor = nullptr; - const auto *jsPandaFile = location.GetJsPandaFile(); + std::shared_ptr jsPandaFile = location.GetJsPandaFile(); auto scriptFunc = [this, &extractor, jsPandaFile](PtScript *) -> bool { extractor = GetExtractor(jsPandaFile); return true; @@ -881,7 +881,7 @@ std::string DebuggerImpl::Trim(const std::string &str) return ret; } -DebugInfoExtractor *DebuggerImpl::GetExtractor(const JSPandaFile *jsPandaFile) +DebugInfoExtractor *DebuggerImpl::GetExtractor(const std::shared_ptr &jsPandaFile) { return JSPandaFileManager::GetInstance()->GetJSPtExtractor(jsPandaFile); } @@ -942,7 +942,7 @@ bool DebuggerImpl::GenerateCallFrame(CallFrame *callFrame, } Method *method = DebuggerApi::GetMethod(frameHandler); auto methodId = method->GetMethodId(); - const JSPandaFile *jsPandaFile = method->GetJSPandaFile(); + std::shared_ptr jsPandaFile = method->GetJSPandaFile(); DebugInfoExtractor *extractor = GetExtractor(jsPandaFile); if (extractor == nullptr) { LOG_DEBUGGER(ERROR) << "GenerateCallFrame: extractor is null"; @@ -1008,7 +1008,7 @@ std::unique_ptr DebuggerImpl::GetLocalScopeChain(const FrameHandler *fram Method *method = DebuggerApi::GetMethod(frameHandler); auto methodId = method->GetMethodId(); - const JSPandaFile *jsPandaFile = method->GetJSPandaFile(); + std::shared_ptr jsPandaFile = method->GetJSPandaFile(); DebugInfoExtractor *extractor = GetExtractor(jsPandaFile); if (extractor == nullptr) { LOG_DEBUGGER(ERROR) << "GetScopeChain: extractor is null"; @@ -1075,7 +1075,7 @@ std::unique_ptr DebuggerImpl::GetModuleScopeChain() } void DebuggerImpl::GetLocalVariables(const FrameHandler *frameHandler, panda_file::File::EntityId methodId, - const JSPandaFile *jsPandaFile, Local &thisVal, Local &localObj) + const std::shared_ptr &jsPandaFile, Local &thisVal, Local &localObj) { auto *extractor = GetExtractor(jsPandaFile); Local value = JSValueRef::Undefined(vm_); diff --git a/tooling/agent/debugger_impl.h b/tooling/agent/debugger_impl.h index 337f3034ae853be3765de4e75cbb9e536f022113..86880f82db121a98691b26000d99b4b35a948f3d 100644 --- a/tooling/agent/debugger_impl.h +++ b/tooling/agent/debugger_impl.h @@ -138,7 +138,7 @@ private: NO_MOVE_SEMANTIC(DebuggerImpl); std::string Trim(const std::string &str); - DebugInfoExtractor *GetExtractor(const JSPandaFile *jsPandaFile); + DebugInfoExtractor *GetExtractor(const std::shared_ptr &jsPandaFile); DebugInfoExtractor *GetExtractor(const std::string &url); std::optional CmptEvaluateValue(CallFrameId callFrameId, const std::string &expression, std::unique_ptr *result); @@ -149,7 +149,7 @@ private: 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); + const std::shared_ptr &jsPandaFile, Local &thisVal, Local &localObj); void GetClosureVariables(const FrameHandler *frameHandler, Local &thisVal, Local &localObj); void CleanUpOnPaused(); diff --git a/tooling/backend/debugger_executor.cpp b/tooling/backend/debugger_executor.cpp index d56afec093872a6cb714bf0bab17c6c1778bad4e..791b76b91c31dd4bba0a50a39519680d61574911 100644 --- a/tooling/backend/debugger_executor.cpp +++ b/tooling/backend/debugger_executor.cpp @@ -206,7 +206,7 @@ Local DebuggerExecutor::GetModuleValue(const EcmaVM *vm, const Frame Local result; std::string varName = name->ToString(); Method *method = DebuggerApi::GetMethod(frameHandler); - const JSPandaFile *jsPandaFile = method->GetJSPandaFile(); + std::shared_ptr jsPandaFile = method->GetJSPandaFile(); if (jsPandaFile != nullptr && (jsPandaFile->IsBundlePack() || !jsPandaFile->IsNewVersion())) { return result; } @@ -221,7 +221,7 @@ bool DebuggerExecutor::SetModuleValue(const EcmaVM *vm, const FrameHandler *fram { std::string varName = name->ToString(); Method *method = DebuggerApi::GetMethod(frameHandler); - const JSPandaFile *jsPandaFile = method->GetJSPandaFile(); + std::shared_ptr jsPandaFile = method->GetJSPandaFile(); if (jsPandaFile != nullptr && (jsPandaFile->IsBundlePack() || !jsPandaFile->IsNewVersion())) { return false; } diff --git a/tooling/test/utils/test_extractor.cpp b/tooling/test/utils/test_extractor.cpp index 4477c17d5a935cc419f4cd733b515aa07389358b..bd8f11cf8ca339a3a05eaf67fd38b4bd46c72bb3 100644 --- a/tooling/test/utils/test_extractor.cpp +++ b/tooling/test/utils/test_extractor.cpp @@ -39,7 +39,8 @@ std::pair TestExtractor::GetBreakpointAddress(const SourceLo return {retId, retOffset}; } -SourceLocation TestExtractor::GetSourceLocation(const JSPandaFile *file, EntityId methodId, uint32_t bytecodeOffset) +SourceLocation TestExtractor::GetSourceLocation(const std::shared_ptr &file, EntityId methodId, + uint32_t bytecodeOffset) { SourceLocation location {file, 0, 0}; auto callbackLineFunc = [&location](int32_t line) -> bool { diff --git a/tooling/test/utils/test_extractor.h b/tooling/test/utils/test_extractor.h index 5fc1110d4ccc070fc6bffd4f59aeb5d42fd4351a..ce36f62e8548a094892415411e56bb3d545be863 100644 --- a/tooling/test/utils/test_extractor.h +++ b/tooling/test/utils/test_extractor.h @@ -23,7 +23,7 @@ using EntityId = panda_file::File::EntityId; // NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init) struct SourceLocation { - const JSPandaFile *file; + std::shared_ptr file; int32_t line; int32_t column; @@ -35,12 +35,13 @@ struct SourceLocation { class TestExtractor : public DebugInfoExtractor { public: - explicit TestExtractor(const JSPandaFile *pandaFile) : DebugInfoExtractor(pandaFile) {} + explicit TestExtractor(const std::shared_ptr &pandaFile) : DebugInfoExtractor(pandaFile) {} ~TestExtractor() = default; std::pair GetBreakpointAddress(const SourceLocation &sourceLocation); - SourceLocation GetSourceLocation(const JSPandaFile *file, EntityId methodId, uint32_t bytecodeOffset); + SourceLocation GetSourceLocation(const std::shared_ptr &file, EntityId methodId, + uint32_t bytecodeOffset); }; } // namespace panda::ecmascript::tooling::test