@@ -2483,6 +2483,30 @@ bool SymbolFileDWARF::ResolveFunction(const DWARFDIE &orig_die,
24832483 return false ;
24842484}
24852485
2486+ DWARFDIE
2487+ SymbolFileDWARF::FindFunctionDefinition (const FunctionCallLabel &label) {
2488+ DWARFDIE definition;
2489+ Module::LookupInfo info (ConstString (label.lookup_name ),
2490+ lldb::eFunctionNameTypeFull,
2491+ lldb::eLanguageTypeUnknown);
2492+
2493+ m_index->GetFunctions (info, *this , {}, [&](DWARFDIE entry) {
2494+ if (entry.GetAttributeValueAsUnsigned (llvm::dwarf::DW_AT_declaration, 0 ))
2495+ return IterationAction::Continue;
2496+
2497+ // We don't check whether the specification DIE for this function
2498+ // corresponds to the declaration DIE because the declaration might be in
2499+ // a type-unit but the definition in the compile-unit (and it's
2500+ // specifcation would point to the declaration in the compile-unit). We
2501+ // rely on the mangled name within the module to be enough to find us the
2502+ // unique definition.
2503+ definition = entry;
2504+ return IterationAction::Stop;
2505+ });
2506+
2507+ return definition;
2508+ }
2509+
24862510llvm::Expected<SymbolContext>
24872511SymbolFileDWARF::ResolveFunctionCallLabel (const FunctionCallLabel &label) {
24882512 std::lock_guard<std::recursive_mutex> guard (GetModuleMutex ());
@@ -2495,37 +2519,19 @@ SymbolFileDWARF::ResolveFunctionCallLabel(const FunctionCallLabel &label) {
24952519 // Label was created using a declaration DIE. Need to fetch the definition
24962520 // to resolve the function call.
24972521 if (die.GetAttributeValueAsUnsigned (llvm::dwarf::DW_AT_declaration, 0 )) {
2498- Module::LookupInfo info (ConstString (label.lookup_name ),
2499- lldb::eFunctionNameTypeFull,
2500- lldb::eLanguageTypeUnknown);
2501-
2502- m_index->GetFunctions (info, *this , {}, [&](DWARFDIE entry) {
2503- if (entry.GetAttributeValueAsUnsigned (llvm::dwarf::DW_AT_declaration, 0 ))
2504- return IterationAction::Continue;
2505-
2506- // We don't check whether the specification DIE for this function
2507- // corresponds to the declaration DIE because the declaration might be in
2508- // a type-unit but the definition in the compile-unit (and it's
2509- // specifcation would point to the declaration in the compile-unit). We
2510- // rely on the mangled name within the module to be enough to find us the
2511- // unique definition.
2512- die = entry;
2513- return IterationAction::Stop;
2514- });
2522+ auto definition = FindFunctionDefinition (label);
2523+ if (!definition)
2524+ return llvm::createStringError (" failed to find definition DIE" );
25152525
2516- if (die.GetAttributeValueAsUnsigned (llvm::dwarf::DW_AT_declaration, 0 ))
2517- return llvm::createStringError (
2518- llvm::formatv (" failed to find definition DIE for {0}" , label));
2526+ die = std::move (definition);
25192527 }
25202528
25212529 SymbolContextList sc_list;
25222530 if (!ResolveFunction (die, /* include_inlines=*/ false , sc_list))
2523- return llvm::createStringError (
2524- llvm::formatv (" failed to resolve function for {0}" , label));
2531+ return llvm::createStringError (" failed to resolve function" );
25252532
25262533 if (sc_list.IsEmpty ())
2527- return llvm::createStringError (
2528- llvm::formatv (" failed to find function for {0}" , label));
2534+ return llvm::createStringError (" failed to find function" );
25292535
25302536 assert (sc_list.GetSize () == 1 );
25312537
0 commit comments