From 44602d28f8a7b2254dcd3f227876588342cf0a66 Mon Sep 17 00:00:00 2001 From: yang-19970325 Date: Wed, 11 Oct 2023 15:03:05 +0800 Subject: [PATCH] Signed-off-by: yang-19970325 Change-Id: Iab6a3f2865453282ef63daf7f3879ab4271c9885 Change-Id: Ie64362dee9bd73d1a4000e3b101e0ab8a574ea17 --- ecmascript/debugger/debugger_api.cpp | 4 ++-- ecmascript/debugger/debugger_api.h | 2 +- ecmascript/debugger/hot_reload_manager.cpp | 7 ++++--- ecmascript/debugger/hot_reload_manager.h | 4 ++-- ecmascript/debugger/tests/hot_reload_manager_test.cpp | 6 +++--- ecmascript/jspandafile/debug_info_extractor.h | 10 ++++++---- 6 files changed, 18 insertions(+), 15 deletions(-) diff --git a/ecmascript/debugger/debugger_api.cpp b/ecmascript/debugger/debugger_api.cpp index 185d2ab0e7..f944febc7f 100644 --- a/ecmascript/debugger/debugger_api.cpp +++ b/ecmascript/debugger/debugger_api.cpp @@ -822,10 +822,10 @@ bool DebuggerApi::IsExceptionCaught(const EcmaVM *ecmaVm) return false; } -DebugInfoExtractor *DebuggerApi::GetPatchExtractor(const EcmaVM *ecmaVm, const std::string &url) +std::vector DebuggerApi::GetPatchExtractors(const EcmaVM *ecmaVm, const std::string &url) { const auto *hotReloadManager = ecmaVm->GetJsDebuggerManager()->GetHotReloadManager(); - return hotReloadManager->GetPatchExtractor(url); + return hotReloadManager->GetPatchExtractors(url); } const JSPandaFile *DebuggerApi::GetBaseJSPandaFile(const EcmaVM *ecmaVm, const JSPandaFile *jsPandaFile) diff --git a/ecmascript/debugger/debugger_api.h b/ecmascript/debugger/debugger_api.h index f2e7807e33..6f3a3f70f4 100644 --- a/ecmascript/debugger/debugger_api.h +++ b/ecmascript/debugger/debugger_api.h @@ -127,7 +127,7 @@ public: std::string_view entryPoint); // HotReload - static DebugInfoExtractor *GetPatchExtractor(const EcmaVM *ecmaVm, const std::string &url); + static std::vector GetPatchExtractors(const EcmaVM *ecmaVm, const std::string &url); static const JSPandaFile *GetBaseJSPandaFile(const EcmaVM *ecmaVm, const JSPandaFile *jsPandaFile); static std::vector GetNativePointer(const EcmaVM *ecmaVm); diff --git a/ecmascript/debugger/hot_reload_manager.cpp b/ecmascript/debugger/hot_reload_manager.cpp index 29f29def9e..a446356019 100644 --- a/ecmascript/debugger/hot_reload_manager.cpp +++ b/ecmascript/debugger/hot_reload_manager.cpp @@ -52,11 +52,12 @@ const JSPandaFile *HotReloadManager::GetBaseJSPandaFile(const JSPandaFile *jsPan return iter->second; } -DebugInfoExtractor *HotReloadManager::GetPatchExtractor(const std::string &url) const +std::vector HotReloadManager::GetPatchExtractors(const std::string &url) const { + std::vector extractors; auto iter = patchExtractors_.find(url); if (iter == patchExtractors_.end()) { - return nullptr; + return extractors; } return iter->second; } @@ -78,7 +79,7 @@ void HotReloadManager::ExtractPatch(const JSPandaFile *jsPandaFile) continue; } notificationMgr->LoadModuleEvent(jsPandaFile->GetJSPandaFileDesc(), recordName); - patchExtractors_[url] = patchExtractor; + patchExtractors_[url].emplace_back(patchExtractor); } } } // namespace panda::ecmascript::tooling diff --git a/ecmascript/debugger/hot_reload_manager.h b/ecmascript/debugger/hot_reload_manager.h index 146f39b707..4764ffd78e 100644 --- a/ecmascript/debugger/hot_reload_manager.h +++ b/ecmascript/debugger/hot_reload_manager.h @@ -31,7 +31,7 @@ public: void NotifyPatchLoaded(const JSPandaFile *baseFile, const JSPandaFile *patchFile); void NotifyPatchUnloaded(const JSPandaFile *patchFile); - DebugInfoExtractor *GetPatchExtractor(const std::string &url) const; + std::vector GetPatchExtractors(const std::string &url) const; const JSPandaFile *GetBaseJSPandaFile(const JSPandaFile *jsPandaFile) const; private: @@ -39,7 +39,7 @@ private: const EcmaVM *vm_; CUnorderedMap baseJSPandaFiles_ {}; - CUnorderedMap patchExtractors_ {}; + CUnorderedMap> patchExtractors_ {}; }; } // namespace panda::ecmascript::tooling #endif // ECMASCRIPT_DEBUGGER_HOT_RELOAD_MANAGER_H diff --git a/ecmascript/debugger/tests/hot_reload_manager_test.cpp b/ecmascript/debugger/tests/hot_reload_manager_test.cpp index 032bc872cc..2008557074 100644 --- a/ecmascript/debugger/tests/hot_reload_manager_test.cpp +++ b/ecmascript/debugger/tests/hot_reload_manager_test.cpp @@ -82,8 +82,8 @@ HWTEST_F_L0(HotReloadManagerTest, LoadAndUnload) EXPECT_TRUE(patchFile != nullptr); EXPECT_TRUE(hotReloadManager->GetBaseJSPandaFile(patchFile.get()) == baseFile.get()); - [[maybe_unused]] auto *patchExtractor = hotReloadManager->GetPatchExtractor(sourceFile); - EXPECT_TRUE(patchExtractor != nullptr); + [[maybe_unused]] auto patchExtractors = hotReloadManager->GetPatchExtractors(sourceFile); + EXPECT_TRUE(!patchExtractors.empty()); Local exception = JSNApi::GetAndClearUncaughtException(ecmaVm); result = JSNApi::IsQuickFixCausedException(ecmaVm, exception, patchFileName); @@ -92,6 +92,6 @@ HWTEST_F_L0(HotReloadManagerTest, LoadAndUnload) res = JSNApi::UnloadPatch(ecmaVm, patchFileName); EXPECT_TRUE(res == PatchErrorCode::SUCCESS); EXPECT_TRUE(hotReloadManager->GetBaseJSPandaFile(patchFile.get()) != baseFile.get()); - EXPECT_TRUE(hotReloadManager->GetPatchExtractor(sourceFile) == nullptr); + EXPECT_TRUE(hotReloadManager->GetPatchExtractors(sourceFile).empty()); } } // namespace panda::test diff --git a/ecmascript/jspandafile/debug_info_extractor.h b/ecmascript/jspandafile/debug_info_extractor.h index c70ae26c3f..2594fd3e00 100644 --- a/ecmascript/jspandafile/debug_info_extractor.h +++ b/ecmascript/jspandafile/debug_info_extractor.h @@ -93,7 +93,7 @@ public: template bool MatchWithLocation(const Callback &cb, int32_t line, int32_t column, - const std::string &url, const std::string &debugRecordName) + const std::string &url, const std::unordered_set &debugRecordName) { if (line == SPECIAL_LINE_MARK) { return false; @@ -110,9 +110,11 @@ public: panda_file::ClassDataAccessor cda(pandaFile, id); CString recordName = JSPandaFile::ParseEntryPoint(utf::Mutf8AsCString(cda.GetDescriptor())); // the recordName for testcases is empty - if (!debugRecordName.empty() && recordName != debugRecordName.c_str() - && debugRecordName != JSPandaFile::ENTRY_MAIN_FUNCTION) { - continue; + if (!debugRecordName.empty()) { + auto iter = debugRecordName.find(std::string(recordName)); + if (iter == debugRecordName.end()) { + continue; + } } cda.EnumerateMethods([&](panda_file::MethodDataAccessor &mda) { methodIds.push_back(mda.GetMethodId());