llvm.org GIT mirror llvm / 5d25204
DebugInfo: .debug_line DWARF64 support This adds support for the 64-bit DWARF format, but is still limited to less than 4GB of debug data by the DataExtractor class. Some versions of the GNU MIPS toolchain generate 64-Bit DWARF even though it isn't actually necessary. Differential Revision: http://reviews.llvm.org/D1988 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238434 91177308-0d34-0410-b5e6-96231b3b80d8 Ed Maste 4 years ago
4 changed file(s) with 46 addition(s) and 14 deletion(s). Raw diff Collapse all Expand all
3737
3838 // The size in bytes of the statement information for this compilation unit
3939 // (not including the total_length field itself).
40 uint32_t TotalLength;
40 uint64_t TotalLength;
4141 // Version identifier for the statement information format.
4242 uint16_t Version;
4343 // The number of bytes following the prologue_length field to the beginning
4444 // of the first byte of the statement program itself.
45 uint32_t PrologueLength;
45 uint64_t PrologueLength;
4646 // The size in bytes of the smallest target machine instruction. Statement
4747 // program opcodes that alter the address register first multiply their
4848 // operands by this value.
6262 std::vector IncludeDirectories;
6363 std::vector FileNames;
6464
65 bool IsDWARF64;
66 uint32_t sizeofTotalLength() const {
67 return IsDWARF64 ? 12 : 4;
68 }
69 uint32_t sizeofPrologueLength() const {
70 return IsDWARF64 ? 8 : 4;
71 }
72
6573 // Length of the prologue in bytes.
6674 uint32_t getLength() const {
67 return PrologueLength + sizeof(TotalLength) + sizeof(Version) +
68 sizeof(PrologueLength);
75 return PrologueLength + sizeofTotalLength() + sizeof(Version) +
76 sizeofPrologueLength();
6977 }
7078 // Length of the line table data in bytes (not including the prologue).
7179 uint32_t getStatementTableLength() const {
72 return TotalLength + sizeof(TotalLength) - getLength();
80 return TotalLength + sizeofTotalLength() - getLength();
7381 }
7482 int32_t getMaxLineIncrementForSpecialOpcode() const {
7583 return LineBase + (int8_t)LineRange - 1;
2424 TotalLength = Version = PrologueLength = 0;
2525 MinInstLength = MaxOpsPerInst = DefaultIsStmt = LineBase = LineRange = 0;
2626 OpcodeBase = 0;
27 IsDWARF64 = false;
2728 StandardOpcodeLengths.clear();
2829 IncludeDirectories.clear();
2930 FileNames.clear();
3132
3233 void DWARFDebugLine::Prologue::dump(raw_ostream &OS) const {
3334 OS << "Line table prologue:\n"
34 << format(" total_length: 0x%8.8x\n", TotalLength)
35 << format(" total_length: 0x%8.8" PRIx64 "\n", TotalLength)
3536 << format(" version: %u\n", Version)
36 << format(" prologue_length: 0x%8.8x\n", PrologueLength)
37 << format(" prologue_length: 0x%8.8" PRIx64 "\n", PrologueLength)
3738 << format(" min_inst_length: %u\n", MinInstLength)
3839 << format(Version >= 4 ? "max_ops_per_inst: %u\n" : "", MaxOpsPerInst)
3940 << format(" default_is_stmt: %u\n", DefaultIsStmt)
6667
6768 bool DWARFDebugLine::Prologue::parse(DataExtractor debug_line_data,
6869 uint32_t *offset_ptr) {
69 const uint32_t prologue_offset = *offset_ptr;
70 const uint64_t prologue_offset = *offset_ptr;
7071
7172 clear();
7273 TotalLength = debug_line_data.getU32(offset_ptr);
74 if (TotalLength == UINT32_MAX) {
75 IsDWARF64 = true;
76 TotalLength = debug_line_data.getU64(offset_ptr);
77 } else if (TotalLength > 0xffffff00) {
78 return false;
79 }
7380 Version = debug_line_data.getU16(offset_ptr);
7481 if (Version < 2)
7582 return false;
7683
77 PrologueLength = debug_line_data.getU32(offset_ptr);
78 const uint32_t end_prologue_offset = PrologueLength + *offset_ptr;
84 PrologueLength = debug_line_data.getUnsigned(offset_ptr,
85 sizeofPrologueLength());
86 const uint64_t end_prologue_offset = PrologueLength + *offset_ptr;
7987 MinInstLength = debug_line_data.getU8(offset_ptr);
8088 if (Version >= 4)
8189 MaxOpsPerInst = debug_line_data.getU8(offset_ptr);
113121 }
114122
115123 if (*offset_ptr != end_prologue_offset) {
116 fprintf(stderr, "warning: parsing line table prologue at 0x%8.8x should"
117 " have ended at 0x%8.8x but it ended at 0x%8.8x\n",
118 prologue_offset, end_prologue_offset, *offset_ptr);
124 fprintf(stderr, "warning: parsing line table prologue at 0x%8.8" PRIx64
125 " should have ended at 0x%8.8" PRIx64
126 " but it ended at 0x%8.8" PRIx64 "\n",
127 prologue_offset, end_prologue_offset, (uint64_t)*offset_ptr);
119128 return false;
120129 }
121130 return true;
257266 }
258267
259268 const uint32_t end_offset = debug_line_offset + Prologue.TotalLength +
260 sizeof(Prologue.TotalLength);
269 Prologue.sizeofTotalLength();
261270
262271 ParsingState State(this);
263272
0 RUN: llvm-dwarfdump %p/Inputs/dwarfdump.elf-mips64-64-bit-dwarf \
1 RUN: --debug-dump=line | FileCheck %s
2
3 # FIXME: llvm-dwarfdump's support for 64-bit dwarf is currently limited to
4 # .debug_line.
5
6 CHECK: total_length: 0x00000212
7 CHECK: version: 2
8 CHECK:prologue_length: 0x000001ab
9 CHECK:min_inst_length: 1
10 CHECK:default_is_stmt: 1
11 CHECK: line_base: -5
12 CHECK: line_range: 14
13 CHECK: opcode_base: 13
14 CHECK: is_stmt end_sequence