Skip to content

Commit ddf62e9

Browse files
committed
fixup! fallback to name lookup if definition is in separate module from declaration
1 parent 946a4c2 commit ddf62e9

File tree

1 file changed

+17
-18
lines changed

1 file changed

+17
-18
lines changed

lldb/source/Expression/IRExecutionUnit.cpp

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -806,27 +806,15 @@ static lldb::ModuleSP FindDebugModule(lldb::user_id_t uid,
806806

807807
/// Returns address of the function referred to by the special function call
808808
/// label \c label.
809-
///
810-
/// \param[in] label Function call label encoding the unique location of the
811-
/// function to look up.
812809
static llvm::Expected<lldb::addr_t>
813-
ResolveFunctionCallLabel(llvm::StringRef name,
810+
ResolveFunctionCallLabel(const FunctionCallLabel &label,
814811
const lldb_private::SymbolContext &sc,
815812
bool &symbol_was_missing_weak) {
816813
symbol_was_missing_weak = false;
817814

818815
if (!sc.target_sp)
819816
return llvm::createStringError("target not available.");
820817

821-
auto label_or_err = FunctionCallLabel::fromString(name);
822-
if (!label_or_err)
823-
return llvm::joinErrors(
824-
llvm::createStringError("failed to create FunctionCallLabel from: %s",
825-
name.data()),
826-
label_or_err.takeError());
827-
828-
const auto &label = *label_or_err;
829-
830818
auto module_sp = sc.target_sp->GetImages().FindModule(label.module_id);
831819
if (!module_sp)
832820
return llvm::createStringError(
@@ -983,19 +971,30 @@ lldb::addr_t IRExecutionUnit::FindInUserDefinedSymbols(
983971
lldb::addr_t IRExecutionUnit::FindSymbol(lldb_private::ConstString name,
984972
bool &missing_weak) {
985973
if (name.GetStringRef().starts_with(FunctionCallLabelPrefix)) {
986-
if (auto addr_or_err = ResolveFunctionCallLabel(name.GetStringRef(),
987-
m_sym_ctx, missing_weak)) {
974+
auto label_or_err = FunctionCallLabel::fromString(name);
975+
if (!label_or_err) {
976+
LLDB_LOG_ERROR(GetLog(LLDBLog::Expressions), label_or_err.takeError(),
977+
"failed to create FunctionCallLabel from '{0}': {1}",
978+
name.GetStringRef());
979+
return LLDB_INVALID_ADDRESS;
980+
}
981+
982+
if (auto addr_or_err =
983+
ResolveFunctionCallLabel(*label_or_err, m_sym_ctx, missing_weak)) {
988984
return *addr_or_err;
989985
} else {
990986
LLDB_LOG_ERROR(GetLog(LLDBLog::Expressions), addr_or_err.takeError(),
991987
"Failed to resolve function call label '{1}': {0}",
992988
name.GetStringRef());
993-
return LLDB_INVALID_ADDRESS;
989+
990+
// Fall back to lookup by name despite error in resolving the label.
991+
// May happen in practice if the definition of a function lives in
992+
// a different lldb_private::Module than it's declaration. Meaning
993+
// we couldn't pin-point it using the information encoded in the label.
994+
name.SetString(label_or_err->lookup_name);
994995
}
995996
}
996997

997-
// TODO: do we still need the following lookups?
998-
999998
std::vector<ConstString> candidate_C_names;
1000999
std::vector<ConstString> candidate_CPlusPlus_names;
10011000

0 commit comments

Comments
 (0)