[DWARF parser] DWARFUnit ctor doesn't need both parsed and raw .debug_abbrev section. Remove the former.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207153 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Alexey Samsonov 2014-04-24 22:51:03 +00:00
parent f93114e7ed
commit a189d1ad57
5 changed files with 34 additions and 36 deletions

View File

@ -16,10 +16,10 @@ namespace llvm {
class DWARFCompileUnit : public DWARFUnit {
public:
DWARFCompileUnit(const DWARFDebugAbbrev *DA, StringRef IS, StringRef AS,
StringRef RS, StringRef SS, StringRef SOS, StringRef AOS,
DWARFCompileUnit(const DWARFDebugAbbrev *DA, StringRef IS, StringRef RS,
StringRef SS, StringRef SOS, StringRef AOS,
const RelocAddrMap *M, bool LE)
: DWARFUnit(DA, IS, AS, RS, SS, SOS, AOS, M, LE) {}
: DWARFUnit(DA, IS, RS, SS, SOS, AOS, M, LE) {}
void dump(raw_ostream &OS);
// VTable anchor.
~DWARFCompileUnit() override;

View File

@ -312,8 +312,8 @@ void DWARFContext::parseCompileUnits() {
isLittleEndian(), 0);
while (DIData.isValidOffset(offset)) {
std::unique_ptr<DWARFCompileUnit> CU(new DWARFCompileUnit(
getDebugAbbrev(), getInfoSection().Data, getAbbrevSection(),
getRangeSection(), getStringSection(), StringRef(), getAddrSection(),
getDebugAbbrev(), getInfoSection().Data, getRangeSection(),
getStringSection(), StringRef(), getAddrSection(),
&getInfoSection().Relocs, isLittleEndian()));
if (!CU->extract(DIData, &offset)) {
break;
@ -331,10 +331,10 @@ void DWARFContext::parseTypeUnits() {
const DataExtractor &DIData =
DataExtractor(I.second.Data, isLittleEndian(), 0);
while (DIData.isValidOffset(offset)) {
std::unique_ptr<DWARFTypeUnit> TU(new DWARFTypeUnit(
getDebugAbbrev(), I.second.Data, getAbbrevSection(),
getRangeSection(), getStringSection(), StringRef(), getAddrSection(),
&I.second.Relocs, isLittleEndian()));
std::unique_ptr<DWARFTypeUnit> TU(
new DWARFTypeUnit(getDebugAbbrev(), I.second.Data, getRangeSection(),
getStringSection(), StringRef(), getAddrSection(),
&I.second.Relocs, isLittleEndian()));
if (!TU->extract(DIData, &offset))
break;
TUs.push_back(std::move(TU));
@ -351,9 +351,8 @@ void DWARFContext::parseDWOCompileUnits() {
DataExtractor(getInfoDWOSection().Data, isLittleEndian(), 0);
while (DIData.isValidOffset(offset)) {
std::unique_ptr<DWARFCompileUnit> DWOCU(new DWARFCompileUnit(
getDebugAbbrevDWO(), getInfoDWOSection().Data, getAbbrevDWOSection(),
getRangeDWOSection(), getStringDWOSection(),
getStringOffsetDWOSection(), getAddrSection(),
getDebugAbbrevDWO(), getInfoDWOSection().Data, getRangeDWOSection(),
getStringDWOSection(), getStringOffsetDWOSection(), getAddrSection(),
&getInfoDWOSection().Relocs, isLittleEndian()));
if (!DWOCU->extract(DIData, &offset)) {
break;
@ -372,10 +371,9 @@ void DWARFContext::parseDWOTypeUnits() {
DataExtractor(I.second.Data, isLittleEndian(), 0);
while (DIData.isValidOffset(offset)) {
std::unique_ptr<DWARFTypeUnit> TU(new DWARFTypeUnit(
getDebugAbbrevDWO(), I.second.Data, getAbbrevDWOSection(),
getRangeDWOSection(), getStringDWOSection(),
getStringOffsetDWOSection(), getAddrSection(), &I.second.Relocs,
isLittleEndian()));
getDebugAbbrevDWO(), I.second.Data, getRangeDWOSection(),
getStringDWOSection(), getStringOffsetDWOSection(), getAddrSection(),
&I.second.Relocs, isLittleEndian()));
if (!TU->extract(DIData, &offset))
break;
DWOTUs.push_back(std::move(TU));

View File

@ -19,10 +19,10 @@ private:
uint64_t TypeHash;
uint32_t TypeOffset;
public:
DWARFTypeUnit(const DWARFDebugAbbrev *DA, StringRef IS, StringRef AS,
StringRef RS, StringRef SS, StringRef SOS, StringRef AOS,
DWARFTypeUnit(const DWARFDebugAbbrev *DA, StringRef IS, StringRef RS,
StringRef SS, StringRef SOS, StringRef AOS,
const RelocAddrMap *M, bool LE)
: DWARFUnit(DA, IS, AS, RS, SS, SOS, AOS, M, LE) {}
: DWARFUnit(DA, IS, RS, SS, SOS, AOS, M, LE) {}
uint32_t getSize() const override { return DWARFUnit::getSize() + 12; }
void dump(raw_ostream &OS);
protected:

View File

@ -17,12 +17,12 @@
using namespace llvm;
using namespace dwarf;
DWARFUnit::DWARFUnit(const DWARFDebugAbbrev *DA, StringRef IS, StringRef AS,
StringRef RS, StringRef SS, StringRef SOS, StringRef AOS,
DWARFUnit::DWARFUnit(const DWARFDebugAbbrev *DA, StringRef IS, StringRef RS,
StringRef SS, StringRef SOS, StringRef AOS,
const RelocAddrMap *M, bool LE)
: Abbrev(DA), InfoSection(IS), AbbrevSection(AS), RangeSection(RS),
StringSection(SS), StringOffsetSection(SOS), AddrOffsetSection(AOS),
RelocMap(M), isLittleEndian(LE) {
: Abbrev(DA), InfoSection(IS), RangeSection(RS), StringSection(SS),
StringOffsetSection(SOS), AddrOffsetSection(AOS), RelocMap(M),
isLittleEndian(LE) {
clear();
}
@ -54,18 +54,20 @@ bool DWARFUnit::getStringOffsetSectionItem(uint32_t Index,
bool DWARFUnit::extractImpl(DataExtractor debug_info, uint32_t *offset_ptr) {
Length = debug_info.getU32(offset_ptr);
Version = debug_info.getU16(offset_ptr);
uint64_t abbrOffset = debug_info.getU32(offset_ptr);
uint64_t AbbrOffset = debug_info.getU32(offset_ptr);
AddrSize = debug_info.getU8(offset_ptr);
bool lengthOK = debug_info.isValidOffset(getNextUnitOffset() - 1);
bool versionOK = DWARFContext::isSupportedVersion(Version);
bool abbrOffsetOK = AbbrevSection.size() > abbrOffset;
bool addrSizeOK = AddrSize == 4 || AddrSize == 8;
bool LengthOK = debug_info.isValidOffset(getNextUnitOffset() - 1);
bool VersionOK = DWARFContext::isSupportedVersion(Version);
bool AddrSizeOK = AddrSize == 4 || AddrSize == 8;
if (!lengthOK || !versionOK || !addrSizeOK || !abbrOffsetOK)
if (!LengthOK || !VersionOK || !AddrSizeOK)
return false;
Abbrevs = Abbrev->getAbbreviationDeclarationSet(AbbrOffset);
if (Abbrevs == nullptr)
return false;
Abbrevs = Abbrev->getAbbreviationDeclarationSet(abbrOffset);
return true;
}

View File

@ -29,7 +29,6 @@ class raw_ostream;
class DWARFUnit {
const DWARFDebugAbbrev *Abbrev;
StringRef InfoSection;
StringRef AbbrevSection;
StringRef RangeSection;
uint32_t RangeSectionBase;
StringRef StringSection;
@ -62,10 +61,9 @@ protected:
virtual bool extractImpl(DataExtractor debug_info, uint32_t *offset_ptr);
public:
DWARFUnit(const DWARFDebugAbbrev *DA, StringRef IS, StringRef AS,
StringRef RS, StringRef SS, StringRef SOS, StringRef AOS,
const RelocAddrMap *M, bool LE);
DWARFUnit(const DWARFDebugAbbrev *DA, StringRef IS, StringRef RS,
StringRef SS, StringRef SOS, StringRef AOS, const RelocAddrMap *M,
bool LE);
virtual ~DWARFUnit();