diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp index 177c143b3c31..68e1b45cac13 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -2534,6 +2534,71 @@ SymbolFileDWARF::GetClangDeclContextForDIE (DWARFCompileUnit *cu, const DWARFDeb return NULL; } +// This function can be used when a DIE is found that is a forward declaration +// DIE and we want to try and find a type that has the complete definition. +TypeSP +SymbolFileDWARF::FindDefinitionTypeForDIE ( + DWARFCompileUnit* cu, + const DWARFDebugInfoEntry *die, + const ConstString &type_name +) +{ + TypeSP type_sp; + + if (cu == NULL || die == NULL || !type_name) + return type_sp; + + const dw_tag_t type_tag = die->Tag(); + std::vector die_info_array; + const size_t num_matches = m_type_index.Find (type_name, die_info_array); + if (num_matches > 0) + { + DWARFCompileUnit* type_cu = NULL; + DWARFCompileUnit* curr_cu = cu; + DWARFDebugInfo *info = DebugInfo(); + for (size_t i=0; iGetCompileUnitAtIndex (die_info_array[i].cu_idx); + + if (type_cu != curr_cu) + { + type_cu->ExtractDIEsIfNeeded (false); + curr_cu = type_cu; + } + + DWARFDebugInfoEntry *type_die = type_cu->GetDIEAtIndexUnchecked (die_info_array[i].die_idx); + + if (type_die != die && type_die->Tag() == type_tag) + { + // Hold off on comparing parent DIE tags until + // we know what happens with stuff in namespaces + // for gcc and clang... + //DWARFDebugInfoEntry *parent_die = die->GetParent(); + //DWARFDebugInfoEntry *parent_type_die = type_die->GetParent(); + //if (parent_die->Tag() == parent_type_die->Tag()) + { + Type *resolved_type = ResolveType (type_cu, type_die, false); + if (resolved_type && resolved_type != DIE_IS_BEING_PARSED) + { + DEBUG_PRINTF ("resolved 0x%8.8x (cu 0x%8.8x) from %s to 0x%8.8x (cu 0x%8.8x)\n", + die->GetOffset(), + dwarf_cu->GetOffset(), + m_obj_file->GetFileSpec().GetFilename().AsCString(), + type_die->GetOffset(), + type_cu->GetOffset()); + + m_die_to_type[die] = resolved_type; + type_sp = m_obj_file->GetModule()->GetTypeList()->FindType(resolved_type->GetID()); + assert (type_sp.get()); + break; + } + } + } + } + } + return type_sp; +} + TypeSP SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry *die, bool *type_is_new_ptr) { @@ -2786,50 +2851,24 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, if (is_forward_declaration) { - // We have a forward declaration - std::vector die_info_array; - const size_t num_matches = m_type_index.Find (type_name_const_str, die_info_array); - DWARFCompileUnit* type_cu = NULL; - DWARFCompileUnit* curr_cu = dwarf_cu; - DWARFDebugInfo *info = DebugInfo(); - for (size_t i=0; iGetCompileUnitAtIndex (die_info_array[i].cu_idx); - - if (type_cu != curr_cu) - { - type_cu->ExtractDIEsIfNeeded (false); - curr_cu = type_cu; - } + // We have a forward declaration to a type and we need + // to try and find a full declaration. We look in the + // current type index just in case we have a forward + // declaration followed by an actual declarations in the + // DWARF. If this fails, we need to look elsewhere... + + type_sp = FindDefinitionTypeForDIE (dwarf_cu, die, type_name_const_str); - DWARFDebugInfoEntry *type_die = type_cu->GetDIEAtIndexUnchecked (die_info_array[i].die_idx); - - if (type_die != die && type_die->Tag() == tag) - { - // Hold off on comparing parent DIE tags until - // we know what happens with stuff in namespaces - // for gcc and clang... -// DWARFDebugInfoEntry *parent_die = die->GetParent(); -// DWARFDebugInfoEntry *parent_type_die = type_die->GetParent(); -// if (parent_die->Tag() == parent_type_die->Tag()) - { - Type *resolved_type = ResolveType (type_cu, type_die, false); - if (resolved_type && resolved_type != DIE_IS_BEING_PARSED) - { - DEBUG_PRINTF ("resolved 0x%8.8x (cu 0x%8.8x) from %s to 0x%8.8x (cu 0x%8.8x)\n", - die->GetOffset(), - dwarf_cu->GetOffset(), - m_obj_file->GetFileSpec().GetFilename().AsCString(), - type_die->GetOffset(), - type_cu->GetOffset()); - - m_die_to_type[die] = resolved_type; - type_sp = m_obj_file->GetModule()->GetTypeList()->FindType(resolved_type->GetID()); - return type_sp; - } - } - } + if (!type_sp) + { + // We weren't able to find a full declaration in + // this DWARF, see if we have a declaration anywhere + // else... + if (m_debug_map_symfile) + type_sp = m_debug_map_symfile->FindDefinitionTypeForDIE (dwarf_cu, die, type_name_const_str); } + if (type_sp) + return type_sp; } assert (tag_decl_kind != -1); bool clang_type_was_created = false; diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h index cde081b77b2b..1c10ef92c025 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h @@ -279,6 +279,11 @@ protected: const NameToDIE &name_to_die, lldb_private::SymbolContextList& sc_list); + lldb::TypeSP FindDefinitionTypeForDIE ( + DWARFCompileUnit* cu, + const DWARFDebugInfoEntry *die, + const lldb_private::ConstString &type_name); + lldb::TypeSP GetTypeForDIE (DWARFCompileUnit *cu, const DWARFDebugInfoEntry* die); diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp index 4647b912077e..3e2d7b76e328 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp @@ -886,6 +886,23 @@ SymbolFileDWARFDebugMap::FindFunctions (const RegularExpression& regex, bool app return sc_list.GetSize() - initial_size; } +TypeSP +SymbolFileDWARFDebugMap::FindDefinitionTypeForDIE ( + DWARFCompileUnit* cu, + const DWARFDebugInfoEntry *die, + const ConstString &type_name +) +{ + TypeSP type_sp; + SymbolFileDWARF *oso_dwarf; + for (uint32_t oso_idx = 0; ((oso_dwarf = GetSymbolFileByOSOIndex (oso_idx)) != NULL); ++oso_idx) + { + type_sp = oso_dwarf->FindDefinitionTypeForDIE (cu, die, type_name); + if (type_sp) + break; + } + return type_sp; +} uint32_t SymbolFileDWARFDebugMap::FindTypes diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h index 7ead7401704c..7dc477120a8f 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h @@ -16,6 +16,8 @@ #include "lldb/Symbol/SymbolFile.h" class SymbolFileDWARF; +class DWARFCompileUnit; +class DWARFDebugInfoEntry; class SymbolFileDWARFDebugMap : public lldb_private::SymbolFile { @@ -190,6 +192,11 @@ protected: void SetCompileUnit (SymbolFileDWARF *oso_dwarf, const lldb::CompUnitSP &cu_sp); + lldb::TypeSP + FindDefinitionTypeForDIE (DWARFCompileUnit* cu, + const DWARFDebugInfoEntry *die, + const lldb_private::ConstString &type_name); + //------------------------------------------------------------------ // Member Variables //------------------------------------------------------------------ diff --git a/lldb/tools/driver/Driver.cpp b/lldb/tools/driver/Driver.cpp index 8d9abdd9eecd..1bc314882f6d 100644 --- a/lldb/tools/driver/Driver.cpp +++ b/lldb/tools/driver/Driver.cpp @@ -1375,7 +1375,7 @@ main (int argc, char const *argv[]) { SBDebugger::Initialize(); - SBHostOS::ThreadCreated ("[main]"); + SBHostOS::ThreadCreated (""); signal (SIGPIPE, SIG_IGN); signal (SIGWINCH, sigwinch_handler);