diff options
| author | Chris Bieneman <beanz@apple.com> | 2017-03-03 21:11:55 +0000 |
|---|---|---|
| committer | Chris Bieneman <beanz@apple.com> | 2017-03-03 21:11:55 +0000 |
| commit | faf1feb57dfad798b29241a8f0714014beed733a (patch) | |
| tree | e293bd463503979a41f6fd948ab3de830e6256cd /llvm/tools/obj2yaml | |
| parent | 29cb868aa4d0279449b56288fde0358adade1a68 (diff) | |
| download | bcm5719-llvm-faf1feb57dfad798b29241a8f0714014beed733a.tar.gz bcm5719-llvm-faf1feb57dfad798b29241a8f0714014beed733a.zip | |
[ObjectYAML] [DWARF] Abstract DWARF Initial Length values
In the DWARF 4 Spec section 7.2.2, data in many DWARF sections, and some DWARF structures start with "Initial Length Values", which are a 32-bit length, and an optional 64-bit length if the 32 bit value == UINT32_MAX.
This patch abstracts the Initial Length type in YAML, and extends its use to all the DWARF structures that are supported in the DWARFYAML code that have Initial Length values.
llvm-svn: 296911
Diffstat (limited to 'llvm/tools/obj2yaml')
| -rw-r--r-- | llvm/tools/obj2yaml/dwarf2yaml.cpp | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/llvm/tools/obj2yaml/dwarf2yaml.cpp b/llvm/tools/obj2yaml/dwarf2yaml.cpp index 4e320cff441..7b45f8acc3c 100644 --- a/llvm/tools/obj2yaml/dwarf2yaml.cpp +++ b/llvm/tools/obj2yaml/dwarf2yaml.cpp @@ -17,6 +17,13 @@ using namespace llvm; +void dumpInitialLength(DataExtractor &Data, uint32_t &Offset, + DWARFYAML::InitialLength &InitialLength) { + InitialLength.TotalLength = Data.getU32(&Offset); + if (InitialLength.isDWARF64()) + InitialLength.TotalLength64 = Data.getU64(&Offset); +} + void dumpDebugAbbrev(DWARFContextInMemory &DCtx, DWARFYAML::Data &Y) { auto AbbrevSetPtr = DCtx.getDebugAbbrev(); if (AbbrevSetPtr) { @@ -55,7 +62,7 @@ void dumpDebugARanges(DWARFContextInMemory &DCtx, DWARFYAML::Data &Y) { while (Set.extract(ArangesData, &Offset)) { DWARFYAML::ARange Range; - Range.Length = Set.getHeader().Length; + Range.Length.setLength(Set.getHeader().Length); Range.Version = Set.getHeader().Version; Range.CuOffset = Set.getHeader().CuOffset; Range.AddrSize = Set.getHeader().AddrSize; @@ -74,11 +81,11 @@ void dumpPubSection(DWARFContextInMemory &DCtx, DWARFYAML::PubSection &Y, StringRef Section) { DataExtractor PubSectionData(Section, DCtx.isLittleEndian(), 0); uint32_t Offset = 0; - Y.Length = PubSectionData.getU32(&Offset); + dumpInitialLength(PubSectionData, Offset, Y.Length); Y.Version = PubSectionData.getU16(&Offset); Y.UnitOffset = PubSectionData.getU32(&Offset); Y.UnitSize = PubSectionData.getU32(&Offset); - while (Offset < Y.Length) { + while (Offset < Y.Length.getLength()) { DWARFYAML::PubEntry NewEntry; NewEntry.DieOffset = PubSectionData.getU32(&Offset); if (Y.IsGNUStyle) @@ -105,7 +112,7 @@ void dumpDebugPubSections(DWARFContextInMemory &DCtx, DWARFYAML::Data &Y) { void dumpDebugInfo(DWARFContextInMemory &DCtx, DWARFYAML::Data &Y) { for (const auto &CU : DCtx.compile_units()) { DWARFYAML::Unit NewUnit; - NewUnit.Length = CU->getLength(); + NewUnit.Length.setLength(CU->getLength()); NewUnit.Version = CU->getVersion(); NewUnit.AbbrOffset = CU->getAbbreviations()->getOffset(); NewUnit.AddrSize = CU->getAddressByteSize(); @@ -233,14 +240,9 @@ void dumpDebugLines(DWARFContextInMemory &DCtx, DWARFYAML::Data &Y) { DataExtractor LineData(DCtx.getLineSection().Data, DCtx.isLittleEndian(), CU->getAddressByteSize()); uint32_t Offset = *StmtOffset; - uint64_t SizeOfPrologueLength = 4; - DebugLines.TotalLength = LineData.getU32(&Offset); - uint64_t LineTableLength = DebugLines.TotalLength; - if (DebugLines.TotalLength == UINT32_MAX) { - DebugLines.TotalLength64 = LineData.getU64(&Offset); - LineTableLength = DebugLines.TotalLength64; - SizeOfPrologueLength = 8; - } + dumpInitialLength(LineData, Offset, DebugLines.Length); + uint64_t LineTableLength = DebugLines.Length.getLength(); + uint64_t SizeOfPrologueLength = DebugLines.Length.isDWARF64() ? 8 : 4; DebugLines.Version = LineData.getU16(&Offset); DebugLines.PrologueLength = LineData.getUnsigned(&Offset, SizeOfPrologueLength); |

