Index: lldb/trunk/include/lldb/Symbol/ObjectFile.h =================================================================== --- lldb/trunk/include/lldb/Symbol/ObjectFile.h +++ lldb/trunk/include/lldb/Symbol/ObjectFile.h @@ -368,7 +368,7 @@ /// The list of sections contained in this object file. //------------------------------------------------------------------ virtual SectionList * - GetSectionList (); + GetSectionList (bool update_module_section_list = true); virtual void CreateSections (SectionList &unified_section_list) = 0; Index: lldb/trunk/lldb.xcodeproj/project.pbxproj =================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj +++ lldb/trunk/lldb.xcodeproj/project.pbxproj @@ -708,6 +708,9 @@ 6D55BAEE1A8CD0B200A70529 /* PlatformAndroidRemoteGDBServer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6D55BAEB1A8CD08C00A70529 /* PlatformAndroidRemoteGDBServer.cpp */; }; 6D762BEE1B1605D2006C929D /* LLDBServerUtilities.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6D762BEC1B1605CD006C929D /* LLDBServerUtilities.cpp */; }; 6D86CEA01B440F8500A7FBFA /* CommandObjectBugreport.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6D86CE9E1B440F6B00A7FBFA /* CommandObjectBugreport.cpp */; }; + 6D95DC001B9DC057000E318A /* DIERef.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6D95DBFD1B9DC057000E318A /* DIERef.cpp */; }; + 6D95DC011B9DC057000E318A /* HashedNameToDIE.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6D95DBFE1B9DC057000E318A /* HashedNameToDIE.cpp */; }; + 6D95DC021B9DC057000E318A /* SymbolFileDWARFDwo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6D95DBFF1B9DC057000E318A /* SymbolFileDWARFDwo.cpp */; }; 8C2D6A53197A1EAF006989C9 /* MemoryHistory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8C2D6A52197A1EAF006989C9 /* MemoryHistory.cpp */; }; 8C2D6A5E197A250F006989C9 /* MemoryHistoryASan.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8C2D6A5A197A1FDC006989C9 /* MemoryHistoryASan.cpp */; }; 8CCB017E19BA28A80009FD44 /* ThreadCollection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8CCB017A19BA283D0009FD44 /* ThreadCollection.cpp */; }; @@ -2385,6 +2388,11 @@ 6D762BED1B1605CD006C929D /* LLDBServerUtilities.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = LLDBServerUtilities.h; path = "tools/lldb-server/LLDBServerUtilities.h"; sourceTree = ""; }; 6D86CE9E1B440F6B00A7FBFA /* CommandObjectBugreport.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectBugreport.cpp; path = source/Commands/CommandObjectBugreport.cpp; sourceTree = ""; }; 6D86CE9F1B440F6B00A7FBFA /* CommandObjectBugreport.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = CommandObjectBugreport.h; path = source/Commands/CommandObjectBugreport.h; sourceTree = ""; }; + 6D95DBFD1B9DC057000E318A /* DIERef.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DIERef.cpp; sourceTree = ""; }; + 6D95DBFE1B9DC057000E318A /* HashedNameToDIE.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HashedNameToDIE.cpp; sourceTree = ""; }; + 6D95DBFF1B9DC057000E318A /* SymbolFileDWARFDwo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SymbolFileDWARFDwo.cpp; sourceTree = ""; }; + 6D95DC031B9DC06F000E318A /* DIERef.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DIERef.h; sourceTree = ""; }; + 6D95DC041B9DC06F000E318A /* SymbolFileDWARFDwo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SymbolFileDWARFDwo.h; sourceTree = ""; }; 8C2D6A52197A1EAF006989C9 /* MemoryHistory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = MemoryHistory.cpp; path = source/Target/MemoryHistory.cpp; sourceTree = ""; }; 8C2D6A54197A1EBE006989C9 /* MemoryHistory.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = MemoryHistory.h; path = include/lldb/Target/MemoryHistory.h; sourceTree = ""; }; 8C2D6A5A197A1FDC006989C9 /* MemoryHistoryASan.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MemoryHistoryASan.cpp; sourceTree = ""; }; @@ -3115,6 +3123,11 @@ 260C89B210F57C5600BB2B04 /* DWARF */ = { isa = PBXGroup; children = ( + 6D95DC031B9DC06F000E318A /* DIERef.h */, + 6D95DC041B9DC06F000E318A /* SymbolFileDWARFDwo.h */, + 6D95DBFD1B9DC057000E318A /* DIERef.cpp */, + 6D95DBFE1B9DC057000E318A /* HashedNameToDIE.cpp */, + 6D95DBFF1B9DC057000E318A /* SymbolFileDWARFDwo.cpp */, 260C89B310F57C5600BB2B04 /* DWARFAbbreviationDeclaration.cpp */, 260C89B410F57C5600BB2B04 /* DWARFAbbreviationDeclaration.h */, 269DDD451B8FD01A00D0DBD8 /* DWARFASTParser.h */, @@ -6258,6 +6271,7 @@ 2689005C13353E0400698AC0 /* ValueObjectVariable.cpp in Sources */, 264A58EE1A7DBCAD00A6B1B0 /* OptionValueFormatEntity.cpp in Sources */, 8C2D6A53197A1EAF006989C9 /* MemoryHistory.cpp in Sources */, + 6D95DC021B9DC057000E318A /* SymbolFileDWARFDwo.cpp in Sources */, 942612F71B95000000EF842E /* LanguageCategory.cpp in Sources */, 2689005D13353E0400698AC0 /* VMRange.cpp in Sources */, 2689005E13353E0E00698AC0 /* ClangASTSource.cpp in Sources */, @@ -6319,6 +6333,7 @@ 2689008313353E2200698AC0 /* CommandObjectMultiword.cpp in Sources */, 2689008413353E2200698AC0 /* CommandObjectRegexCommand.cpp in Sources */, 2689008513353E2200698AC0 /* CommandReturnObject.cpp in Sources */, + 6D95DC001B9DC057000E318A /* DIERef.cpp in Sources */, 3FDFE53519A29327009756A7 /* HostInfoBase.cpp in Sources */, 26474CBE18D0CB2D0073DEBA /* RegisterContextMach_i386.cpp in Sources */, 2689008613353E2200698AC0 /* Options.cpp in Sources */, @@ -6487,6 +6502,7 @@ 26744EF31338317700EF765A /* GDBRemoteCommunicationServer.cpp in Sources */, 264A97BF133918BC0017F0BE /* PlatformRemoteGDBServer.cpp in Sources */, EB8375E71B553DE800BA907D /* ThreadPlanCallFunctionUsingABI.cpp in Sources */, + 6D95DC011B9DC057000E318A /* HashedNameToDIE.cpp in Sources */, 2697A54D133A6305004E4240 /* PlatformDarwin.cpp in Sources */, 26651A18133BF9E0005B64B7 /* Opcode.cpp in Sources */, 3FDFED0B19B7C8DE009756A7 /* HostThreadMacOSX.mm in Sources */, Index: lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp =================================================================== --- lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp +++ lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp @@ -1684,6 +1684,12 @@ static ConstString g_sect_name_dwarf_debug_ranges (".debug_ranges"); static ConstString g_sect_name_dwarf_debug_str (".debug_str"); static ConstString g_sect_name_dwarf_debug_str_offsets (".debug_str_offsets"); + static ConstString g_sect_name_dwarf_debug_abbrev_dwo (".debug_abbrev.dwo"); + static ConstString g_sect_name_dwarf_debug_info_dwo (".debug_info.dwo"); + static ConstString g_sect_name_dwarf_debug_line_dwo (".debug_line.dwo"); + static ConstString g_sect_name_dwarf_debug_loc_dwo (".debug_loc.dwo"); + static ConstString g_sect_name_dwarf_debug_str_dwo (".debug_str.dwo"); + static ConstString g_sect_name_dwarf_debug_str_offsets_dwo (".debug_str_offsets.dwo"); static ConstString g_sect_name_eh_frame (".eh_frame"); SectionType sect_type = eSectionTypeOther; @@ -1717,20 +1723,26 @@ // MISSING? .gnu_debugdata - "mini debuginfo / MiniDebugInfo" section, http://sourceware.org/gdb/onlinedocs/gdb/MiniDebugInfo.html // MISSING? .debug-index - http://src.chromium.org/viewvc/chrome/trunk/src/build/gdb-add-index?pathrev=144644 // MISSING? .debug_types - Type descriptions from DWARF 4? See http://gcc.gnu.org/wiki/DwarfSeparateTypeInfo - else if (name == g_sect_name_dwarf_debug_abbrev) sect_type = eSectionTypeDWARFDebugAbbrev; - else if (name == g_sect_name_dwarf_debug_addr) sect_type = eSectionTypeDWARFDebugAddr; - else if (name == g_sect_name_dwarf_debug_aranges) sect_type = eSectionTypeDWARFDebugAranges; - else if (name == g_sect_name_dwarf_debug_frame) sect_type = eSectionTypeDWARFDebugFrame; - else if (name == g_sect_name_dwarf_debug_info) sect_type = eSectionTypeDWARFDebugInfo; - else if (name == g_sect_name_dwarf_debug_line) sect_type = eSectionTypeDWARFDebugLine; - else if (name == g_sect_name_dwarf_debug_loc) sect_type = eSectionTypeDWARFDebugLoc; - else if (name == g_sect_name_dwarf_debug_macinfo) sect_type = eSectionTypeDWARFDebugMacInfo; - else if (name == g_sect_name_dwarf_debug_pubnames) sect_type = eSectionTypeDWARFDebugPubNames; - else if (name == g_sect_name_dwarf_debug_pubtypes) sect_type = eSectionTypeDWARFDebugPubTypes; - else if (name == g_sect_name_dwarf_debug_ranges) sect_type = eSectionTypeDWARFDebugRanges; - else if (name == g_sect_name_dwarf_debug_str) sect_type = eSectionTypeDWARFDebugStr; - else if (name == g_sect_name_dwarf_debug_str_offsets) sect_type = eSectionTypeDWARFDebugStrOffsets; - else if (name == g_sect_name_eh_frame) sect_type = eSectionTypeEHFrame; + else if (name == g_sect_name_dwarf_debug_abbrev) sect_type = eSectionTypeDWARFDebugAbbrev; + else if (name == g_sect_name_dwarf_debug_addr) sect_type = eSectionTypeDWARFDebugAddr; + else if (name == g_sect_name_dwarf_debug_aranges) sect_type = eSectionTypeDWARFDebugAranges; + else if (name == g_sect_name_dwarf_debug_frame) sect_type = eSectionTypeDWARFDebugFrame; + else if (name == g_sect_name_dwarf_debug_info) sect_type = eSectionTypeDWARFDebugInfo; + else if (name == g_sect_name_dwarf_debug_line) sect_type = eSectionTypeDWARFDebugLine; + else if (name == g_sect_name_dwarf_debug_loc) sect_type = eSectionTypeDWARFDebugLoc; + else if (name == g_sect_name_dwarf_debug_macinfo) sect_type = eSectionTypeDWARFDebugMacInfo; + else if (name == g_sect_name_dwarf_debug_pubnames) sect_type = eSectionTypeDWARFDebugPubNames; + else if (name == g_sect_name_dwarf_debug_pubtypes) sect_type = eSectionTypeDWARFDebugPubTypes; + else if (name == g_sect_name_dwarf_debug_ranges) sect_type = eSectionTypeDWARFDebugRanges; + else if (name == g_sect_name_dwarf_debug_str) sect_type = eSectionTypeDWARFDebugStr; + else if (name == g_sect_name_dwarf_debug_str_offsets) sect_type = eSectionTypeDWARFDebugStrOffsets; + else if (name == g_sect_name_dwarf_debug_abbrev_dwo) sect_type = eSectionTypeDWARFDebugAbbrev; + else if (name == g_sect_name_dwarf_debug_info_dwo) sect_type = eSectionTypeDWARFDebugInfo; + else if (name == g_sect_name_dwarf_debug_line_dwo) sect_type = eSectionTypeDWARFDebugLine; + else if (name == g_sect_name_dwarf_debug_loc_dwo) sect_type = eSectionTypeDWARFDebugLoc; + else if (name == g_sect_name_dwarf_debug_str_dwo) sect_type = eSectionTypeDWARFDebugStr; + else if (name == g_sect_name_dwarf_debug_str_offsets_dwo) sect_type = eSectionTypeDWARFDebugStrOffsets; + else if (name == g_sect_name_eh_frame) sect_type = eSectionTypeEHFrame; switch (header.sh_type) { Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/CMakeLists.txt =================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/CMakeLists.txt +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/CMakeLists.txt @@ -1,4 +1,5 @@ add_lldb_library(lldbPluginSymbolFileDWARF + DIERef.cpp DWARFAbbreviationDeclaration.cpp DWARFASTParserClang.cpp DWARFAttribute.cpp @@ -26,6 +27,7 @@ LogChannelDWARF.cpp NameToDIE.cpp SymbolFileDWARF.cpp + SymbolFileDWARFDwo.cpp SymbolFileDWARFDebugMap.cpp UniqueDWARFASTType.cpp ) Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/DIERef.h =================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DIERef.h +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DIERef.h @@ -0,0 +1,42 @@ +//===-- DIERef.h ------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef SymbolFileDWARF_DIERef_h_ +#define SymbolFileDWARF_DIERef_h_ + +#include "lldb/Core/dwarf.h" +#include "lldb/lldb-defines.h" + +class DWARFFormValue; + +struct DIERef +{ + DIERef(); + + explicit + DIERef(dw_offset_t d); + + DIERef(dw_offset_t c, dw_offset_t d); + + explicit + DIERef(lldb::user_id_t uid); + + explicit + DIERef(const DWARFFormValue& form_value); + + lldb::user_id_t + GetUID() const; + + dw_offset_t cu_offset; + dw_offset_t die_offset; +}; + +typedef std::vector DIEArray; + +#endif // SymbolFileDWARF_DIERef_h_ Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/DIERef.cpp =================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DIERef.cpp +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DIERef.cpp @@ -0,0 +1,56 @@ +//===-- DIERef.cpp ----------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "DIERef.h" +#include "DWARFCompileUnit.h" +#include "DWARFFormValue.h" + +DIERef::DIERef() : + cu_offset(DW_INVALID_OFFSET), + die_offset(DW_INVALID_OFFSET) +{} + +DIERef::DIERef(dw_offset_t d) : + cu_offset(DW_INVALID_OFFSET), + die_offset(d) +{} + +DIERef::DIERef(dw_offset_t c, dw_offset_t d) : + cu_offset(c), + die_offset(d) +{} + +DIERef::DIERef(lldb::user_id_t uid) : + cu_offset(uid>>32), + die_offset(uid&0xffffffff) +{} + +DIERef::DIERef(const DWARFFormValue& form_value) : + cu_offset(DW_INVALID_OFFSET), + die_offset(DW_INVALID_OFFSET) +{ + if (form_value.IsValid()) + { + const DWARFCompileUnit* dwarf_cu = form_value.GetCompileUnit(); + if (dwarf_cu) + { + if (dwarf_cu->GetBaseObjOffset() != DW_INVALID_OFFSET) + cu_offset = dwarf_cu->GetBaseObjOffset(); + else + cu_offset = dwarf_cu->GetOffset(); + } + die_offset = form_value.Reference(); + } +} + +lldb::user_id_t +DIERef::GetUID() const +{ + return ((lldb::user_id_t)cu_offset) << 32 | die_offset; +} Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp =================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -150,7 +150,7 @@ // // } - Type *type_ptr = dwarf->m_die_to_type.lookup (die.GetDIE()); + Type *type_ptr = dwarf->GetDIEToType().lookup (die.GetDIE()); TypeList* type_list = dwarf->GetTypeList(); if (type_ptr == NULL) { @@ -186,7 +186,7 @@ case DW_TAG_unspecified_type: { // Set a bit that lets us know that we are currently parsing this - dwarf->m_die_to_type[die.GetDIE()] = DIE_IS_BEING_PARSED; + dwarf->GetDIEToType()[die.GetDIE()] = DIE_IS_BEING_PARSED; const size_t num_attributes = die.GetAttributes (attributes); uint32_t encoding = 0; @@ -220,7 +220,7 @@ break; case DW_AT_byte_size: byte_size = form_value.Unsigned(); break; case DW_AT_encoding: encoding = form_value.Unsigned(); break; - case DW_AT_type: encoding_uid = form_value.Reference(); break; + case DW_AT_type: encoding_uid = DIERef(form_value).GetUID(); break; default: case DW_AT_sibling: break; @@ -355,7 +355,7 @@ clang_type, resolve_state)); - dwarf->m_die_to_type[die.GetDIE()] = type_sp.get(); + dwarf->GetDIEToType()[die.GetDIE()] = type_sp.get(); // Type* encoding_type = GetUniquedTypeForDIEOffset(encoding_uid, type_sp, NULL, 0, 0, false); // if (encoding_type != NULL) @@ -373,7 +373,7 @@ case DW_TAG_class_type: { // Set a bit that lets us know that we are currently parsing this - dwarf->m_die_to_type[die.GetDIE()] = DIE_IS_BEING_PARSED; + dwarf->GetDIEToType()[die.GetDIE()] = DIE_IS_BEING_PARSED; bool byte_size_valid = false; LanguageType class_language = eLanguageTypeUnknown; @@ -471,7 +471,7 @@ type_sp = unique_ast_entry_ap->m_type_sp; if (type_sp) { - dwarf->m_die_to_type[die.GetDIE()] = type_sp.get(); + dwarf->GetDIEToType()[die.GetDIE()] = type_sp.get(); return type_sp; } } @@ -554,7 +554,7 @@ // We found a real definition for this type elsewhere // so lets use it and cache the fact that we found // a complete type for this die - dwarf->m_die_to_type[die.GetDIE()] = type_sp.get(); + dwarf->GetDIEToType()[die.GetDIE()] = type_sp.get(); return type_sp; } } @@ -612,13 +612,13 @@ // We found a real definition for this type elsewhere // so lets use it and cache the fact that we found // a complete type for this die - dwarf->m_die_to_type[die.GetDIE()] = type_sp.get(); + dwarf->GetDIEToType()[die.GetDIE()] = type_sp.get(); return type_sp; } } assert (tag_decl_kind != -1); bool clang_type_was_created = false; - clang_type.SetCompilerType(&m_ast, dwarf->m_forward_decl_die_to_clang_type.lookup (die.GetDIE())); + clang_type.SetCompilerType(&m_ast, dwarf->GetForwardDeclDieToClangType().lookup (die.GetDIE())); if (!clang_type) { clang::DeclContext *decl_ctx = GetClangDeclContextContainingDIE (die, nullptr); @@ -766,21 +766,20 @@ // will automatically call the SymbolFile virtual function // "SymbolFileDWARF::CompleteType(Type *)" // When the definition needs to be defined. - dwarf->m_forward_decl_die_to_clang_type[die.GetDIE()] = clang_type.GetOpaqueQualType(); - dwarf->m_forward_decl_clang_type_to_die[ClangASTContext::RemoveFastQualifiers(clang_type).GetOpaqueQualType()] = die.GetDIE(); + dwarf->GetForwardDeclDieToClangType()[die.GetDIE()] = clang_type.GetOpaqueQualType(); + dwarf->GetForwardDeclClangTypeToDie()[ClangASTContext::RemoveFastQualifiers(clang_type).GetOpaqueQualType()] = die.GetDIERef(); m_ast.SetHasExternalStorage (clang_type.GetOpaqueQualType(), true); } } - } break; case DW_TAG_enumeration_type: { // Set a bit that lets us know that we are currently parsing this - dwarf->m_die_to_type[die.GetDIE()] = DIE_IS_BEING_PARSED; + dwarf->GetDIEToType()[die.GetDIE()] = DIE_IS_BEING_PARSED; - lldb::user_id_t encoding_uid = DW_INVALID_OFFSET; + DWARFFormValue encoding_form; const size_t num_attributes = die.GetAttributes (attributes); if (num_attributes > 0) @@ -801,7 +800,7 @@ type_name_cstr = form_value.AsCString(); type_name_const_str.SetCString(type_name_cstr); break; - case DW_AT_type: encoding_uid = form_value.Reference(); break; + case DW_AT_type: encoding_form = form_value; break; case DW_AT_byte_size: byte_size = form_value.Unsigned(); break; case DW_AT_accessibility: break; //accessibility = DW_ACCESS_to_AccessType(form_value.Unsigned()); break; case DW_AT_declaration: break; //is_forward_declaration = form_value.Boolean(); break; @@ -824,12 +823,12 @@ DEBUG_PRINTF ("0x%8.8" PRIx64 ": %s (\"%s\")\n", die.GetID(), DW_TAG_value_to_name(tag), type_name_cstr); CompilerType enumerator_clang_type; - clang_type.SetCompilerType (&m_ast, dwarf->m_forward_decl_die_to_clang_type.lookup (die.GetDIE())); + clang_type.SetCompilerType (&m_ast, dwarf->GetForwardDeclDieToClangType().lookup (die.GetDIE())); if (!clang_type) { - if (encoding_uid != DW_INVALID_OFFSET) + if (encoding_form.IsValid()) { - Type *enumerator_type = dwarf->ResolveTypeUID(encoding_uid); + Type *enumerator_type = dwarf->ResolveTypeUID(DIERef(encoding_form).GetUID()); if (enumerator_type) enumerator_clang_type = enumerator_type->GetFullCompilerType (); } @@ -856,7 +855,7 @@ type_name_const_str, byte_size, NULL, - encoding_uid, + DIERef(encoding_form).GetUID(), Type::eEncodingIsUID, &decl, clang_type, @@ -880,18 +879,17 @@ case DW_TAG_subroutine_type: { // Set a bit that lets us know that we are currently parsing this - dwarf->m_die_to_type[die.GetDIE()] = DIE_IS_BEING_PARSED; + dwarf->GetDIEToType()[die.GetDIE()] = DIE_IS_BEING_PARSED; - //const char *mangled = NULL; - dw_offset_t type_die_offset = DW_INVALID_OFFSET; + DWARFFormValue type_die_form; bool is_variadic = false; bool is_inline = false; bool is_static = false; bool is_virtual = false; bool is_explicit = false; bool is_artificial = false; - dw_offset_t specification_die_offset = DW_INVALID_OFFSET; - dw_offset_t abstract_origin_die_offset = DW_INVALID_OFFSET; + DWARFFormValue specification_die_form; + DWARFFormValue abstract_origin_die_form; dw_offset_t object_pointer_die_offset = DW_INVALID_OFFSET; unsigned type_quals = 0; @@ -919,7 +917,7 @@ case DW_AT_linkage_name: case DW_AT_MIPS_linkage_name: break; // mangled = form_value.AsCString(&dwarf->get_debug_str_data()); break; - case DW_AT_type: type_die_offset = form_value.Reference(); break; + case DW_AT_type: type_die_form = form_value; break; case DW_AT_accessibility: accessibility = DW_ACCESS_to_AccessType(form_value.Unsigned()); break; case DW_AT_declaration: break; // is_forward_declaration = form_value.Boolean(); break; case DW_AT_inline: is_inline = form_value.Boolean(); break; @@ -939,11 +937,11 @@ break; case DW_AT_specification: - specification_die_offset = form_value.Reference(); + specification_die_form = form_value; break; case DW_AT_abstract_origin: - abstract_origin_die_offset = form_value.Reference(); + abstract_origin_die_form = form_value; break; case DW_AT_object_pointer: @@ -996,8 +994,8 @@ CompilerType return_clang_type; Type *func_type = NULL; - if (type_die_offset != DW_INVALID_OFFSET) - func_type = dwarf->ResolveTypeUID(type_die_offset); + if (type_die_form.IsValid()) + func_type = dwarf->ResolveTypeUID(DIERef(type_die_form).GetUID()); if (func_type) return_clang_type = func_type->GetForwardCompilerType (); @@ -1113,12 +1111,12 @@ if (debug_map_symfile) { class_symfile = debug_map_symfile->GetSymbolFileByOSOIndex(SymbolFileDWARFDebugMap::GetOSOIndexFromUserID(class_type->GetID())); - class_type_die = class_symfile->DebugInfo()->GetDIE (class_type->GetID()); + class_type_die = class_symfile->DebugInfo()->GetDIE (DIERef(class_type->GetID())); } else { class_symfile = dwarf; - class_type_die = dwarf->DebugInfo()->GetDIE (class_type->GetID()); + class_type_die = dwarf->DebugInfo()->GetDIE (DIERef(class_type->GetID())); } if (class_type_die) { @@ -1134,7 +1132,7 @@ // like having stuff added to them after their definitions are // complete... - type_ptr = dwarf->m_die_to_type[die.GetDIE()]; + type_ptr = dwarf->GetDIEToType()[die.GetDIE()]; if (type_ptr && type_ptr != DIE_IS_BEING_PARSED) { type_sp = type_ptr->shared_from_this(); @@ -1143,7 +1141,7 @@ } } - if (specification_die_offset != DW_INVALID_OFFSET) + if (specification_die_form.IsValid()) { // We have a specification which we are going to base our function // prototype off of, so we need this type to be completed so that the @@ -1152,7 +1150,7 @@ class_type->GetForwardCompilerType (); // If we have a specification, then the function type should have been // made with the specification and not with this die. - DWARFDIE spec_die = dwarf->DebugInfo()->GetDIE(specification_die_offset); + DWARFDIE spec_die = dwarf->DebugInfo()->GetDIE(DIERef(specification_die_form)); clang::DeclContext *spec_clang_decl_ctx = GetClangDeclContextForDIE (spec_die); if (spec_clang_decl_ctx) { @@ -1160,13 +1158,13 @@ } else { - dwarf->GetObjectFile()->GetModule()->ReportWarning ("0x%8.8" PRIx64 ": DW_AT_specification(0x%8.8x) has no decl\n", + dwarf->GetObjectFile()->GetModule()->ReportWarning ("0x%8.8" PRIx64 ": DW_AT_specification(0x%8.8" PRIx64 ") has no decl\n", die.GetID(), - specification_die_offset); + specification_die_form.Reference()); } type_handled = true; } - else if (abstract_origin_die_offset != DW_INVALID_OFFSET) + else if (abstract_origin_die_form.IsValid()) { // We have a specification which we are going to base our function // prototype off of, so we need this type to be completed so that the @@ -1174,7 +1172,7 @@ // clang decl context. class_type->GetForwardCompilerType (); - DWARFDIE abs_die = dwarf->DebugInfo()->GetDIE (abstract_origin_die_offset); + DWARFDIE abs_die = dwarf->DebugInfo()->GetDIE (DIERef(abstract_origin_die_form)); clang::DeclContext *abs_clang_decl_ctx = GetClangDeclContextForDIE (abs_die); if (abs_clang_decl_ctx) { @@ -1182,9 +1180,9 @@ } else { - dwarf->GetObjectFile()->GetModule()->ReportWarning ("0x%8.8" PRIx64 ": DW_AT_abstract_origin(0x%8.8x) has no decl\n", + dwarf->GetObjectFile()->GetModule()->ReportWarning ("0x%8.8" PRIx64 ": DW_AT_abstract_origin(0x%8.8" PRIx64 ") has no decl\n", die.GetID(), - abstract_origin_die_offset); + abstract_origin_die_form.Reference()); } type_handled = true; } @@ -1264,10 +1262,10 @@ // class hasn't been asked to complete itself through the // clang::ExternalASTSource protocol, so we need to just have the // class complete itself and do things the right way, then our - // DIE should then have an entry in the dwarf->m_die_to_type map. First - // we need to modify the dwarf->m_die_to_type so it doesn't think we are + // DIE should then have an entry in the dwarf->GetDIEToType() map. First + // we need to modify the dwarf->GetDIEToType() so it doesn't think we are // trying to parse this DIE anymore... - dwarf->m_die_to_type[die.GetDIE()] = NULL; + dwarf->GetDIEToType()[die.GetDIE()] = NULL; // Now we get the full type to force our class type to complete itself // using the clang::ExternalASTSource protocol which will parse all @@ -1275,7 +1273,7 @@ class_type->GetFullCompilerType (); // The type for this DIE should have been filled in the function call above - type_ptr = dwarf->m_die_to_type[die.GetDIE()]; + type_ptr = dwarf->GetDIEToType()[die.GetDIE()]; if (type_ptr && type_ptr != DIE_IS_BEING_PARSED) { type_sp = type_ptr->shared_from_this(); @@ -1352,9 +1350,9 @@ case DW_TAG_array_type: { // Set a bit that lets us know that we are currently parsing this - dwarf->m_die_to_type[die.GetDIE()] = DIE_IS_BEING_PARSED; + dwarf->GetDIEToType()[die.GetDIE()] = DIE_IS_BEING_PARSED; - lldb::user_id_t type_die_offset = DW_INVALID_OFFSET; + DWARFFormValue type_die_form; int64_t first_index = 0; uint32_t byte_stride = 0; uint32_t bit_stride = 0; @@ -1379,7 +1377,7 @@ type_name_const_str.SetCString(type_name_cstr); break; - case DW_AT_type: type_die_offset = form_value.Reference(); break; + case DW_AT_type: type_die_form = form_value; break; case DW_AT_byte_size: break; // byte_size = form_value.Unsigned(); break; case DW_AT_byte_stride: byte_stride = form_value.Unsigned(); break; case DW_AT_bit_stride: bit_stride = form_value.Unsigned(); break; @@ -1403,7 +1401,7 @@ DEBUG_PRINTF ("0x%8.8" PRIx64 ": %s (\"%s\")\n", die.GetID(), DW_TAG_value_to_name(tag), type_name_cstr); - Type *element_type = dwarf->ResolveTypeUID(type_die_offset); + Type *element_type = dwarf->ResolveTypeUID(DIERef(type_die_form).GetUID()); if (element_type) { @@ -1440,7 +1438,7 @@ empty_name, array_element_bit_stride / 8, NULL, - type_die_offset, + DIERef(type_die_form).GetUID(), Type::eEncodingIsUID, &decl, clang_type, @@ -1453,8 +1451,8 @@ case DW_TAG_ptr_to_member_type: { - dw_offset_t type_die_offset = DW_INVALID_OFFSET; - dw_offset_t containing_type_die_offset = DW_INVALID_OFFSET; + DWARFFormValue type_die_form; + DWARFFormValue containing_type_die_form; const size_t num_attributes = die.GetAttributes (attributes); @@ -1468,15 +1466,15 @@ switch (attr) { case DW_AT_type: - type_die_offset = form_value.Reference(); break; + type_die_form = form_value; break; case DW_AT_containing_type: - containing_type_die_offset = form_value.Reference(); break; + containing_type_die_form = form_value; break; } } } - Type *pointee_type = dwarf->ResolveTypeUID(type_die_offset); - Type *class_type = dwarf->ResolveTypeUID(containing_type_die_offset); + Type *pointee_type = dwarf->ResolveTypeUID(DIERef(type_die_form).GetUID()); + Type *class_type = dwarf->ResolveTypeUID(DIERef(containing_type_die_form).GetUID()); CompilerType pointee_clang_type = pointee_type->GetForwardCompilerType (); CompilerType class_clang_type = class_type->GetLayoutCompilerType (); @@ -1532,7 +1530,7 @@ // We are ready to put this type into the uniqued list up at the module level type_list->Insert (type_sp); - dwarf->m_die_to_type[die.GetDIE()] = type_sp.get(); + dwarf->GetDIEToType()[die.GetDIE()] = type_sp.get(); } } else if (type_ptr != DIE_IS_BEING_PARSED) @@ -1654,8 +1652,7 @@ case DW_AT_type: if (attributes.ExtractFormValueAtIndex(i, form_value)) { - const dw_offset_t type_die_offset = form_value.Reference(); - lldb_type = die.ResolveTypeUID(type_die_offset); + lldb_type = die.ResolveTypeUID(DIERef(form_value).GetUID()); if (lldb_type) clang_type = lldb_type->GetForwardCompilerType (); } @@ -1855,8 +1852,8 @@ const size_t num_matches = method_die_offsets.size(); for (size_t i=0; iGetDIE (die_offset); + const DIERef& die_ref = method_die_offsets[i]; + DWARFDIE method_die = debug_info->GetDIE (die_ref); if (method_die) method_die.ResolveType (); @@ -2310,7 +2307,7 @@ SymbolFileDWARF *dwarf = die.GetDWARF(); // Supply the type _only_ if it has already been parsed - Type *func_type = dwarf->m_die_to_type.lookup (die.GetDIE()); + Type *func_type = dwarf->GetDIEToType().lookup (die.GetDIE()); assert(func_type == NULL || func_type != DIE_IS_BEING_PARSED); @@ -2386,7 +2383,7 @@ bool is_artificial = false; - lldb::user_id_t encoding_uid = LLDB_INVALID_UID; + DWARFFormValue encoding_form; AccessType accessibility = eAccessNone; uint32_t member_byte_offset = UINT32_MAX; size_t byte_size = 0; @@ -2406,7 +2403,7 @@ case DW_AT_decl_line: decl.SetLine(form_value.Unsigned()); break; case DW_AT_decl_column: decl.SetColumn(form_value.Unsigned()); break; case DW_AT_name: name = form_value.AsCString(); break; - case DW_AT_type: encoding_uid = form_value.Reference(); break; + case DW_AT_type: encoding_form = form_value; break; case DW_AT_bit_offset: bit_offset = form_value.Unsigned(); break; case DW_AT_bit_size: bit_size = form_value.Unsigned(); break; case DW_AT_byte_size: byte_size = form_value.Unsigned(); break; @@ -2545,7 +2542,7 @@ // Handle static members if (is_external && member_byte_offset == UINT32_MAX) { - Type *var_type = die.ResolveTypeUID(encoding_uid); + Type *var_type = die.ResolveTypeUID(DIERef(encoding_form).GetUID()); if (var_type) { @@ -2561,7 +2558,7 @@ if (is_artificial == false) { - Type *member_type = die.ResolveTypeUID(encoding_uid); + Type *member_type = die.ResolveTypeUID(DIERef(encoding_form).GetUID()); clang::FieldDecl *field_decl = NULL; if (tag == DW_TAG_member) @@ -2712,7 +2709,7 @@ module_sp->ReportError ("0x%8.8" PRIx64 ": DW_TAG_member '%s' refers to type 0x%8.8" PRIx64 " which extends beyond the bounds of 0x%8.8" PRIx64, die.GetID(), name, - encoding_uid, + encoding_form.Reference(), parent_die.GetID()); } @@ -2737,11 +2734,11 @@ module_sp->ReportError ("0x%8.8" PRIx64 ": DW_TAG_member '%s' refers to type 0x%8.8" PRIx64 " which was unable to be parsed", die.GetID(), name, - encoding_uid); + encoding_form.Reference()); else module_sp->ReportError ("0x%8.8" PRIx64 ": DW_TAG_member refers to type 0x%8.8" PRIx64 " which was unable to be parsed", die.GetID(), - encoding_uid); + encoding_form.Reference()); } } @@ -2792,7 +2789,7 @@ { Declaration decl; DWARFExpression location(die.GetCU()); - lldb::user_id_t encoding_uid = LLDB_INVALID_UID; + DWARFFormValue encoding_form; AccessType accessibility = default_accessibility; bool is_virtual = false; bool is_base_of_class = true; @@ -2809,7 +2806,7 @@ case DW_AT_decl_file: decl.SetFile(sc.comp_unit->GetSupportFiles().GetFileSpecAtIndex(form_value.Unsigned())); break; case DW_AT_decl_line: decl.SetLine(form_value.Unsigned()); break; case DW_AT_decl_column: decl.SetColumn(form_value.Unsigned()); break; - case DW_AT_type: encoding_uid = form_value.Reference(); break; + case DW_AT_type: encoding_form = form_value; break; case DW_AT_data_member_location: if (form_value.BlockData()) { @@ -2861,12 +2858,12 @@ } } - Type *base_class_type = die.ResolveTypeUID(encoding_uid); + Type *base_class_type = die.ResolveTypeUID(DIERef(encoding_form).GetUID()); if (base_class_type == NULL) { module_sp->ReportError("0x%8.8x: DW_TAG_inheritance failed to resolve the base class at 0x%8.8" PRIx64 " from enclosing type 0x%8.8x. \nPlease file a bug and attach the file at the start of this error message", die.GetOffset(), - encoding_uid, + encoding_form.Reference(), parent_die.GetOffset()); break; } @@ -2942,7 +2939,7 @@ { const char *name = NULL; Declaration decl; - dw_offset_t param_type_die_offset = DW_INVALID_OFFSET; + DWARFFormValue param_type_die_form; bool is_artificial = false; // one of None, Auto, Register, Extern, Static, PrivateExtern @@ -2961,7 +2958,7 @@ case DW_AT_decl_column: decl.SetColumn(form_value.Unsigned()); break; case DW_AT_name: name = form_value.AsCString(); break; - case DW_AT_type: param_type_die_offset = form_value.Reference(); break; + case DW_AT_type: param_type_die_form = form_value; break; case DW_AT_artificial: is_artificial = form_value.Boolean(); break; case DW_AT_location: // if (form_value.BlockData()) @@ -3006,7 +3003,7 @@ // being in the formal parameter DIE... if (name == NULL || ::strcmp(name, "this")==0) { - Type *this_type = die.ResolveTypeUID (param_type_die_offset); + Type *this_type = die.ResolveTypeUID (DIERef(param_type_die_form).GetUID()); if (this_type) { uint32_t encoding_mask = this_type->GetEncodingMask(); @@ -3049,7 +3046,7 @@ if (!skip) { - Type *type = die.ResolveTypeUID(param_type_die_offset); + Type *type = die.ResolveTypeUID(DIERef(param_type_die_form).GetUID()); if (type) { function_param_types.push_back (type->GetForwardCompilerType ()); @@ -3471,7 +3468,7 @@ src_die.GetOffset(), dst_die.GetOffset()); } - Type *src_child_type = dst_die.GetDWARF()->m_die_to_type[src_die.GetDIE()]; + Type *src_child_type = dst_die.GetDWARF()->GetDIEToType()[src_die.GetDIE()]; if (src_child_type) { if (log) @@ -3479,7 +3476,7 @@ static_cast(src_child_type), src_child_type->GetID(), src_die.GetOffset(), dst_die.GetOffset()); - dst_die.GetDWARF()->m_die_to_type[dst_die.GetDIE()] = src_child_type; + dst_die.GetDWARF()->GetDIEToType()[dst_die.GetDIE()] = src_child_type; } else { @@ -3522,7 +3519,7 @@ log->Printf ("warning: tried to unique decl context from 0x%8.8x for 0x%8.8x, but none was found", src_die.GetOffset(), dst_die.GetOffset()); } - Type *src_child_type = dst_die.GetDWARF()->m_die_to_type[src_die.GetDIE()]; + Type *src_child_type = dst_die.GetDWARF()->GetDIEToType()[src_die.GetDIE()]; if (src_child_type) { if (log) @@ -3531,7 +3528,7 @@ src_child_type->GetID(), src_die.GetOffset(), dst_die.GetOffset()); - dst_die.GetDWARF()->m_die_to_type[dst_die.GetDIE()] = src_child_type; + dst_die.GetDWARF()->GetDIEToType()[dst_die.GetDIE()] = src_child_type; } else { @@ -3581,7 +3578,7 @@ log->Printf ("warning: tried to unique decl context from 0x%8.8x for 0x%8.8x, but none was found", src_die.GetOffset(), dst_die.GetOffset()); } - Type *src_child_type = dst_die.GetDWARF()->m_die_to_type[src_die.GetDIE()]; + Type *src_child_type = dst_die.GetDWARF()->GetDIEToType()[src_die.GetDIE()]; if (src_child_type) { if (log) @@ -3589,7 +3586,7 @@ static_cast(src_child_type), src_child_type->GetID(), src_die.GetOffset(), dst_die.GetOffset()); - dst_die.GetDWARF()->m_die_to_type[dst_die.GetDIE()] = src_child_type; + dst_die.GetDWARF()->GetDIEToType()[dst_die.GetDIE()] = src_child_type; } else { Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h =================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h @@ -13,9 +13,10 @@ #include "lldb/lldb-enumerations.h" #include "DWARFDebugInfoEntry.h" #include "DWARFDIE.h" -#include "SymbolFileDWARF.h" class NameToDIE; +class SymbolFileDWARF; +class SymbolFileDWARFDwo; class DWARFCompileUnit { @@ -30,6 +31,7 @@ }; DWARFCompileUnit(SymbolFileDWARF* dwarf2Data); + ~DWARFCompileUnit(); bool Extract(const lldb_private::DWARFDataExtractor &debug_info, lldb::offset_t *offset_ptr); size_t ExtractDIEsIfNeeded (bool cu_die_only); @@ -51,11 +53,13 @@ dw_offset_t GetAbbrevOffset() const; uint8_t GetAddressByteSize() const { return m_addr_size; } dw_addr_t GetBaseAddress() const { return m_base_addr; } - dw_addr_t GetAddrBase() const { return 0; } // TODO: Read out DW_AT_addr_base from the parent compile unit + dw_addr_t GetAddrBase() const { return m_addr_base; } + void SetAddrBase(dw_addr_t addr_base, dw_offset_t base_obj_offset); void ClearDIEs(bool keep_compile_unit_die); void BuildAddressRangeTable (SymbolFileDWARF* dwarf2Data, DWARFDebugAranges* debug_aranges); + lldb_private::TypeSystem * GetTypeSystem(); @@ -96,6 +100,9 @@ m_die_array.reserve(GetDebugInfoSize() / 24); m_die_array.push_back(die); } + + void + AddCompileUnitDIE (DWARFDebugInfoEntry& die); bool HasDIEsParsed () const @@ -125,10 +132,7 @@ } void - SetUserData(void *d) - { - m_user_data = d; - } + SetUserData(void *d); bool Supports_DW_AT_APPLE_objc_complete_type (); @@ -140,8 +144,7 @@ Supports_unnamed_objc_bitfields (); void - Index (const uint32_t cu_idx, - NameToDIE& func_basenames, + Index (NameToDIE& func_basenames, NameToDIE& func_fullnames, NameToDIE& func_methods, NameToDIE& func_selectors, @@ -183,8 +186,21 @@ bool GetIsOptimized (); + SymbolFileDWARFDwo* + GetDwoSymbolFile() const + { + return m_dwo_symbol_file.get(); + } + + dw_offset_t + GetBaseObjOffset() const + { + return m_base_obj_offset; + } + protected: SymbolFileDWARF* m_dwarf2Data; + std::unique_ptr m_dwo_symbol_file; const DWARFAbbreviationDeclarationSet *m_abbrevs; void * m_user_data; DWARFDebugInfoEntry::collection m_die_array; // The compile unit debug information entry item @@ -201,9 +217,27 @@ lldb::LanguageType m_language_type; bool m_is_dwarf64; lldb_private::LazyBool m_is_optimized; - + dw_addr_t m_addr_base; // Value of DW_AT_addr_base + dw_offset_t m_base_obj_offset; // If this is a dwo compile unit this is the offset of + // the base compile unit in the main object file + void ParseProducerInfo (); + + static void + IndexPrivate (DWARFCompileUnit* dwarf_cu, + const lldb::LanguageType cu_language, + const DWARFFormValue::FixedFormSizes& fixed_form_sizes, + const dw_offset_t cu_offset, + NameToDIE& func_basenames, + NameToDIE& func_fullnames, + NameToDIE& func_methods, + NameToDIE& func_selectors, + NameToDIE& objc_class_selectors, + NameToDIE& globals, + NameToDIE& types, + NameToDIE& namespaces); + private: const DWARFDebugInfoEntry* Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp =================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp @@ -28,6 +28,7 @@ #include "LogChannelDWARF.h" #include "NameToDIE.h" #include "SymbolFileDWARF.h" +#include "SymbolFileDWARFDwo.h" #include "SymbolFileDWARFDebugMap.h" using namespace lldb; @@ -54,10 +55,15 @@ m_producer_version_update (0), m_language_type (eLanguageTypeUnknown), m_is_dwarf64 (false), - m_is_optimized (eLazyBoolCalculate) + m_is_optimized (eLazyBoolCalculate), + m_addr_base (0), + m_base_obj_offset (DW_INVALID_OFFSET) { } +DWARFCompileUnit::~DWARFCompileUnit() +{} + void DWARFCompileUnit::Clear() { @@ -74,6 +80,8 @@ m_language_type = eLanguageTypeUnknown; m_is_dwarf64 = false; m_is_optimized = eLazyBoolCalculate; + m_addr_base = 0; + m_base_obj_offset = DW_INVALID_OFFSET; } bool @@ -131,6 +139,9 @@ if (keep_compile_unit_die) m_die_array.push_back(tmp_array.front()); } + + if (m_dwo_symbol_file) + m_dwo_symbol_file->GetCompileUnit()->ClearDIEs(keep_compile_unit_die); } //---------------------------------------------------------------------- @@ -192,12 +203,12 @@ const bool null_die = die.IsNULL(); if (depth == 0) { - uint64_t base_addr = die.GetAttributeValueAsUnsigned(m_dwarf2Data, this, DW_AT_low_pc, LLDB_INVALID_ADDRESS); + if (initial_die_array_size == 0) + AddCompileUnitDIE(die); + uint64_t base_addr = die.GetAttributeValueAsAddress(m_dwarf2Data, this, DW_AT_low_pc, LLDB_INVALID_ADDRESS); if (base_addr == LLDB_INVALID_ADDRESS) - base_addr = die.GetAttributeValueAsUnsigned(m_dwarf2Data, this, DW_AT_entry_pc, 0); + base_addr = die.GetAttributeValueAsAddress(m_dwarf2Data, this, DW_AT_entry_pc, 0); SetBaseAddress (base_addr); - if (initial_die_array_size == 0) - AddDIE (die); if (cu_die_only) return 1; } @@ -287,9 +298,83 @@ verbose_log->PutCString (strm.GetString().c_str()); } - return m_die_array.size(); + if (!m_dwo_symbol_file) + return m_die_array.size(); + + DWARFCompileUnit* dwo_cu = m_dwo_symbol_file->GetCompileUnit(); + size_t dwo_die_count = dwo_cu->ExtractDIEsIfNeeded(cu_die_only); + return m_die_array.size() + dwo_die_count - 1; // We have 2 CU die, but we waht to count it only as one } +void +DWARFCompileUnit::AddCompileUnitDIE(DWARFDebugInfoEntry& die) +{ + assert (m_die_array.empty() && "Compile unit DIE already added"); + AddDIE(die); + + DWARFDebugInfoEntry& cu_die = m_die_array.front(); + + const char* dwo_name = cu_die.GetAttributeValueAsString(m_dwarf2Data, + this, + DW_AT_GNU_dwo_name, + nullptr); + if (!dwo_name) + return; + + FileSpec dwo_file(dwo_name, true); + if (dwo_file.IsRelative()) + { + const char* comp_dir = cu_die.GetAttributeValueAsString(m_dwarf2Data, + this, + DW_AT_comp_dir, + nullptr); + if (!comp_dir) + return; + + dwo_file.SetFile(comp_dir, true); + dwo_file.AppendPathComponent(dwo_name); + } + + if (!dwo_file.Exists()) + return; + + DataBufferSP dwo_file_data_sp; + lldb::offset_t dwo_file_data_offset = 0; + ObjectFileSP dwo_obj_file = ObjectFile::FindPlugin(m_dwarf2Data->GetObjectFile()->GetModule(), + &dwo_file, + 0 /* file_offset */, + dwo_file.GetByteSize(), + dwo_file_data_sp, + dwo_file_data_offset); + if (dwo_obj_file == nullptr) + return; + + std::unique_ptr dwo_symbol_file(new SymbolFileDWARFDwo(dwo_obj_file, this)); + + DWARFCompileUnit* dwo_cu = dwo_symbol_file->GetCompileUnit(); + if (!dwo_cu) + return; // Can't fetch the compile unit from the dwo file. + + DWARFDIE dwo_cu_die = dwo_cu->GetCompileUnitDIEOnly(); + if (!dwo_cu_die.IsValid()) + return; // Can't fetch the compile unit DIE from the dwo file. + + uint64_t main_dwo_id = cu_die.GetAttributeValueAsUnsigned(m_dwarf2Data, + this, + DW_AT_GNU_dwo_id, + 0); + uint64_t sub_dwo_id = dwo_cu_die.GetAttributeValueAsUnsigned(DW_AT_GNU_dwo_id, 0); + if (main_dwo_id != sub_dwo_id) + return; // The 2 dwo ID isn't match. Don't use the dwo file as it belongs to a differectn compilation. + + m_dwo_symbol_file = std::move(dwo_symbol_file); + + dw_addr_t addr_base = cu_die.GetAttributeValueAsUnsigned(m_dwarf2Data, + this, + DW_AT_GNU_addr_base, + 0); + dwo_cu->SetAddrBase(addr_base, m_offset); +} dw_offset_t DWARFCompileUnit::GetAbbrevOffset() const @@ -380,10 +465,11 @@ lldb::user_id_t DWARFCompileUnit::GetID () const { + dw_offset_t local_id = m_base_obj_offset != DW_INVALID_OFFSET ? m_base_obj_offset : m_offset; if (m_dwarf2Data) - return m_dwarf2Data->MakeUserID(GetOffset()); + return m_dwarf2Data->MakeUserID(local_id); else - return GetOffset(); + return local_id; } void @@ -509,6 +595,17 @@ const DWARFDebugInfoEntry* die = DIEPtr(); if (die) die->BuildFunctionAddressRangeTable (m_dwarf2Data, this, m_func_aranges_ap.get()); + + if (m_dwo_symbol_file) + { + DWARFCompileUnit* dwo_cu = m_dwo_symbol_file->GetCompileUnit(); + const DWARFDebugInfoEntry* dwo_die = dwo_cu->DIEPtr(); + if (dwo_die) + dwo_die->BuildFunctionAddressRangeTable (m_dwo_symbol_file.get(), + dwo_cu, + m_func_aranges_ap.get()); + } + const bool minimize = false; m_func_aranges_ap->Sort(minimize); } @@ -550,6 +647,9 @@ { if (die_offset != DW_INVALID_OFFSET) { + if (m_dwo_symbol_file) + return m_dwo_symbol_file->GetCompileUnit()->GetDIE(die_offset); + if (ContainsDIEOffset(die_offset)) { ExtractDIEsIfNeeded (false); @@ -563,7 +663,9 @@ } else { - return m_dwarf2Data->DebugInfo()->GetDIE (die_offset); + // Don't specify the compile unit offset as we don't know it because the DIE belongs to + // a different compile unit in the same symbol file. + return m_dwarf2Data->DebugInfo()->GetDIE (DIERef(die_offset)); } } return DWARFDIE(); // Not found @@ -609,8 +711,7 @@ void -DWARFCompileUnit::Index (const uint32_t cu_idx, - NameToDIE& func_basenames, +DWARFCompileUnit::Index (NameToDIE& func_basenames, NameToDIE& func_fullnames, NameToDIE& func_methods, NameToDIE& func_selectors, @@ -619,9 +720,6 @@ NameToDIE& types, NameToDIE& namespaces) { - DWARFFormValue::FixedFormSizes fixed_form_sizes = - DWARFFormValue::GetFixedFormSizesForAddressSize (GetAddressByteSize(), m_is_dwarf64); - Log *log (LogChannelDWARF::GetLogIfAll (DWARF_LOG_LOOKUPS)); if (log) @@ -632,9 +730,57 @@ } const LanguageType cu_language = GetLanguageType(); + DWARFFormValue::FixedFormSizes fixed_form_sizes = + DWARFFormValue::GetFixedFormSizesForAddressSize (GetAddressByteSize(), m_is_dwarf64); + + IndexPrivate(this, + cu_language, + fixed_form_sizes, + GetOffset(), + func_basenames, + func_fullnames, + func_methods, + func_selectors, + objc_class_selectors, + globals, + types, + namespaces); + + SymbolFileDWARFDwo* dwo_symbol_file = GetDwoSymbolFile(); + if (dwo_symbol_file) + { + IndexPrivate(dwo_symbol_file->GetCompileUnit(), + cu_language, + fixed_form_sizes, + GetOffset(), + func_basenames, + func_fullnames, + func_methods, + func_selectors, + objc_class_selectors, + globals, + types, + namespaces); + } +} + +void +DWARFCompileUnit::IndexPrivate (DWARFCompileUnit* dwarf_cu, + const LanguageType cu_language, + const DWARFFormValue::FixedFormSizes& fixed_form_sizes, + const dw_offset_t cu_offset, + NameToDIE& func_basenames, + NameToDIE& func_fullnames, + NameToDIE& func_methods, + NameToDIE& func_selectors, + NameToDIE& objc_class_selectors, + NameToDIE& globals, + NameToDIE& types, + NameToDIE& namespaces) +{ DWARFDebugInfoEntry::const_iterator pos; - DWARFDebugInfoEntry::const_iterator begin = m_die_array.begin(); - DWARFDebugInfoEntry::const_iterator end = m_die_array.end(); + DWARFDebugInfoEntry::const_iterator begin = dwarf_cu->m_die_array.begin(); + DWARFDebugInfoEntry::const_iterator end = dwarf_cu->m_die_array.end(); for (pos = begin; pos != end; ++pos) { const DWARFDebugInfoEntry &die = *pos; @@ -672,8 +818,8 @@ bool has_location = false; bool is_global_or_static_variable = false; - dw_offset_t specification_die_offset = DW_INVALID_OFFSET; - const size_t num_attributes = die.GetAttributes(this, fixed_form_sizes, attributes); + DWARFFormValue specification_die_form; + const size_t num_attributes = die.GetAttributes(dwarf_cu, fixed_form_sizes, attributes); if (num_attributes > 0) { for (uint32_t i=0; iDebugInfo()->GetDIE (specification_die_offset); + DWARFDIE specification_die = dwarf_cu->GetSymbolFileDWARF()->DebugInfo()->GetDIE (DIERef(specification_die_form)); if (specification_die.GetParent().IsStructOrClass()) is_method = true; } @@ -817,12 +963,12 @@ if (is_method) - func_methods.Insert (ConstString(name), die.GetOffset()); + func_methods.Insert (ConstString(name), DIERef(cu_offset, die.GetOffset())); else - func_basenames.Insert (ConstString(name), die.GetOffset()); + func_basenames.Insert (ConstString(name), DIERef(cu_offset, die.GetOffset())); if (!is_method && !mangled_cstr && !objc_method.IsValid(true)) - func_fullnames.Insert (ConstString(name), die.GetOffset()); + func_fullnames.Insert (ConstString(name), DIERef(cu_offset, die.GetOffset())); } if (mangled_cstr) { @@ -833,10 +979,10 @@ if (name != mangled_cstr && ((mangled_cstr[0] == '_') || (name && ::strcmp(name, mangled_cstr) != 0))) { Mangled mangled (ConstString(mangled_cstr), true); - func_fullnames.Insert (mangled.GetMangledName(), die.GetOffset()); + func_fullnames.Insert (mangled.GetMangledName(), DIERef(cu_offset, die.GetOffset())); ConstString demangled = mangled.GetDemangledName(cu_language); if (demangled) - func_fullnames.Insert (demangled, die.GetOffset()); + func_fullnames.Insert (demangled, DIERef(cu_offset, die.GetOffset())); } } } @@ -846,7 +992,7 @@ if (has_address) { if (name) - func_basenames.Insert (ConstString(name), die.GetOffset()); + func_basenames.Insert (ConstString(name), DIERef(cu_offset, die.GetOffset())); if (mangled_cstr) { // Make sure our mangled name isn't the same string table entry @@ -856,14 +1002,14 @@ if (name != mangled_cstr && ((mangled_cstr[0] == '_') || (::strcmp(name, mangled_cstr) != 0))) { Mangled mangled (ConstString(mangled_cstr), true); - func_fullnames.Insert (mangled.GetMangledName(), die.GetOffset()); + func_fullnames.Insert (mangled.GetMangledName(), DIERef(cu_offset, die.GetOffset())); ConstString demangled = mangled.GetDemangledName(cu_language); if (demangled) - func_fullnames.Insert (demangled, die.GetOffset()); + func_fullnames.Insert (demangled, DIERef(cu_offset, die.GetOffset())); } } else - func_fullnames.Insert (ConstString(name), die.GetOffset()); + func_fullnames.Insert (ConstString(name), DIERef(cu_offset, die.GetOffset())); } break; @@ -879,19 +1025,19 @@ case DW_TAG_unspecified_type: if (name && is_declaration == false) { - types.Insert (ConstString(name), die.GetOffset()); + types.Insert (ConstString(name), DIERef(cu_offset, die.GetOffset())); } break; case DW_TAG_namespace: if (name) - namespaces.Insert (ConstString(name), die.GetOffset()); + namespaces.Insert (ConstString(name), DIERef(cu_offset, die.GetOffset())); break; case DW_TAG_variable: if (name && has_location && is_global_or_static_variable) { - globals.Insert (ConstString(name), die.GetOffset()); + globals.Insert (ConstString(name), DIERef(cu_offset, die.GetOffset())); // Be sure to include variables by their mangled and demangled // names if they have any since a variable can have a basename // "i", a mangled named "_ZN12_GLOBAL__N_11iE" and a demangled @@ -904,10 +1050,10 @@ if (mangled_cstr && name != mangled_cstr && ((mangled_cstr[0] == '_') || (::strcmp(name, mangled_cstr) != 0))) { Mangled mangled (ConstString(mangled_cstr), true); - globals.Insert (mangled.GetMangledName(), die.GetOffset()); + globals.Insert (mangled.GetMangledName(), DIERef(cu_offset, die.GetOffset())); ConstString demangled = mangled.GetDemangledName(cu_language); if (demangled) - globals.Insert (demangled, die.GetOffset()); + globals.Insert (demangled, DIERef(cu_offset, die.GetOffset())); } } break; @@ -1097,3 +1243,18 @@ else return nullptr; } + +void +DWARFCompileUnit::SetUserData(void *d) +{ + m_user_data = d; + if (m_dwo_symbol_file) + m_dwo_symbol_file->GetCompileUnit()->SetUserData(d); +} + +void +DWARFCompileUnit::SetAddrBase(dw_addr_t addr_base, dw_offset_t base_obj_offset) +{ + m_addr_base = addr_base; + m_base_obj_offset = base_obj_offset; +} Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIE.h =================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIE.h +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIE.h @@ -13,6 +13,7 @@ #include "lldb/lldb-types.h" #include "lldb/Core/dwarf.h" +struct DIERef; class DWARFASTParser; class DWARFAttributes; class DWARFCompileUnit; @@ -95,6 +96,9 @@ return m_die; } + DIERef + GetDIERef() const; + lldb_private::TypeSystem * GetTypeSystem () const; @@ -232,6 +236,9 @@ uint64_t GetAttributeValueAsReference (const dw_attr_t attr, uint64_t fail_value) const; + uint64_t + GetAttributeValueAsAddress (const dw_attr_t attr, uint64_t fail_value) const; + size_t GetAttributes (DWARFAttributes &attributes, uint32_t depth = 0) const; Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp =================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp @@ -25,6 +25,18 @@ #include "lldb/Core/Module.h" #include "lldb/Symbol/ObjectFile.h" +DIERef +DWARFDIE::GetDIERef() const +{ + if (!IsValid()) + return DIERef(); + + dw_offset_t cu_offset = m_cu->GetOffset(); + if (m_cu->GetBaseObjOffset() != DW_INVALID_OFFSET) + cu_offset = m_cu->GetBaseObjOffset(); + return DIERef(cu_offset, m_die->GetOffset()); +} + dw_tag_t DWARFDIE::Tag() const { @@ -122,6 +134,15 @@ return fail_value; } +uint64_t +DWARFDIE::GetAttributeValueAsAddress (const dw_attr_t attr, uint64_t fail_value) const +{ + if (IsValid()) + return m_die->GetAttributeValueAsAddress(GetDWARF(), GetCU(), attr, fail_value); + else + return fail_value; +} + DWARFDIE DWARFDIE::LookupDeepestBlock (lldb::addr_t file_addr) const @@ -143,7 +164,7 @@ if (cu->ContainsDIEOffset(block_die->GetOffset())) return DWARFDIE(cu, block_die); else - return DWARFDIE(dwarf->DebugInfo()->GetCompileUnitContainingDIE(block_die->GetOffset()), block_die); + return DWARFDIE(dwarf->DebugInfo()->GetCompileUnitContainingDIE(DIERef(cu->GetOffset(), block_die->GetOffset())), block_die); } } } @@ -156,11 +177,19 @@ const dw_offset_t die_offset = GetOffset(); if (die_offset != DW_INVALID_OFFSET) { + lldb::user_id_t id = 0; SymbolFileDWARF *dwarf = GetDWARF(); if (dwarf) - return dwarf->MakeUserID(die_offset); + id = dwarf->MakeUserID(die_offset); else - return die_offset; + id = die_offset; + + if (m_cu) + { + assert ((id&0xffffffff00000000ull) == 0 || m_cu->GetOffset() == 0); + id |= ((lldb::user_id_t)m_cu->GetOffset()) << 32; + } + return id; } return LLDB_INVALID_UID; } Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h =================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h @@ -36,18 +36,13 @@ DWARFDebugInfo(); void SetDwarfData(SymbolFileDWARF* dwarf2Data); - DWARFDIE - LookupAddress(const dw_addr_t address, - const dw_offset_t cu_offset); // Can be valid (find in .debug_aranges), or DW_INVALID_OFFSET if we need to search manually - size_t GetNumCompileUnits(); bool ContainsCompileUnit (const DWARFCompileUnit *cu) const; DWARFCompileUnit* GetCompileUnitAtIndex (uint32_t idx); DWARFCompileUnit* GetCompileUnit (dw_offset_t cu_offset, uint32_t* idx_ptr = NULL); - DWARFCompileUnit* GetCompileUnitContainingDIE (dw_offset_t die_offset); + DWARFCompileUnit* GetCompileUnitContainingDIE (const DIERef& die_ref); - DWARFDIE GetDIE (dw_offset_t die_offset); - DWARFDIE GetDIEContainingOffset (dw_offset_t die_offset); + DWARFDIE GetDIE (const DIERef& die_ref); void Dump(lldb_private::Stream *s, const uint32_t die_offset, const uint32_t recurse_depth); static void Parse(SymbolFileDWARF* parser, Callback callback, void* userData); Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp =================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp @@ -103,48 +103,6 @@ return *m_cu_aranges_ap.get(); } - -//---------------------------------------------------------------------- -// LookupAddress -//---------------------------------------------------------------------- -DWARFDIE -DWARFDebugInfo::LookupAddress (const dw_addr_t address, - const dw_offset_t hint_die_offset) -{ - DWARFDIE die; - DWARFCompileUnit *cu = nullptr; - if (hint_die_offset != DW_INVALID_OFFSET) - { - cu = GetCompileUnit(hint_die_offset); - } - else - { - DWARFDebugAranges &cu_aranges = GetCompileUnitAranges (); - const dw_offset_t cu_offset = cu_aranges.FindAddress (address); - cu = GetCompileUnit(cu_offset); - } - - if (cu) - { - die = cu->LookupAddress(address); - } - else - { - // The hint_die_offset may have been a pointer to the actual item that - // we are looking for - die = GetDIE(hint_die_offset); - if (die) - { - DWARFDebugInfoEntry* function_die = nullptr; - - if (die.GetDIE()->LookupAddress (address, die.GetDWARF(), die.GetCU(), &function_die, nullptr)) - die.Set (die.GetCU(), function_die); - } - } - return die; -} - - void DWARFDebugInfo::ParseCompileUnitHeadersIfNeeded() { @@ -251,10 +209,18 @@ } DWARFCompileUnit * -DWARFDebugInfo::GetCompileUnitContainingDIE (dw_offset_t die_offset) +DWARFDebugInfo::GetCompileUnitContainingDIE (const DIERef& die_ref) { + dw_offset_t search_offset = die_ref.die_offset; + bool is_cu_offset = false; + if (m_dwarf2Data->GetID() == 0 && die_ref.cu_offset != DW_INVALID_OFFSET) + { + is_cu_offset = true; + search_offset = die_ref.cu_offset; + } + DWARFCompileUnitSP cu_sp; - if (die_offset != DW_INVALID_OFFSET) + if (search_offset != DW_INVALID_OFFSET) { ParseCompileUnitHeadersIfNeeded(); @@ -262,19 +228,25 @@ const size_t num_cus = m_compile_units.size(); if (num_cus == 1) { - if (m_compile_units[0]->ContainsDIEOffset(die_offset)) + if ((is_cu_offset && m_compile_units[0]->GetOffset() == search_offset) || + (!is_cu_offset && m_compile_units[0]->ContainsDIEOffset(search_offset))) + { cu_sp = m_compile_units[0]; + } } else if (num_cus) { CompileUnitColl::const_iterator end_pos = m_compile_units.end(); CompileUnitColl::const_iterator begin_pos = m_compile_units.begin(); - CompileUnitColl::const_iterator pos = std::upper_bound(begin_pos, end_pos, die_offset, OffsetLessThanCompileUnitOffset); + CompileUnitColl::const_iterator pos = std::upper_bound(begin_pos, end_pos, search_offset, OffsetLessThanCompileUnitOffset); if (pos != begin_pos) { --pos; - if ((*pos)->ContainsDIEOffset(die_offset)) + if ((is_cu_offset && (*pos)->GetOffset() == search_offset) || + (!is_cu_offset && (*pos)->ContainsDIEOffset(search_offset))) + { cu_sp = *pos; + } } } } @@ -287,11 +259,11 @@ // Get the DIE (Debug Information Entry) with the specified offset. //---------------------------------------------------------------------- DWARFDIE -DWARFDebugInfo::GetDIE(dw_offset_t die_offset) +DWARFDebugInfo::GetDIE(const DIERef& die_ref) { - DWARFCompileUnit *cu = GetCompileUnitContainingDIE(die_offset); + DWARFCompileUnit *cu = GetCompileUnitContainingDIE(die_ref); if (cu) - return cu->GetDIE (die_offset); + return cu->GetDIE (die_ref.die_offset); return DWARFDIE(); // Not found } Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h =================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h @@ -115,62 +115,62 @@ DWARFAttributes& attrs, uint32_t curr_depth = 0) const; // "curr_depth" for internal use only, don't set this yourself!!! - dw_offset_t GetAttributeValue( - SymbolFileDWARF* dwarf2Data, - const DWARFCompileUnit* cu, - const dw_attr_t attr, - DWARFFormValue& formValue, - dw_offset_t* end_attr_offset_ptr = NULL) const; - const char* GetAttributeValueAsString( SymbolFileDWARF* dwarf2Data, const DWARFCompileUnit* cu, const dw_attr_t attr, - const char* fail_value) const; + const char* fail_value, + bool check_specification_or_abstract_origin = false) const; uint64_t GetAttributeValueAsUnsigned( SymbolFileDWARF* dwarf2Data, const DWARFCompileUnit* cu, const dw_attr_t attr, - uint64_t fail_value) const; + uint64_t fail_value, + bool check_specification_or_abstract_origin = false) const; uint64_t GetAttributeValueAsReference( SymbolFileDWARF* dwarf2Data, const DWARFCompileUnit* cu, const dw_attr_t attr, - uint64_t fail_value) const; + uint64_t fail_value, + bool check_specification_or_abstract_origin = false) const; int64_t GetAttributeValueAsSigned( SymbolFileDWARF* dwarf2Data, const DWARFCompileUnit* cu, const dw_attr_t attr, - int64_t fail_value) const; + int64_t fail_value, + bool check_specification_or_abstract_origin = false) const; + + uint64_t GetAttributeValueAsAddress( + SymbolFileDWARF* dwarf2Data, + const DWARFCompileUnit* cu, + const dw_attr_t attr, + uint64_t fail_value, + bool check_specification_or_abstract_origin = false) const; dw_addr_t GetAttributeHighPC( SymbolFileDWARF* dwarf2Data, const DWARFCompileUnit* cu, dw_addr_t lo_pc, - uint64_t fail_value) const; + uint64_t fail_value, + bool check_specification_or_abstract_origin = false) const; bool GetAttributeAddressRange( SymbolFileDWARF* dwarf2Data, const DWARFCompileUnit* cu, dw_addr_t& lo_pc, dw_addr_t& hi_pc, - uint64_t fail_value) const; + uint64_t fail_value, + bool check_specification_or_abstract_origin = false) const; size_t GetAttributeAddressRanges ( SymbolFileDWARF* dwarf2Data, const DWARFCompileUnit* cu, DWARFRangeList &ranges, - bool check_hi_lo_pc) const; - - dw_offset_t GetAttributeValueAsLocation( - SymbolFileDWARF* dwarf2Data, - const DWARFCompileUnit* cu, - const dw_attr_t attr, - lldb_private::DWARFDataExtractor& data, - uint32_t &block_size) const; + bool check_hi_lo_pc, + bool check_specification_or_abstract_origin = false) const; const char* GetName( SymbolFileDWARF* dwarf2Data, @@ -382,6 +382,13 @@ DWARFDebugInfoEntry::collection &die_collection); protected: + dw_offset_t GetAttributeValue(SymbolFileDWARF* dwarf2Data, + const DWARFCompileUnit* cu, + const dw_attr_t attr, + DWARFFormValue& formValue, + dw_offset_t* end_attr_offset_ptr = nullptr, + bool check_specification_or_abstract_origin = false) const; + dw_offset_t m_offset; // Offset within the .debug_info of the start of this entry uint32_t m_parent_idx; // How many to subtract from "this" to get the parent. If zero this die has no parent uint32_t m_sibling_idx:31, // How many to add to "this" to get the sibling. @@ -389,7 +396,6 @@ uint32_t m_abbr_idx:DIE_ABBR_IDX_BITSIZE, m_has_children:1, // Set to 1 if this DIE has children m_tag:16; // A copy of the DW_TAG value so we don't have to go through the compile unit abbrev table - }; #endif // SymbolFileDWARF_DWARFDebugInfoEntry_h_ Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp =================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp @@ -19,7 +19,6 @@ #include "lldb/Symbol/ObjectFile.h" #include "DWARFCompileUnit.h" -#include "SymbolFileDWARF.h" #include "DWARFDebugAbbrev.h" #include "DWARFDebugAranges.h" #include "DWARFDebugInfo.h" @@ -29,6 +28,8 @@ #include "DWARFLocationDescription.h" #include "DWARFLocationList.h" #include "DWARFDebugRanges.h" +#include "SymbolFileDWARF.h" +#include "SymbolFileDWARFDwo.h" using namespace lldb_private; using namespace std; @@ -245,7 +246,7 @@ if (form_value.ExtractValue(debug_info_data, &offset)) { if (attr == DW_AT_low_pc || attr == DW_AT_entry_pc) - ((DWARFCompileUnit*)cu)->SetBaseAddress(form_value.Unsigned()); + const_cast(cu)->SetBaseAddress(form_value.Address()); } } else @@ -403,12 +404,27 @@ DWARFExpression *frame_base ) const { - if (dwarf2Data == NULL) + if (dwarf2Data == nullptr) return false; + SymbolFileDWARFDwo* dwo_symbol_file = cu->GetDwoSymbolFile(); + if (dwo_symbol_file) + return GetDIENamesAndRanges(dwo_symbol_file, + dwo_symbol_file->GetCompileUnit(), + name, + mangled, + ranges, + decl_file, + decl_line, + decl_column, + call_file, + call_line, + call_column, + frame_base); + dw_addr_t lo_pc = LLDB_INVALID_ADDRESS; dw_addr_t hi_pc = LLDB_INVALID_ADDRESS; - std::vector die_offsets; + std::vector die_refs; bool set_frame_base_loclist_addr = false; lldb::offset_t offset; @@ -438,7 +454,7 @@ switch (attr) { case DW_AT_low_pc: - lo_pc = form_value.Unsigned(); + lo_pc = form_value.Address(); if (do_offset) hi_pc += lo_pc; @@ -446,13 +462,18 @@ break; case DW_AT_entry_pc: - lo_pc = form_value.Unsigned(); + lo_pc = form_value.Address(); break; case DW_AT_high_pc: - hi_pc = form_value.Unsigned(); - if (form_value.Form() != DW_FORM_addr) + if (form_value.Form() == DW_FORM_addr || + form_value.Form() == DW_FORM_GNU_addr_index) { + hi_pc = form_value.Address(); + } + else + { + hi_pc = form_value.Unsigned(); if (lo_pc == LLDB_INVALID_ADDRESS) do_offset = hi_pc != LLDB_INVALID_ADDRESS; else @@ -483,11 +504,11 @@ break; case DW_AT_abstract_origin: - die_offsets.push_back(form_value.Reference()); + die_refs.emplace_back(form_value); break; case DW_AT_specification: - die_offsets.push_back(form_value.Reference()); + die_refs.emplace_back(form_value); break; case DW_AT_decl_file: @@ -579,14 +600,11 @@ if (ranges.IsEmpty() || name == NULL || mangled == NULL) { - std::vector::const_iterator pos; - std::vector::const_iterator end = die_offsets.end(); - for (pos = die_offsets.begin(); pos != end; ++pos) + for (const DIERef& die_ref : die_refs) { - dw_offset_t die_offset = *pos; - if (die_offset != DW_INVALID_OFFSET) + if (die_ref.die_offset != DW_INVALID_OFFSET) { - DWARFDIE die = dwarf2Data->DebugInfo()->GetDIE(die_offset); + DWARFDIE die = dwarf2Data->DebugInfo()->GetDIE(die_ref); if (die) die.GetDIE()->GetDIENamesAndRanges(die.GetDWARF(), die.GetCU(), name, mangled, ranges, decl_file, decl_line, decl_column, call_file, call_line, call_column); } @@ -867,6 +885,16 @@ lldb::offset_t offset = 0; if (cu) { + if (m_tag != DW_TAG_compile_unit) + { + SymbolFileDWARFDwo* dwo_symbol_file = cu->GetDwoSymbolFile(); + if (dwo_symbol_file) + return GetAttributes(dwo_symbol_file->GetCompileUnit(), + fixed_form_sizes, + attributes, + curr_depth); + } + dwarf2Data = cu->GetSymbolFileDWARF(); abbrevDecl = GetAbbreviationDeclarationPtr(dwarf2Data, cu, offset); } @@ -951,9 +979,19 @@ const DWARFCompileUnit* cu, const dw_attr_t attr, DWARFFormValue& form_value, - dw_offset_t* end_attr_offset_ptr + dw_offset_t* end_attr_offset_ptr, + bool check_specification_or_abstract_origin ) const { + SymbolFileDWARFDwo* dwo_symbol_file = cu->GetDwoSymbolFile(); + if (dwo_symbol_file && m_tag != DW_TAG_compile_unit) + return GetAttributeValue(dwo_symbol_file, + dwo_symbol_file->GetCompileUnit(), + attr, + form_value, + end_attr_offset_ptr, + check_specification_or_abstract_origin); + lldb::offset_t offset; const DWARFAbbreviationDeclaration* abbrevDecl = GetAbbreviationDeclarationPtr(dwarf2Data, cu, offset); @@ -981,7 +1019,58 @@ } } - return 0; + if (check_specification_or_abstract_origin) + { + if (GetAttributeValue(dwarf2Data, cu, DW_AT_specification, form_value)) + { + DWARFDIE die = const_cast(cu)->GetDIE(form_value.Reference()); + if (die) + { + dw_offset_t die_offset = die.GetDIE()->GetAttributeValue(die.GetDWARF(), + die.GetCU(), + attr, + form_value, + end_attr_offset_ptr, + false); + if (die_offset) + return die_offset; + } + } + + if (GetAttributeValue(dwarf2Data, cu, DW_AT_abstract_origin, form_value)) + { + DWARFDIE die = const_cast(cu)->GetDIE(form_value.Reference()); + if (die) + { + dw_offset_t die_offset = die.GetDIE()->GetAttributeValue(die.GetDWARF(), + die.GetCU(), + attr, + form_value, + end_attr_offset_ptr, + false); + if (die_offset) + return die_offset; + } + } + } + + if (!dwo_symbol_file) + return 0; + + DWARFCompileUnit* dwo_cu = dwo_symbol_file->GetCompileUnit(); + if (!dwo_cu) + return 0; + + DWARFDIE dwo_cu_die = dwo_cu->GetCompileUnitDIEOnly(); + if (!dwo_cu_die.IsValid()) + return 0; + + return dwo_cu_die.GetDIE()->GetAttributeValue(dwo_symbol_file, + dwo_cu, + attr, + form_value, + end_attr_offset_ptr, + check_specification_or_abstract_origin); } //---------------------------------------------------------------------- @@ -998,10 +1087,11 @@ SymbolFileDWARF* dwarf2Data, const DWARFCompileUnit* cu, const dw_attr_t attr, - const char* fail_value) const + const char* fail_value, + bool check_specification_or_abstract_origin) const { DWARFFormValue form_value; - if (GetAttributeValue(dwarf2Data, cu, attr, form_value)) + if (GetAttributeValue(dwarf2Data, cu, attr, form_value, nullptr, check_specification_or_abstract_origin)) return form_value.AsCString(); return fail_value; } @@ -1017,11 +1107,12 @@ SymbolFileDWARF* dwarf2Data, const DWARFCompileUnit* cu, const dw_attr_t attr, - uint64_t fail_value + uint64_t fail_value, + bool check_specification_or_abstract_origin ) const { DWARFFormValue form_value; - if (GetAttributeValue(dwarf2Data, cu, attr, form_value)) + if (GetAttributeValue(dwarf2Data, cu, attr, form_value, nullptr, check_specification_or_abstract_origin)) return form_value.Unsigned(); return fail_value; } @@ -1037,11 +1128,12 @@ SymbolFileDWARF* dwarf2Data, const DWARFCompileUnit* cu, const dw_attr_t attr, - int64_t fail_value + int64_t fail_value, + bool check_specification_or_abstract_origin ) const { DWARFFormValue form_value; - if (GetAttributeValue(dwarf2Data, cu, attr, form_value)) + if (GetAttributeValue(dwarf2Data, cu, attr, form_value, nullptr, check_specification_or_abstract_origin)) return form_value.Signed(); return fail_value; } @@ -1058,15 +1150,32 @@ SymbolFileDWARF* dwarf2Data, const DWARFCompileUnit* cu, const dw_attr_t attr, - uint64_t fail_value + uint64_t fail_value, + bool check_specification_or_abstract_origin ) const { DWARFFormValue form_value; - if (GetAttributeValue(dwarf2Data, cu, attr, form_value)) + if (GetAttributeValue(dwarf2Data, cu, attr, form_value, nullptr, check_specification_or_abstract_origin)) return form_value.Reference(); return fail_value; } +uint64_t +DWARFDebugInfoEntry::GetAttributeValueAsAddress +( + SymbolFileDWARF* dwarf2Data, + const DWARFCompileUnit* cu, + const dw_attr_t attr, + uint64_t fail_value, + bool check_specification_or_abstract_origin +) const +{ + DWARFFormValue form_value; + if (GetAttributeValue(dwarf2Data, cu, attr, form_value, nullptr, check_specification_or_abstract_origin)) + return form_value.Address(); + return fail_value; +} + //---------------------------------------------------------------------- // GetAttributeHighPC // @@ -1081,11 +1190,12 @@ SymbolFileDWARF* dwarf2Data, const DWARFCompileUnit* cu, dw_addr_t lo_pc, - uint64_t fail_value + uint64_t fail_value, + bool check_specification_or_abstract_origin ) const { DWARFFormValue form_value; - if (GetAttributeValue(dwarf2Data, cu, DW_AT_high_pc, form_value)) + if (GetAttributeValue(dwarf2Data, cu, DW_AT_high_pc, form_value, nullptr, check_specification_or_abstract_origin)) { dw_form_t form = form_value.Form(); if (form == DW_FORM_addr || form == DW_FORM_GNU_addr_index) @@ -1112,13 +1222,14 @@ const DWARFCompileUnit* cu, dw_addr_t& lo_pc, dw_addr_t& hi_pc, - uint64_t fail_value + uint64_t fail_value, + bool check_specification_or_abstract_origin ) const { - lo_pc = GetAttributeValueAsUnsigned(dwarf2Data, cu, DW_AT_low_pc, fail_value); + lo_pc = GetAttributeValueAsAddress(dwarf2Data, cu, DW_AT_low_pc, fail_value, check_specification_or_abstract_origin); if (lo_pc != fail_value) { - hi_pc = GetAttributeHighPC(dwarf2Data, cu, lo_pc, fail_value); + hi_pc = GetAttributeHighPC(dwarf2Data, cu, lo_pc, fail_value, check_specification_or_abstract_origin); if (hi_pc != fail_value) return true; } @@ -1131,11 +1242,16 @@ DWARFDebugInfoEntry::GetAttributeAddressRanges (SymbolFileDWARF* dwarf2Data, const DWARFCompileUnit* cu, DWARFRangeList &ranges, - bool check_hi_lo_pc) const + bool check_hi_lo_pc, + bool check_specification_or_abstract_origin) const { ranges.Clear(); - dw_offset_t debug_ranges_offset = GetAttributeValueAsUnsigned(dwarf2Data, cu, DW_AT_ranges, DW_INVALID_OFFSET); + dw_offset_t debug_ranges_offset = GetAttributeValueAsUnsigned(dwarf2Data, + cu, + DW_AT_ranges, + DW_INVALID_OFFSET, + check_specification_or_abstract_origin); if (debug_ranges_offset != DW_INVALID_OFFSET) { DWARFDebugRanges* debug_ranges = dwarf2Data->DebugRanges(); @@ -1147,7 +1263,7 @@ { dw_addr_t lo_pc = LLDB_INVALID_ADDRESS; dw_addr_t hi_pc = LLDB_INVALID_ADDRESS; - if (GetAttributeAddressRange (dwarf2Data, cu, lo_pc, hi_pc, LLDB_INVALID_ADDRESS)) + if (GetAttributeAddressRange (dwarf2Data, cu, lo_pc, hi_pc, LLDB_INVALID_ADDRESS, check_specification_or_abstract_origin)) { if (lo_pc < hi_pc) ranges.Append(DWARFRangeList::Entry(lo_pc, hi_pc - lo_pc)); @@ -1157,56 +1273,6 @@ } //---------------------------------------------------------------------- -// GetAttributeValueAsLocation -// -// Get the value of an attribute as reference and fix up and compile -// unit relative offsets as needed. -//---------------------------------------------------------------------- -dw_offset_t -DWARFDebugInfoEntry::GetAttributeValueAsLocation -( - SymbolFileDWARF* dwarf2Data, - const DWARFCompileUnit* cu, - const dw_attr_t attr, - DWARFDataExtractor& location_data, - uint32_t &block_size -) const -{ - block_size = 0; - DWARFFormValue form_value; - - // Empty out data in case we don't find anything - location_data.Clear(); - dw_offset_t end_addr_offset = DW_INVALID_OFFSET; - const dw_offset_t attr_offset = GetAttributeValue(dwarf2Data, cu, attr, form_value, &end_addr_offset); - if (attr_offset) - { - const uint8_t* blockData = form_value.BlockData(); - if (blockData) - { - // We have an inlined location list in the .debug_info section - const DWARFDataExtractor& debug_info = dwarf2Data->get_debug_info_data(); - dw_offset_t block_offset = blockData - debug_info.GetDataStart(); - block_size = (end_addr_offset - attr_offset) - form_value.Unsigned(); - location_data.SetData(debug_info, block_offset, block_size); - } - else - { - // We have a location list offset as the value that is - // the offset into the .debug_loc section that describes - // the value over it's lifetime - lldb::offset_t debug_loc_offset = form_value.Unsigned(); - if (dwarf2Data) - { - assert(dwarf2Data->get_debug_loc_data().GetAddressByteSize() == cu->GetAddressByteSize()); - return DWARFLocationList::Extract(dwarf2Data->get_debug_loc_data(), &debug_loc_offset, location_data); - } - } - } - return attr_offset; -} - -//---------------------------------------------------------------------- // GetName // // Get value of the DW_AT_name attribute and return it if one exists, @@ -1219,25 +1285,9 @@ const DWARFCompileUnit* cu ) const { - DWARFFormValue form_value; - if (GetAttributeValue(dwarf2Data, cu, DW_AT_name, form_value)) - return form_value.AsCString(); - else if (GetAttributeValue(dwarf2Data, cu, DW_AT_specification, form_value)) - { - DWARFDIE die = const_cast(cu)->GetDIE(form_value.Reference()); - if (die) - return die.GetName(); - } - else if (GetAttributeValue(dwarf2Data, cu, DW_AT_abstract_origin, form_value)) - { - DWARFDIE die = const_cast(cu)->GetDIE(form_value.Reference()); - if (die) - return die.GetName(); - } - return nullptr; + return GetAttributeValueAsString(dwarf2Data, cu, DW_AT_name, nullptr, true); } - //---------------------------------------------------------------------- // GetMangledName // @@ -1253,19 +1303,19 @@ ) const { const char* name = nullptr; - DWARFFormValue form_value; - if (GetAttributeValue(dwarf2Data, cu, DW_AT_MIPS_linkage_name, form_value)) - name = form_value.AsCString(); + name = GetAttributeValueAsString(dwarf2Data, cu, DW_AT_MIPS_linkage_name, nullptr, true); + if (name) + return name; - if (GetAttributeValue(dwarf2Data, cu, DW_AT_linkage_name, form_value)) - name = form_value.AsCString(); + name = GetAttributeValueAsString(dwarf2Data, cu, DW_AT_linkage_name, nullptr, true); + if (name) + return name; - if (substitute_name_allowed && name == nullptr) - { - if (GetAttributeValue(dwarf2Data, cu, DW_AT_name, form_value)) - name = form_value.AsCString(); - } + if (!substitute_name_allowed) + return nullptr; + + name = GetAttributeValueAsString(dwarf2Data, cu, DW_AT_name, nullptr, true); return name; } @@ -1283,24 +1333,19 @@ const DWARFCompileUnit* cu ) const { - const char* name = NULL; + const char* name = nullptr; if (!dwarf2Data) return name; - - DWARFFormValue form_value; - if (GetAttributeValue(dwarf2Data, cu, DW_AT_MIPS_linkage_name, form_value)) - name = form_value.AsCString(); - else if (GetAttributeValue(dwarf2Data, cu, DW_AT_linkage_name, form_value)) - name = form_value.AsCString(); - else if (GetAttributeValue(dwarf2Data, cu, DW_AT_name, form_value)) - name = form_value.AsCString(); - else if (GetAttributeValue(dwarf2Data, cu, DW_AT_specification, form_value)) - { - DWARFDIE die = const_cast(cu)->GetDIE(form_value.Reference()); - if (die) - name = die.GetPubname(); - } + name = GetAttributeValueAsString(dwarf2Data, cu, DW_AT_MIPS_linkage_name, nullptr, true); + if (name) + return name; + + name = GetAttributeValueAsString(dwarf2Data, cu, DW_AT_linkage_name, nullptr, true); + if (name) + return name; + + name = GetAttributeValueAsString(dwarf2Data, cu, DW_AT_name, nullptr, true); return name; } @@ -1340,15 +1385,11 @@ } else { - DWARFFormValue form_value; - if (die.GetAttributeValue(dwarf2Data, cu, DW_AT_name, form_value)) + const char* name = die.GetAttributeValueAsString(dwarf2Data, cu, DW_AT_name, nullptr, true); + if (name) { - const char* name = form_value.AsCString(); - if (name) - { - s.PutCString(name); - return true; - } + s.PutCString(name); + return true; } } } @@ -1390,8 +1431,6 @@ else { const char* name = die.GetPubname(dwarf2Data, cu); - // if (die.GetAttributeValue(dwarf2Data, cu, DW_AT_name, form_value)) - // name = form_value.AsCString(&dwarf2Data->get_debug_str_data()); if (name) s.PutCString(name); else @@ -1810,7 +1849,7 @@ if (match_addr_range) { - dw_addr_t lo_pc = GetAttributeValueAsUnsigned(dwarf2Data, cu, DW_AT_low_pc, LLDB_INVALID_ADDRESS); + dw_addr_t lo_pc = GetAttributeValueAsAddress(dwarf2Data, cu, DW_AT_low_pc, LLDB_INVALID_ADDRESS); if (lo_pc != LLDB_INVALID_ADDRESS) { dw_addr_t hi_pc = GetAttributeHighPC(dwarf2Data, cu, lo_pc, LLDB_INVALID_ADDRESS); Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFFormValue.h =================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFFormValue.h +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFFormValue.h @@ -93,6 +93,7 @@ void SetSigned(int64_t sval) { m_value.value.sval = sval; } const char* AsCString() const; dw_addr_t Address() const; + bool IsValid() const { return m_form != 0; } bool SkipValue(const lldb_private::DWARFDataExtractor& debug_info_data, lldb::offset_t *offset_ptr) const; static bool SkipValue(const dw_form_t form, const lldb_private::DWARFDataExtractor& debug_info_data, lldb::offset_t *offset_ptr, const DWARFCompileUnit* cu); static bool IsBlockForm(const dw_form_t form); Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h =================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h @@ -52,13 +52,14 @@ struct DIEInfo { + dw_offset_t cu_offset; dw_offset_t offset; // The DIE offset dw_tag_t tag; uint32_t type_flags; // Any flags for this DIEInfo uint32_t qualified_name_hash; // A 32 bit hash of the fully qualified name DIEInfo (); - DIEInfo (dw_offset_t o, dw_tag_t t, uint32_t f, uint32_t h); + DIEInfo (dw_offset_t c, dw_offset_t o, dw_tag_t t, uint32_t f, uint32_t h); }; struct Atom @@ -178,7 +179,7 @@ Result GetHashDataForName (const char *name, lldb::offset_t* hash_data_offset_ptr, - Pair &pair) const; + Pair &pair) const override; const lldb_private::DWARFDataExtractor &m_data; const lldb_private::DWARFDataExtractor &m_string_table; @@ -200,8 +201,6 @@ const uint32_t qualified_name_hash, DIEArray &die_offsets); - - static void ExtractClassOrStructDIEArray (const DIEInfoArray &die_info_array, bool return_implementation_only_if_available, @@ -217,5 +216,4 @@ GetAtomTypeName (uint16_t atom); }; - #endif // SymbolFileDWARF_HashedNameToDIE_h_ Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp =================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp @@ -14,7 +14,7 @@ { const size_t count = die_info_array.size(); for (size_t i=0; i +#include "lldb/Core/dwarf.h" +#include "lldb/Core/UniqueCStringMap.h" #include "lldb/lldb-defines.h" +#include "DIERef.h" class SymbolFileDWARF; -typedef std::vector DIEArray; - class NameToDIE { public: - NameToDIE () : + NameToDIE () : m_map() { } - + ~NameToDIE () { } - + void Dump (lldb_private::Stream *s); void - Insert (const lldb_private::ConstString& name, uint32_t die_offset); + Insert (const lldb_private::ConstString& name, const DIERef& die_ref); void Finalize(); size_t - Find (const lldb_private::ConstString &name, - DIEArray &info_array) const; + Find (const lldb_private::ConstString &name, DIEArray &info_array) const; size_t - Find (const lldb_private::RegularExpression& regex, - DIEArray &info_array) const; + Find (const lldb_private::RegularExpression& regex, DIEArray &info_array) const; size_t - FindAllEntriesForCompileUnit (uint32_t cu_offset, - uint32_t cu_end_offset, - DIEArray &info_array) const; + FindAllEntriesForCompileUnit (dw_offset_t cu_offset, DIEArray &info_array) const; void - ForEach (std::function const &callback) const; + ForEach (std::function const &callback) const; protected: - lldb_private::UniqueCStringMap m_map; - + lldb_private::UniqueCStringMap m_map; }; #endif // SymbolFileDWARF_NameToDIE_h_ Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp =================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp @@ -18,6 +18,7 @@ #include "DWARFDebugInfo.h" #include "DWARFDebugInfoEntry.h" #include "SymbolFileDWARF.h" + using namespace lldb; using namespace lldb_private; @@ -29,9 +30,9 @@ } void -NameToDIE::Insert (const ConstString& name, uint32_t die_offset) +NameToDIE::Insert (const ConstString& name, const DIERef& die_ref) { - m_map.Append(name.GetCString(), die_offset); + m_map.Append(name.GetCString(), die_ref); } size_t @@ -47,17 +48,15 @@ } size_t -NameToDIE::FindAllEntriesForCompileUnit (uint32_t cu_offset, - uint32_t cu_end_offset, - DIEArray &info_array) const +NameToDIE::FindAllEntriesForCompileUnit (dw_offset_t cu_offset, DIEArray &info_array) const { const size_t initial_size = info_array.size(); const uint32_t size = m_map.GetSize(); for (uint32_t i=0; iPrintf("%p: {0x%8.8x} \"%s\"\n", (const void *)cstr, m_map.GetValueAtIndexUnchecked(i), cstr); + const DIERef& die_ref = m_map.GetValueAtIndexUnchecked(i); + s->Printf("%p: {0x%8.8x/0x%8.8x} \"%s\"\n", cstr, die_ref.cu_offset, die_ref.die_offset, cstr); } } void -NameToDIE::ForEach (std::function const &callback) const +NameToDIE::ForEach (std::function const &callback) const { const uint32_t size = m_map.GetSize(); for (uint32_t i=0; i DIEToTypePtr; + typedef llvm::DenseMap DIEToVariableSP; + typedef llvm::DenseMap DIEToClangType; + typedef llvm::DenseMap ClangTypeToDIE; enum { @@ -343,11 +351,7 @@ DISALLOW_COPY_AND_ASSIGN (SymbolFileDWARF); - lldb::CompUnitSP - ParseCompileUnit (DWARFCompileUnit* dwarf_cu, - uint32_t cu_idx); - - DWARFCompileUnit* + virtual DWARFCompileUnit* GetDWARFCompileUnit (lldb_private::CompileUnit *comp_unit); DWARFCompileUnit* @@ -401,7 +405,7 @@ // Given a die_offset, figure out the symbol context representing that die. bool - ResolveFunction (dw_offset_t offset, + ResolveFunction (const DIERef& die_ref, bool include_inlines, lldb_private::SymbolContextList& sc_list); @@ -451,11 +455,6 @@ lldb::TypeSP GetTypeForDIE (const DWARFDIE &die); - uint32_t - FindTypes (std::vector die_offsets, - uint32_t max_matches, - lldb_private::TypeList& types); - void Index(); @@ -472,12 +471,10 @@ GetDebugMapSymfile (); DWARFDIE - FindBlockContainingSpecification (dw_offset_t func_die_offset, - dw_offset_t spec_block_die_offset); + FindBlockContainingSpecification (const DIERef& func_die_ref, dw_offset_t spec_block_die_offset); DWARFDIE - FindBlockContainingSpecification (const DWARFDIE &die, - dw_offset_t spec_block_die_offset); + FindBlockContainingSpecification (const DWARFDIE &die, dw_offset_t spec_block_die_offset); UniqueDWARFASTTypeMap & GetUniqueDWARFASTTypeMap (); @@ -486,7 +483,7 @@ UserIDMatches (lldb::user_id_t uid) const { const lldb::user_id_t high_uid = uid & 0xffffffff00000000ull; - if (high_uid) + if (high_uid != 0 && GetID() != 0) return high_uid == GetID(); return true; } @@ -526,6 +523,18 @@ void UpdateExternalModuleListIfNeeded(); + virtual DIEToTypePtr& + GetDIEToType() { return m_die_to_type; } + + virtual DIEToVariableSP& + GetDIEToVariable() { return m_die_to_variable_sp; } + + virtual DIEToClangType& + GetForwardDeclDieToClangType() { return m_forward_decl_die_to_clang_type; } + + virtual ClangTypeToDIE& + GetForwardDeclClangTypeToDie() { return m_forward_decl_clang_type_to_die; } + lldb::ModuleWP m_debug_map_module_wp; SymbolFileDWARFDebugMap * m_debug_map_symfile; lldb_private::Flags m_flags; @@ -571,10 +580,6 @@ std::unique_ptr m_ranges; UniqueDWARFASTTypeMap m_unique_ast_type_map; - typedef llvm::DenseMap DIEToTypePtr; - typedef llvm::DenseMap DIEToVariableSP; - typedef llvm::DenseMap DIEToClangType; - typedef llvm::DenseMap ClangTypeToDIE; DIEToTypePtr m_die_to_type; DIEToVariableSP m_die_to_variable_sp; DIEToClangType m_forward_decl_die_to_clang_type; Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp =================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -72,6 +72,7 @@ #include "DWARFFormValue.h" #include "DWARFLocationList.h" #include "LogChannelDWARF.h" +#include "SymbolFileDWARFDwo.h" #include "SymbolFileDWARFDebugMap.h" #include @@ -917,7 +918,11 @@ } else { - if (GetDebugMapSymfile ()) + if (dwarf_cu->GetSymbolFileDWARF() != this) + { + return dwarf_cu->GetSymbolFileDWARF()->ParseCompileUnit(dwarf_cu, cu_idx); + } + else if (GetDebugMapSymfile ()) { // Let the debug map create the compile unit cu_sp = m_debug_map_symfile->GetCompileUnit(this); @@ -1386,7 +1391,7 @@ DWARFDebugInfo* debug_info = DebugInfo(); if (debug_info) { - DWARFDIE die = debug_info->GetDIE(type_uid); + DWARFDIE die = debug_info->GetDIE(DIERef(type_uid)); if (die) { DWARFASTParser *dwarf_ast = die.GetDWARFParser(); @@ -1406,7 +1411,7 @@ DWARFDebugInfo* debug_info = DebugInfo(); if (debug_info) { - DWARFDIE die = debug_info->GetDIE(type_uid); + DWARFDIE die = debug_info->GetDIE(DIERef(type_uid)); if (die) { DWARFASTParser *dwarf_ast = die.GetDWARFParser(); @@ -1427,7 +1432,7 @@ DWARFDebugInfo* debug_info = DebugInfo(); if (debug_info) { - DWARFDIE type_die = debug_info->GetDIE (type_uid); + DWARFDIE type_die = debug_info->GetDIE (DIERef(type_uid)); if (type_die) { const bool assert_not_being_parsed = true; @@ -1493,7 +1498,7 @@ SymbolFileDWARF::HasForwardDeclForClangType (const CompilerType &clang_type) { CompilerType clang_type_no_qualifiers = ClangASTContext::RemoveFastQualifiers(clang_type); - return m_forward_decl_clang_type_to_die.lookup (clang_type_no_qualifiers.GetOpaqueQualType()) != nullptr; + return GetForwardDeclClangTypeToDie().count (clang_type_no_qualifiers.GetOpaqueQualType()); } @@ -1502,8 +1507,8 @@ { // We have a struct/union/class/enum that needs to be fully resolved. CompilerType clang_type_no_qualifiers = ClangASTContext::RemoveFastQualifiers(clang_type); - const DWARFDebugInfoEntry* die = m_forward_decl_clang_type_to_die.lookup (clang_type_no_qualifiers.GetOpaqueQualType()); - if (die == NULL) + auto die_it = GetForwardDeclClangTypeToDie().find (clang_type_no_qualifiers.GetOpaqueQualType()); + if (die_it == GetForwardDeclClangTypeToDie().end()) { // We have already resolved this type... return true; @@ -1512,11 +1517,12 @@ // map in case anyone child members or other types require this type to get resolved. // The type will get resolved when all of the calls to SymbolFileDWARF::ResolveClangOpaqueTypeDefinition // are done. - m_forward_decl_clang_type_to_die.erase (clang_type_no_qualifiers.GetOpaqueQualType()); + GetForwardDeclClangTypeToDie().erase (clang_type_no_qualifiers.GetOpaqueQualType()); DWARFDebugInfo* debug_info = DebugInfo(); - DWARFDIE dwarf_die (debug_info->GetCompileUnitContainingDIE (die->GetOffset()), die); - Type *type = m_die_to_type.lookup (die); + + DWARFDIE dwarf_die = debug_info->GetDIE(die_it->getSecond()); + Type *type = GetDIEToType().lookup (dwarf_die.GetDIE()); Log *log (LogChannelDWARF::GetLogIfAny(DWARF_LOG_DEBUG_INFO|DWARF_LOG_TYPE_COMPLETION)); if (log) @@ -1537,7 +1543,7 @@ { if (die) { - Type *type = m_die_to_type.lookup (die.GetDIE()); + Type *type = GetDIEToType().lookup (die.GetDIE()); if (type == NULL) type = GetTypeForDIE (die).get(); @@ -1623,8 +1629,7 @@ m_fetched_external_modules = true; DWARFDebugInfo * debug_info = DebugInfo(); - debug_info->GetNumCompileUnits(); - + const uint32_t num_compile_units = GetNumCompileUnits(); for (uint32_t cu_idx = 0; cu_idx < num_compile_units; ++cu_idx) { @@ -2000,8 +2005,7 @@ bool clear_dies = dwarf_cu->ExtractDIEsIfNeeded (false) > 1; - dwarf_cu->Index (cu_idx, - m_function_basename_index, + dwarf_cu->Index (m_function_basename_index, m_function_fullname_index, m_function_method_index, m_function_selector_index, @@ -2127,8 +2131,8 @@ bool done = false; for (size_t i=0; iGetDIE (die_offset); + const DIERef& die_ref = die_offsets[i]; + DWARFDIE die = debug_info->GetDIE (die_ref); if (die) { @@ -2169,7 +2173,7 @@ if (m_using_apple_tables) { GetObjectFile()->GetModule()->ReportErrorIfModifyDetected ("the DWARF debug information has been modified (.apple_names accelerator table had bad die 0x%8.8x for '%s')\n", - die_offset, name.GetCString()); + die_ref.die_offset, name.GetCString()); } } } @@ -2215,7 +2219,7 @@ const uint32_t original_size = variables.GetSize(); DIEArray die_offsets; - + if (m_using_apple_tables) { if (m_apple_names_ap.get()) @@ -2244,8 +2248,8 @@ DWARFDebugInfo* debug_info = DebugInfo(); for (size_t i=0; iGetDIE (die_offset); + const DIERef& die_ref = die_offsets[i]; + DWARFDIE die = debug_info->GetDIE (die_ref); if (die) { @@ -2261,7 +2265,7 @@ if (m_using_apple_tables) { GetObjectFile()->GetModule()->ReportErrorIfModifyDetected ("the DWARF debug information has been modified (.apple_names accelerator table had bad die 0x%8.8x for regex '%s')\n", - die_offset, regex.GetText()); + die_ref.die_offset, regex.GetText()); } } } @@ -2273,11 +2277,11 @@ bool -SymbolFileDWARF::ResolveFunction (dw_offset_t die_offset, +SymbolFileDWARF::ResolveFunction (const DIERef& die_ref, bool include_inlines, SymbolContextList& sc_list) { - DWARFDIE die = DebugInfo()->GetDIE (die_offset); + DWARFDIE die = DebugInfo()->GetDIE (die_ref); return ResolveFunction (die, include_inlines, sc_list); } @@ -2397,10 +2401,7 @@ if (num_matches) { for (size_t i=0; iFindByName (name_cstr, die_offsets); for (uint32_t i = 0; i < num_matches; i++) { - const dw_offset_t die_offset = die_offsets[i]; - DWARFDIE die = info->GetDIE (die_offset); + const DIERef& die_ref = die_offsets[i]; + DWARFDIE die = info->GetDIE (die_ref); if (die) { if (!DIEInDeclContext(parent_decl_ctx, die)) @@ -2509,7 +2510,7 @@ else { GetObjectFile()->GetModule()->ReportErrorIfModifyDetected ("the DWARF debug information has been modified (.apple_names accelerator table had bad die 0x%8.8x for '%s')", - die_offset, name_cstr); + die_ref.die_offset, name_cstr); } } } @@ -2525,8 +2526,8 @@ for (uint32_t i = 0; i < num_matches; i++) { - const dw_offset_t die_offset = die_offsets[i]; - DWARFDIE die = info->GetDIE (die_offset); + const DIERef& die_ref = die_offsets[i]; + DWARFDIE die = info->GetDIE (die_ref); if (die) { const char *die_name = die.GetName(); @@ -2542,7 +2543,7 @@ else { GetObjectFile()->GetModule()->ReportError ("the DWARF debug information has been modified (.apple_names accelerator table had bad die 0x%8.8x for '%s')", - die_offset, name_cstr); + die_ref.die_offset, name_cstr); } } die_offsets.clear(); @@ -2559,8 +2560,8 @@ for (uint32_t i = 0; i < num_matches; i++) { - const dw_offset_t die_offset = die_offsets[i]; - DWARFDIE die = info->GetDIE (die_offset); + const DIERef& die_ref = die_offsets[i]; + DWARFDIE die = info->GetDIE (die_ref); if (die) { if (!DIEInDeclContext(parent_decl_ctx, die)) @@ -2609,7 +2610,7 @@ else { GetObjectFile()->GetModule()->ReportWarning ("function at die offset 0x%8.8x had no function type", - die_offset); + die_ref.die_offset); } } } @@ -2621,7 +2622,7 @@ else { GetObjectFile()->GetModule()->ReportErrorIfModifyDetected ("the DWARF debug information has been modified (.apple_names accelerator table had bad die 0x%8.8x for '%s')", - die_offset, name_cstr); + die_ref.die_offset, name_cstr); } } die_offsets.clear(); @@ -2856,8 +2857,8 @@ DWARFDebugInfo* debug_info = DebugInfo(); for (size_t i=0; iGetDIE (die_offset); + const DIERef& die_ref = die_offsets[i]; + DWARFDIE die = debug_info->GetDIE (die_ref); if (die) { @@ -2878,7 +2879,7 @@ if (m_using_apple_tables) { GetObjectFile()->GetModule()->ReportErrorIfModifyDetected ("the DWARF debug information has been modified (.apple_types accelerator table had bad die 0x%8.8x for '%s')\n", - die_offset, name.GetCString()); + die_ref.die_offset, name.GetCString()); } } @@ -2960,8 +2961,8 @@ DWARFDebugInfo* debug_info = DebugInfo(); for (size_t i=0; iGetDIE (die_offset); + const DIERef& die_ref = die_offsets[i]; + DWARFDIE die = debug_info->GetDIE (die_ref); if (die) { @@ -2981,7 +2982,7 @@ if (m_using_apple_tables) { GetObjectFile()->GetModule()->ReportErrorIfModifyDetected ("the DWARF debug information has been modified (.apple_namespaces accelerator table had bad die 0x%8.8x for '%s')\n", - die_offset, name.GetCString()); + die_ref.die_offset, name.GetCString()); } } @@ -3001,42 +3002,13 @@ return namespace_decl_ctx; } -uint32_t -SymbolFileDWARF::FindTypes(std::vector die_offsets, uint32_t max_matches, TypeList& types) -{ - // Remember how many sc_list are in the list before we search in case - // we are appending the results to a variable list. - uint32_t original_size = types.GetSize(); - - const uint32_t num_die_offsets = die_offsets.size(); - // Parse all of the types we found from the pubtypes matches - uint32_t i; - uint32_t num_matches = 0; - for (i = 0; i < num_die_offsets; ++i) - { - Type *matching_type = ResolveTypeUID (die_offsets[i]); - if (matching_type) - { - // We found a type pointer, now find the shared pointer form our type list - types.InsertUnique (matching_type->shared_from_this()); - ++num_matches; - if (num_matches >= max_matches) - break; - } - } - - // Return the number of variable that were appended to the list - return types.GetSize() - original_size; -} - - TypeSP SymbolFileDWARF::GetTypeForDIE (const DWARFDIE &die) { TypeSP type_sp; if (die) { - Type *type_ptr = m_die_to_type.lookup (die.GetDIE()); + Type *type_ptr = GetDIEToType().lookup (die.GetDIE()); if (type_ptr == NULL) { CompileUnit* lldb_cu = GetCompUnitForDWARFCompUnit(die.GetCU()); @@ -3195,8 +3167,8 @@ DWARFDebugInfo* debug_info = DebugInfo(); for (size_t i=0; iGetDIE (die_offset); + const DIERef& die_ref = die_offsets[i]; + DWARFDIE type_die = debug_info->GetDIE (die_ref); if (type_die) { @@ -3233,7 +3205,7 @@ type_cu->GetID()); if (die) - m_die_to_type[die.GetDIE()] = resolved_type; + GetDIEToType()[die.GetDIE()] = resolved_type; type_sp = resolved_type->shared_from_this(); break; } @@ -3245,7 +3217,7 @@ if (m_using_apple_tables) { GetObjectFile()->GetModule()->ReportErrorIfModifyDetected ("the DWARF debug information has been modified (.apple_types accelerator table had bad die 0x%8.8x for '%s')\n", - die_offset, type_name.GetCString()); + die_ref.die_offset, type_name.GetCString()); } } @@ -3419,8 +3391,8 @@ DWARFDebugInfo* debug_info = DebugInfo(); for (size_t i=0; iGetDIE (die_offset); + const DIERef& die_ref = die_offsets[i]; + DWARFDIE type_die = debug_info->GetDIE (die_ref); if (type_die) { @@ -3503,7 +3475,7 @@ if (m_using_apple_tables) { GetObjectFile()->GetModule()->ReportErrorIfModifyDetected ("the DWARF debug information has been modified (.apple_types accelerator table had bad die 0x%8.8x for '%s')\n", - die_offset, type_name.GetCString()); + die_ref.die_offset, type_name.GetCString()); } } @@ -3646,9 +3618,9 @@ if (sc.function) { - DWARFDIE function_die = info->GetDIE(sc.function->GetID()); + DWARFDIE function_die = info->GetDIE(DIERef(sc.function->GetID())); - const dw_addr_t func_lo_pc = function_die.GetAttributeValueAsUnsigned (DW_AT_low_pc, LLDB_INVALID_ADDRESS); + const dw_addr_t func_lo_pc = function_die.GetAttributeValueAsAddress (DW_AT_low_pc, LLDB_INVALID_ADDRESS); if (func_lo_pc != LLDB_INVALID_ADDRESS) { const size_t num_variables = ParseVariables(sc, function_die.GetFirstChild(), func_lo_pc, true, true); @@ -3695,7 +3667,6 @@ Index (); m_global_index.FindAllEntriesForCompileUnit (dwarf_cu->GetOffset(), - dwarf_cu->GetNextCompileUnitOffset(), die_offsets); } @@ -3705,8 +3676,8 @@ DWARFDebugInfo* debug_info = DebugInfo(); for (size_t i=0; iGetDIE (die_offset); + const DIERef& die_ref = die_offsets[i]; + DWARFDIE die = debug_info->GetDIE (die_ref); if (die) { VariableSP var_sp (ParseVariableDIE(sc, die, LLDB_INVALID_ADDRESS)); @@ -3720,7 +3691,7 @@ { if (m_using_apple_tables) { - GetObjectFile()->GetModule()->ReportErrorIfModifyDetected ("the DWARF debug information has been modified (.apple_names accelerator table had bad die 0x%8.8x)\n", die_offset); + GetObjectFile()->GetModule()->ReportErrorIfModifyDetected ("the DWARF debug information has been modified (.apple_names accelerator table had bad die 0x%8.8x)\n", die_ref.die_offset); } } @@ -3741,11 +3712,14 @@ const lldb::addr_t func_low_pc ) { + if (die.GetDWARF() != this) + return die.GetDWARF()->ParseVariableDIE(sc, die, func_low_pc); + VariableSP var_sp; if (!die) return var_sp; - var_sp = m_die_to_variable_sp[die.GetDIE()]; + var_sp = GetDIEToVariable()[die.GetDIE()]; if (var_sp) return var_sp; // Already been parsed! @@ -3764,7 +3738,7 @@ const char *mangled = NULL; Declaration decl; uint32_t i; - lldb::user_id_t type_uid = LLDB_INVALID_UID; + DWARFFormValue type_die_form; DWARFExpression location(die.GetCU()); bool is_external = false; bool is_artificial = false; @@ -3788,7 +3762,7 @@ case DW_AT_name: name = form_value.AsCString(); break; case DW_AT_linkage_name: case DW_AT_MIPS_linkage_name: mangled = form_value.AsCString(); break; - case DW_AT_type: type_uid = form_value.Reference(); break; + case DW_AT_type: type_die_form = form_value; break; case DW_AT_external: is_external = form_value.Boolean(); break; case DW_AT_const_value: // If we have already found a DW_AT_location attribute, ignore this attribute. @@ -4063,7 +4037,7 @@ if (symbol_context_scope) { - SymbolFileTypeSP type_sp(new SymbolFileType(*this, type_uid)); + SymbolFileTypeSP type_sp(new SymbolFileType(*this, DIERef(type_die_form).GetUID())); if (const_value.Form() && type_sp && type_sp->GetType()) location.CopyOpcodeData(const_value.Unsigned(), type_sp->GetType()->GetByteSize(), die.GetCU()->GetAddressByteSize()); @@ -4094,20 +4068,20 @@ // was missing vital information to be able to be displayed in the debugger // (missing location due to optimization, etc)) so we don't re-parse // this DIE over and over later... - m_die_to_variable_sp[die.GetDIE()] = var_sp; + GetDIEToVariable()[die.GetDIE()] = var_sp; } return var_sp; } DWARFDIE -SymbolFileDWARF::FindBlockContainingSpecification (dw_offset_t func_die_offset, +SymbolFileDWARF::FindBlockContainingSpecification (const DIERef& func_die_ref, dw_offset_t spec_block_die_offset) { // Give the concrete function die specified by "func_die_offset", find the // concrete block whose DW_AT_specification or DW_AT_abstract_origin points // to "spec_block_die_offset" - return FindBlockContainingSpecification (DebugInfo()->GetDIE (func_die_offset), spec_block_die_offset); + return FindBlockContainingSpecification (DebugInfo()->GetDIE (func_die_ref), spec_block_die_offset); } @@ -4166,7 +4140,7 @@ dw_tag_t tag = die.Tag(); // Check to see if we have already parsed this variable or constant? - VariableSP var_sp = m_die_to_variable_sp[die.GetDIE()]; + VariableSP var_sp = GetDIEToVariable()[die.GetDIE()]; if (var_sp) { if (cc_variable_list) @@ -4219,7 +4193,7 @@ // a concrete block counterpart in the current function. We need // to find the concrete block so we can correctly add the // variable to it - const DWARFDIE concrete_block_die = FindBlockContainingSpecification (sc.function->GetID(), + const DWARFDIE concrete_block_die = FindBlockContainingSpecification (DIERef(sc.function->GetID()), sc_parent_die.GetOffset()); if (concrete_block_die) block = sc.function->GetBlock(true).FindBlockByID(concrete_block_die.GetID()); @@ -4324,5 +4298,3 @@ } return m_debug_map_symfile; } - - Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h =================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h @@ -0,0 +1,58 @@ +//===-- SymbolFileDWARFDwo.h ------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef SymbolFileDWARFDwo_SymbolFileDWARFDwo_h_ +#define SymbolFileDWARFDwo_SymbolFileDWARFDwo_h_ + +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes +#include "SymbolFileDWARF.h" + +class SymbolFileDWARFDwo : public SymbolFileDWARF +{ +public: + SymbolFileDWARFDwo(lldb::ObjectFileSP objfile, DWARFCompileUnit* dwarf_cu); + + virtual + ~SymbolFileDWARFDwo() = default; + + const lldb_private::DWARFDataExtractor& + GetCachedSectionData(uint32_t got_flag, + lldb::SectionType sect_type, + lldb_private::DWARFDataExtractor &data) override; + + lldb::CompUnitSP + ParseCompileUnit(DWARFCompileUnit* dwarf_cu, uint32_t cu_idx) override; + + DWARFCompileUnit* + GetCompileUnit(); + + DWARFCompileUnit* + GetDWARFCompileUnit(lldb_private::CompileUnit *comp_unit) override; + +protected: + DIEToTypePtr& + GetDIEToType() override; + + DIEToVariableSP& + GetDIEToVariable() override; + + DIEToClangType& + GetForwardDeclDieToClangType() override; + + ClangTypeToDIE& + GetForwardDeclClangTypeToDie() override; + + lldb::ObjectFileSP m_obj_file_sp; + DWARFCompileUnit* m_base_dwarf_cu; +}; + +#endif // SymbolFileDWARFDwo_SymbolFileDWARFDwo_h_ Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp =================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp @@ -0,0 +1,104 @@ +//===-- SymbolFileDWARFDwo.cpp ----------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "SymbolFileDWARFDwo.h" + +#include "lldb/Core/Section.h" +#include "lldb/Symbol/ObjectFile.h" + +#include "DWARFCompileUnit.h" +#include "DWARFDebugInfo.h" + +using namespace lldb; +using namespace lldb_private; + +SymbolFileDWARFDwo::SymbolFileDWARFDwo(ObjectFileSP objfile, DWARFCompileUnit* dwarf_cu) : + SymbolFileDWARF(objfile.get()), + m_obj_file_sp(objfile), + m_base_dwarf_cu(dwarf_cu) +{ +} + +const lldb_private::DWARFDataExtractor& +SymbolFileDWARFDwo::GetCachedSectionData(uint32_t got_flag, + lldb::SectionType sect_type, + lldb_private::DWARFDataExtractor &data) +{ + if (!m_flags.IsClear (got_flag)) + return data; + + const SectionList* section_list = m_obj_file->GetSectionList(false /* update_module_section_list */); + if (section_list) + { + SectionSP section_sp (section_list->FindSectionByType(sect_type, true)); + if (section_sp) + { + // See if we memory mapped the DWARF segment? + if (m_dwarf_data.GetByteSize()) + { + data.SetData(m_dwarf_data, section_sp->GetOffset(), section_sp->GetFileSize()); + m_flags.Set (got_flag); + return data; + } + + if (m_obj_file->ReadSectionData(section_sp.get(), data) != 0) + { + m_flags.Set (got_flag); + return data; + } + + data.Clear(); + } + } + return SymbolFileDWARF::GetCachedSectionData(got_flag, sect_type, data); +} + +lldb::CompUnitSP +SymbolFileDWARFDwo::ParseCompileUnit(DWARFCompileUnit* dwarf_cu, uint32_t cu_idx) +{ + assert(GetCompileUnit() == dwarf_cu && "SymbolFileDWARFDwo::ParseCompileUnit called with incompatible compile unit"); + return m_base_dwarf_cu->GetSymbolFileDWARF()->ParseCompileUnit(m_base_dwarf_cu, UINT32_MAX); +} + +DWARFCompileUnit* +SymbolFileDWARFDwo::GetCompileUnit() +{ + assert(GetNumCompileUnits() == 1 && "Only dwo files with 1 compile unit is supported"); + return DebugInfo()->GetCompileUnitAtIndex(0); +} + +DWARFCompileUnit* +SymbolFileDWARFDwo::GetDWARFCompileUnit(lldb_private::CompileUnit *comp_unit) +{ + return GetCompileUnit(); +} + +SymbolFileDWARF::DIEToTypePtr& +SymbolFileDWARFDwo::GetDIEToType() +{ + return m_base_dwarf_cu->GetSymbolFileDWARF()->GetDIEToType(); +} + +SymbolFileDWARF::DIEToVariableSP& +SymbolFileDWARFDwo::GetDIEToVariable() +{ + return m_base_dwarf_cu->GetSymbolFileDWARF()->GetDIEToVariable(); +} + +SymbolFileDWARF::DIEToClangType& +SymbolFileDWARFDwo::GetForwardDeclDieToClangType() +{ + return m_base_dwarf_cu->GetSymbolFileDWARF()->GetForwardDeclDieToClangType(); +} + +SymbolFileDWARF::ClangTypeToDIE& +SymbolFileDWARFDwo::GetForwardDeclClangTypeToDie() +{ + return m_base_dwarf_cu->GetSymbolFileDWARF()->GetForwardDeclClangTypeToDie(); +} Index: lldb/trunk/source/Symbol/ObjectFile.cpp =================================================================== --- lldb/trunk/source/Symbol/ObjectFile.cpp +++ lldb/trunk/source/Symbol/ObjectFile.cpp @@ -602,15 +602,23 @@ } SectionList * -ObjectFile::GetSectionList() +ObjectFile::GetSectionList(bool update_module_section_list) { if (m_sections_ap.get() == nullptr) { - ModuleSP module_sp(GetModule()); - if (module_sp) + if (update_module_section_list) { - lldb_private::Mutex::Locker locker(module_sp->GetMutex()); - CreateSections(*module_sp->GetUnifiedSectionList()); + ModuleSP module_sp(GetModule()); + if (module_sp) + { + lldb_private::Mutex::Locker locker(module_sp->GetMutex()); + CreateSections(*module_sp->GetUnifiedSectionList()); + } + } + else + { + SectionList unified_section_list; + CreateSections(unified_section_list); } } return m_sections_ap.get();