llvm.org GIT mirror llvm / 72df688
[C++11] Convert DWARF parser to range-based for loops git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@203766 91177308-0d34-0410-b5e6-96231b3b80d8 Alexey Samsonov 6 years ago
16 changed file(s) with 165 addition(s) and 167 deletion(s). Raw diff Collapse all Expand all
1717 Code = 0;
1818 Tag = 0;
1919 HasChildren = false;
20 Attributes.clear();
20 AttributeSpecs.clear();
2121 }
2222
2323 DWARFAbbreviationDeclaration::DWARFAbbreviationDeclaration() {
5050 }
5151 if (Attr == 0 && Form == 0)
5252 break;
53 Attributes.push_back(AttributeSpec(Attr, Form));
53 AttributeSpec AS = {Attr, Form};
54 AttributeSpecs.push_back(AS);
5455 }
5556
5657 if (Tag == 0) {
6869 else
6970 OS << format("DW_TAG_Unknown_%x", getTag());
7071 OS << "\tDW_CHILDREN_" << (hasChildren() ? "yes" : "no") << '\n';
71 for (unsigned i = 0, e = Attributes.size(); i != e; ++i) {
72 for (const AttributeSpec &Spec : AttributeSpecs) {
7273 OS << '\t';
73 const char *attrString = AttributeString(Attributes[i].Attr);
74 const char *attrString = AttributeString(Spec.Attr);
7475 if (attrString)
7576 OS << attrString;
7677 else
77 OS << format("DW_AT_Unknown_%x", Attributes[i].Attr);
78 OS << format("DW_AT_Unknown_%x", Spec.Attr);
7879 OS << '\t';
79 const char *formString = FormEncodingString(Attributes[i].Form);
80 const char *formString = FormEncodingString(Spec.Form);
8081 if (formString)
8182 OS << formString;
8283 else
83 OS << format("DW_FORM_Unknown_%x", Attributes[i].Form);
84 OS << format("DW_FORM_Unknown_%x", Spec.Form);
8485 OS << '\n';
8586 }
8687 OS << '\n';
8889
8990 uint32_t
9091 DWARFAbbreviationDeclaration::findAttributeIndex(uint16_t attr) const {
91 for (uint32_t i = 0, e = Attributes.size(); i != e; ++i) {
92 if (Attributes[i].Attr == attr)
92 for (uint32_t i = 0, e = AttributeSpecs.size(); i != e; ++i) {
93 if (AttributeSpecs[i].Attr == attr)
9394 return i;
9495 }
9596 return -1U;
2222 bool HasChildren;
2323
2424 struct AttributeSpec {
25 AttributeSpec(uint16_t Attr, uint16_t Form) : Attr(Attr), Form(Form) {}
2625 uint16_t Attr;
2726 uint16_t Form;
2827 };
29 SmallVector Attributes;
28 typedef SmallVector AttributeSpecVector;
29 AttributeSpecVector AttributeSpecs;
3030 public:
3131 DWARFAbbreviationDeclaration();
3232
3333 uint32_t getCode() const { return Code; }
3434 uint32_t getTag() const { return Tag; }
3535 bool hasChildren() const { return HasChildren; }
36 uint32_t getNumAttributes() const { return Attributes.size(); }
37 uint16_t getAttrByIndex(uint32_t idx) const {
38 return idx < Attributes.size() ? Attributes[idx].Attr : 0;
36
37 typedef iterator_range
38 attr_iterator_range;
39
40 attr_iterator_range attributes() const {
41 return attr_iterator_range(AttributeSpecs.begin(), AttributeSpecs.end());
3942 }
43
4044 uint16_t getFormByIndex(uint32_t idx) const {
41 return idx < Attributes.size() ? Attributes[idx].Form : 0;
45 return idx < AttributeSpecs.size() ? AttributeSpecs[idx].Form : 0;
4246 }
4347
4448 uint32_t findAttributeIndex(uint16_t attr) const;
7474
7575 if (DumpType == DIDT_All || DumpType == DIDT_Info) {
7676 OS << "\n.debug_info contents:\n";
77 for (unsigned i = 0, e = getNumCompileUnits(); i != e; ++i)
78 getCompileUnitAtIndex(i)->dump(OS);
77 for (const auto &CU : compile_units())
78 CU->dump(OS);
7979 }
8080
8181 if ((DumpType == DIDT_All || DumpType == DIDT_InfoDwo) &&
8282 getNumDWOCompileUnits()) {
8383 OS << "\n.debug_info.dwo contents:\n";
84 for (unsigned i = 0, e = getNumDWOCompileUnits(); i != e; ++i)
85 getDWOCompileUnitAtIndex(i)->dump(OS);
84 for (const auto &DWOCU : dwo_compile_units())
85 DWOCU->dump(OS);
8686 }
8787
8888 if ((DumpType == DIDT_All || DumpType == DIDT_Types) && getNumTypeUnits()) {
8989 OS << "\n.debug_types contents:\n";
90 for (unsigned i = 0, e = getNumTypeUnits(); i != e; ++i)
91 getTypeUnitAtIndex(i)->dump(OS);
92 }
93
94 if (DumpType == DIDT_All || DumpType == DIDT_TypesDwo)
95 if (getNumDWOTypeUnits()) {
96 OS << "\n.debug_types.dwo contents:\n";
97 for (unsigned i = 0, e = getNumDWOTypeUnits(); i != e; ++i)
98 getDWOTypeUnitAtIndex(i)->dump(OS);
99 }
90 for (const auto &TU : type_units())
91 TU->dump(OS);
92 }
93
94 if ((DumpType == DIDT_All || DumpType == DIDT_TypesDwo) &&
95 getNumDWOTypeUnits()) {
96 OS << "\n.debug_types.dwo contents:\n";
97 for (const auto &DWOTU : dwo_type_units())
98 DWOTU->dump(OS);
99 }
100100
101101 if (DumpType == DIDT_All || DumpType == DIDT_Loc) {
102102 OS << "\n.debug_loc contents:\n";
120120 uint8_t savedAddressByteSize = 0;
121121 if (DumpType == DIDT_All || DumpType == DIDT_Line) {
122122 OS << "\n.debug_line contents:\n";
123 for (unsigned i = 0, e = getNumCompileUnits(); i != e; ++i) {
124 DWARFCompileUnit *cu = getCompileUnitAtIndex(i);
125 savedAddressByteSize = cu->getAddressByteSize();
123 for (const auto &CU : compile_units()) {
124 savedAddressByteSize = CU->getAddressByteSize();
126125 unsigned stmtOffset =
127 cu->getCompileUnitDIE()->getAttributeValueAsSectionOffset(
128 cu, DW_AT_stmt_list, -1U);
126 CU->getCompileUnitDIE()->getAttributeValueAsSectionOffset(
127 CU, DW_AT_stmt_list, -1U);
129128 if (stmtOffset != -1U) {
130129 DataExtractor lineData(getLineSection().Data, isLittleEndian(),
131130 savedAddressByteSize);
296295 }
297296
298297 void DWARFContext::parseCompileUnits() {
298 if (!CUs.empty())
299 return;
299300 uint32_t offset = 0;
300301 const DataExtractor &DIData = DataExtractor(getInfoSection().Data,
301302 isLittleEndian(), 0);
313314 }
314315
315316 void DWARFContext::parseTypeUnits() {
316 const TypeSectionMap &Sections = getTypesSections();
317 for (TypeSectionMap::const_iterator I = Sections.begin(), E = Sections.end();
318 I != E; ++I) {
317 if (!TUs.empty())
318 return;
319 for (const auto &I : getTypesSections()) {
319320 uint32_t offset = 0;
320321 const DataExtractor &DIData =
321 DataExtractor(I->second.Data, isLittleEndian(), 0);
322 DataExtractor(I.second.Data, isLittleEndian(), 0);
322323 while (DIData.isValidOffset(offset)) {
323324 std::unique_ptr TU(new DWARFTypeUnit(
324 getDebugAbbrev(), I->second.Data, getAbbrevSection(),
325 getDebugAbbrev(), I.second.Data, getAbbrevSection(),
325326 getRangeSection(), getStringSection(), StringRef(), getAddrSection(),
326 &I->second.Relocs, isLittleEndian()));
327 &I.second.Relocs, isLittleEndian()));
327328 if (!TU->extract(DIData, &offset))
328329 break;
329330 TUs.push_back(TU.release());
333334 }
334335
335336 void DWARFContext::parseDWOCompileUnits() {
337 if (!DWOCUs.empty())
338 return;
336339 uint32_t offset = 0;
337340 const DataExtractor &DIData =
338341 DataExtractor(getInfoDWOSection().Data, isLittleEndian(), 0);
351354 }
352355
353356 void DWARFContext::parseDWOTypeUnits() {
354 const TypeSectionMap &Sections = getTypesDWOSections();
355 for (TypeSectionMap::const_iterator I = Sections.begin(), E = Sections.end();
356 I != E; ++I) {
357 if (!DWOTUs.empty())
358 return;
359 for (const auto &I : getTypesDWOSections()) {
357360 uint32_t offset = 0;
358361 const DataExtractor &DIData =
359 DataExtractor(I->second.Data, isLittleEndian(), 0);
362 DataExtractor(I.second.Data, isLittleEndian(), 0);
360363 while (DIData.isValidOffset(offset)) {
361364 std::unique_ptr TU(new DWARFTypeUnit(
362 getDebugAbbrevDWO(), I->second.Data, getAbbrevDWOSection(),
365 getDebugAbbrevDWO(), I.second.Data, getAbbrevDWOSection(),
363366 getRangeDWOSection(), getStringDWOSection(),
364 getStringOffsetDWOSection(), getAddrSection(), &I->second.Relocs,
367 getStringOffsetDWOSection(), getAddrSection(), &I.second.Relocs,
365368 isLittleEndian()));
366369 if (!TU->extract(DIData, &offset))
367370 break;
387390 }
388391
389392 DWARFCompileUnit *DWARFContext::getCompileUnitForOffset(uint32_t Offset) {
390 if (CUs.empty())
391 parseCompileUnits();
393 parseCompileUnits();
392394
393395 DWARFCompileUnit **CU =
394396 std::lower_bound(CUs.begin(), CUs.end(), Offset, OffsetComparator());
521523 if (!LineTable->lookupAddressRange(Address, Size, RowVector))
522524 return Lines;
523525
524 uint32_t NumRows = RowVector.size();
525 for (uint32_t i = 0; i < NumRows; ++i) {
526 uint32_t RowIndex = RowVector[i];
526 for (uint32_t RowIndex : RowVector) {
527527 // Take file number and line/column from the row.
528528 const DWARFDebugLine::Row &Row = LineTable->Rows[RowIndex];
529529 std::string FileName = "";
2727 /// information parsing. The actual data is supplied through pure virtual
2828 /// methods that a concrete implementation provides.
2929 class DWARFContext : public DIContext {
30 SmallVector CUs;
31 SmallVector TUs;
30 typedef SmallVector CUVector;
31 typedef SmallVector TUVector;
32
33 CUVector CUs;
34 TUVector TUs;
3235 std::unique_ptr Abbrev;
3336 std::unique_ptr Loc;
3437 std::unique_ptr Aranges;
3538 std::unique_ptr Line;
3639 std::unique_ptr DebugFrame;
3740
38 SmallVector DWOCUs;
39 SmallVector DWOTUs;
41 CUVector DWOCUs;
42 TUVector DWOTUs;
4043 std::unique_ptr AbbrevDWO;
4144
4245 DWARFContext(DWARFContext &) LLVM_DELETED_FUNCTION;
4346 DWARFContext &operator=(DWARFContext &) LLVM_DELETED_FUNCTION;
4447
45 /// Read compile units from the debug_info section and store them in CUs.
48 /// Read compile units from the debug_info section (if necessary)
49 /// and store them in CUs.
4650 void parseCompileUnits();
4751
48 /// Read type units from the debug_types sections and store them in CUs.
52 /// Read type units from the debug_types sections (if necessary)
53 /// and store them in TUs.
4954 void parseTypeUnits();
5055
51 /// Read compile units from the debug_info.dwo section and store them in
52 /// DWOCUs.
56 /// Read compile units from the debug_info.dwo section (if necessary)
57 /// and store them in DWOCUs.
5358 void parseDWOCompileUnits();
5459
55 /// Read type units from the debug_types.dwo section and store them in
56 /// DWOTUs.
60 /// Read type units from the debug_types.dwo section (if necessary)
61 /// and store them in DWOTUs.
5762 void parseDWOTypeUnits();
5863
5964 public:
7176
7277 void dump(raw_ostream &OS, DIDumpType DumpType = DIDT_All) override;
7378
79 typedef iterator_range cu_iterator_range;
80 typedef iterator_range tu_iterator_range;
81
82 /// Get compile units in this context.
83 cu_iterator_range compile_units() {
84 parseCompileUnits();
85 return cu_iterator_range(CUs.begin(), CUs.end());
86 }
87
88 /// Get type units in this context.
89 tu_iterator_range type_units() {
90 parseTypeUnits();
91 return tu_iterator_range(TUs.begin(), TUs.end());
92 }
93
94 /// Get compile units in the DWO context.
95 cu_iterator_range dwo_compile_units() {
96 parseDWOCompileUnits();
97 return cu_iterator_range(DWOCUs.begin(), DWOCUs.end());
98 }
99
100 /// Get type units in the DWO context.
101 tu_iterator_range dwo_type_units() {
102 parseDWOTypeUnits();
103 return tu_iterator_range(DWOTUs.begin(), DWOTUs.end());
104 }
105
74106 /// Get the number of compile units in this context.
75107 unsigned getNumCompileUnits() {
76 if (CUs.empty())
77 parseCompileUnits();
108 parseCompileUnits();
78109 return CUs.size();
79110 }
80111
81112 /// Get the number of compile units in this context.
82113 unsigned getNumTypeUnits() {
83 if (TUs.empty())
84 parseTypeUnits();
114 parseTypeUnits();
85115 return TUs.size();
86116 }
87117
88118 /// Get the number of compile units in the DWO context.
89119 unsigned getNumDWOCompileUnits() {
90 if (DWOCUs.empty())
91 parseDWOCompileUnits();
120 parseDWOCompileUnits();
92121 return DWOCUs.size();
93122 }
94123
95124 /// Get the number of compile units in the DWO context.
96125 unsigned getNumDWOTypeUnits() {
97 if (DWOTUs.empty())
98 parseDWOTypeUnits();
126 parseDWOTypeUnits();
99127 return DWOTUs.size();
100128 }
101129
102130 /// Get the compile unit at the specified index for this compile unit.
103131 DWARFCompileUnit *getCompileUnitAtIndex(unsigned index) {
104 if (CUs.empty())
105 parseCompileUnits();
132 parseCompileUnits();
106133 return CUs[index];
107 }
108
109 /// Get the type unit at the specified index for this compile unit.
110 DWARFTypeUnit *getTypeUnitAtIndex(unsigned index) {
111 if (TUs.empty())
112 parseTypeUnits();
113 return TUs[index];
114134 }
115135
116136 /// Get the compile unit at the specified index for the DWO compile units.
117137 DWARFCompileUnit *getDWOCompileUnitAtIndex(unsigned index) {
118 if (DWOCUs.empty())
119 parseDWOCompileUnits();
138 parseDWOCompileUnits();
120139 return DWOCUs[index];
121 }
122
123 /// Get the type unit at the specified index for the DWO type units.
124 DWARFTypeUnit *getDWOTypeUnitAtIndex(unsigned index) {
125 if (DWOTUs.empty())
126 parseDWOTypeUnits();
127 return DWOTUs[index];
128140 }
129141
130142 /// Get a pointer to the parsed DebugAbbrev object.
3232 }
3333
3434 void DWARFAbbreviationDeclarationSet::dump(raw_ostream &OS) const {
35 for (unsigned i = 0, e = Decls.size(); i != e; ++i)
36 Decls[i].dump(OS);
35 for (const auto &Decl : Decls)
36 Decl.dump(OS);
3737 }
3838
3939 const DWARFAbbreviationDeclaration*
4040 DWARFAbbreviationDeclarationSet::getAbbreviationDeclaration(uint32_t abbrCode)
4141 const {
4242 if (IdxOffset == UINT32_MAX) {
43 DWARFAbbreviationDeclarationCollConstIter pos;
44 DWARFAbbreviationDeclarationCollConstIter end = Decls.end();
45 for (pos = Decls.begin(); pos != end; ++pos) {
46 if (pos->getCode() == abbrCode)
47 return &(*pos);
43 for (const auto &Decl : Decls) {
44 if (Decl.getCode() == abbrCode)
45 return &Decl;
4846 }
4947 } else {
5048 uint32_t idx = abbrCode - IdxOffset;
8078 return;
8179 }
8280
83 DWARFAbbreviationDeclarationCollMapConstIter pos;
84 for (pos = AbbrevCollMap.begin(); pos != AbbrevCollMap.end(); ++pos) {
85 OS << format("Abbrev table for offset: 0x%8.8" PRIx64 "\n", pos->first);
86 pos->second.dump(OS);
81 for (const auto &I : AbbrevCollMap) {
82 OS << format("Abbrev table for offset: 0x%8.8" PRIx64 "\n", I.first);
83 I.second.dump(OS);
8784 }
8885 }
8986
9393 HeaderData.CuOffset, HeaderData.AddrSize, HeaderData.SegSize);
9494
9595 const uint32_t hex_width = HeaderData.AddrSize * 2;
96 for (DescriptorConstIter pos = ArangeDescriptors.begin(),
97 end = ArangeDescriptors.end(); pos != end; ++pos)
98 OS << format("[0x%*.*" PRIx64 " -", hex_width, hex_width, pos->Address)
96 for (const auto &Desc : ArangeDescriptors) {
97 OS << format("[0x%*.*" PRIx64 " -", hex_width, hex_width, Desc.Address)
9998 << format(" 0x%*.*" PRIx64 ")\n",
100 hex_width, hex_width, pos->getEndAddress());
99 hex_width, hex_width, Desc.getEndAddress());
100 }
101101 }
99 #ifndef LLVM_DEBUGINFO_DWARFDEBUGARANGESET_H
1010 #define LLVM_DEBUGINFO_DWARFDEBUGARANGESET_H
1111
12 #include "llvm/ADT/iterator_range.h"
1213 #include "llvm/Support/DataExtractor.h"
1314 #include
1415
4344
4445 private:
4546 typedef std::vector DescriptorColl;
46 typedef DescriptorColl::const_iterator DescriptorConstIter;
47 typedef iterator_range desc_iterator_range;
4748
4849 uint32_t Offset;
4950 Header HeaderData;
5657 void dump(raw_ostream &OS) const;
5758
5859 uint32_t getCompileUnitDIEOffset() const { return HeaderData.CuOffset; }
60
61 desc_iterator_range descriptors() const {
62 return desc_iterator_range(ArangeDescriptors.begin(),
63 ArangeDescriptors.end());
64 }
5965 uint32_t getNumDescriptors() const { return ArangeDescriptors.size(); }
60 const Descriptor *getDescriptor(uint32_t i) const {
61 if (i < ArangeDescriptors.size())
62 return &ArangeDescriptors[i];
63 return NULL;
64 }
6566 };
6667
6768 }
3232 return;
3333
3434 Aranges.reserve(TotalRanges);
35 for (RangeSetColl::const_iterator I = Sets.begin(), E = Sets.end(); I != E;
36 ++I) {
37 uint32_t CUOffset = I->getCompileUnitDIEOffset();
35 for (const auto &I : Sets) {
36 uint32_t CUOffset = I.getCompileUnitDIEOffset();
3837
39 for (uint32_t i = 0, n = I->getNumDescriptors(); i < n; ++i) {
40 const DWARFDebugArangeSet::Descriptor *ArangeDescPtr =
41 I->getDescriptor(i);
42 uint64_t LowPC = ArangeDescPtr->Address;
43 uint64_t HighPC = LowPC + ArangeDescPtr->Length;
38 for (const auto &Desc : I.descriptors()) {
39 uint64_t LowPC = Desc.Address;
40 uint64_t HighPC = Desc.getEndAddress();
4441 appendRange(CUOffset, LowPC, HighPC);
4542 }
4643 }
5855 // Generate aranges from DIEs: even if .debug_aranges section is present,
5956 // it may describe only a small subset of compilation units, so we need to
6057 // manually build aranges for the rest of them.
61 for (uint32_t i = 0, n = CTX->getNumCompileUnits(); i < n; ++i) {
62 if (DWARFCompileUnit *CU = CTX->getCompileUnitAtIndex(i)) {
63 uint32_t CUOffset = CU->getOffset();
64 if (ParsedCUOffsets.insert(CUOffset).second)
65 CU->buildAddressRangeTable(this, true, CUOffset);
66 }
58 for (const auto &CU : CTX->compile_units()) {
59 uint32_t CUOffset = CU->getOffset();
60 if (ParsedCUOffsets.insert(CUOffset).second)
61 CU->buildAddressRangeTable(this, true, CUOffset);
6762 }
6863
6964 sortAndMinimize();
185185 void FrameEntry::dumpInstructions(raw_ostream &OS) const {
186186 // TODO: at the moment only instruction names are dumped. Expand this to
187187 // dump operands as well.
188 for (std::vector::const_iterator I = Instructions.begin(),
189 E = Instructions.end();
190 I != E; ++I) {
191 uint8_t Opcode = I->Opcode;
188 for (const auto &Instr : Instructions) {
189 uint8_t Opcode = Instr.Opcode;
192190 if (Opcode & DWARF_CFI_PRIMARY_OPCODE_MASK)
193191 Opcode &= DWARF_CFI_PRIMARY_OPCODE_MASK;
194192 OS << " " << CallFrameString(Opcode) << ":\n";
288286
289287
290288 DWARFDebugFrame::~DWARFDebugFrame() {
291 for (EntryVector::iterator I = Entries.begin(), E = Entries.end();
292 I != E; ++I) {
293 delete *I;
289 for (const auto &Entry : Entries) {
290 delete Entry;
294291 }
295292 }
296293
380377
381378 void DWARFDebugFrame::dump(raw_ostream &OS) const {
382379 OS << "\n";
383 for (EntryVector::const_iterator I = Entries.begin(), E = Entries.end();
384 I != E; ++I) {
385 FrameEntry *Entry = *I;
380 for (const auto &Entry : Entries) {
386381 Entry->dumpHeader(OS);
387382 Entry->dumpInstructions(OS);
388383 OS << "\n";
4141
4242 } // namespace llvm
4343
44 #endif
45
44 #endif
3939 AbbrevDecl->hasChildren() ? '*' : ' ');
4040
4141 // Dump all data in the DIE for the attributes.
42 const uint32_t numAttributes = AbbrevDecl->getNumAttributes();
43 for (uint32_t i = 0; i != numAttributes; ++i) {
44 uint16_t attr = AbbrevDecl->getAttrByIndex(i);
45 uint16_t form = AbbrevDecl->getFormByIndex(i);
46 dumpAttribute(OS, u, &offset, attr, form, indent);
42 for (const auto &AttrSpec : AbbrevDecl->attributes()) {
43 dumpAttribute(OS, u, &offset, AttrSpec.Attr, AttrSpec.Form, indent);
4744 }
4845
4946 const DWARFDebugInfoEntryMinimal *child = getFirstChild();
115112 assert(FixedFormSizes.size() > 0);
116113
117114 // Skip all data in the .debug_info for the attributes
118 for (uint32_t i = 0, n = AbbrevDecl->getNumAttributes(); i < n; ++i) {
119 uint16_t Form = AbbrevDecl->getFormByIndex(i);
115 for (const auto &AttrSpec : AbbrevDecl->attributes()) {
116 uint16_t Form = AttrSpec.Form;
120117
121118 uint8_t FixedFormSize =
122119 (Form < FixedFormSizes.size()) ? FixedFormSizes[Form] : 0;
5959 bool isSubroutineDIE() const;
6060
6161 uint32_t getOffset() const { return Offset; }
62 uint32_t getNumAttributes() const {
63 return !isNULL() ? AbbrevDecl->getNumAttributes() : 0;
64 }
6562 bool hasChildren() const { return !isNULL() && AbbrevDecl->hasChildren(); }
6663
6764 // We know we are kept in a vector of contiguous entries, so we know
8989 OS << "Address Line Column File ISA Discriminator Flags\n"
9090 << "------------------ ------ ------ ------ --- ------------- "
9191 "-------------\n";
92 for (std::vector::const_iterator pos = Rows.begin(),
93 end = Rows.end(); pos != end; ++pos)
94 pos->dump(OS);
92 for (const Row &R : Rows) {
93 R.dump(OS);
94 }
9595 }
9696 }
9797
1414 using namespace llvm;
1515
1616 void DWARFDebugLoc::dump(raw_ostream &OS) const {
17 for (LocationLists::const_iterator I = Locations.begin(), E = Locations.end(); I != E; ++I) {
18 OS << format("0x%8.8x: ", I->Offset);
17 for (const LocationList &L : Locations) {
18 OS << format("0x%8.8x: ", L.Offset);
1919 const unsigned Indent = 12;
20 for (SmallVectorImpl::const_iterator I2 = I->Entries.begin(), E2 = I->Entries.end(); I2 != E2; ++I2) {
21 if (I2 != I->Entries.begin())
20 for (const Entry &E : L.Entries) {
21 if (&E != L.Entries.begin())
2222 OS.indent(Indent);
23 OS << "Beginning address offset: " << format("0x%016" PRIx64, I2->Begin)
23 OS << "Beginning address offset: " << format("0x%016" PRIx64, E.Begin)
2424 << '\n';
2525 OS.indent(Indent) << " Ending address offset: "
26 << format("0x%016" PRIx64, I2->End) << '\n';
26 << format("0x%016" PRIx64, E.End) << '\n';
2727 OS.indent(Indent) << " Location description: ";
28 for (SmallVectorImpl::const_iterator I3 = I2->Loc.begin(), E3 = I2->Loc.end(); I3 != E3; ++I3) {
29 OS << format("%2.2x ", *I3);
28 for (unsigned char Loc : E.Loc) {
29 OS << format("%2.2x ", Loc);
3030 }
3131 OS << "\n\n";
3232 }
4444 }
4545
4646 void DWARFDebugRangeList::dump(raw_ostream &OS) const {
47 for (int i = 0, n = Entries.size(); i != n; ++i) {
47 for (const RangeListEntry &RLE : Entries) {
4848 const char *format_str = (AddressSize == 4
4949 ? "%08x %08" PRIx64 " %08" PRIx64 "\n"
5050 : "%08x %016" PRIx64 " %016" PRIx64 "\n");
51 OS << format(format_str, Offset, Entries[i].StartAddress,
52 Entries[i].EndAddress);
51 OS << format(format_str, Offset, RLE.StartAddress, RLE.EndAddress);
5352 }
5453 OS << format("%08x \n", Offset);
5554 }
5655
5756 bool DWARFDebugRangeList::containsAddress(uint64_t BaseAddress,
5857 uint64_t Address) const {
59 for (int i = 0, n = Entries.size(); i != n; ++i) {
60 if (Entries[i].isBaseAddressSelectionEntry(AddressSize))
61 BaseAddress = Entries[i].EndAddress;
62 else if (Entries[i].containsAddress(BaseAddress, Address))
58 for (const RangeListEntry &RLE : Entries) {
59 if (RLE.isBaseAddressSelectionEntry(AddressSize))
60 BaseAddress = RLE.EndAddress;
61 else if (RLE.containsAddress(BaseAddress, Address))
6362 return true;
6463 }
6564 return false;
330330 const DWARFDebugInfoEntryMinimal *
331331 DWARFUnit::getSubprogramForAddress(uint64_t Address) {
332332 extractDIEsIfNeeded(false);
333 for (size_t i = 0, n = DieArray.size(); i != n; i++)
334 if (DieArray[i].isSubprogramDIE() &&
335 DieArray[i].addressRangeContainsAddress(this, Address)) {
336 return &DieArray[i];
337 }
333 for (const DWARFDebugInfoEntryMinimal &DIE : DieArray) {
334 if (DIE.isSubprogramDIE() &&
335 DIE.addressRangeContainsAddress(this, Address)) {
336 return &DIE;
337 }
338 }
338339 return 0;
339340 }
340341