@@ -481,6 +481,13 @@ static ConstString GetDWARFMachOSegmentName() {
481
481
return g_dwarf_section_name;
482
482
}
483
483
484
+ llvm::DenseMap<lldb::opaque_compiler_type_t , DIERef> &
485
+ SymbolFileDWARF::GetForwardDeclCompilerTypeToDIE () {
486
+ if (SymbolFileDWARFDebugMap *debug_map_symfile = GetDebugMapSymfile ())
487
+ return debug_map_symfile->GetForwardDeclCompilerTypeToDIE ();
488
+ return m_forward_decl_compiler_type_to_die;
489
+ }
490
+
484
491
UniqueDWARFASTTypeMap &SymbolFileDWARF::GetUniqueDWARFASTTypeMap () {
485
492
SymbolFileDWARFDebugMap *debug_map_symfile = GetDebugMapSymfile ();
486
493
if (debug_map_symfile)
@@ -1631,27 +1638,45 @@ bool SymbolFileDWARF::CompleteType(CompilerType &compiler_type) {
1631
1638
return true ;
1632
1639
}
1633
1640
1634
- DWARFDIE dwarf_die = GetDIE (die_it->getSecond ());
1635
- if (dwarf_die) {
1636
- // Once we start resolving this type, remove it from the forward
1637
- // declaration map in case anyone child members or other types require this
1638
- // type to get resolved. The type will get resolved when all of the calls
1639
- // to SymbolFileDWARF::ResolveClangOpaqueTypeDefinition are done.
1640
- GetForwardDeclCompilerTypeToDIE ().erase (die_it);
1641
-
1642
- Type *type = GetDIEToType ().lookup (dwarf_die.GetDIE ());
1641
+ DWARFDIE decl_die = GetDIE (die_it->getSecond ());
1642
+ // Once we start resolving this type, remove it from the forward
1643
+ // declaration map in case anyone's child members or other types require this
1644
+ // type to get resolved.
1645
+ GetForwardDeclCompilerTypeToDIE ().erase (die_it);
1646
+ DWARFDIE def_die = FindDefinitionDIE (decl_die);
1647
+ if (!def_die) {
1648
+ SymbolFileDWARFDebugMap *debug_map_symfile = GetDebugMapSymfile ();
1649
+ if (debug_map_symfile) {
1650
+ // We weren't able to find a full declaration in this DWARF, see
1651
+ // if we have a declaration anywhere else...
1652
+ def_die = debug_map_symfile->FindDefinitionDIE (decl_die);
1653
+ }
1654
+ }
1655
+ if (!def_die) {
1656
+ // If we don't have definition DIE, CompleteTypeFromDWARF will forcefully
1657
+ // complete this type.
1658
+ def_die = decl_die;
1659
+ }
1643
1660
1644
- Log * log = GetLog (DWARFLog::DebugInfo | DWARFLog::TypeCompletion );
1645
- if (log )
1646
- GetObjectFile ()-> GetModule ()-> LogMessageVerboseBacktrace (
1647
- log , " {0:x8}: {1} ({2}) '{3}' resolving forward declaration... " ,
1648
- dwarf_die. GetID (), DW_TAG_value_to_name (dwarf_die. Tag ()),
1649
- dwarf_die. Tag (), type-> GetName (). AsCString ()) ;
1650
- assert (compiler_type);
1651
- if (DWARFASTParser *dwarf_ast = GetDWARFParser (*dwarf_die. GetCU ()))
1652
- return dwarf_ast-> CompleteTypeFromDWARF (dwarf_die, type, compiler_type );
1661
+ DWARFASTParser *dwarf_ast = GetDWARFParser (*def_die. GetCU () );
1662
+ if (!dwarf_ast )
1663
+ return false ;
1664
+ Type *type = GetDIEToType (). lookup (decl_die. GetDIE ());
1665
+ if (decl_die != def_die) {
1666
+ GetDIEToType ()[def_die. GetDIE ()] = type ;
1667
+ DWARFASTParserClang *ast_parser =
1668
+ static_cast <DWARFASTParserClang *>(dwarf_ast);
1669
+ ast_parser-> MapDeclDIEToDefDIE (decl_die, def_die );
1653
1670
}
1654
- return false ;
1671
+
1672
+ Log *log = GetLog (DWARFLog::DebugInfo | DWARFLog::TypeCompletion);
1673
+ if (log )
1674
+ GetObjectFile ()->GetModule ()->LogMessageVerboseBacktrace (
1675
+ log , " {0:x8}: {1} ({2}) '{3}' resolving forward declaration..." ,
1676
+ def_die.GetID (), DW_TAG_value_to_name (def_die.Tag ()), def_die.Tag (),
1677
+ type->GetName ().AsCString ());
1678
+ assert (compiler_type);
1679
+ return dwarf_ast->CompleteTypeFromDWARF (def_die, type, compiler_type);
1655
1680
}
1656
1681
1657
1682
Type *SymbolFileDWARF::ResolveType (const DWARFDIE &die,
@@ -3047,8 +3072,15 @@ TypeSP SymbolFileDWARF::FindCompleteObjCDefinitionTypeForDIE(
3047
3072
3048
3073
DWARFDIE
3049
3074
SymbolFileDWARF::FindDefinitionDIE (const DWARFDIE &die) {
3050
- if (!die.GetName ())
3075
+ const char *name = die.GetName ();
3076
+ if (!name)
3051
3077
return {};
3078
+ if (!die.GetAttributeValueAsUnsigned (DW_AT_declaration, 0 ))
3079
+ return die;
3080
+
3081
+ Progress progress (llvm::formatv (
3082
+ " Searching definition DIE in {0}: '{1}'" ,
3083
+ GetObjectFile ()->GetFileSpec ().GetFilename ().GetString (), name));
3052
3084
3053
3085
const dw_tag_t tag = die.Tag ();
3054
3086
@@ -3058,7 +3090,7 @@ SymbolFileDWARF::FindDefinitionDIE(const DWARFDIE &die) {
3058
3090
log ,
3059
3091
" SymbolFileDWARF::FindDefinitionDIE(tag={0} "
3060
3092
" ({1}), name='{2}')" ,
3061
- DW_TAG_value_to_name (tag), tag, die. GetName () );
3093
+ DW_TAG_value_to_name (tag), tag, name );
3062
3094
}
3063
3095
3064
3096
// Get the type system that we are looking to find a type for. We will
@@ -3132,7 +3164,7 @@ SymbolFileDWARF::FindDefinitionDIE(const DWARFDIE &die) {
3132
3164
log ,
3133
3165
" SymbolFileDWARF::FindDefinitionDIE(tag={0} ({1}), "
3134
3166
" name='{2}') ignoring die={3:x16} ({4})" ,
3135
- DW_TAG_value_to_name (tag), tag, die. GetName () , type_die.GetOffset (),
3167
+ DW_TAG_value_to_name (tag), tag, name , type_die.GetOffset (),
3136
3168
type_die.GetName ());
3137
3169
}
3138
3170
return true ;
@@ -3144,7 +3176,7 @@ SymbolFileDWARF::FindDefinitionDIE(const DWARFDIE &die) {
3144
3176
log ,
3145
3177
" SymbolFileDWARF::FindDefinitionTypeDIE(tag={0} ({1}), name='{2}') "
3146
3178
" trying die={3:x16} ({4})" ,
3147
- DW_TAG_value_to_name (tag), tag, die. GetName () , type_die.GetOffset (),
3179
+ DW_TAG_value_to_name (tag), tag, name , type_die.GetOffset (),
3148
3180
type_dwarf_decl_ctx.GetQualifiedName ());
3149
3181
}
3150
3182
0 commit comments