diff options
Diffstat (limited to 'llvm/lib/DebugInfo')
-rw-r--r-- | llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/DebugInfo/DWARF/DWARFDebugInfoEntry.cpp | 10 | ||||
-rw-r--r-- | llvm/lib/DebugInfo/DWARF/DWARFFormValue.cpp | 54 | ||||
-rw-r--r-- | llvm/lib/DebugInfo/DWARF/DWARFTypeUnit.cpp | 2 |
4 files changed, 36 insertions, 32 deletions
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp b/llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp index cef4eab296b..7111ad3f9fc 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp @@ -120,7 +120,7 @@ void DWARFAcceleratorTable::dump(raw_ostream &OS) const { for (auto &Atom : AtomForms) { OS << format("{Atom[%d]: ", i++); if (Atom.extractValue(AccelSection, &DataOffset, nullptr)) - Atom.dump(OS, nullptr); + Atom.dump(OS); else OS << "Error extracting the value"; OS << "} "; diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDebugInfoEntry.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDebugInfoEntry.cpp index 880fc5c3fa2..55378e59b3c 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFDebugInfoEntry.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFDebugInfoEntry.cpp @@ -158,13 +158,13 @@ void DWARFDebugInfoEntryMinimal::dumpAttribute(raw_ostream &OS, else if (attr == DW_AT_decl_line || attr == DW_AT_call_line) OS << *formValue.getAsUnsignedConstant(); else - formValue.dump(OS, u); + formValue.dump(OS); // We have dumped the attribute raw value. For some attributes // having both the raw value and the pretty-printed value is // interesting. These attributes are handled below. if (attr == DW_AT_specification || attr == DW_AT_abstract_origin) { - Optional<uint64_t> Ref = formValue.getAsReference(u); + Optional<uint64_t> Ref = formValue.getAsReference(); if (Ref.hasValue()) { uint32_t RefOffset = Ref.getValue(); DWARFDebugInfoEntryMinimal DIE; @@ -264,7 +264,7 @@ const char *DWARFDebugInfoEntryMinimal::getAttributeValueAsString( DWARFFormValue FormValue; if (!getAttributeValue(U, Attr, FormValue)) return FailValue; - Optional<const char *> Result = FormValue.getAsCString(U); + Optional<const char *> Result = FormValue.getAsCString(); return Result.hasValue() ? Result.getValue() : FailValue; } @@ -274,7 +274,7 @@ uint64_t DWARFDebugInfoEntryMinimal::getAttributeValueAsAddress( DWARFFormValue FormValue; if (!getAttributeValue(U, Attr, FormValue)) return FailValue; - Optional<uint64_t> Result = FormValue.getAsAddress(U); + Optional<uint64_t> Result = FormValue.getAsAddress(); return Result.hasValue() ? Result.getValue() : FailValue; } @@ -294,7 +294,7 @@ uint64_t DWARFDebugInfoEntryMinimal::getAttributeValueAsReference( DWARFFormValue FormValue; if (!getAttributeValue(U, Attr, FormValue)) return FailValue; - Optional<uint64_t> Result = FormValue.getAsReference(U); + Optional<uint64_t> Result = FormValue.getAsReference(); return Result.hasValue() ? Result.getValue() : FailValue; } diff --git a/llvm/lib/DebugInfo/DWARF/DWARFFormValue.cpp b/llvm/lib/DebugInfo/DWARF/DWARFFormValue.cpp index a2d625a06de..5d9c118473a 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFFormValue.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFFormValue.cpp @@ -133,8 +133,10 @@ bool DWARFFormValue::isFormClass(DWARFFormValue::FormClass FC) const { FC == FC_SectionOffset; } -bool DWARFFormValue::extractValue(DataExtractor data, uint32_t *offset_ptr, +bool DWARFFormValue::extractValue(const DataExtractor &data, + uint32_t *offset_ptr, const DWARFUnit *cu) { + U = cu; bool indirect = false; bool is_block = false; Value.data = nullptr; @@ -145,14 +147,14 @@ bool DWARFFormValue::extractValue(DataExtractor data, uint32_t *offset_ptr, switch (Form) { case DW_FORM_addr: case DW_FORM_ref_addr: { - if (!cu) + if (!U) return false; uint16_t AddrSize = (Form == DW_FORM_addr) - ? cu->getAddressByteSize() - : getRefAddrSize(cu->getAddressByteSize(), cu->getVersion()); - RelocAddrMap::const_iterator AI = cu->getRelocMap()->find(*offset_ptr); - if (AI != cu->getRelocMap()->end()) { + ? U->getAddressByteSize() + : U->getRefAddrByteSize(); + RelocAddrMap::const_iterator AI = U->getRelocMap()->find(*offset_ptr); + if (AI != U->getRelocMap()->end()) { const std::pair<uint8_t, int64_t> &R = AI->second; Value.uval = data.getUnsigned(offset_ptr, AddrSize) + R.second; } else @@ -188,10 +190,10 @@ bool DWARFFormValue::extractValue(DataExtractor data, uint32_t *offset_ptr, case DW_FORM_data4: case DW_FORM_ref4: { Value.uval = data.getU32(offset_ptr); - if (!cu) + if (!U) break; - RelocAddrMap::const_iterator AI = cu->getRelocMap()->find(*offset_ptr-4); - if (AI != cu->getRelocMap()->end()) + RelocAddrMap::const_iterator AI = U->getRelocMap()->find(*offset_ptr-4); + if (AI != U->getRelocMap()->end()) Value.uval += AI->second.second; break; } @@ -219,11 +221,11 @@ bool DWARFFormValue::extractValue(DataExtractor data, uint32_t *offset_ptr, case DW_FORM_GNU_strp_alt: { // FIXME: This is 64-bit for DWARF64. Value.uval = data.getU32(offset_ptr); - if (!cu) + if (!U) break; RelocAddrMap::const_iterator AI = - cu->getRelocMap()->find(*offset_ptr - 4); - if (AI != cu->getRelocMap()->end()) + U->getRelocMap()->find(*offset_ptr - 4); + if (AI != U->getRelocMap()->end()) Value.uval += AI->second.second; break; } @@ -256,8 +258,8 @@ bool DWARFFormValue::extractValue(DataExtractor data, uint32_t *offset_ptr, bool DWARFFormValue::skipValue(DataExtractor debug_info_data, uint32_t* offset_ptr, - const DWARFUnit *cu) const { - return DWARFFormValue::skipValue(Form, debug_info_data, offset_ptr, cu); + const DWARFUnit *U) const { + return DWARFFormValue::skipValue(Form, debug_info_data, offset_ptr, U); } bool @@ -371,7 +373,7 @@ DWARFFormValue::skipValue(dwarf::Form form, DataExtractor debug_info_data, } void -DWARFFormValue::dump(raw_ostream &OS, const DWARFUnit *cu) const { +DWARFFormValue::dump(raw_ostream &OS) const { uint64_t uvalue = Value.uval; bool cu_relative_offset = false; @@ -380,7 +382,9 @@ DWARFFormValue::dump(raw_ostream &OS, const DWARFUnit *cu) const { case DW_FORM_GNU_addr_index: { OS << format(" indexed (%8.8x) address = ", (uint32_t)uvalue); uint64_t Address; - if (cu->getAddrOffsetSectionItem(uvalue, Address)) + if (U == nullptr) + OS << "<invalid dwarf unit>"; + else if (U->getAddrOffsetSectionItem(uvalue, Address)) OS << format("0x%016" PRIx64, Address); else OS << "<no .debug_addr section>"; @@ -431,17 +435,17 @@ DWARFFormValue::dump(raw_ostream &OS, const DWARFUnit *cu) const { case DW_FORM_udata: OS << Value.uval; break; case DW_FORM_strp: { OS << format(" .debug_str[0x%8.8x] = ", (uint32_t)uvalue); - dumpString(OS, cu); + dumpString(OS); break; } case DW_FORM_GNU_str_index: { OS << format(" indexed (%8.8x) string = ", (uint32_t)uvalue); - dumpString(OS, cu); + dumpString(OS); break; } case DW_FORM_GNU_strp_alt: { OS << format("alt indirect string, offset: 0x%" PRIx64 "", uvalue); - dumpString(OS, cu); + dumpString(OS); break; } case DW_FORM_ref_addr: @@ -490,13 +494,13 @@ DWARFFormValue::dump(raw_ostream &OS, const DWARFUnit *cu) const { if (cu_relative_offset) { OS << " => {"; WithColor(OS, syntax::Address).get() - << format("0x%8.8" PRIx64, uvalue + (cu ? cu->getOffset() : 0)); + << format("0x%8.8" PRIx64, uvalue + (U ? U->getOffset() : 0)); OS << "}"; } } -void DWARFFormValue::dumpString(raw_ostream &OS, const DWARFUnit *U) const { - Optional<const char *> DbgStr = getAsCString(U); +void DWARFFormValue::dumpString(raw_ostream &OS) const { + Optional<const char *> DbgStr = getAsCString(); if (DbgStr.hasValue()) { raw_ostream &COS = WithColor(OS, syntax::String); COS << '"'; @@ -505,7 +509,7 @@ void DWARFFormValue::dumpString(raw_ostream &OS, const DWARFUnit *U) const { } } -Optional<const char *> DWARFFormValue::getAsCString(const DWARFUnit *U) const { +Optional<const char *> DWARFFormValue::getAsCString() const { if (!isFormClass(FC_String)) return None; if (Form == DW_FORM_string) @@ -526,7 +530,7 @@ Optional<const char *> DWARFFormValue::getAsCString(const DWARFUnit *U) const { return None; } -Optional<uint64_t> DWARFFormValue::getAsAddress(const DWARFUnit *U) const { +Optional<uint64_t> DWARFFormValue::getAsAddress() const { if (!isFormClass(FC_Address)) return None; if (Form == DW_FORM_GNU_addr_index) { @@ -539,7 +543,7 @@ Optional<uint64_t> DWARFFormValue::getAsAddress(const DWARFUnit *U) const { return Value.uval; } -Optional<uint64_t> DWARFFormValue::getAsReference(const DWARFUnit *U) const { +Optional<uint64_t> DWARFFormValue::getAsReference() const { if (!isFormClass(FC_Reference)) return None; switch (Form) { diff --git a/llvm/lib/DebugInfo/DWARF/DWARFTypeUnit.cpp b/llvm/lib/DebugInfo/DWARF/DWARFTypeUnit.cpp index 38ed3aeaaf3..fa3f1d4d2b8 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFTypeUnit.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFTypeUnit.cpp @@ -30,7 +30,7 @@ void DWARFTypeUnit::dump(raw_ostream &OS, bool SummarizeTypes) { DWARFFormValue NameVal; const char *Name = ""; if (TD->getAttributeValue(this, llvm::dwarf::DW_AT_name, NameVal)) - if (auto ON = NameVal.getAsCString(this)) + if (auto ON = NameVal.getAsCString()) Name = *ON; if (SummarizeTypes) { |