summaryrefslogtreecommitdiff
path: root/lib/DebugInfo
diff options
context:
space:
mode:
authorAlexey Samsonov <samsonov@google.com>2013-10-28 23:41:49 +0000
committerAlexey Samsonov <samsonov@google.com>2013-10-28 23:41:49 +0000
commit6faff4886a3059a8cda08f015d29a6c9a0a4de3c (patch)
treeb053da16d95ba9281bcfb868b049df1009f01f41 /lib/DebugInfo
parent1765daa21c51a3e6bfc7db4adbbcbac0e0dcff3e (diff)
DWARF parser: Use ArrayRef to represent form sizes and simplify DWARFDIE::extractFast() interface. No functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193560 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/DebugInfo')
-rw-r--r--lib/DebugInfo/DWARFDebugInfoEntry.cpp13
-rw-r--r--lib/DebugInfo/DWARFDebugInfoEntry.h5
-rw-r--r--lib/DebugInfo/DWARFFormValue.cpp6
-rw-r--r--lib/DebugInfo/DWARFUnit.cpp5
4 files changed, 11 insertions, 18 deletions
diff --git a/lib/DebugInfo/DWARFDebugInfoEntry.cpp b/lib/DebugInfo/DWARFDebugInfoEntry.cpp
index 3383cee0806..39d8e3e9189 100644
--- a/lib/DebugInfo/DWARFDebugInfoEntry.cpp
+++ b/lib/DebugInfo/DWARFDebugInfoEntry.cpp
@@ -93,7 +93,6 @@ void DWARFDebugInfoEntryMinimal::dumpAttribute(raw_ostream &OS,
}
bool DWARFDebugInfoEntryMinimal::extractFast(const DWARFUnit *U,
- const uint8_t *FixedFormSizes,
uint32_t *OffsetPtr) {
Offset = *OffsetPtr;
DataExtractor DebugInfoData = U->getDebugInfoExtractor();
@@ -105,21 +104,19 @@ bool DWARFDebugInfoEntryMinimal::extractFast(const DWARFUnit *U,
}
AbbrevDecl = U->getAbbreviations()->getAbbreviationDeclaration(AbbrCode);
assert(AbbrevDecl);
- assert(FixedFormSizes); // For best performance this should be specified!
+ ArrayRef<uint8_t> FixedFormSizes = DWARFFormValue::getFixedFormSizes(
+ U->getAddressByteSize(), U->getVersion());
+ assert(FixedFormSizes.size() > 0);
// Skip all data in the .debug_info for the attributes
for (uint32_t i = 0, n = AbbrevDecl->getNumAttributes(); i < n; ++i) {
uint16_t Form = AbbrevDecl->getFormByIndex(i);
- // FIXME: Currently we're checking if this is less than the last
- // entry in the fixed_form_sizes table, but this should be changed
- // to use dynamic dispatch.
uint8_t FixedFormSize =
- (Form < DW_FORM_ref_sig8) ? FixedFormSizes[Form] : 0;
+ (Form < FixedFormSizes.size()) ? FixedFormSizes[Form] : 0;
if (FixedFormSize)
*OffsetPtr += FixedFormSize;
- else if (!DWARFFormValue::skipValue(Form, DebugInfoData, OffsetPtr,
- U)) {
+ else if (!DWARFFormValue::skipValue(Form, DebugInfoData, OffsetPtr, U)) {
// Restore the original offset.
*OffsetPtr = Offset;
return false;
diff --git a/lib/DebugInfo/DWARFDebugInfoEntry.h b/lib/DebugInfo/DWARFDebugInfoEntry.h
index e073d87b2b5..12479bfd3c5 100644
--- a/lib/DebugInfo/DWARFDebugInfoEntry.h
+++ b/lib/DebugInfo/DWARFDebugInfoEntry.h
@@ -45,11 +45,10 @@ public:
void dumpAttribute(raw_ostream &OS, const DWARFUnit *u, uint32_t *offset_ptr,
uint16_t attr, uint16_t form, unsigned indent = 0) const;
- /// Extracts a debug info entry, which is a child of a given compile unit,
+ /// Extracts a debug info entry, which is a child of a given unit,
/// starting at a given offset. If DIE can't be extracted, returns false and
/// doesn't change OffsetPtr.
- bool extractFast(const DWARFUnit *U, const uint8_t *FixedFormSizes,
- uint32_t *OffsetPtr);
+ bool extractFast(const DWARFUnit *U, uint32_t *OffsetPtr);
/// Extract a debug info entry for a given compile unit from the
/// .debug_info and .debug_abbrev data starting at the given offset.
diff --git a/lib/DebugInfo/DWARFFormValue.cpp b/lib/DebugInfo/DWARFFormValue.cpp
index 1a59dd8d0cf..b07f2755e93 100644
--- a/lib/DebugInfo/DWARFFormValue.cpp
+++ b/lib/DebugInfo/DWARFFormValue.cpp
@@ -62,8 +62,8 @@ static uint8_t getRefAddrSize(uint8_t AddrSize, uint16_t Version) {
return (Version == 2) ? AddrSize : 4;
}
-const uint8_t *
-DWARFFormValue::getFixedFormSizes(uint8_t AddrSize, uint16_t Version) {
+ArrayRef<uint8_t> DWARFFormValue::getFixedFormSizes(uint8_t AddrSize,
+ uint16_t Version) {
uint8_t RefAddrSize = getRefAddrSize(AddrSize, Version);
if (AddrSize == 4 && RefAddrSize == 4)
return FixedFormSizes<4, 4>::sizes;
@@ -73,7 +73,7 @@ DWARFFormValue::getFixedFormSizes(uint8_t AddrSize, uint16_t Version) {
return FixedFormSizes<8, 4>::sizes;
if (AddrSize == 8 && RefAddrSize == 8)
return FixedFormSizes<8, 8>::sizes;
- return 0;
+ return None;
}
static const DWARFFormValue::FormClass DWARF4FormClasses[] = {
diff --git a/lib/DebugInfo/DWARFUnit.cpp b/lib/DebugInfo/DWARFUnit.cpp
index 25062cd922a..090d441a148 100644
--- a/lib/DebugInfo/DWARFUnit.cpp
+++ b/lib/DebugInfo/DWARFUnit.cpp
@@ -194,12 +194,9 @@ void DWARFUnit::extractDIEsToVector(
uint32_t NextCUOffset = getNextUnitOffset();
DWARFDebugInfoEntryMinimal DIE;
uint32_t Depth = 0;
- const uint8_t *FixedFormSizes =
- DWARFFormValue::getFixedFormSizes(getAddressByteSize(), getVersion());
bool IsCUDie = true;
- while (Offset < NextCUOffset &&
- DIE.extractFast(this, FixedFormSizes, &Offset)) {
+ while (Offset < NextCUOffset && DIE.extractFast(this, &Offset)) {
if (IsCUDie) {
if (AppendCUDie)
Dies.push_back(DIE);