diff options
-rw-r--r-- | lldb/include/lldb/Core/Section.h | 2 | ||||
-rw-r--r-- | lldb/include/lldb/lldb-enumerations.h | 5 | ||||
-rw-r--r-- | lldb/source/Core/Section.cpp | 8 | ||||
-rw-r--r-- | lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp | 55 | ||||
-rw-r--r-- | lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp | 51 | ||||
-rw-r--r-- | lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp | 130 | ||||
-rw-r--r-- | lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h | 5 |
7 files changed, 129 insertions, 127 deletions
diff --git a/lldb/include/lldb/Core/Section.h b/lldb/include/lldb/Core/Section.h index f88df65dbb1..f698a5a0778 100644 --- a/lldb/include/lldb/Core/Section.h +++ b/lldb/include/lldb/Core/Section.h @@ -55,7 +55,7 @@ public: FindSectionByID (lldb::user_id_t sect_id) const; lldb::SectionSP - FindSectionByType (lldb::SectionType sect_type, uint32_t start_idx = 0) const; + FindSectionByType (lldb::SectionType sect_type, bool check_children, uint32_t start_idx = 0) const; lldb::SectionSP GetSharedPointer (const Section *section, bool check_children) const; diff --git a/lldb/include/lldb/lldb-enumerations.h b/lldb/include/lldb/lldb-enumerations.h index 40b9ba02c23..05dcf34f674 100644 --- a/lldb/include/lldb/lldb-enumerations.h +++ b/lldb/include/lldb/lldb-enumerations.h @@ -374,10 +374,11 @@ typedef enum SectionType eSectionTypeDWARFDebugLine, eSectionTypeDWARFDebugLoc, eSectionTypeDWARFDebugMacInfo, - eSectionTypeDWARFDebugPubnames, - eSectionTypeDWARFDebugPubtypes, + eSectionTypeDWARFDebugPubNames, + eSectionTypeDWARFDebugPubTypes, eSectionTypeDWARFDebugRanges, eSectionTypeDWARFDebugStr, + eSectionTypeEHFrame, eSectionTypeOther } SectionType; diff --git a/lldb/source/Core/Section.cpp b/lldb/source/Core/Section.cpp index e4617a8ee99..a86695d46e7 100644 --- a/lldb/source/Core/Section.cpp +++ b/lldb/source/Core/Section.cpp @@ -568,7 +568,7 @@ SectionList::FindSectionByID (user_id_t sect_id) const SectionSP -SectionList::FindSectionByType (lldb::SectionType sect_type, uint32_t start_idx) const +SectionList::FindSectionByType (lldb::SectionType sect_type, bool check_children, uint32_t start_idx) const { SectionSP sect_sp; uint32_t num_sections = m_sections.size(); @@ -579,6 +579,12 @@ SectionList::FindSectionByType (lldb::SectionType sect_type, uint32_t start_idx) sect_sp = m_sections[idx]; break; } + else if (check_children) + { + sect_sp = m_sections[idx]->GetChildren().FindSectionByType (sect_type, check_children, 0); + if (sect_sp) + break; + } } return sect_sp; } diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp index c4772202b7a..032fb75c06d 100644 --- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp +++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp @@ -421,17 +421,52 @@ ObjectFileELF::GetSectionList() ConstString name(m_shstr_data.PeekCStr(header.sh_name)); uint64_t size = header.sh_type == SHT_NOBITS ? 0 : header.sh_size; + static ConstString g_sect_name_text (".text"); + static ConstString g_sect_name_data (".data"); + static ConstString g_sect_name_bss (".bss"); + static ConstString g_sect_name_dwarf_debug_abbrev (".debug_abbrev"); + static ConstString g_sect_name_dwarf_debug_aranges (".debug_aranges"); + static ConstString g_sect_name_dwarf_debug_frame (".debug_frame"); + static ConstString g_sect_name_dwarf_debug_info (".debug_info"); + static ConstString g_sect_name_dwarf_debug_line (".debug_line"); + static ConstString g_sect_name_dwarf_debug_loc (".debug_loc"); + static ConstString g_sect_name_dwarf_debug_macinfo (".debug_macinfo"); + static ConstString g_sect_name_dwarf_debug_pubnames (".debug_pubnames"); + static ConstString g_sect_name_dwarf_debug_pubtypes (".debug_pubtypes"); + 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_eh_frame (".eh_frame"); + + SectionType sect_type = eSectionTypeOther; + + if (name == g_sect_name_text) sect_type = eSectionTypeCode; + else if (name == g_sect_name_data) sect_type = eSectionTypeData; + else if (name == g_sect_name_bss) sect_type = eSectionTypeZeroFill; + else if (name == g_sect_name_dwarf_debug_abbrev) sect_type = eSectionTypeDWARFDebugAbbrev; + 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_eh_frame) sect_type = eSectionTypeEHFrame; + + SectionSP section(new Section( - 0, // Parent section. - GetModule(), // Module to which this section belongs. - SectionIndex(I), // Section ID. - name, // Section name. - eSectionTypeOther, // FIXME: Fill in as appropriate. - header.sh_addr, // VM address. - header.sh_size, // VM size in bytes of this section. - header.sh_offset, // Offset of this section in the file. - size, // Size of the section as found in the file. - header.sh_flags)); // Flags for this section. + 0, // Parent section. + GetModule(), // Module to which this section belongs. + SectionIndex(I), // Section ID. + name, // Section name. + sect_type, // Section type. + header.sh_addr, // VM address. + header.sh_size, // VM size in bytes of this section. + header.sh_offset, // Offset of this section in the file. + size, // Size of the section as found in the file. + header.sh_flags)); // Flags for this section. m_sections_ap->AddSection(section); } diff --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp index de5c73c84b4..c0d7eecef23 100644 --- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp +++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp @@ -373,16 +373,53 @@ ObjectFileMachO::ParseSections () static ConstString g_sect_name_objc_const ("__objc_const"); static ConstString g_sect_name_objc_classlist ("__objc_classlist"); static ConstString g_sect_name_cfstring ("__cfstring"); + + static ConstString g_sect_name_dwarf_debug_abbrev ("__debug_abbrev"); + static ConstString g_sect_name_dwarf_debug_aranges ("__debug_aranges"); + static ConstString g_sect_name_dwarf_debug_frame ("__debug_frame"); + static ConstString g_sect_name_dwarf_debug_info ("__debug_info"); + static ConstString g_sect_name_dwarf_debug_line ("__debug_line"); + static ConstString g_sect_name_dwarf_debug_loc ("__debug_loc"); + static ConstString g_sect_name_dwarf_debug_macinfo ("__debug_macinfo"); + static ConstString g_sect_name_dwarf_debug_pubnames ("__debug_pubnames"); + static ConstString g_sect_name_dwarf_debug_pubtypes ("__debug_pubtypes"); + 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_eh_frame ("__eh_frame"); + SectionType sect_type = eSectionTypeOther; - if (section_name == g_sect_name_objc_selrefs) - { + + if (section_name == g_sect_name_dwarf_debug_abbrev) + sect_type = eSectionTypeDWARFDebugAbbrev; + else if (section_name == g_sect_name_dwarf_debug_aranges) + sect_type = eSectionTypeDWARFDebugAranges; + else if (section_name == g_sect_name_dwarf_debug_frame) + sect_type = eSectionTypeDWARFDebugFrame; + else if (section_name == g_sect_name_dwarf_debug_info) + sect_type = eSectionTypeDWARFDebugInfo; + else if (section_name == g_sect_name_dwarf_debug_line) + sect_type = eSectionTypeDWARFDebugLine; + else if (section_name == g_sect_name_dwarf_debug_loc) + sect_type = eSectionTypeDWARFDebugLoc; + else if (section_name == g_sect_name_dwarf_debug_macinfo) + sect_type = eSectionTypeDWARFDebugMacInfo; + else if (section_name == g_sect_name_dwarf_debug_pubnames) + sect_type = eSectionTypeDWARFDebugPubNames; + else if (section_name == g_sect_name_dwarf_debug_pubtypes) + sect_type = eSectionTypeDWARFDebugPubTypes; + else if (section_name == g_sect_name_dwarf_debug_ranges) + sect_type = eSectionTypeDWARFDebugRanges; + else if (section_name == g_sect_name_dwarf_debug_str) + sect_type = eSectionTypeDWARFDebugStr; + else if (section_name == g_sect_name_objc_selrefs) sect_type = eSectionTypeDataCStringPointers; - } else if (section_name == g_sect_name_objc_msgrefs) - { sect_type = eSectionTypeDataObjCMessageRefs; - } + else if (section_name == g_sect_name_eh_frame) + sect_type = eSectionTypeEHFrame; + else if (section_name == g_sect_name_cfstring) + sect_type = eSectionTypeDataObjCCFStrings; else if (section_name == g_sect_name_objc_data || section_name == g_sect_name_objc_classrefs || section_name == g_sect_name_objc_superrefs || @@ -391,10 +428,6 @@ ObjectFileMachO::ParseSections () { sect_type = eSectionTypeDataPointers; } - else if (section_name == g_sect_name_cfstring) - { - sect_type = eSectionTypeDataObjCCFStrings; - } if (sect_type == eSectionTypeOther) { diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp index 0c84d2b1160..866617bcf44 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -57,83 +57,6 @@ using namespace lldb; using namespace lldb_private; -static const ConstString& -GetSectionNameDebugInfo() -{ - static const ConstString g_sect_name("__debug_info"); - return g_sect_name; -} - -static const ConstString& -GetSectionNameDebugAbbrev() -{ - static const ConstString g_sect_name ("__debug_abbrev"); - return g_sect_name; -} - -static const ConstString& -GetSectionNameDebugAranges() -{ - static const ConstString g_sect_name ("__debug_aranges"); - return g_sect_name; -} - -static const ConstString& -GetSectionNameDebugFrame() -{ - static const ConstString g_sect_name ("__debug_frame"); - return g_sect_name; -} - -static const ConstString& -GetSectionNameDebugLine() -{ - static const ConstString g_sect_name ("__debug_line"); - return g_sect_name; -} - -static const ConstString& -GetSectionNameDebugLoc() -{ - static const ConstString g_sect_name ("__debug_loc"); - return g_sect_name; -} - -static const ConstString& -GetSectionNameDebugMacInfo() -{ - static const ConstString g_sect_name ("__debug_macinfo"); - return g_sect_name; -} - -static const ConstString& -GetSectionNameDebugPubNames() -{ - static const ConstString g_sect_name ("__debug_pubnames"); - return g_sect_name; -} - -static const ConstString& -GetSectionNameDebugPubTypes() -{ - static const ConstString g_sect_name ("__debug_pubtypes"); - return g_sect_name; -} - -static const ConstString& -GetSectionNameDebugRanges() -{ - static const ConstString g_sect_name ("__debug_ranges"); - return g_sect_name; -} - -static const ConstString& -GetSectionNameDebugStr() -{ - static const ConstString g_sect_name ("__debug_str"); - return g_sect_name; -} - static uint32_t DwarfToClangAccessibility (uint32_t dwarf_accessibility) { @@ -283,68 +206,71 @@ SymbolFileDWARF::GetAbilities () section = section_list->FindSectionByName(g_dwarf_section_name).get(); if (section) + { section->MemoryMapSectionDataFromObjectFile(m_obj_file, m_dwarf_data); + section_list = §ion->GetChildren (); + } - section = section_list->FindSectionByName (GetSectionNameDebugInfo()).get(); + section = section_list->FindSectionByType (eSectionTypeDWARFDebugInfo, true).get(); if (section != NULL) { debug_info_file_size = section->GetByteSize(); - section = section_list->FindSectionByName (GetSectionNameDebugAbbrev()).get(); + section = section_list->FindSectionByType (eSectionTypeDWARFDebugAbbrev, true).get(); if (section) debug_abbrev_file_size = section->GetByteSize(); else m_flags.Set (flagsGotDebugAbbrevData); - section = section_list->FindSectionByName (GetSectionNameDebugAranges()).get(); + section = section_list->FindSectionByType (eSectionTypeDWARFDebugAranges, true).get(); if (section) debug_aranges_file_size = section->GetByteSize(); else m_flags.Set (flagsGotDebugArangesData); - section = section_list->FindSectionByName (GetSectionNameDebugFrame()).get(); + section = section_list->FindSectionByType (eSectionTypeDWARFDebugFrame, true).get(); if (section) debug_frame_file_size = section->GetByteSize(); else m_flags.Set (flagsGotDebugFrameData); - section = section_list->FindSectionByName (GetSectionNameDebugLine()).get(); + section = section_list->FindSectionByType (eSectionTypeDWARFDebugLine, true).get(); if (section) debug_line_file_size = section->GetByteSize(); else m_flags.Set (flagsGotDebugLineData); - section = section_list->FindSectionByName (GetSectionNameDebugLoc()).get(); + section = section_list->FindSectionByType (eSectionTypeDWARFDebugLoc, true).get(); if (section) debug_loc_file_size = section->GetByteSize(); else m_flags.Set (flagsGotDebugLocData); - section = section_list->FindSectionByName (GetSectionNameDebugMacInfo()).get(); + section = section_list->FindSectionByType (eSectionTypeDWARFDebugMacInfo, true).get(); if (section) debug_macinfo_file_size = section->GetByteSize(); else m_flags.Set (flagsGotDebugMacInfoData); - section = section_list->FindSectionByName (GetSectionNameDebugPubNames()).get(); + section = section_list->FindSectionByType (eSectionTypeDWARFDebugPubNames, true).get(); if (section) debug_pubnames_file_size = section->GetByteSize(); else m_flags.Set (flagsGotDebugPubNamesData); - section = section_list->FindSectionByName (GetSectionNameDebugPubTypes()).get(); + section = section_list->FindSectionByType (eSectionTypeDWARFDebugPubTypes, true).get(); if (section) debug_pubtypes_file_size = section->GetByteSize(); else m_flags.Set (flagsGotDebugPubTypesData); - section = section_list->FindSectionByName (GetSectionNameDebugRanges()).get(); + section = section_list->FindSectionByType (eSectionTypeDWARFDebugRanges, true).get(); if (section) debug_ranges_file_size = section->GetByteSize(); else m_flags.Set (flagsGotDebugRangesData); - section = section_list->FindSectionByName (GetSectionNameDebugStr()).get(); + section = section_list->FindSectionByType (eSectionTypeDWARFDebugStr, true).get(); if (section) debug_str_file_size = section->GetByteSize(); else @@ -376,7 +302,7 @@ SymbolFileDWARF::GetAbilities () } const DataExtractor& -SymbolFileDWARF::GetCachedSectionData (uint32_t got_flag, const ConstString §ion_name, DataExtractor &data) +SymbolFileDWARF::GetCachedSectionData (uint32_t got_flag, SectionType sect_type, DataExtractor &data) { if (m_flags.IsClear (got_flag)) { @@ -384,8 +310,8 @@ SymbolFileDWARF::GetCachedSectionData (uint32_t got_flag, const ConstString &sec const SectionList *section_list = m_obj_file->GetSectionList(); if (section_list) { - Section *section = section_list->FindSectionByName (section_name).get(); - if (section ) + Section *section = section_list->FindSectionByType(sect_type, true).get(); + if (section) { // See if we memory mapped the DWARF segment? if (m_dwarf_data.GetByteSize()) @@ -406,67 +332,67 @@ SymbolFileDWARF::GetCachedSectionData (uint32_t got_flag, const ConstString &sec const DataExtractor& SymbolFileDWARF::get_debug_abbrev_data() { - return GetCachedSectionData (flagsGotDebugAbbrevData, GetSectionNameDebugAbbrev(), m_data_debug_abbrev); + return GetCachedSectionData (flagsGotDebugAbbrevData, eSectionTypeDWARFDebugAbbrev, m_data_debug_abbrev); } const DataExtractor& SymbolFileDWARF::get_debug_aranges_data() { - return GetCachedSectionData (flagsGotDebugArangesData, GetSectionNameDebugAranges(), m_data_debug_aranges); + return GetCachedSectionData (flagsGotDebugArangesData, eSectionTypeDWARFDebugAranges, m_data_debug_aranges); } const DataExtractor& SymbolFileDWARF::get_debug_frame_data() { - return GetCachedSectionData (flagsGotDebugFrameData, GetSectionNameDebugFrame(), m_data_debug_frame); + return GetCachedSectionData (flagsGotDebugFrameData, eSectionTypeDWARFDebugFrame, m_data_debug_frame); } const DataExtractor& SymbolFileDWARF::get_debug_info_data() { - return GetCachedSectionData (flagsGotDebugInfoData, GetSectionNameDebugInfo(), m_data_debug_info); + return GetCachedSectionData (flagsGotDebugInfoData, eSectionTypeDWARFDebugInfo, m_data_debug_info); } const DataExtractor& SymbolFileDWARF::get_debug_line_data() { - return GetCachedSectionData (flagsGotDebugLineData, GetSectionNameDebugLine(), m_data_debug_line); + return GetCachedSectionData (flagsGotDebugLineData, eSectionTypeDWARFDebugLine, m_data_debug_line); } const DataExtractor& SymbolFileDWARF::get_debug_loc_data() { - return GetCachedSectionData (flagsGotDebugLocData, GetSectionNameDebugLoc(), m_data_debug_loc); + return GetCachedSectionData (flagsGotDebugLocData, eSectionTypeDWARFDebugLoc, m_data_debug_loc); } const DataExtractor& SymbolFileDWARF::get_debug_macinfo_data() { - return GetCachedSectionData (flagsGotDebugMacInfoData, GetSectionNameDebugMacInfo(), m_data_debug_macinfo); + return GetCachedSectionData (flagsGotDebugMacInfoData, eSectionTypeDWARFDebugMacInfo, m_data_debug_macinfo); } const DataExtractor& SymbolFileDWARF::get_debug_pubnames_data() { - return GetCachedSectionData (flagsGotDebugPubNamesData, GetSectionNameDebugPubNames(), m_data_debug_pubnames); + return GetCachedSectionData (flagsGotDebugPubNamesData, eSectionTypeDWARFDebugPubNames, m_data_debug_pubnames); } const DataExtractor& SymbolFileDWARF::get_debug_pubtypes_data() { - return GetCachedSectionData (flagsGotDebugPubTypesData, GetSectionNameDebugPubTypes(), m_data_debug_pubtypes); + return GetCachedSectionData (flagsGotDebugPubTypesData, eSectionTypeDWARFDebugPubTypes, m_data_debug_pubtypes); } const DataExtractor& SymbolFileDWARF::get_debug_ranges_data() { - return GetCachedSectionData (flagsGotDebugRangesData, GetSectionNameDebugRanges(), m_data_debug_ranges); + return GetCachedSectionData (flagsGotDebugRangesData, eSectionTypeDWARFDebugRanges, m_data_debug_ranges); } const DataExtractor& SymbolFileDWARF::get_debug_str_data() { - return GetCachedSectionData (flagsGotDebugStrData, GetSectionNameDebugStr(), m_data_debug_str); + return GetCachedSectionData (flagsGotDebugStrData, eSectionTypeDWARFDebugStr, m_data_debug_str); } diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h index 8868450c95d..f2a507ca85c 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h @@ -170,9 +170,10 @@ public: const DWARFDebugRanges* DebugRanges() const; const lldb_private::DataExtractor& - GetCachedSectionData (uint32_t got_flag, const lldb_private::ConstString §ion_name, lldb_private::DataExtractor &data); + GetCachedSectionData (uint32_t got_flag, lldb::SectionType sect_type, lldb_private::DataExtractor &data); - static bool SupportedVersion(uint16_t version); + static bool + SupportedVersion(uint16_t version); clang::DeclContext * GetClangDeclContextForDIE (const DWARFCompileUnit *cu, const DWARFDebugInfoEntry *die); |