diff options
| author | David Blaikie <dblaikie@gmail.com> | 2015-12-02 06:21:34 +0000 |
|---|---|---|
| committer | David Blaikie <dblaikie@gmail.com> | 2015-12-02 06:21:34 +0000 |
| commit | b073cb9be2bbd9458035f6ce28b8df78a5399b8a (patch) | |
| tree | 4d99d4ef04bd63995861e9e14f1026e28504bc97 /llvm/lib | |
| parent | 12e7b99ed052e5e2104d36c83f343a0dd7864d1d (diff) | |
| download | bcm5719-llvm-b073cb9be2bbd9458035f6ce28b8df78a5399b8a.tar.gz bcm5719-llvm-b073cb9be2bbd9458035f6ce28b8df78a5399b8a.zip | |
[llvm-dwp] Emit a rather fictional debug_cu_index
This is very rudimentary support for debug_cu_index, but it is enough to
allow llvm-dwarfdump to find the offsets for contributions and
correctly dump debug_info.
It will need to actually find the real signature of the unit and build
the real hash table with the right number of buckets, as per the DWP
specification.
It will also need to be expanded to cover the tu_index as well.
llvm-svn: 254489
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/DebugInfo/DWARF/DWARFContext.cpp | 16 | ||||
| -rw-r--r-- | llvm/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp | 12 | ||||
| -rw-r--r-- | llvm/lib/MC/MCObjectFileInfo.cpp | 12 |
3 files changed, 27 insertions, 13 deletions
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp index 2165d353ba0..a4195b75c47 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp @@ -163,20 +163,12 @@ void DWARFContext::dump(raw_ostream &OS, DIDumpType DumpType) { if (DumpType == DIDT_All || DumpType == DIDT_CUIndex) { OS << "\n.debug_cu_index contents:\n"; - DataExtractor CUIndexData(getCUIndexSection(), isLittleEndian(), - savedAddressByteSize); - DWARFUnitIndex CUIndex; - if (CUIndex.parse(CUIndexData)) - CUIndex.dump(OS); + getCUIndex().dump(OS); } if (DumpType == DIDT_All || DumpType == DIDT_TUIndex) { OS << "\n.debug_tu_index contents:\n"; - DataExtractor TUIndexData(getTUIndexSection(), isLittleEndian(), - savedAddressByteSize); - DWARFUnitIndex TUIndex; - if (TUIndex.parse(TUIndexData)) - TUIndex.dump(OS); + getTUIndex().dump(OS); } if (DumpType == DIDT_All || DumpType == DIDT_LineDwo) { @@ -280,7 +272,7 @@ const DWARFUnitIndex &DWARFContext::getCUIndex() { DataExtractor CUIndexData(getCUIndexSection(), isLittleEndian(), 0); - CUIndex = llvm::make_unique<DWARFUnitIndex>(); + CUIndex = llvm::make_unique<DWARFUnitIndex>(DW_SECT_INFO); CUIndex->parse(CUIndexData); return *CUIndex; } @@ -291,7 +283,7 @@ const DWARFUnitIndex &DWARFContext::getTUIndex() { DataExtractor TUIndexData(getTUIndexSection(), isLittleEndian(), 0); - TUIndex = llvm::make_unique<DWARFUnitIndex>(); + TUIndex = llvm::make_unique<DWARFUnitIndex>(DW_SECT_TYPES); TUIndex->parse(TUIndexData); return *TUIndex; } diff --git a/llvm/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp b/llvm/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp index baefed30f36..e8e7441d976 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp @@ -30,6 +30,13 @@ void DWARFUnitIndex::Header::dump(raw_ostream &OS) const { } bool DWARFUnitIndex::parse(DataExtractor IndexData) { + bool b = parseImpl(IndexData); + if (!b) + *this = DWARFUnitIndex(InfoColumnKind); + return b; +} + +bool DWARFUnitIndex::parseImpl(DataExtractor IndexData) { uint32_t Offset = 0; if (!Header.parse(IndexData, &Offset)) return false; @@ -62,7 +69,7 @@ bool DWARFUnitIndex::parse(DataExtractor IndexData) { // Read the Column Headers for (unsigned i = 0; i != Header.NumColumns; ++i) { ColumnKinds[i] = static_cast<DWARFSectionKind>(IndexData.getU32(&Offset)); - if (ColumnKinds[i] == DW_SECT_INFO || ColumnKinds[i] == DW_SECT_TYPES) { + if (ColumnKinds[i] == InfoColumnKind) { if (InfoColumn != -1) return false; InfoColumn = i; @@ -107,6 +114,9 @@ StringRef DWARFUnitIndex::getColumnHeader(DWARFSectionKind DS) { } void DWARFUnitIndex::dump(raw_ostream &OS) const { + if (!Header.NumBuckets) + return; + Header.dump(OS); OS << "Index Signature "; for (unsigned i = 0; i != Header.NumColumns; ++i) diff --git a/llvm/lib/MC/MCObjectFileInfo.cpp b/llvm/lib/MC/MCObjectFileInfo.cpp index 8b75457a246..41e28698b1c 100644 --- a/llvm/lib/MC/MCObjectFileInfo.cpp +++ b/llvm/lib/MC/MCObjectFileInfo.cpp @@ -259,6 +259,9 @@ void MCObjectFileInfo::initMachOMCObjectFileInfo(Triple T) { DwarfDebugInlineSection = Ctx->getMachOSection("__DWARF", "__debug_inlined", MachO::S_ATTR_DEBUG, SectionKind::getMetadata()); + DwarfCUIndexSection = + Ctx->getMachOSection("__DWARF", "__debug_cu_index", MachO::S_ATTR_DEBUG, + SectionKind::getMetadata()); StackMapSection = Ctx->getMachOSection("__LLVM_STACKMAPS", "__llvm_stackmaps", 0, SectionKind::getMetadata()); @@ -531,6 +534,10 @@ void MCObjectFileInfo::initELFMCObjectFileInfo(Triple T) { DwarfAddrSection = Ctx->getELFSection(".debug_addr", ELF::SHT_PROGBITS, 0, "addr_sec"); + // DWP Sections + DwarfCUIndexSection = + Ctx->getELFSection(".debug_cu_index", ELF::SHT_PROGBITS, 0); + StackMapSection = Ctx->getELFSection(".llvm_stackmaps", ELF::SHT_PROGBITS, ELF::SHF_ALLOC); @@ -713,6 +720,11 @@ void MCObjectFileInfo::initCOFFMCObjectFileInfo(Triple T) { COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | COFF::IMAGE_SCN_MEM_READ, SectionKind::getMetadata(), "addr_sec"); + DwarfCUIndexSection = Ctx->getCOFFSection( + ".debug_cu_index", + COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | + COFF::IMAGE_SCN_MEM_READ, + SectionKind::getMetadata()); DwarfAccelNamesSection = Ctx->getCOFFSection( ".apple_names", COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | |

