llvm.org GIT mirror llvm / 2a213a4
llvm-dwarfdump: Support for debug_line.dwo section for file names for type units under fission. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@202091 91177308-0d34-0410-b5e6-96231b3b80d8 David Blaikie 6 years ago
9 changed file(s) with 53 addition(s) and 15 deletion(s). Raw diff Collapse all Expand all
106106 DIDT_Types,
107107 DIDT_TypesDwo,
108108 DIDT_Line,
109 DIDT_LineDwo,
109110 DIDT_Loc,
110111 DIDT_Ranges,
111112 DIDT_Pubnames,
133133 DWARFDebugLine::parseStatementTable(lineData, &getLineSection().Relocs, &stmtOffset, state);
134134 }
135135 }
136 }
137
138 if (DumpType == DIDT_All || DumpType == DIDT_LineDwo) {
139 OS << "\n.debug_line.dwo contents:\n";
140 unsigned stmtOffset = 0;
141 DataExtractor lineData(getLineDWOSection().Data, isLittleEndian(),
142 savedAddressByteSize);
143 DWARFDebugLine::DumpingState state(OS);
144 while (DWARFDebugLine::parsePrologue(lineData, &stmtOffset, &state.Prologue))
145 state.finalize();
136146 }
137147
138148 if (DumpType == DIDT_All || DumpType == DIDT_Str) {
644654 .Case("debug_gnu_pubtypes", &GnuPubTypesSection)
645655 .Case("debug_info.dwo", &InfoDWOSection.Data)
646656 .Case("debug_abbrev.dwo", &AbbrevDWOSection)
657 .Case("debug_line.dwo", &LineDWOSection.Data)
647658 .Case("debug_str.dwo", &StringDWOSection)
648659 .Case("debug_str_offsets.dwo", &StringOffsetDWOSection)
649660 .Case("debug_addr", &AddrSection)
165165 virtual StringRef getARangeSection() = 0;
166166 virtual StringRef getDebugFrameSection() = 0;
167167 virtual const Section &getLineSection() = 0;
168 virtual const Section &getLineDWOSection() = 0;
168169 virtual StringRef getStringSection() = 0;
169170 virtual StringRef getRangeSection() = 0;
170171 virtual StringRef getPubNamesSection() = 0;
207208 StringRef ARangeSection;
208209 StringRef DebugFrameSection;
209210 Section LineSection;
211 Section LineDWOSection;
210212 StringRef StringSection;
211213 StringRef RangeSection;
212214 StringRef PubNamesSection;
237239 virtual StringRef getARangeSection() { return ARangeSection; }
238240 virtual StringRef getDebugFrameSection() { return DebugFrameSection; }
239241 virtual const Section &getLineSection() { return LineSection; }
242 virtual const Section &getLineDWOSection() { return LineDWOSection; }
240243 virtual StringRef getStringSection() { return StringSection; }
241244 virtual StringRef getRangeSection() { return RangeSection; }
242245 virtual StringRef getPubNamesSection() { return PubNamesSection; }
1717
1818 void DWARFDebugLine::Prologue::dump(raw_ostream &OS) const {
1919 OS << "Line table prologue:\n"
20 << format(" total_length: 0x%8.8x\n", TotalLength)
21 << format(" version: %u\n", Version)
22 << format("prologue_length: 0x%8.8x\n", PrologueLength)
23 << format("min_inst_length: %u\n", MinInstLength)
24 << format("default_is_stmt: %u\n", DefaultIsStmt)
25 << format(" line_base: %i\n", LineBase)
26 << format(" line_range: %u\n", LineRange)
27 << format(" opcode_base: %u\n", OpcodeBase);
20 << format(" total_length: 0x%8.8x\n", TotalLength)
21 << format(" version: %u\n", Version)
22 << format(" prologue_length: 0x%8.8x\n", PrologueLength)
23 << format(" min_inst_length: %u\n", MinInstLength)
24 << format(Version >= 4 ? "max_ops_per_inst: %u\n" : "", MaxOpsPerInst)
25 << format(" default_is_stmt: %u\n", DefaultIsStmt)
26 << format(" line_base: %i\n", LineBase)
27 << format(" line_range: %u\n", LineRange)
28 << format(" opcode_base: %u\n", OpcodeBase);
2829
2930 for (uint32_t i = 0; i < StandardOpcodeLengths.size(); ++i)
3031 OS << format("standard_opcode_lengths[%s] = %u\n", LNStandardString(i+1),
171172 prologue->clear();
172173 prologue->TotalLength = debug_line_data.getU32(offset_ptr);
173174 prologue->Version = debug_line_data.getU16(offset_ptr);
174 if (prologue->Version != 2)
175 if (prologue->Version < 2)
175176 return false;
176177
177178 prologue->PrologueLength = debug_line_data.getU32(offset_ptr);
178179 const uint32_t end_prologue_offset = prologue->PrologueLength + *offset_ptr;
179180 prologue->MinInstLength = debug_line_data.getU8(offset_ptr);
181 if (prologue->Version >= 4)
182 prologue->MaxOpsPerInst = debug_line_data.getU8(offset_ptr);
180183 prologue->DefaultIsStmt = debug_line_data.getU8(offset_ptr);
181184 prologue->LineBase = debug_line_data.getU8(offset_ptr);
182185 prologue->LineRange = debug_line_data.getU8(offset_ptr);
219222 return true;
220223 }
221224
222 bool
223 DWARFDebugLine::parseStatementTable(DataExtractor debug_line_data,
224 const RelocAddrMap *RMap,
225 uint32_t *offset_ptr, State &state) {
225 bool DWARFDebugLine::parseStatementTable(DataExtractor debug_line_data,
226 const RelocAddrMap *RMap,
227 uint32_t *offset_ptr, State &state) {
226228 const uint32_t debug_line_offset = *offset_ptr;
227229
228230 Prologue *prologue = &state.Prologue;
3333
3434 struct Prologue {
3535 Prologue()
36 : TotalLength(0), Version(0), PrologueLength(0), MinInstLength(0),
37 DefaultIsStmt(0), LineBase(0), LineRange(0), OpcodeBase(0) {}
36 : TotalLength(0), Version(0), PrologueLength(0), MinInstLength(0),
37 MaxOpsPerInst(0), DefaultIsStmt(0), LineBase(0), LineRange(0),
38 OpcodeBase(0) {}
3839
3940 // The size in bytes of the statement information for this compilation unit
4041 // (not including the total_length field itself).
4849 // program opcodes that alter the address register first multiply their
4950 // operands by this value.
5051 uint8_t MinInstLength;
52 // The maximum number of individual operations that may be encoded in an
53 // instruction.
54 uint8_t MaxOpsPerInst;
5155 // The initial value of theis_stmtregister.
5256 uint8_t DefaultIsStmt;
5357 // This parameter affects the meaning of the special opcodes. See below.
0 struct foo {
1 };
2
3 foo f;
4
5 // Built with GCC
6 // $ mkdir -p /tmp/dbginfo
7 // $ cp dwarfdump-line-dwo.cc /tmp/dbginfo
8 // $ cd /tmp/dbginfo
9 // $ g++ -c -fdebug-types-section dwarfdump-line-dwo.cc -o
0 RUN: llvm-dwarfdump %p/Inputs/dwarfdump-line-dwo.elf-x86-64 | FileCheck %s
1
2 CHECK: .debug_line.dwo contents:
3 CHECK: version: 4
4 CHECK: max_ops_per_inst: 1
5 CHECK: file_names[ 1]{{.*}}dwarfdump-line-dwo.cc
6464 clEnumValN(DIDT_Types, "types", ".debug_types"),
6565 clEnumValN(DIDT_TypesDwo, "types.dwo", ".debug_types.dwo"),
6666 clEnumValN(DIDT_Line, "line", ".debug_line"),
67 clEnumValN(DIDT_LineDwo, "line.dwo", ".debug_line.dwo"),
6768 clEnumValN(DIDT_Loc, "loc", ".debug_loc"),
6869 clEnumValN(DIDT_Frames, "frames", ".debug_frame"),
6970 clEnumValN(DIDT_Ranges, "ranges", ".debug_ranges"),