@@ -806,27 +806,15 @@ static lldb::ModuleSP FindDebugModule(lldb::user_id_t uid,
806
806
807
807
// / Returns address of the function referred to by the special function call
808
808
// / label \c label.
809
- // /
810
- // / \param[in] label Function call label encoding the unique location of the
811
- // / function to look up.
812
809
static llvm::Expected<lldb::addr_t >
813
- ResolveFunctionCallLabel (llvm::StringRef name ,
810
+ ResolveFunctionCallLabel (const FunctionCallLabel &label ,
814
811
const lldb_private::SymbolContext &sc,
815
812
bool &symbol_was_missing_weak) {
816
813
symbol_was_missing_weak = false ;
817
814
818
815
if (!sc.target_sp )
819
816
return llvm::createStringError (" target not available." );
820
817
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
-
830
818
auto module_sp = sc.target_sp ->GetImages ().FindModule (label.module_id );
831
819
if (!module_sp)
832
820
return llvm::createStringError (
@@ -983,19 +971,30 @@ lldb::addr_t IRExecutionUnit::FindInUserDefinedSymbols(
983
971
lldb::addr_t IRExecutionUnit::FindSymbol (lldb_private::ConstString name,
984
972
bool &missing_weak) {
985
973
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)) {
988
984
return *addr_or_err;
989
985
} else {
990
986
LLDB_LOG_ERROR (GetLog (LLDBLog::Expressions), addr_or_err.takeError (),
991
987
" Failed to resolve function call label '{1}': {0}" ,
992
988
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 );
994
995
}
995
996
}
996
997
997
- // TODO: do we still need the following lookups?
998
-
999
998
std::vector<ConstString> candidate_C_names;
1000
999
std::vector<ConstString> candidate_CPlusPlus_names;
1001
1000
0 commit comments