llvm.org GIT mirror llvm / a34ec4a
llvm-dwarfdump: type unit dwo support git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198850 91177308-0d34-0410-b5e6-96231b3b80d8 David Blaikie 6 years ago
4 changed file(s) with 62 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
104104 DIDT_Info,
105105 DIDT_InfoDwo,
106106 DIDT_Types,
107 DIDT_TypesDwo,
107108 DIDT_Line,
108109 DIDT_Loc,
109110 DIDT_Ranges,
8989 for (unsigned i = 0, e = getNumTypeUnits(); i != e; ++i)
9090 getTypeUnitAtIndex(i)->dump(OS);
9191 }
92
93 if (DumpType == DIDT_All || DumpType == DIDT_TypesDwo)
94 if (getNumDWOTypeUnits()) {
95 OS << "\n.debug_types.dwo contents:\n";
96 for (unsigned i = 0, e = getNumDWOTypeUnits(); i != e; ++i)
97 getDWOTypeUnitAtIndex(i)->dump(OS);
98 }
9299
93100 if (DumpType == DIDT_All || DumpType == DIDT_Loc) {
94101 OS << "\n.debug_loc contents:\n";
329336 }
330337 DWOCUs.push_back(DWOCU.take());
331338 offset = DWOCUs.back()->getNextUnitOffset();
339 }
340 }
341
342 void DWARFContext::parseDWOTypeUnits() {
343 const TypeSectionMap &Sections = getTypesDWOSections();
344 for (TypeSectionMap::const_iterator I = Sections.begin(), E = Sections.end();
345 I != E; ++I) {
346 uint32_t offset = 0;
347 const DataExtractor &DIData =
348 DataExtractor(I->second.Data, isLittleEndian(), 0);
349 while (DIData.isValidOffset(offset)) {
350 OwningPtr TU(new DWARFTypeUnit(
351 getDebugAbbrevDWO(), I->second.Data, getAbbrevDWOSection(),
352 getRangeDWOSection(), getStringDWOSection(),
353 getStringOffsetDWOSection(), getAddrSection(), &I->second.Relocs,
354 isLittleEndian()));
355 if (!TU->extract(DIData, &offset))
356 break;
357 DWOTUs.push_back(TU.take());
358 offset = DWOTUs.back()->getNextUnitOffset();
359 }
332360 }
333361 }
334362
631659 // Find debug_types data by section rather than name as there are
632660 // multiple, comdat grouped, debug_types sections.
633661 TypesSections[*i].Data = data;
662 } else if (name == "debug_types.dwo") {
663 TypesDWOSections[*i].Data = data;
634664 }
635665
636666 section_iterator RelocatedSection = i->getRelocatedSection();
651681 .Case("debug_line", &LineSection.Relocs)
652682 .Default(0);
653683 if (!Map) {
654 if (RelSecName != "debug_types")
655 continue;
656684 // Find debug_types relocs by section rather than name as there are
657685 // multiple, comdat grouped, debug_types sections.
658 Map = &TypesSections[*RelocatedSection].Relocs;
686 if (RelSecName == "debug_types")
687 Map = &TypesSections[*RelocatedSection].Relocs;
688 else if (RelSecName == "debug_types.dwo")
689 Map = &TypesDWOSections[*RelocatedSection].Relocs;
690 else
691 continue;
659692 }
660693
661694 if (i->begin_relocations() != i->end_relocations()) {
3737 OwningPtr DebugFrame;
3838
3939 SmallVector DWOCUs;
40 SmallVector DWOTUs;
4041 OwningPtr AbbrevDWO;
4142
4243 DWARFContext(DWARFContext &) LLVM_DELETED_FUNCTION;
5152 /// Read compile units from the debug_info.dwo section and store them in
5253 /// DWOCUs.
5354 void parseDWOCompileUnits();
55
56 /// Read type units from the debug_types.dwo section and store them in
57 /// DWOTUs.
58 void parseDWOTypeUnits();
5459
5560 public:
5661 struct Section {
8893 return DWOCUs.size();
8994 }
9095
96 /// Get the number of compile units in the DWO context.
97 unsigned getNumDWOTypeUnits() {
98 if (DWOTUs.empty())
99 parseDWOTypeUnits();
100 return DWOTUs.size();
101 }
102
91103 /// Get the compile unit at the specified index for this compile unit.
92104 DWARFCompileUnit *getCompileUnitAtIndex(unsigned index) {
93105 if (CUs.empty())
107119 if (DWOCUs.empty())
108120 parseDWOCompileUnits();
109121 return DWOCUs[index];
122 }
123
124 /// Get the type unit at the specified index for the DWO type units.
125 DWARFTypeUnit *getDWOTypeUnitAtIndex(unsigned index) {
126 if (DWOTUs.empty())
127 parseDWOTypeUnits();
128 return DWOTUs[index];
110129 }
111130
112131 /// Get a pointer to the parsed DebugAbbrev object.
155174
156175 // Sections for DWARF5 split dwarf proposal.
157176 virtual const Section &getInfoDWOSection() = 0;
177 virtual const TypeSectionMap &getTypesDWOSections() = 0;
158178 virtual StringRef getAbbrevDWOSection() = 0;
159179 virtual StringRef getStringDWOSection() = 0;
160180 virtual StringRef getStringOffsetDWOSection() = 0;
196216
197217 // Sections for DWARF5 split dwarf proposal.
198218 Section InfoDWOSection;
219 TypeSectionMap TypesDWOSections;
199220 StringRef AbbrevDWOSection;
200221 StringRef StringDWOSection;
201222 StringRef StringOffsetDWOSection;
225246
226247 // Sections for DWARF5 split dwarf proposal.
227248 virtual const Section &getInfoDWOSection() { return InfoDWOSection; }
249 virtual const TypeSectionMap &getTypesDWOSections() {
250 return TypesDWOSections;
251 }
228252 virtual StringRef getAbbrevDWOSection() { return AbbrevDWOSection; }
229253 virtual StringRef getStringDWOSection() { return StringDWOSection; }
230254 virtual StringRef getStringOffsetDWOSection() {
6262 clEnumValN(DIDT_Info, "info", ".debug_info"),
6363 clEnumValN(DIDT_InfoDwo, "info.dwo", ".debug_info.dwo"),
6464 clEnumValN(DIDT_Types, "types", ".debug_types"),
65 clEnumValN(DIDT_TypesDwo, "types.dwo", ".debug_types.dwo"),
6566 clEnumValN(DIDT_Line, "line", ".debug_line"),
6667 clEnumValN(DIDT_Loc, "loc", ".debug_loc"),
6768 clEnumValN(DIDT_Frames, "frames", ".debug_frame"),