llvm.org GIT mirror llvm / 8d74900
[DebugInfo] Pass DWARFSection down to DWARFUnit constructor (NFC). Keep the actual section contents and the relocation map together. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@219261 91177308-0d34-0410-b5e6-96231b3b80d8 Alexey Samsonov 5 years ago
4 changed file(s) with 25 addition(s) and 25 deletion(s). Raw diff Collapse all Expand all
1515
1616 class DWARFCompileUnit : public DWARFUnit {
1717 public:
18 DWARFCompileUnit(DWARFContext& Context, const DWARFDebugAbbrev *DA,
19 StringRef IS, StringRef RS, StringRef SS, StringRef SOS,
20 StringRef AOS, const RelocAddrMap *M, bool LE,
18 DWARFCompileUnit(DWARFContext &Context, const DWARFSection &Section,
19 const DWARFDebugAbbrev *DA, StringRef RS, StringRef SS,
20 StringRef SOS, StringRef AOS, bool LE,
2121 const DWARFUnitSectionBase &UnitSection)
22 : DWARFUnit(Context, DA, IS, RS, SS, SOS, AOS, M, LE, UnitSection) {}
22 : DWARFUnit(Context, Section, DA, RS, SS, SOS, AOS, LE, UnitSection) {}
2323 void dump(raw_ostream &OS);
2424 // VTable anchor.
2525 ~DWARFCompileUnit() override;
1818 uint64_t TypeHash;
1919 uint32_t TypeOffset;
2020 public:
21 DWARFTypeUnit(DWARFContext &Context, const DWARFDebugAbbrev *DA,
22 StringRef IS, StringRef RS, StringRef SS, StringRef SOS,
23 StringRef AOS, const RelocAddrMap *M, bool LE,
21 DWARFTypeUnit(DWARFContext &Context, const DWARFSection &Section,
22 const DWARFDebugAbbrev *DA, StringRef RS, StringRef SS,
23 StringRef SOS, StringRef AOS, bool LE,
2424 const DWARFUnitSectionBase &UnitSection)
25 : DWARFUnit(Context, DA, IS, RS, SS, SOS, AOS, M, LE, UnitSection) {}
25 : DWARFUnit(Context, Section, DA, RS, SS, SOS, AOS, LE, UnitSection) {}
2626 uint32_t getHeaderSize() const override {
2727 return DWARFUnit::getHeaderSize() + 12;
2828 }
2929 C.getAddrSection(), C.isLittleEndian());
3030 }
3131
32 DWARFUnit::DWARFUnit(DWARFContext &DC, const DWARFDebugAbbrev *DA,
33 StringRef IS, StringRef RS, StringRef SS, StringRef SOS,
34 StringRef AOS, const RelocAddrMap *M, bool LE,
35 const DWARFUnitSectionBase& UnitSection)
36 : Context(DC), Abbrev(DA), InfoSection(IS), RangeSection(RS),
37 StringSection(SS), StringOffsetSection(SOS), AddrOffsetSection(AOS),
38 RelocMap(M), isLittleEndian(LE), UnitSection(UnitSection) {
32 DWARFUnit::DWARFUnit(DWARFContext &DC, const DWARFSection &Section,
33 const DWARFDebugAbbrev *DA, StringRef RS, StringRef SS,
34 StringRef SOS, StringRef AOS, bool LE,
35 const DWARFUnitSectionBase &UnitSection)
36 : Context(DC), InfoSection(Section), Abbrev(DA), RangeSection(RS),
37 StringSection(SS), StringOffsetSection(SOS), AddrOffsetSection(AOS),
38 isLittleEndian(LE), UnitSection(UnitSection) {
3939 clear();
4040 }
4141
8787 DataExtractor Data(Section.Data, LE, 0);
8888 uint32_t Offset = 0;
8989 while (Data.isValidOffset(Offset)) {
90 auto U =
91 llvm::make_unique(Context, DA, Section.Data, RS, SS, SOS,
92 AOS, &Section.Relocs, LE, *this);
90 auto U = llvm::make_unique(Context, Section, DA, RS, SS, SOS,
91 AOS, LE, *this);
9392 if (!U->extract(Data, &Offset))
9493 break;
9594 this->push_back(std::move(U));
101100
102101 class DWARFUnit {
103102 DWARFContext &Context;
103 // Section containing this DWARFUnit.
104 const DWARFSection &InfoSection;
104105
105106 const DWARFDebugAbbrev *Abbrev;
106 StringRef InfoSection;
107107 StringRef RangeSection;
108108 uint32_t RangeSectionBase;
109109 StringRef StringSection;
110110 StringRef StringOffsetSection;
111111 StringRef AddrOffsetSection;
112112 uint32_t AddrOffsetSectionBase;
113 const RelocAddrMap *RelocMap;
114113 bool isLittleEndian;
115114 const DWARFUnitSectionBase &UnitSection;
116115
139138 virtual uint32_t getHeaderSize() const { return 11; }
140139
141140 public:
142 DWARFUnit(DWARFContext& Context, const DWARFDebugAbbrev *DA, StringRef IS,
143 StringRef RS, StringRef SS, StringRef SOS, StringRef AOS,
144 const RelocAddrMap *M, bool LE, const DWARFUnitSectionBase &UnitSection);
141 DWARFUnit(DWARFContext &Context, const DWARFSection &Section,
142 const DWARFDebugAbbrev *DA, StringRef RS, StringRef SS,
143 StringRef SOS, StringRef AOS, bool LE,
144 const DWARFUnitSectionBase &UnitSection);
145145
146146 virtual ~DWARFUnit();
147147
163163 bool getStringOffsetSectionItem(uint32_t Index, uint32_t &Result) const;
164164
165165 DataExtractor getDebugInfoExtractor() const {
166 return DataExtractor(InfoSection, isLittleEndian, AddrSize);
166 return DataExtractor(InfoSection.Data, isLittleEndian, AddrSize);
167167 }
168168 DataExtractor getStringExtractor() const {
169169 return DataExtractor(StringSection, false, 0);
170170 }
171171
172 const RelocAddrMap *getRelocMap() const { return RelocMap; }
172 const RelocAddrMap *getRelocMap() const { return &InfoSection.Relocs; }
173173
174174 bool extract(DataExtractor debug_info, uint32_t* offset_ptr);
175175