diff options
author | George Rimar <grimar@accesssoftek.com> | 2018-10-23 09:46:15 +0000 |
---|---|---|
committer | George Rimar <grimar@accesssoftek.com> | 2018-10-23 09:46:15 +0000 |
commit | e4dee2696eb350e1f738cecf9097be719a5f7721 (patch) | |
tree | 3310f30697040dc57349a685944f7b83e6cd7765 | |
parent | 816e57be35bd9eef85657862fca128dcf99a0a5b (diff) | |
download | bcm5719-llvm-e4dee2696eb350e1f738cecf9097be719a5f7721.tar.gz bcm5719-llvm-e4dee2696eb350e1f738cecf9097be719a5f7721.zip |
[LLDB] - Implement the support for the .debug_loclists section.
This implements the support for .debug_loclists section, which is
DWARF 5 version of .debug_loc.
Currently, clang is able to emit it with the use of D53365.
Differential revision: https://reviews.llvm.org/D53436
llvm-svn: 345016
-rw-r--r-- | lldb/include/lldb/Expression/DWARFExpression.h | 1 | ||||
-rw-r--r-- | lldb/include/lldb/lldb-enumerations.h | 1 | ||||
-rw-r--r-- | lldb/source/Core/Section.cpp | 2 | ||||
-rw-r--r-- | lldb/source/Expression/DWARFExpression.cpp | 12 | ||||
-rw-r--r-- | lldb/source/Expression/IRExecutionUnit.cpp | 3 | ||||
-rw-r--r-- | lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp | 6 | ||||
-rw-r--r-- | lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp | 4 | ||||
-rw-r--r-- | lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp | 3 | ||||
-rw-r--r-- | lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp | 4 | ||||
-rw-r--r-- | lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp | 16 | ||||
-rw-r--r-- | lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h | 4 | ||||
-rw-r--r-- | lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwp.cpp | 2 | ||||
-rw-r--r-- | lldb/source/Symbol/ObjectFile.cpp | 1 |
13 files changed, 55 insertions, 4 deletions
diff --git a/lldb/include/lldb/Expression/DWARFExpression.h b/lldb/include/lldb/Expression/DWARFExpression.h index ef5929a686c..0e4cdb37310 100644 --- a/lldb/include/lldb/Expression/DWARFExpression.h +++ b/lldb/include/lldb/Expression/DWARFExpression.h @@ -41,6 +41,7 @@ public: NonLocationList, // Not a location list RegularLocationList, // Location list format used in non-split dwarf files SplitDwarfLocationList, // Location list format used in split dwarf files + LocLists, // Location list format used in DWARF v5 (.debug_loclists). }; //------------------------------------------------------------------ diff --git a/lldb/include/lldb/lldb-enumerations.h b/lldb/include/lldb/lldb-enumerations.h index 8a7cff4b8ea..d85efab8a51 100644 --- a/lldb/include/lldb/lldb-enumerations.h +++ b/lldb/include/lldb/lldb-enumerations.h @@ -676,6 +676,7 @@ enum SectionType { eSectionTypeOther, eSectionTypeDWARFDebugLineStr, // DWARF v5 .debug_line_str eSectionTypeDWARFDebugRngLists, // DWARF v5 .debug_rnglists + eSectionTypeDWARFDebugLocLists, // DWARF v5 .debug_loclists }; FLAGS_ENUM(EmulateInstructionOptions){ diff --git a/lldb/source/Core/Section.cpp b/lldb/source/Core/Section.cpp index d516b63bcb7..24dbb428a07 100644 --- a/lldb/source/Core/Section.cpp +++ b/lldb/source/Core/Section.cpp @@ -77,6 +77,8 @@ const char *Section::GetTypeAsCString() const { return "dwarf-line-str"; case eSectionTypeDWARFDebugLoc: return "dwarf-loc"; + case eSectionTypeDWARFDebugLocLists: + return "dwarf-loclists"; case eSectionTypeDWARFDebugMacInfo: return "dwarf-macinfo"; case eSectionTypeDWARFDebugMacro: diff --git a/lldb/source/Expression/DWARFExpression.cpp b/lldb/source/Expression/DWARFExpression.cpp index a3f0b022f25..4816b883bfa 100644 --- a/lldb/source/Expression/DWARFExpression.cpp +++ b/lldb/source/Expression/DWARFExpression.cpp @@ -3037,6 +3037,7 @@ bool DWARFExpression::AddressRangeForLocationListEntry( high_pc = debug_loc_data.GetAddress(offset_ptr); return true; case SplitDwarfLocationList: + case LocLists: switch (debug_loc_data.GetU8(offset_ptr)) { case DW_LLE_end_of_list: return false; @@ -3054,8 +3055,19 @@ bool DWARFExpression::AddressRangeForLocationListEntry( high_pc = low_pc + length; return true; } + case DW_LLE_start_length: { + low_pc = debug_loc_data.GetAddress(offset_ptr); + high_pc = low_pc + debug_loc_data.GetULEB128(offset_ptr); + return true; + } + case DW_LLE_start_end: { + low_pc = debug_loc_data.GetAddress(offset_ptr); + high_pc = debug_loc_data.GetAddress(offset_ptr); + return true; + } default: // Not supported entry type + lldbassert(false && "Not supported location list type"); return false; } } diff --git a/lldb/source/Expression/IRExecutionUnit.cpp b/lldb/source/Expression/IRExecutionUnit.cpp index e34a4c7fac5..57c54e144a4 100644 --- a/lldb/source/Expression/IRExecutionUnit.cpp +++ b/lldb/source/Expression/IRExecutionUnit.cpp @@ -553,6 +553,8 @@ lldb::SectionType IRExecutionUnit::GetSectionTypeFromSectionName( sect_type = lldb::eSectionTypeDWARFDebugLine; else if (dwarf_name.equals("loc")) sect_type = lldb::eSectionTypeDWARFDebugLoc; + else if (dwarf_name.equals("loclists")) + sect_type = lldb::eSectionTypeDWARFDebugLocLists; break; case 'm': @@ -1088,6 +1090,7 @@ bool IRExecutionUnit::CommitOneAllocation(lldb::ProcessSP &process_sp, case lldb::eSectionTypeDWARFDebugInfo: case lldb::eSectionTypeDWARFDebugLine: case lldb::eSectionTypeDWARFDebugLoc: + case lldb::eSectionTypeDWARFDebugLocLists: case lldb::eSectionTypeDWARFDebugMacInfo: case lldb::eSectionTypeDWARFDebugPubNames: case lldb::eSectionTypeDWARFDebugPubTypes: diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp index 2958503aec4..d7ca18cd2c9 100644 --- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp +++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp @@ -1790,6 +1790,7 @@ void ObjectFileELF::CreateSections(SectionList &unified_section_list) { static ConstString g_sect_name_dwarf_debug_line(".debug_line"); static ConstString g_sect_name_dwarf_debug_line_str(".debug_line_str"); static ConstString g_sect_name_dwarf_debug_loc(".debug_loc"); + static ConstString g_sect_name_dwarf_debug_loclists(".debug_loclists"); static ConstString g_sect_name_dwarf_debug_macinfo(".debug_macinfo"); static ConstString g_sect_name_dwarf_debug_macro(".debug_macro"); static ConstString g_sect_name_dwarf_debug_names(".debug_names"); @@ -1807,6 +1808,7 @@ void ObjectFileELF::CreateSections(SectionList &unified_section_list) { static ConstString g_sect_name_dwarf_debug_line_str_dwo(".debug_line_str.dwo"); static ConstString g_sect_name_dwarf_debug_macro_dwo(".debug_macro.dwo"); static ConstString g_sect_name_dwarf_debug_loc_dwo(".debug_loc.dwo"); + static ConstString g_sect_name_dwarf_debug_loclists_dwo(".debug_loclists.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"); @@ -1868,6 +1870,8 @@ void ObjectFileELF::CreateSections(SectionList &unified_section_list) { sect_type = eSectionTypeDWARFDebugLineStr; else if (name == g_sect_name_dwarf_debug_loc) sect_type = eSectionTypeDWARFDebugLoc; + else if (name == g_sect_name_dwarf_debug_loclists) + sect_type = eSectionTypeDWARFDebugLocLists; else if (name == g_sect_name_dwarf_debug_macinfo) sect_type = eSectionTypeDWARFDebugMacInfo; else if (name == g_sect_name_dwarf_debug_macro) @@ -1900,6 +1904,8 @@ void ObjectFileELF::CreateSections(SectionList &unified_section_list) { sect_type = eSectionTypeDWARFDebugMacro; else if (name == g_sect_name_dwarf_debug_loc_dwo) sect_type = eSectionTypeDWARFDebugLoc; + else if (name == g_sect_name_dwarf_debug_loclists_dwo) + sect_type = eSectionTypeDWARFDebugLocLists; else if (name == g_sect_name_dwarf_debug_str_dwo) sect_type = eSectionTypeDWARFDebugStr; else if (name == g_sect_name_dwarf_debug_str_offsets_dwo) diff --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp index 3550476c62b..e2939f4f10e 100644 --- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp +++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp @@ -1199,6 +1199,7 @@ AddressClass ObjectFileMachO::GetAddressClass(lldb::addr_t file_addr) { case eSectionTypeDWARFDebugLine: case eSectionTypeDWARFDebugLineStr: case eSectionTypeDWARFDebugLoc: + case eSectionTypeDWARFDebugLocLists: case eSectionTypeDWARFDebugMacInfo: case eSectionTypeDWARFDebugMacro: case eSectionTypeDWARFDebugNames: @@ -1457,6 +1458,7 @@ static lldb::SectionType GetSectionType(uint32_t flags, 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_loclists("__debug_loclists"); static ConstString g_sect_name_dwarf_debug_macinfo("__debug_macinfo"); static ConstString g_sect_name_dwarf_debug_names("__debug_names"); static ConstString g_sect_name_dwarf_debug_pubnames("__debug_pubnames"); @@ -1486,6 +1488,8 @@ static lldb::SectionType GetSectionType(uint32_t flags, return eSectionTypeDWARFDebugLine; if (section_name == g_sect_name_dwarf_debug_loc) return eSectionTypeDWARFDebugLoc; + if (section_name == g_sect_name_dwarf_debug_loclists) + return eSectionTypeDWARFDebugLocLists; if (section_name == g_sect_name_dwarf_debug_macinfo) return eSectionTypeDWARFDebugMacInfo; if (section_name == g_sect_name_dwarf_debug_names) diff --git a/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp b/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp index b2967f1532a..40637574e4b 100644 --- a/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp +++ b/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp @@ -691,6 +691,7 @@ void ObjectFilePECOFF::CreateSections(SectionList &unified_section_list) { 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_loclists(".debug_loclists"); static ConstString g_sect_name_dwarf_debug_macinfo(".debug_macinfo"); static ConstString g_sect_name_dwarf_debug_names(".debug_names"); static ConstString g_sect_name_dwarf_debug_pubnames(".debug_pubnames"); @@ -736,6 +737,8 @@ void ObjectFilePECOFF::CreateSections(SectionList &unified_section_list) { section_type = eSectionTypeDWARFDebugLine; else if (const_sect_name == g_sect_name_dwarf_debug_loc) section_type = eSectionTypeDWARFDebugLoc; + else if (const_sect_name == g_sect_name_dwarf_debug_loclists) + section_type = eSectionTypeDWARFDebugLocLists; else if (const_sect_name == g_sect_name_dwarf_debug_macinfo) section_type = eSectionTypeDWARFDebugMacInfo; else if (const_sect_name == g_sect_name_dwarf_debug_names) diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp index df93f9555db..66cf47cd450 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp @@ -531,7 +531,7 @@ bool DWARFDebugInfoEntry::GetDIENamesAndRanges( block_length); } else { const DWARFDataExtractor &debug_loc_data = - dwarf2Data->get_debug_loc_data(); + dwarf2Data->DebugLocData(); const dw_offset_t debug_loc_offset = form_value.Unsigned(); size_t loc_list_length = DWARFExpression::LocationListSize( @@ -726,7 +726,7 @@ void DWARFDebugInfoEntry::DumpAttribute( uint64_t debug_loc_offset = form_value.Unsigned(); if (dwarf2Data) { DWARFExpression::PrintDWARFLocationList( - s, cu, dwarf2Data->get_debug_loc_data(), debug_loc_offset); + s, cu, dwarf2Data->DebugLocData(), debug_loc_offset); } } } break; diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp index 563305028e2..3a758ce126d 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -654,10 +654,22 @@ const DWARFDataExtractor &SymbolFileDWARF::get_debug_macro_data() { return GetCachedSectionData(eSectionTypeDWARFDebugMacro, m_data_debug_macro); } +const DWARFDataExtractor &SymbolFileDWARF::DebugLocData() { + const DWARFDataExtractor &debugLocData = get_debug_loc_data(); + if (debugLocData.GetByteSize() > 0) + return debugLocData; + return get_debug_loclists_data(); +} + const DWARFDataExtractor &SymbolFileDWARF::get_debug_loc_data() { return GetCachedSectionData(eSectionTypeDWARFDebugLoc, m_data_debug_loc); } +const DWARFDataExtractor &SymbolFileDWARF::get_debug_loclists_data() { + return GetCachedSectionData(eSectionTypeDWARFDebugLocLists, + m_data_debug_loclists); +} + const DWARFDataExtractor &SymbolFileDWARF::get_debug_ranges_data() { return GetCachedSectionData(eSectionTypeDWARFDebugRanges, m_data_debug_ranges); @@ -3346,7 +3358,7 @@ VariableSP SymbolFileDWARF::ParseVariableDIE(const SymbolContext &sc, uint32_t block_length = form_value.Unsigned(); location.CopyOpcodeData(module, data, block_offset, block_length); } else { - const DWARFDataExtractor &debug_loc_data = get_debug_loc_data(); + const DWARFDataExtractor &debug_loc_data = DebugLocData(); const dw_offset_t debug_loc_offset = form_value.Unsigned(); size_t loc_list_length = DWARFExpression::LocationListSize( @@ -3860,6 +3872,8 @@ SymbolFileDWARFDebugMap *SymbolFileDWARF::GetDebugMapSymfile() { DWARFExpression::LocationListFormat SymbolFileDWARF::GetLocationListFormat() const { + if (m_data_debug_loclists.m_data.GetByteSize() > 0) + return DWARFExpression::LocLists; return DWARFExpression::RegularLocationList; } diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h index d2ec3eeba2e..03137cf68b0 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h @@ -246,6 +246,7 @@ public: const lldb_private::DWARFDataExtractor &get_debug_line_str_data(); const lldb_private::DWARFDataExtractor &get_debug_macro_data(); const lldb_private::DWARFDataExtractor &get_debug_loc_data(); + const lldb_private::DWARFDataExtractor &get_debug_loclists_data(); const lldb_private::DWARFDataExtractor &get_debug_ranges_data(); const lldb_private::DWARFDataExtractor &get_debug_rnglists_data(); const lldb_private::DWARFDataExtractor &get_debug_str_data(); @@ -269,6 +270,8 @@ public: const DWARFDebugRanges *DebugRanges() const; + const lldb_private::DWARFDataExtractor &DebugLocData(); + static bool SupportedVersion(uint16_t version); DWARFDIE @@ -477,6 +480,7 @@ protected: DWARFDataSegment m_data_debug_line_str; DWARFDataSegment m_data_debug_macro; DWARFDataSegment m_data_debug_loc; + DWARFDataSegment m_data_debug_loclists; DWARFDataSegment m_data_debug_ranges; DWARFDataSegment m_data_debug_rnglists; DWARFDataSegment m_data_debug_str; diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwp.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwp.cpp index ae10e7179e3..2c18355c2a2 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwp.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwp.cpp @@ -30,7 +30,7 @@ lldbSectTypeToLlvmSectionKind(lldb::SectionType type) { case lldb::eSectionTypeDWARFDebugLine: return llvm::DW_SECT_LINE; case lldb::eSectionTypeDWARFDebugLoc: - return llvm::DW_SECT_LOC; + return llvm::DW_SECT_LOC; case lldb::eSectionTypeDWARFDebugStrOffsets: return llvm::DW_SECT_STR_OFFSETS; // case lldb::eSectionTypeDWARFDebugMacinfo: diff --git a/lldb/source/Symbol/ObjectFile.cpp b/lldb/source/Symbol/ObjectFile.cpp index 3711a664622..937766d492e 100644 --- a/lldb/source/Symbol/ObjectFile.cpp +++ b/lldb/source/Symbol/ObjectFile.cpp @@ -352,6 +352,7 @@ AddressClass ObjectFile::GetAddressClass(addr_t file_addr) { case eSectionTypeDWARFDebugLine: case eSectionTypeDWARFDebugLineStr: case eSectionTypeDWARFDebugLoc: + case eSectionTypeDWARFDebugLocLists: case eSectionTypeDWARFDebugMacInfo: case eSectionTypeDWARFDebugMacro: case eSectionTypeDWARFDebugNames: |