Skip to content

Commit 0f39ba7

Browse files
author
git apple-llvm automerger
committed
Merge commit 'ef30dd34e9ac' from llvm.org/main into next
2 parents bafcae3 + ef30dd3 commit 0f39ba7

File tree

3 files changed

+38
-25
lines changed

3 files changed

+38
-25
lines changed

lldb/source/Expression/IRExecutionUnit.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -838,7 +838,7 @@ ResolveFunctionCallLabel(const FunctionCallLabel &label,
838838
auto sc_or_err = symbol_file->ResolveFunctionCallLabel(label);
839839
if (!sc_or_err)
840840
return llvm::joinErrors(
841-
llvm::createStringError("failed to resolve function by UID"),
841+
llvm::createStringError("failed to resolve function by UID:"),
842842
sc_or_err.takeError());
843843

844844
SymbolContextList sc_list;

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

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2502,6 +2502,30 @@ bool SymbolFileDWARF::ResolveFunction(const DWARFDIE &orig_die,
25022502
return false;
25032503
}
25042504

2505+
DWARFDIE
2506+
SymbolFileDWARF::FindFunctionDefinition(const FunctionCallLabel &label) {
2507+
DWARFDIE definition;
2508+
Module::LookupInfo info(ConstString(label.lookup_name),
2509+
lldb::eFunctionNameTypeFull,
2510+
lldb::eLanguageTypeUnknown);
2511+
2512+
m_index->GetFunctions(info, *this, {}, [&](DWARFDIE entry) {
2513+
if (entry.GetAttributeValueAsUnsigned(llvm::dwarf::DW_AT_declaration, 0))
2514+
return IterationAction::Continue;
2515+
2516+
// We don't check whether the specification DIE for this function
2517+
// corresponds to the declaration DIE because the declaration might be in
2518+
// a type-unit but the definition in the compile-unit (and it's
2519+
// specifcation would point to the declaration in the compile-unit). We
2520+
// rely on the mangled name within the module to be enough to find us the
2521+
// unique definition.
2522+
definition = entry;
2523+
return IterationAction::Stop;
2524+
});
2525+
2526+
return definition;
2527+
}
2528+
25052529
llvm::Expected<SymbolContext>
25062530
SymbolFileDWARF::ResolveFunctionCallLabel(const FunctionCallLabel &label) {
25072531
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
@@ -2514,37 +2538,19 @@ SymbolFileDWARF::ResolveFunctionCallLabel(const FunctionCallLabel &label) {
25142538
// Label was created using a declaration DIE. Need to fetch the definition
25152539
// to resolve the function call.
25162540
if (die.GetAttributeValueAsUnsigned(llvm::dwarf::DW_AT_declaration, 0)) {
2517-
Module::LookupInfo info(ConstString(label.lookup_name),
2518-
lldb::eFunctionNameTypeFull,
2519-
lldb::eLanguageTypeUnknown);
2520-
2521-
m_index->GetFunctions(info, *this, {}, [&](DWARFDIE entry) {
2522-
if (entry.GetAttributeValueAsUnsigned(llvm::dwarf::DW_AT_declaration, 0))
2523-
return IterationAction::Continue;
2524-
2525-
// We don't check whether the specification DIE for this function
2526-
// corresponds to the declaration DIE because the declaration might be in
2527-
// a type-unit but the definition in the compile-unit (and it's
2528-
// specifcation would point to the declaration in the compile-unit). We
2529-
// rely on the mangled name within the module to be enough to find us the
2530-
// unique definition.
2531-
die = entry;
2532-
return IterationAction::Stop;
2533-
});
2541+
auto definition = FindFunctionDefinition(label);
2542+
if (!definition)
2543+
return llvm::createStringError("failed to find definition DIE");
25342544

2535-
if (die.GetAttributeValueAsUnsigned(llvm::dwarf::DW_AT_declaration, 0))
2536-
return llvm::createStringError(
2537-
llvm::formatv("failed to find definition DIE for {0}", label));
2545+
die = std::move(definition);
25382546
}
25392547

25402548
SymbolContextList sc_list;
25412549
if (!ResolveFunction(die, /*include_inlines=*/false, sc_list))
2542-
return llvm::createStringError(
2543-
llvm::formatv("failed to resolve function for {0}", label));
2550+
return llvm::createStringError("failed to resolve function");
25442551

25452552
if (sc_list.IsEmpty())
2546-
return llvm::createStringError(
2547-
llvm::formatv("failed to find function for {0}", label));
2553+
return llvm::createStringError("failed to find function");
25482554

25492555
assert(sc_list.GetSize() == 1);
25502556

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,13 @@ class SymbolFileDWARF : public SymbolFileCommon {
393393
/// Returns the DWARFIndex for this symbol, if it exists.
394394
DWARFIndex *getIndex() { return m_index.get(); }
395395

396+
private:
397+
/// Find the definition DIE for the specified \c label in this
398+
/// SymbolFile.
399+
///
400+
/// \returns A valid definition DIE on success.
401+
DWARFDIE FindFunctionDefinition(const FunctionCallLabel &label);
402+
396403
protected:
397404
SymbolFileDWARF(const SymbolFileDWARF &) = delete;
398405
const SymbolFileDWARF &operator=(const SymbolFileDWARF &) = delete;

0 commit comments

Comments
 (0)