summaryrefslogtreecommitdiffstats
path: root/llvm/lib/DebugInfo/DWARF/DWARFFormValue.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/DebugInfo/DWARF/DWARFFormValue.cpp')
-rw-r--r--llvm/lib/DebugInfo/DWARF/DWARFFormValue.cpp95
1 files changed, 14 insertions, 81 deletions
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFFormValue.cpp b/llvm/lib/DebugInfo/DWARF/DWARFFormValue.cpp
index 39c1f5fd5c5..dda4a0cdb31 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFFormValue.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFFormValue.cpp
@@ -59,48 +59,13 @@ static const DWARFFormValue::FormClass DWARF4FormClasses[] = {
DWARFFormValue::FC_Flag, // 0x19 DW_FORM_flag_present
};
-namespace {
-
-/// A helper class that can be used in DWARFFormValue.cpp functions that need
-/// to know the byte size of DW_FORM values that vary in size depending on the
-/// DWARF version, address byte size, or DWARF32 or DWARF64.
-class FormSizeHelper {
- uint16_t Version;
- uint8_t AddrSize;
- llvm::dwarf::DwarfFormat Format;
-
-public:
- FormSizeHelper(uint16_t V, uint8_t A, llvm::dwarf::DwarfFormat F)
- : Version(V), AddrSize(A), Format(F) {}
-
- uint8_t getAddressByteSize() const { return AddrSize; }
-
- uint8_t getRefAddrByteSize() const {
- if (Version == 2)
- return AddrSize;
- return getDwarfOffsetByteSize();
- }
-
- uint8_t getDwarfOffsetByteSize() const {
- switch (Format) {
- case dwarf::DwarfFormat::DWARF32:
- return 4;
- case dwarf::DwarfFormat::DWARF64:
- return 8;
- }
- llvm_unreachable("Invalid Format value");
- }
-};
-
-} // end anonymous namespace
-
-template <class T>
-static Optional<uint8_t> getFixedByteSize(dwarf::Form Form, const T *U) {
+Optional<uint8_t>
+DWARFFormValue::getFixedByteSize(dwarf::Form Form,
+ const DWARFFormParams &Params) {
switch (Form) {
case DW_FORM_addr:
- if (U)
- return U->getAddressByteSize();
- return None;
+ assert(Params.Version && Params.AddrSize && "Invalid Params for form");
+ return Params.AddrSize;
case DW_FORM_block: // ULEB128 length L followed by L bytes.
case DW_FORM_block1: // 1 byte length L followed by L bytes.
@@ -121,9 +86,8 @@ static Optional<uint8_t> getFixedByteSize(dwarf::Form Form, const T *U) {
return None;
case DW_FORM_ref_addr:
- if (U)
- return U->getRefAddrByteSize();
- return None;
+ assert(Params.Version && Params.AddrSize && "Invalid Params for form");
+ return Params.getRefAddrByteSize();
case DW_FORM_flag:
case DW_FORM_data1:
@@ -154,9 +118,8 @@ static Optional<uint8_t> getFixedByteSize(dwarf::Form Form, const T *U) {
case DW_FORM_line_strp:
case DW_FORM_sec_offset:
case DW_FORM_strp_sup:
- if (U)
- return U->getDwarfOffsetByteSize();
- return None;
+ assert(Params.Version && Params.AddrSize && "Invalid Params for form");
+ return Params.getDwarfOffsetByteSize();
case DW_FORM_data8:
case DW_FORM_ref8:
@@ -181,9 +144,9 @@ static Optional<uint8_t> getFixedByteSize(dwarf::Form Form, const T *U) {
return None;
}
-template <class T>
-static bool skipFormValue(dwarf::Form Form, const DataExtractor &DebugInfoData,
- uint32_t *OffsetPtr, const T *U) {
+bool DWARFFormValue::skipValue(dwarf::Form Form, DataExtractor DebugInfoData,
+ uint32_t *OffsetPtr,
+ const DWARFFormParams &Params) {
bool Indirect = false;
do {
switch (Form) {
@@ -243,7 +206,8 @@ static bool skipFormValue(dwarf::Form Form, const DataExtractor &DebugInfoData,
case DW_FORM_line_strp:
case DW_FORM_GNU_ref_alt:
case DW_FORM_GNU_strp_alt:
- if (Optional<uint8_t> FixedSize = ::getFixedByteSize(Form, U)) {
+ if (Optional<uint8_t> FixedSize =
+ DWARFFormValue::getFixedByteSize(Form, Params)) {
*OffsetPtr += *FixedSize;
return true;
}
@@ -277,19 +241,6 @@ static bool skipFormValue(dwarf::Form Form, const DataExtractor &DebugInfoData,
return true;
}
-Optional<uint8_t> DWARFFormValue::getFixedByteSize(dwarf::Form Form,
- const DWARFUnit *U) {
- return ::getFixedByteSize(Form, U);
-}
-
-Optional<uint8_t>
-DWARFFormValue::getFixedByteSize(dwarf::Form Form, uint16_t Version,
- uint8_t AddrSize,
- llvm::dwarf::DwarfFormat Format) {
- FormSizeHelper FSH(Version, AddrSize, Format);
- return ::getFixedByteSize(Form, &FSH);
-}
-
bool DWARFFormValue::isFormClass(DWARFFormValue::FormClass FC) const {
// First, check DWARF4 form classes.
if (Form < makeArrayRef(DWARF4FormClasses).size() &&
@@ -448,24 +399,6 @@ bool DWARFFormValue::extractValue(const DataExtractor &Data,
return true;
}
-bool DWARFFormValue::skipValue(DataExtractor DebugInfoData, uint32_t *OffsetPtr,
- const DWARFUnit *U) const {
- return DWARFFormValue::skipValue(Form, DebugInfoData, OffsetPtr, U);
-}
-
-bool DWARFFormValue::skipValue(dwarf::Form Form, DataExtractor DebugInfoData,
- uint32_t *OffsetPtr, const DWARFUnit *U) {
- return skipFormValue(Form, DebugInfoData, OffsetPtr, U);
-}
-
-bool DWARFFormValue::skipValue(dwarf::Form Form, DataExtractor DebugInfoData,
- uint32_t *OffsetPtr, uint16_t Version,
- uint8_t AddrSize,
- llvm::dwarf::DwarfFormat Format) {
- FormSizeHelper FSH(Version, AddrSize, Format);
- return skipFormValue(Form, DebugInfoData, OffsetPtr, &FSH);
-}
-
void DWARFFormValue::dump(raw_ostream &OS) const {
uint64_t UValue = Value.uval;
bool CURelativeOffset = false;
OpenPOWER on IntegriCloud