summaryrefslogtreecommitdiffstats
path: root/llvm/include
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2016-10-31 16:46:02 +0000
committerGreg Clayton <gclayton@apple.com>2016-10-31 16:46:02 +0000
commitcddab279f6978fca9ae5a5676c7346f384579d2c (patch)
tree6624cdcb50838123e6cf69e73541ad40e33cacf4 /llvm/include
parent218770b827cac5e36e9739d0c47f4c67d05434ea (diff)
downloadbcm5719-llvm-cddab279f6978fca9ae5a5676c7346f384579d2c.tar.gz
bcm5719-llvm-cddab279f6978fca9ae5a5676c7346f384579d2c.zip
Modify DWARFFormValue to remember the DWARFUnit that it was decoded with.
Modifying DWARFFormValue to remember the DWARFUnit that it was encoded with can simplify the usage of instances of this class. Previously users would have to try and pass in the same DWARFUnit that was used to decode the form value and there was a possibility that a different DWARFUnit might be supplied to the functions that extract values (strings, CU relative references, addresses) and cause problems. This fixes this potential issue by storing the DWARFUnit inside the DWARFFormValue so that this mistake can't be made. Instances of DWARFFormValue are not stored permanently and are used as temporary values, so the increase in size of an instance of DWARFFormValue isn't a big deal. This makes decoding form values more bullet proof and is a change that will be used by future modifications. https://reviews.llvm.org/D26052 llvm-svn: 285594
Diffstat (limited to 'llvm/include')
-rw-r--r--llvm/include/llvm/DebugInfo/DWARF/DWARFFormValue.h23
-rw-r--r--llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h4
2 files changed, 16 insertions, 11 deletions
diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFFormValue.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFFormValue.h
index 19efd933d72..c3dc4691913 100644
--- a/llvm/include/llvm/DebugInfo/DWARF/DWARFFormValue.h
+++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFFormValue.h
@@ -49,15 +49,16 @@ private:
const uint8_t* data;
};
- dwarf::Form Form; // Form for this value.
+ dwarf::Form Form; // Form for this value.
ValueType Value; // Contains all data for the form.
+ const DWARFUnit *U; // Remember the DWARFUnit at extract time.
public:
- DWARFFormValue(dwarf::Form F = dwarf::Form(0)) : Form(F) {}
+ DWARFFormValue(dwarf::Form F = dwarf::Form(0)) : Form(F), U(nullptr) {}
dwarf::Form getForm() const { return Form; }
bool isFormClass(FormClass FC) const;
-
- void dump(raw_ostream &OS, const DWARFUnit *U) const;
+ const DWARFUnit *getUnit() const { return U; }
+ void dump(raw_ostream &OS) const;
/// \brief extracts a value in data at offset *offset_ptr.
///
@@ -65,24 +66,24 @@ public:
/// case no relocation processing will be performed and some
/// kind of forms that depend on Unit information are disallowed.
/// \returns whether the extraction succeeded.
- bool extractValue(DataExtractor data, uint32_t *offset_ptr,
- const DWARFUnit *u);
+ bool extractValue(const DataExtractor &Data, uint32_t *OffsetPtr,
+ const DWARFUnit *U);
bool isInlinedCStr() const {
return Value.data != nullptr && Value.data == (const uint8_t*)Value.cstr;
}
/// getAsFoo functions below return the extracted value as Foo if only
/// DWARFFormValue has form class is suitable for representing Foo.
- Optional<uint64_t> getAsReference(const DWARFUnit *U) const;
+ Optional<uint64_t> getAsReference() const;
Optional<uint64_t> getAsUnsignedConstant() const;
Optional<int64_t> getAsSignedConstant() const;
- Optional<const char *> getAsCString(const DWARFUnit *U) const;
- Optional<uint64_t> getAsAddress(const DWARFUnit *U) const;
+ Optional<const char *> getAsCString() const;
+ Optional<uint64_t> getAsAddress() const;
Optional<uint64_t> getAsSectionOffset() const;
Optional<ArrayRef<uint8_t>> getAsBlock() const;
bool skipValue(DataExtractor debug_info_data, uint32_t *offset_ptr,
- const DWARFUnit *u) const;
+ const DWARFUnit *U) const;
static bool skipValue(dwarf::Form form, DataExtractor debug_info_data,
uint32_t *offset_ptr, const DWARFUnit *u);
static bool skipValue(dwarf::Form form, DataExtractor debug_info_data,
@@ -92,7 +93,7 @@ public:
static ArrayRef<uint8_t> getFixedFormSizes(uint8_t AddrSize,
uint16_t Version);
private:
- void dumpString(raw_ostream &OS, const DWARFUnit *U) const;
+ void dumpString(raw_ostream &OS) const;
};
}
diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h
index fc2875cb28f..f8ce95fbbea 100644
--- a/llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h
+++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h
@@ -195,6 +195,10 @@ public:
return Abbrevs;
}
uint8_t getAddressByteSize() const { return AddrSize; }
+ uint8_t getRefAddrByteSize() const {
+ // FIXME: Support DWARF64.
+ return (Version == 2) ? AddrSize : 4;
+ }
uint64_t getBaseAddress() const { return BaseAddr; }
void setBaseAddress(uint64_t base_addr) {
OpenPOWER on IntegriCloud