!4978 Fix breakpoints problem while Multiple modules. abc

Merge pull request !4978 from 杨阳/fix_breakpoint111
This commit is contained in:
openharmony_ci 2023-10-20 03:47:31 +00:00 committed by Gitee
commit 0c92778215
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
6 changed files with 18 additions and 15 deletions

View File

@ -822,10 +822,10 @@ bool DebuggerApi::IsExceptionCaught(const EcmaVM *ecmaVm)
return false;
}
DebugInfoExtractor *DebuggerApi::GetPatchExtractor(const EcmaVM *ecmaVm, const std::string &url)
std::vector<DebugInfoExtractor *> 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)

View File

@ -127,7 +127,7 @@ public:
std::string_view entryPoint);
// HotReload
static DebugInfoExtractor *GetPatchExtractor(const EcmaVM *ecmaVm, const std::string &url);
static std::vector<DebugInfoExtractor *> GetPatchExtractors(const EcmaVM *ecmaVm, const std::string &url);
static const JSPandaFile *GetBaseJSPandaFile(const EcmaVM *ecmaVm, const JSPandaFile *jsPandaFile);
static std::vector<void *> GetNativePointer(const EcmaVM *ecmaVm);

View File

@ -52,11 +52,12 @@ const JSPandaFile *HotReloadManager::GetBaseJSPandaFile(const JSPandaFile *jsPan
return iter->second;
}
DebugInfoExtractor *HotReloadManager::GetPatchExtractor(const std::string &url) const
std::vector<DebugInfoExtractor *> HotReloadManager::GetPatchExtractors(const std::string &url) const
{
std::vector<DebugInfoExtractor *> 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

View File

@ -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<DebugInfoExtractor *> GetPatchExtractors(const std::string &url) const;
const JSPandaFile *GetBaseJSPandaFile(const JSPandaFile *jsPandaFile) const;
private:
@ -39,7 +39,7 @@ private:
const EcmaVM *vm_;
CUnorderedMap<const JSPandaFile *, const JSPandaFile *> baseJSPandaFiles_ {};
CUnorderedMap<std::string, DebugInfoExtractor *> patchExtractors_ {};
CUnorderedMap<std::string, std::vector<DebugInfoExtractor *>> patchExtractors_ {};
};
} // namespace panda::ecmascript::tooling
#endif // ECMASCRIPT_DEBUGGER_HOT_RELOAD_MANAGER_H

View File

@ -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<ObjectRef> 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

View File

@ -93,7 +93,7 @@ public:
template<class Callback>
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<std::string> &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());