Skip to content

Commit 6973ac2

Browse files
committed
fixup! implement SymbolFileDWARFDebugMap::ResolveFunctionCallLabel
1 parent 5789808 commit 6973ac2

File tree

6 files changed

+54
-8
lines changed

6 files changed

+54
-8
lines changed

lldb/include/lldb/Core/ModuleList.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,14 @@ class ModuleList {
352352
// UUID values is very efficient and accurate.
353353
lldb::ModuleSP FindModule(const UUID &uuid) const;
354354

355+
/// Find a module by LLDB-specific unique identifier.
356+
///
357+
/// \param[in] uid The UID of the module assigned to it on construction.
358+
///
359+
/// \returns ModuleSP of module with \c uid. Returns nullptr if no such
360+
/// module could be found.
361+
lldb::ModuleSP FindModule(lldb::user_id_t uid) const;
362+
355363
/// Finds the first module whose file specification matches \a module_spec.
356364
lldb::ModuleSP FindFirstModule(const ModuleSpec &module_spec) const;
357365

lldb/source/Core/ModuleList.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,20 @@ ModuleSP ModuleList::FindModule(const UUID &uuid) const {
584584
return module_sp;
585585
}
586586

587+
ModuleSP ModuleList::FindModule(lldb::user_id_t uid) const {
588+
ModuleSP module_sp;
589+
ForEach([&](const ModuleSP &m) {
590+
if (m->GetID() == uid) {
591+
module_sp = m;
592+
return IterationAction::Stop;
593+
}
594+
595+
return IterationAction::Continue;
596+
});
597+
598+
return module_sp;
599+
}
600+
587601
void ModuleList::FindTypes(Module *search_first, const TypeQuery &query,
588602
TypeResults &results) const {
589603
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);

lldb/source/Expression/IRExecutionUnit.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,7 @@ ResolveFunctionCallLabel(llvm::StringRef name,
827827

828828
const auto &label = *label_or_err;
829829

830-
auto module_sp = FindDebugModule(label.module_id, sc.target_sp->GetImages());
830+
auto module_sp = sc.target_sp->GetImages().FindModule(label.module_id);
831831
if (!module_sp)
832832
return llvm::createStringError(
833833
llvm::formatv("failed to find module by UID {0}", label.module_id));

lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -259,15 +259,25 @@ static std::optional<std::string> MakeLLDBFuncAsmLabel(const DWARFDIE &die) {
259259
if (!dwarf)
260260
return std::nullopt;
261261

262-
ObjectFile *main_obj = dwarf->GetMainObjectFile();
263-
if (!main_obj)
264-
return std::nullopt;
262+
auto get_module_id = [&](SymbolFile *sym) {
263+
if (!sym)
264+
return LLDB_INVALID_UID;
265265

266-
auto module_sp = main_obj->GetModule();
267-
if (!module_sp)
268-
return std::nullopt;
266+
auto *obj = sym->GetMainObjectFile();
267+
if (!obj)
268+
return LLDB_INVALID_UID;
269+
270+
auto module_sp = obj->GetModule();
271+
if (!module_sp)
272+
return LLDB_INVALID_UID;
273+
274+
return module_sp->GetID();
275+
};
276+
277+
lldb::user_id_t module_id = get_module_id(dwarf->GetDebugMapSymfile());
278+
if (module_id == LLDB_INVALID_UID)
279+
module_id = get_module_id(dwarf);
269280

270-
lldb::user_id_t module_id = module_sp->GetID();
271281
if (module_id == LLDB_INVALID_UID)
272282
return std::nullopt;
273283

lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1602,3 +1602,14 @@ void SymbolFileDWARFDebugMap::GetCompileOptions(
16021602
return IterationAction::Continue;
16031603
});
16041604
}
1605+
1606+
llvm::Error SymbolFileDWARFDebugMap::ResolveFunctionCallLabel(
1607+
SymbolContextList &sc_list, const FunctionCallLabel &label) {
1608+
const uint64_t oso_idx = GetOSOIndexFromUserID(label.symbol_id);
1609+
SymbolFileDWARF *oso_dwarf = GetSymbolFileByOSOIndex(oso_idx);
1610+
if (!oso_dwarf)
1611+
return llvm::createStringError(llvm::formatv(
1612+
"couldn't find symbol file for {0} in debug-map.", label));
1613+
1614+
return oso_dwarf->ResolveFunctionCallLabel(sc_list, label);
1615+
}

lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,9 @@ class SymbolFileDWARFDebugMap : public SymbolFileCommon {
144144
void
145145
GetCompileOptions(std::unordered_map<lldb::CompUnitSP, Args> &args) override;
146146

147+
llvm::Error ResolveFunctionCallLabel(SymbolContextList &sc_list,
148+
const FunctionCallLabel &label) override;
149+
147150
protected:
148151
enum { kHaveInitializedOSOs = (1 << 0), kNumFlags };
149152

0 commit comments

Comments
 (0)