summaryrefslogtreecommitdiff
path: root/lib/DebugInfo
diff options
context:
space:
mode:
authorAlexey Samsonov <samsonov@google.com>2014-04-24 22:51:03 +0000
committerAlexey Samsonov <samsonov@google.com>2014-04-24 22:51:03 +0000
commita189d1ad57e712ff20167269b9014241ed2d84be (patch)
tree008dc22b743e19cd368f6bba616fd9555694455d /lib/DebugInfo
parentf93114e7ed44ea52754f03d52663ce5c335b40eb (diff)
downloadllvm-a189d1ad57e712ff20167269b9014241ed2d84be.tar.gz
llvm-a189d1ad57e712ff20167269b9014241ed2d84be.tar.bz2
llvm-a189d1ad57e712ff20167269b9014241ed2d84be.tar.xz
[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
Diffstat (limited to 'lib/DebugInfo')
-rw-r--r--lib/DebugInfo/DWARFCompileUnit.h6
-rw-r--r--lib/DebugInfo/DWARFContext.cpp24
-rw-r--r--lib/DebugInfo/DWARFTypeUnit.h6
-rw-r--r--lib/DebugInfo/DWARFUnit.cpp26
-rw-r--r--lib/DebugInfo/DWARFUnit.h8
5 files changed, 34 insertions, 36 deletions
diff --git a/lib/DebugInfo/DWARFCompileUnit.h b/lib/DebugInfo/DWARFCompileUnit.h
index d1853d80a3..2ed188e70c 100644
--- a/lib/DebugInfo/DWARFCompileUnit.h
+++ b/lib/DebugInfo/DWARFCompileUnit.h
@@ -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;
diff --git a/lib/DebugInfo/DWARFContext.cpp b/lib/DebugInfo/DWARFContext.cpp
index 863c7568d5..76d6106ba5 100644
--- a/lib/DebugInfo/DWARFContext.cpp
+++ b/lib/DebugInfo/DWARFContext.cpp
@@ -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));
diff --git a/lib/DebugInfo/DWARFTypeUnit.h b/lib/DebugInfo/DWARFTypeUnit.h
index 05e13ff104..365aa26996 100644
--- a/lib/DebugInfo/DWARFTypeUnit.h
+++ b/lib/DebugInfo/DWARFTypeUnit.h
@@ -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:
diff --git a/lib/DebugInfo/DWARFUnit.cpp b/lib/DebugInfo/DWARFUnit.cpp
index 7aba46ca37..41b6a252a2 100644
--- a/lib/DebugInfo/DWARFUnit.cpp
+++ b/lib/DebugInfo/DWARFUnit.cpp
@@ -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;
}
diff --git a/lib/DebugInfo/DWARFUnit.h b/lib/DebugInfo/DWARFUnit.h
index 78997f5ca3..9743b22f72 100644
--- a/lib/DebugInfo/DWARFUnit.h
+++ b/lib/DebugInfo/DWARFUnit.h
@@ -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();