@@ -2502,6 +2502,30 @@ bool SymbolFileDWARF::ResolveFunction(const DWARFDIE &orig_die,
2502
2502
return false ;
2503
2503
}
2504
2504
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
+
2505
2529
llvm::Expected<SymbolContext>
2506
2530
SymbolFileDWARF::ResolveFunctionCallLabel (const FunctionCallLabel &label) {
2507
2531
std::lock_guard<std::recursive_mutex> guard (GetModuleMutex ());
@@ -2514,37 +2538,19 @@ SymbolFileDWARF::ResolveFunctionCallLabel(const FunctionCallLabel &label) {
2514
2538
// Label was created using a declaration DIE. Need to fetch the definition
2515
2539
// to resolve the function call.
2516
2540
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" );
2534
2544
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);
2538
2546
}
2539
2547
2540
2548
SymbolContextList sc_list;
2541
2549
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" );
2544
2551
2545
2552
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" );
2548
2554
2549
2555
assert (sc_list.GetSize () == 1 );
2550
2556
0 commit comments