@@ -2483,6 +2483,30 @@ bool SymbolFileDWARF::ResolveFunction(const DWARFDIE &orig_die,
2483
2483
return false ;
2484
2484
}
2485
2485
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
+
2486
2510
llvm::Expected<SymbolContext>
2487
2511
SymbolFileDWARF::ResolveFunctionCallLabel (const FunctionCallLabel &label) {
2488
2512
std::lock_guard<std::recursive_mutex> guard (GetModuleMutex ());
@@ -2495,37 +2519,19 @@ SymbolFileDWARF::ResolveFunctionCallLabel(const FunctionCallLabel &label) {
2495
2519
// Label was created using a declaration DIE. Need to fetch the definition
2496
2520
// to resolve the function call.
2497
2521
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" );
2515
2525
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);
2519
2527
}
2520
2528
2521
2529
SymbolContextList sc_list;
2522
2530
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" );
2525
2532
2526
2533
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" );
2529
2535
2530
2536
assert (sc_list.GetSize () == 1 );
2531
2537
0 commit comments