diff options
Diffstat (limited to 'include/llvm/DebugInfo/DWARF')
25 files changed, 212 insertions, 186 deletions
diff --git a/include/llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h b/include/llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h index ccf2891c2e21..39ae53c4e7fe 100644 --- a/include/llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h +++ b/include/llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h @@ -130,11 +130,11 @@ public: /// \param Attr DWARF attribute to search for. /// \param U the DWARFUnit the contains the DIE. /// \returns Optional DWARF form value if the attribute was extracted. - Optional<DWARFFormValue> getAttributeValue(const uint32_t DIEOffset, + Optional<DWARFFormValue> getAttributeValue(const uint64_t DIEOffset, const dwarf::Attribute Attr, const DWARFUnit &U) const; - bool extract(DataExtractor Data, uint32_t* OffsetPtr); + bool extract(DataExtractor Data, uint64_t* OffsetPtr); void dump(raw_ostream &OS) const; // Return an optional byte size of all attribute data in this abbreviation diff --git a/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h b/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h index 303375703d2e..c9042e593260 100644 --- a/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h +++ b/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h @@ -96,7 +96,7 @@ class AppleAcceleratorTable : public DWARFAcceleratorTable { using AtomType = uint16_t; using Form = dwarf::Form; - uint32_t DIEOffsetBase; + uint64_t DIEOffsetBase; SmallVector<std::pair<AtomType, Form>, 3> Atoms; Optional<uint64_t> extractOffset(Optional<DWARFFormValue> Value) const; @@ -109,7 +109,7 @@ class AppleAcceleratorTable : public DWARFAcceleratorTable { /// Returns true if we should continue scanning for entries or false if we've /// reached the last (sentinel) entry of encountered a parsing error. bool dumpName(ScopedPrinter &W, SmallVectorImpl<DWARFFormValue> &AtomForms, - uint32_t *DataOffset) const; + uint64_t *DataOffset) const; public: /// Apple-specific implementation of an Accelerator Entry. @@ -119,7 +119,7 @@ public: Entry(const HeaderData &Data); Entry() = default; - void extract(const AppleAcceleratorTable &AccelTable, uint32_t *Offset); + void extract(const AppleAcceleratorTable &AccelTable, uint64_t *Offset); public: Optional<uint64_t> getCUOffset() const override; @@ -143,7 +143,7 @@ public: class ValueIterator : public std::iterator<std::input_iterator_tag, Entry> { const AppleAcceleratorTable *AccelTable = nullptr; Entry Current; ///< The current entry. - unsigned DataOffset = 0; ///< Offset into the section. + uint64_t DataOffset = 0; ///< Offset into the section. unsigned Data = 0; ///< Current data entry. unsigned NumData = 0; ///< Number of data entries. @@ -151,7 +151,7 @@ public: void Next(); public: /// Construct a new iterator for the entries at \p DataOffset. - ValueIterator(const AppleAcceleratorTable &AccelTable, unsigned DataOffset); + ValueIterator(const AppleAcceleratorTable &AccelTable, uint64_t DataOffset); /// End marker. ValueIterator() = default; @@ -193,7 +193,7 @@ public: /// DieOffset is the offset into the .debug_info section for the DIE /// related to the input hash data offset. /// DieTag is the tag of the DIE - std::pair<uint32_t, dwarf::Tag> readAtoms(uint32_t &HashDataOffset); + std::pair<uint64_t, dwarf::Tag> readAtoms(uint64_t *HashDataOffset); void dump(raw_ostream &OS) const override; /// Look up all entries in the accelerator table matching \c Key. @@ -245,7 +245,7 @@ public: struct Header : public HeaderPOD { SmallString<8> AugmentationString; - Error extract(const DWARFDataExtractor &AS, uint32_t *Offset); + Error extract(const DWARFDataExtractor &AS, uint64_t *Offset); void dump(ScopedPrinter &W) const; }; @@ -354,12 +354,12 @@ public: DataExtractor StrData; uint32_t Index; - uint32_t StringOffset; - uint32_t EntryOffset; + uint64_t StringOffset; + uint64_t EntryOffset; public: NameTableEntry(const DataExtractor &StrData, uint32_t Index, - uint32_t StringOffset, uint32_t EntryOffset) + uint64_t StringOffset, uint64_t EntryOffset) : StrData(StrData), Index(Index), StringOffset(StringOffset), EntryOffset(EntryOffset) {} @@ -367,17 +367,17 @@ public: uint32_t getIndex() const { return Index; } /// Returns the offset of the name of the described entities. - uint32_t getStringOffset() const { return StringOffset; } + uint64_t getStringOffset() const { return StringOffset; } /// Return the string referenced by this name table entry or nullptr if the /// string offset is not valid. const char *getString() const { - uint32_t Off = StringOffset; + uint64_t Off = StringOffset; return StrData.getCStr(&Off); } /// Returns the offset of the first Entry in the list. - uint32_t getEntryOffset() const { return EntryOffset; } + uint64_t getEntryOffset() const { return EntryOffset; } }; /// Represents a single accelerator table within the DWARF v5 .debug_names @@ -389,40 +389,40 @@ public: // Base of the whole unit and of various important tables, as offsets from // the start of the section. - uint32_t Base; - uint32_t CUsBase; - uint32_t BucketsBase; - uint32_t HashesBase; - uint32_t StringOffsetsBase; - uint32_t EntryOffsetsBase; - uint32_t EntriesBase; + uint64_t Base; + uint64_t CUsBase; + uint64_t BucketsBase; + uint64_t HashesBase; + uint64_t StringOffsetsBase; + uint64_t EntryOffsetsBase; + uint64_t EntriesBase; void dumpCUs(ScopedPrinter &W) const; void dumpLocalTUs(ScopedPrinter &W) const; void dumpForeignTUs(ScopedPrinter &W) const; void dumpAbbreviations(ScopedPrinter &W) const; - bool dumpEntry(ScopedPrinter &W, uint32_t *Offset) const; + bool dumpEntry(ScopedPrinter &W, uint64_t *Offset) const; void dumpName(ScopedPrinter &W, const NameTableEntry &NTE, Optional<uint32_t> Hash) const; void dumpBucket(ScopedPrinter &W, uint32_t Bucket) const; - Expected<AttributeEncoding> extractAttributeEncoding(uint32_t *Offset); + Expected<AttributeEncoding> extractAttributeEncoding(uint64_t *Offset); Expected<std::vector<AttributeEncoding>> - extractAttributeEncodings(uint32_t *Offset); + extractAttributeEncodings(uint64_t *Offset); - Expected<Abbrev> extractAbbrev(uint32_t *Offset); + Expected<Abbrev> extractAbbrev(uint64_t *Offset); public: - NameIndex(const DWARFDebugNames &Section, uint32_t Base) + NameIndex(const DWARFDebugNames &Section, uint64_t Base) : Section(Section), Base(Base) {} /// Reads offset of compilation unit CU. CU is 0-based. - uint32_t getCUOffset(uint32_t CU) const; + uint64_t getCUOffset(uint32_t CU) const; uint32_t getCUCount() const { return Hdr.CompUnitCount; } /// Reads offset of local type unit TU, TU is 0-based. - uint32_t getLocalTUOffset(uint32_t TU) const; + uint64_t getLocalTUOffset(uint32_t TU) const; uint32_t getLocalTUCount() const { return Hdr.LocalTypeUnitCount; } /// Reads signature of foreign type unit TU. TU is 0-based. @@ -451,7 +451,7 @@ public: return Abbrevs; } - Expected<Entry> getEntry(uint32_t *Offset) const; + Expected<Entry> getEntry(uint64_t *Offset) const; /// Look up all entries in this Name Index matching \c Key. iterator_range<ValueIterator> equal_range(StringRef Key) const; @@ -460,8 +460,8 @@ public: NameIterator end() const { return NameIterator(this, getNameCount() + 1); } Error extract(); - uint32_t getUnitOffset() const { return Base; } - uint32_t getNextUnitOffset() const { return Base + 4 + Hdr.UnitLength; } + uint64_t getUnitOffset() const { return Base; } + uint64_t getNextUnitOffset() const { return Base + 4 + Hdr.UnitLength; } void dump(ScopedPrinter &W) const; friend class DWARFDebugNames; @@ -479,12 +479,12 @@ public: bool IsLocal; Optional<Entry> CurrentEntry; - unsigned DataOffset = 0; ///< Offset into the section. + uint64_t DataOffset = 0; ///< Offset into the section. std::string Key; ///< The Key we are searching for. Optional<uint32_t> Hash; ///< Hash of Key, if it has been computed. bool getEntryAtCurrentOffset(); - Optional<uint32_t> findEntryOffsetInCurrentIndex(); + Optional<uint64_t> findEntryOffsetInCurrentIndex(); bool findInCurrentIndex(); void searchFromStartOfCurrentIndex(); void next(); @@ -572,7 +572,7 @@ public: private: SmallVector<NameIndex, 0> NameIndices; - DenseMap<uint32_t, const NameIndex *> CUToNameIndex; + DenseMap<uint64_t, const NameIndex *> CUToNameIndex; public: DWARFDebugNames(const DWARFDataExtractor &AccelSection, @@ -591,7 +591,7 @@ public: /// Return the Name Index covering the compile unit at CUOffset, or nullptr if /// there is no Name Index covering that unit. - const NameIndex *getCUNameIndex(uint32_t CUOffset); + const NameIndex *getCUNameIndex(uint64_t CUOffset); }; } // end namespace llvm diff --git a/include/llvm/DebugInfo/DWARF/DWARFAttribute.h b/include/llvm/DebugInfo/DWARF/DWARFAttribute.h index c8ad19ad6bf6..dfc778346dbe 100644 --- a/include/llvm/DebugInfo/DWARF/DWARFAttribute.h +++ b/include/llvm/DebugInfo/DWARF/DWARFAttribute.h @@ -23,7 +23,7 @@ namespace llvm { /// attributes in a DWARFDie. struct DWARFAttribute { /// The debug info/types offset for this attribute. - uint32_t Offset = 0; + uint64_t Offset = 0; /// The debug info/types section byte size of the data for this attribute. uint32_t ByteSize = 0; /// The attribute enumeration of this attribute. diff --git a/include/llvm/DebugInfo/DWARF/DWARFContext.h b/include/llvm/DebugInfo/DWARF/DWARFContext.h index 23cf21c3523f..fae163622edb 100644 --- a/include/llvm/DebugInfo/DWARF/DWARFContext.h +++ b/include/llvm/DebugInfo/DWARF/DWARFContext.h @@ -225,10 +225,10 @@ public: DWARFCompileUnit *getDWOCompileUnitForHash(uint64_t Hash); /// Return the compile unit that includes an offset (relative to .debug_info). - DWARFCompileUnit *getCompileUnitForOffset(uint32_t Offset); + DWARFCompileUnit *getCompileUnitForOffset(uint64_t Offset); /// Get a DIE given an exact offset. - DWARFDie getDIEForOffset(uint32_t Offset); + DWARFDie getDIEForOffset(uint64_t Offset); unsigned getMaxVersion() { // Ensure info units have been parsed to discover MaxVersion @@ -301,10 +301,10 @@ public: std::function<void(Error)> RecoverableErrorCallback); DataExtractor getStringExtractor() const { - return DataExtractor(DObj->getStringSection(), false, 0); + return DataExtractor(DObj->getStrSection(), false, 0); } DataExtractor getLineStringExtractor() const { - return DataExtractor(DObj->getLineStringSection(), false, 0); + return DataExtractor(DObj->getLineStrSection(), false, 0); } /// Wraps the returned DIEs for a given address. diff --git a/include/llvm/DebugInfo/DWARF/DWARFDataExtractor.h b/include/llvm/DebugInfo/DWARF/DWARFDataExtractor.h index 7c2a159b71fa..980724c525d2 100644 --- a/include/llvm/DebugInfo/DWARF/DWARFDataExtractor.h +++ b/include/llvm/DebugInfo/DWARF/DWARFDataExtractor.h @@ -35,20 +35,25 @@ public: /// Extracts a value and applies a relocation to the result if /// one exists for the given offset. - uint64_t getRelocatedValue(uint32_t Size, uint32_t *Off, - uint64_t *SectionIndex = nullptr) const; + uint64_t getRelocatedValue(uint32_t Size, uint64_t *Off, + uint64_t *SectionIndex = nullptr, + Error *Err = nullptr) const; /// Extracts an address-sized value and applies a relocation to the result if /// one exists for the given offset. - uint64_t getRelocatedAddress(uint32_t *Off, uint64_t *SecIx = nullptr) const { + uint64_t getRelocatedAddress(uint64_t *Off, uint64_t *SecIx = nullptr) const { return getRelocatedValue(getAddressSize(), Off, SecIx); } + uint64_t getRelocatedAddress(Cursor &C, uint64_t *SecIx = nullptr) const { + return getRelocatedValue(getAddressSize(), &getOffset(C), SecIx, + &getError(C)); + } /// Extracts a DWARF-encoded pointer in \p Offset using \p Encoding. /// There is a DWARF encoding that uses a PC-relative adjustment. /// For these values, \p AbsPosOffset is used to fix them, which should /// reflect the absolute address of this pointer. - Optional<uint64_t> getEncodedPointer(uint32_t *Offset, uint8_t Encoding, + Optional<uint64_t> getEncodedPointer(uint64_t *Offset, uint8_t Encoding, uint64_t AbsPosOffset = 0) const; size_t size() const { return Section == nullptr ? 0 : Section->Data.size(); } diff --git a/include/llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h b/include/llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h index 28fd8484b4a9..1398e16252a9 100644 --- a/include/llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h +++ b/include/llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h @@ -20,7 +20,7 @@ namespace llvm { class raw_ostream; class DWARFAbbreviationDeclarationSet { - uint32_t Offset; + uint64_t Offset; /// Code of the first abbreviation, if all abbreviations in the set have /// consecutive codes. UINT32_MAX otherwise. uint32_t FirstAbbrCode; @@ -32,9 +32,9 @@ class DWARFAbbreviationDeclarationSet { public: DWARFAbbreviationDeclarationSet(); - uint32_t getOffset() const { return Offset; } + uint64_t getOffset() const { return Offset; } void dump(raw_ostream &OS) const; - bool extract(DataExtractor Data, uint32_t *OffsetPtr); + bool extract(DataExtractor Data, uint64_t *OffsetPtr); const DWARFAbbreviationDeclaration * getAbbreviationDeclaration(uint32_t AbbrCode) const; diff --git a/include/llvm/DebugInfo/DWARF/DWARFDebugAddr.h b/include/llvm/DebugInfo/DWARF/DWARFDebugAddr.h index a98bf282fe7c..4539b9c9d581 100644 --- a/include/llvm/DebugInfo/DWARF/DWARFDebugAddr.h +++ b/include/llvm/DebugInfo/DWARF/DWARFDebugAddr.h @@ -45,7 +45,7 @@ public: private: dwarf::DwarfFormat Format; - uint32_t HeaderOffset; + uint64_t HeaderOffset; Header HeaderData; uint32_t DataSize = 0; std::vector<uint64_t> Addrs; @@ -54,11 +54,11 @@ public: void clear(); /// Extract an entire table, including all addresses. - Error extract(DWARFDataExtractor Data, uint32_t *OffsetPtr, + Error extract(DWARFDataExtractor Data, uint64_t *OffsetPtr, uint16_t Version, uint8_t AddrSize, std::function<void(Error)> WarnCallback); - uint32_t getHeaderOffset() const { return HeaderOffset; } + uint64_t getHeaderOffset() const { return HeaderOffset; } uint8_t getAddrSize() const { return HeaderData.AddrSize; } void dump(raw_ostream &OS, DIDumpOptions DumpOpts = {}) const; diff --git a/include/llvm/DebugInfo/DWARF/DWARFDebugArangeSet.h b/include/llvm/DebugInfo/DWARF/DWARFDebugArangeSet.h index 5b6c578bc3bf..ebe4ad6e24dd 100644 --- a/include/llvm/DebugInfo/DWARF/DWARFDebugArangeSet.h +++ b/include/llvm/DebugInfo/DWARF/DWARFDebugArangeSet.h @@ -49,7 +49,7 @@ private: using DescriptorColl = std::vector<Descriptor>; using desc_iterator_range = iterator_range<DescriptorColl::const_iterator>; - uint32_t Offset; + uint64_t Offset; Header HeaderData; DescriptorColl ArangeDescriptors; @@ -57,7 +57,7 @@ public: DWARFDebugArangeSet() { clear(); } void clear(); - bool extract(DataExtractor data, uint32_t *offset_ptr); + bool extract(DataExtractor data, uint64_t *offset_ptr); void dump(raw_ostream &OS) const; uint32_t getCompileUnitDIEOffset() const { return HeaderData.CuOffset; } diff --git a/include/llvm/DebugInfo/DWARF/DWARFDebugAranges.h b/include/llvm/DebugInfo/DWARF/DWARFDebugAranges.h index 03223fbc80a9..172f1d2c9dbe 100644 --- a/include/llvm/DebugInfo/DWARF/DWARFDebugAranges.h +++ b/include/llvm/DebugInfo/DWARF/DWARFDebugAranges.h @@ -28,7 +28,7 @@ private: void extract(DataExtractor DebugArangesData); /// Call appendRange multiple times and then call construct. - void appendRange(uint32_t CUOffset, uint64_t LowPC, uint64_t HighPC); + void appendRange(uint64_t CUOffset, uint64_t LowPC, uint64_t HighPC); void construct(); struct Range { @@ -60,10 +60,10 @@ private: struct RangeEndpoint { uint64_t Address; - uint32_t CUOffset; + uint64_t CUOffset; bool IsRangeStart; - RangeEndpoint(uint64_t Address, uint32_t CUOffset, bool IsRangeStart) + RangeEndpoint(uint64_t Address, uint64_t CUOffset, bool IsRangeStart) : Address(Address), CUOffset(CUOffset), IsRangeStart(IsRangeStart) {} bool operator<(const RangeEndpoint &Other) const { @@ -76,7 +76,7 @@ private: std::vector<RangeEndpoint> Endpoints; RangeColl Aranges; - DenseSet<uint32_t> ParsedCUOffsets; + DenseSet<uint64_t> ParsedCUOffsets; }; } // end namespace llvm diff --git a/include/llvm/DebugInfo/DWARF/DWARFDebugFrame.h b/include/llvm/DebugInfo/DWARF/DWARFDebugFrame.h index d960f4bc9b1c..c6539df0d756 100644 --- a/include/llvm/DebugInfo/DWARF/DWARFDebugFrame.h +++ b/include/llvm/DebugInfo/DWARF/DWARFDebugFrame.h @@ -69,7 +69,7 @@ public: /// starting at *Offset and ending at EndOffset. *Offset is updated /// to EndOffset upon successful parsing, or indicates the offset /// where a problem occurred in case an error is returned. - Error parse(DataExtractor Data, uint32_t *Offset, uint32_t EndOffset); + Error parse(DWARFDataExtractor Data, uint64_t *Offset, uint64_t EndOffset); void dump(raw_ostream &OS, const MCRegisterInfo *MRI, bool IsEH, unsigned IndentLevel = 1) const; diff --git a/include/llvm/DebugInfo/DWARF/DWARFDebugInfoEntry.h b/include/llvm/DebugInfo/DWARF/DWARFDebugInfoEntry.h index f50063b24370..ded960337ec6 100644 --- a/include/llvm/DebugInfo/DWARF/DWARFDebugInfoEntry.h +++ b/include/llvm/DebugInfo/DWARF/DWARFDebugInfoEntry.h @@ -22,7 +22,7 @@ class DWARFUnit; /// DWARFDebugInfoEntry - A DIE with only the minimum required data. class DWARFDebugInfoEntry { /// Offset within the .debug_info of the start of this entry. - uint32_t Offset = 0; + uint64_t Offset = 0; /// The integer depth of this DIE within the compile unit DIEs where the /// compile/type unit DIE has a depth of zero. @@ -36,14 +36,14 @@ public: /// 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, uint32_t *OffsetPtr); + bool extractFast(const DWARFUnit &U, uint64_t *OffsetPtr); /// High performance extraction should use this call. - bool extractFast(const DWARFUnit &U, uint32_t *OffsetPtr, - const DWARFDataExtractor &DebugInfoData, uint32_t UEndOffset, + bool extractFast(const DWARFUnit &U, uint64_t *OffsetPtr, + const DWARFDataExtractor &DebugInfoData, uint64_t UEndOffset, uint32_t Depth); - uint32_t getOffset() const { return Offset; } + uint64_t getOffset() const { return Offset; } uint32_t getDepth() const { return Depth; } dwarf::Tag getTag() const { diff --git a/include/llvm/DebugInfo/DWARF/DWARFDebugLine.h b/include/llvm/DebugInfo/DWARF/DWARFDebugLine.h index e7425c192373..c2be8304ad84 100644 --- a/include/llvm/DebugInfo/DWARF/DWARFDebugLine.h +++ b/include/llvm/DebugInfo/DWARF/DWARFDebugLine.h @@ -18,6 +18,7 @@ #include "llvm/DebugInfo/DWARF/DWARFRelocMap.h" #include "llvm/DebugInfo/DWARF/DWARFTypeUnit.h" #include "llvm/Support/MD5.h" +#include "llvm/Support/Path.h" #include <cstdint> #include <map> #include <string> @@ -128,13 +129,15 @@ public: bool hasFileAtIndex(uint64_t FileIndex) const; - bool getFileNameByIndex(uint64_t FileIndex, StringRef CompDir, - DILineInfoSpecifier::FileLineInfoKind Kind, - std::string &Result) const; + bool + getFileNameByIndex(uint64_t FileIndex, StringRef CompDir, + DILineInfoSpecifier::FileLineInfoKind Kind, + std::string &Result, + sys::path::Style Style = sys::path::Style::native) const; void clear(); void dump(raw_ostream &OS, DIDumpOptions DumpOptions) const; - Error parse(const DWARFDataExtractor &DebugLineData, uint32_t *OffsetPtr, + Error parse(const DWARFDataExtractor &DebugLineData, uint64_t *OffsetPtr, const DWARFContext &Ctx, const DWARFUnit *U = nullptr); }; @@ -278,7 +281,7 @@ public: /// Parse prologue and all rows. Error parse( - DWARFDataExtractor &DebugLineData, uint32_t *OffsetPtr, + DWARFDataExtractor &DebugLineData, uint64_t *OffsetPtr, const DWARFContext &Ctx, const DWARFUnit *U, std::function<void(Error)> RecoverableErrorCallback, raw_ostream *OS = nullptr); @@ -305,9 +308,9 @@ public: std::vector<uint32_t> &Result) const; }; - const LineTable *getLineTable(uint32_t Offset) const; + const LineTable *getLineTable(uint64_t Offset) const; Expected<const LineTable *> getOrParseLineTable( - DWARFDataExtractor &DebugLineData, uint32_t Offset, + DWARFDataExtractor &DebugLineData, uint64_t Offset, const DWARFContext &Ctx, const DWARFUnit *U, std::function<void(Error)> RecoverableErrorCallback); @@ -350,17 +353,17 @@ public: bool done() const { return Done; } /// Get the offset the parser has reached. - uint32_t getOffset() const { return Offset; } + uint64_t getOffset() const { return Offset; } private: - DWARFUnit *prepareToParse(uint32_t Offset); - void moveToNextTable(uint32_t OldOffset, const Prologue &P); + DWARFUnit *prepareToParse(uint64_t Offset); + void moveToNextTable(uint64_t OldOffset, const Prologue &P); LineToUnitMap LineToUnit; DWARFDataExtractor &DebugLineData; const DWARFContext &Context; - uint32_t Offset = 0; + uint64_t Offset = 0; bool Done = false; }; @@ -377,7 +380,7 @@ private: struct Sequence Sequence; }; - using LineTableMapTy = std::map<uint32_t, LineTable>; + using LineTableMapTy = std::map<uint64_t, LineTable>; using LineTableIter = LineTableMapTy::iterator; using LineTableConstIter = LineTableMapTy::const_iterator; diff --git a/include/llvm/DebugInfo/DWARF/DWARFDebugLoc.h b/include/llvm/DebugInfo/DWARF/DWARFDebugLoc.h index cced6048e811..c79d98e34f6e 100644 --- a/include/llvm/DebugInfo/DWARF/DWARFDebugLoc.h +++ b/include/llvm/DebugInfo/DWARF/DWARFDebugLoc.h @@ -11,6 +11,7 @@ #include "llvm/ADT/Optional.h" #include "llvm/ADT/SmallVector.h" +#include "llvm/DebugInfo/DIContext.h" #include "llvm/DebugInfo/DWARF/DWARFDataExtractor.h" #include "llvm/DebugInfo/DWARF/DWARFRelocMap.h" #include <cstdint> @@ -29,19 +30,20 @@ public: /// The ending address of the instruction range. uint64_t End; /// The location of the variable within the specified range. - SmallVector<char, 4> Loc; + SmallVector<uint8_t, 4> Loc; }; /// A list of locations that contain one variable. struct LocationList { /// The beginning offset where this location list is stored in the debug_loc /// section. - unsigned Offset; + uint64_t Offset; /// All the locations in which the variable is stored. SmallVector<Entry, 2> Entries; /// Dump this list on OS. - void dump(raw_ostream &OS, bool IsLittleEndian, unsigned AddressSize, - const MCRegisterInfo *MRI, DWARFUnit *U, uint64_t BaseAddress, + void dump(raw_ostream &OS, uint64_t BaseAddress, bool IsLittleEndian, + unsigned AddressSize, const MCRegisterInfo *MRI, DWARFUnit *U, + DIDumpOptions DumpOpts, unsigned Indent) const; }; @@ -58,7 +60,7 @@ private: public: /// Print the location lists found within the debug_loc section. - void dump(raw_ostream &OS, const MCRegisterInfo *RegInfo, + void dump(raw_ostream &OS, const MCRegisterInfo *RegInfo, DIDumpOptions DumpOpts, Optional<uint64_t> Offset) const; /// Parse the debug_loc section accessible via the 'data' parameter using the @@ -68,25 +70,29 @@ public: /// Return the location list at the given offset or nullptr. LocationList const *getLocationListAtOffset(uint64_t Offset) const; - Optional<LocationList> parseOneLocationList(DWARFDataExtractor Data, - uint32_t *Offset); + Expected<LocationList> + parseOneLocationList(const DWARFDataExtractor &Data, uint64_t *Offset); }; class DWARFDebugLoclists { public: struct Entry { uint8_t Kind; + uint64_t Offset; uint64_t Value0; uint64_t Value1; - SmallVector<char, 4> Loc; + SmallVector<uint8_t, 4> Loc; + void dump(raw_ostream &OS, uint64_t &BaseAddr, bool IsLittleEndian, + unsigned AddressSize, const MCRegisterInfo *MRI, DWARFUnit *U, + DIDumpOptions DumpOpts, unsigned Indent, size_t MaxEncodingStringLength) const; }; struct LocationList { - unsigned Offset; + uint64_t Offset; SmallVector<Entry, 2> Entries; void dump(raw_ostream &OS, uint64_t BaseAddr, bool IsLittleEndian, unsigned AddressSize, const MCRegisterInfo *RegInfo, - DWARFUnit *U, unsigned Indent) const; + DWARFUnit *U, DIDumpOptions DumpOpts, unsigned Indent) const; }; private: @@ -99,15 +105,16 @@ private: bool IsLittleEndian; public: - void parse(DataExtractor data, unsigned Version); + void parse(DataExtractor data, uint64_t Offset, uint64_t EndOffset, uint16_t Version); void dump(raw_ostream &OS, uint64_t BaseAddr, const MCRegisterInfo *RegInfo, - Optional<uint64_t> Offset) const; + DIDumpOptions DumpOpts, Optional<uint64_t> Offset) const; /// Return the location list at the given offset or nullptr. LocationList const *getLocationListAtOffset(uint64_t Offset) const; - static Optional<LocationList> - parseOneLocationList(DataExtractor Data, unsigned *Offset, unsigned Version); + static Expected<LocationList> parseOneLocationList(const DataExtractor &Data, + uint64_t *Offset, + unsigned Version); }; } // end namespace llvm diff --git a/include/llvm/DebugInfo/DWARF/DWARFDebugPubTable.h b/include/llvm/DebugInfo/DWARF/DWARFDebugPubTable.h index 99e91ca90319..ae57306b90e1 100644 --- a/include/llvm/DebugInfo/DWARF/DWARFDebugPubTable.h +++ b/include/llvm/DebugInfo/DWARF/DWARFDebugPubTable.h @@ -25,7 +25,7 @@ class DWARFDebugPubTable { public: struct Entry { /// Section offset from the beginning of the compilation unit. - uint32_t SecOffset; + uint64_t SecOffset; /// An entry of the various gnu_pub* debug sections. dwarf::PubIndexEntryDescriptor Descriptor; @@ -50,7 +50,7 @@ public: /// The offset from the beginning of the .debug_info section of the /// compilation unit header referenced by the set. - uint32_t Offset; + uint64_t Offset; /// The size in bytes of the contents of the .debug_info section generated /// to represent that compilation unit. diff --git a/include/llvm/DebugInfo/DWARF/DWARFDebugRangeList.h b/include/llvm/DebugInfo/DWARF/DWARFDebugRangeList.h index a66f60292343..2f72c642a2d5 100644 --- a/include/llvm/DebugInfo/DWARF/DWARFDebugRangeList.h +++ b/include/llvm/DebugInfo/DWARF/DWARFDebugRangeList.h @@ -53,14 +53,13 @@ public: assert(AddressSize == 4 || AddressSize == 8); if (AddressSize == 4) return StartAddress == -1U; - else - return StartAddress == -1ULL; + return StartAddress == -1ULL; } }; private: /// Offset in .debug_ranges section. - uint32_t Offset; + uint64_t Offset; uint8_t AddressSize; std::vector<RangeListEntry> Entries; @@ -69,7 +68,7 @@ public: void clear(); void dump(raw_ostream &OS) const; - Error extract(const DWARFDataExtractor &data, uint32_t *offset_ptr); + Error extract(const DWARFDataExtractor &data, uint64_t *offset_ptr); const std::vector<RangeListEntry> &getEntries() { return Entries; } /// getAbsoluteRanges - Returns absolute address ranges defined by this range diff --git a/include/llvm/DebugInfo/DWARF/DWARFDebugRnglists.h b/include/llvm/DebugInfo/DWARF/DWARFDebugRnglists.h index 167ddde3ec3d..952c41e188c7 100644 --- a/include/llvm/DebugInfo/DWARF/DWARFDebugRnglists.h +++ b/include/llvm/DebugInfo/DWARF/DWARFDebugRnglists.h @@ -34,7 +34,7 @@ struct RangeListEntry : public DWARFListEntryBase { uint64_t Value0; uint64_t Value1; - Error extract(DWARFDataExtractor Data, uint32_t End, uint32_t *OffsetPtr); + Error extract(DWARFDataExtractor Data, uint64_t End, uint64_t *OffsetPtr); void dump(raw_ostream &OS, uint8_t AddrSize, uint8_t MaxEncodingStringLength, uint64_t &CurrentBase, DIDumpOptions DumpOpts, llvm::function_ref<Optional<object::SectionedAddress>(uint32_t)> diff --git a/include/llvm/DebugInfo/DWARF/DWARFDie.h b/include/llvm/DebugInfo/DWARF/DWARFDie.h index 21e68f983bb3..f7f08b4a499d 100644 --- a/include/llvm/DebugInfo/DWARF/DWARFDie.h +++ b/include/llvm/DebugInfo/DWARF/DWARFDie.h @@ -63,7 +63,7 @@ public: /// Get the absolute offset into the debug info or types section. /// /// \returns the DIE offset or -1U if invalid. - uint32_t getOffset() const { + uint64_t getOffset() const { assert(isValid() && "must check validity prior to calling"); return Die->getOffset(); } diff --git a/include/llvm/DebugInfo/DWARF/DWARFExpression.h b/include/llvm/DebugInfo/DWARF/DWARFExpression.h index f066dd58d606..456d9df957ad 100644 --- a/include/llvm/DebugInfo/DWARF/DWARFExpression.h +++ b/include/llvm/DebugInfo/DWARF/DWARFExpression.h @@ -77,18 +77,18 @@ public: uint8_t Opcode; ///< The Op Opcode, DW_OP_<something>. Description Desc; bool Error; - uint32_t EndOffset; + uint64_t EndOffset; uint64_t Operands[2]; - uint32_t OperandEndOffsets[2]; + uint64_t OperandEndOffsets[2]; public: Description &getDescription() { return Desc; } uint8_t getCode() { return Opcode; } uint64_t getRawOperand(unsigned Idx) { return Operands[Idx]; } - uint32_t getOperandEndOffset(unsigned Idx) { return OperandEndOffsets[Idx]; } - uint32_t getEndOffset() { return EndOffset; } + uint64_t getOperandEndOffset(unsigned Idx) { return OperandEndOffsets[Idx]; } + uint64_t getEndOffset() { return EndOffset; } bool extract(DataExtractor Data, uint16_t Version, uint8_t AddressSize, - uint32_t Offset); + uint64_t Offset); bool isError() { return Error; } bool print(raw_ostream &OS, const DWARFExpression *Expr, const MCRegisterInfo *RegInfo, DWARFUnit *U, bool isEH); @@ -101,9 +101,9 @@ public: Operation> { friend class DWARFExpression; const DWARFExpression *Expr; - uint32_t Offset; + uint64_t Offset; Operation Op; - iterator(const DWARFExpression *Expr, uint32_t Offset) + iterator(const DWARFExpression *Expr, uint64_t Offset) : Expr(Expr), Offset(Offset) { Op.Error = Offset >= Expr->Data.getData().size() || diff --git a/include/llvm/DebugInfo/DWARF/DWARFFormValue.h b/include/llvm/DebugInfo/DWARF/DWARFFormValue.h index 731e71ed9eae..6fec6fcb6b34 100644 --- a/include/llvm/DebugInfo/DWARF/DWARFFormValue.h +++ b/include/llvm/DebugInfo/DWARF/DWARFFormValue.h @@ -70,7 +70,7 @@ public: static DWARFFormValue createFromBlockValue(dwarf::Form F, ArrayRef<uint8_t> D); static DWARFFormValue createFromUnit(dwarf::Form F, const DWARFUnit *Unit, - uint32_t *OffsetPtr); + uint64_t *OffsetPtr); dwarf::Form getForm() const { return Form; } uint64_t getRawUValue() const { return Value.uval; } @@ -87,12 +87,12 @@ public: /// in \p FormParams is needed to interpret some forms. The optional /// \p Context and \p Unit allows extracting information if the form refers /// to other sections (e.g., .debug_str). - bool extractValue(const DWARFDataExtractor &Data, uint32_t *OffsetPtr, + bool extractValue(const DWARFDataExtractor &Data, uint64_t *OffsetPtr, dwarf::FormParams FormParams, const DWARFContext *Context = nullptr, const DWARFUnit *Unit = nullptr); - bool extractValue(const DWARFDataExtractor &Data, uint32_t *OffsetPtr, + bool extractValue(const DWARFDataExtractor &Data, uint64_t *OffsetPtr, dwarf::FormParams FormParams, const DWARFUnit *U) { return extractValue(Data, OffsetPtr, FormParams, nullptr, U); } @@ -128,7 +128,7 @@ public: /// \param OffsetPtr A reference to the offset that will be updated. /// \param Params DWARF parameters to help interpret forms. /// \returns true on success, false if the form was not skipped. - bool skipValue(DataExtractor DebugInfoData, uint32_t *OffsetPtr, + bool skipValue(DataExtractor DebugInfoData, uint64_t *OffsetPtr, const dwarf::FormParams Params) const { return DWARFFormValue::skipValue(Form, DebugInfoData, OffsetPtr, Params); } @@ -144,7 +144,7 @@ public: /// \param FormParams DWARF parameters to help interpret forms. /// \returns true on success, false if the form was not skipped. static bool skipValue(dwarf::Form Form, DataExtractor DebugInfoData, - uint32_t *OffsetPtr, + uint64_t *OffsetPtr, const dwarf::FormParams FormParams); private: diff --git a/include/llvm/DebugInfo/DWARF/DWARFListTable.h b/include/llvm/DebugInfo/DWARF/DWARFListTable.h index a1ea69b040f0..496fdb2477f9 100644 --- a/include/llvm/DebugInfo/DWARF/DWARFListTable.h +++ b/include/llvm/DebugInfo/DWARF/DWARFListTable.h @@ -26,7 +26,7 @@ namespace llvm { /// entries. struct DWARFListEntryBase { /// The offset at which the entry is located in the section. - uint32_t Offset; + uint64_t Offset; /// The DWARF encoding (DW_RLE_* or DW_LLE_*). uint8_t EntryKind; /// The index of the section this entry belongs to. @@ -46,8 +46,8 @@ public: const ListEntries &getEntries() const { return Entries; } bool empty() const { return Entries.empty(); } void clear() { Entries.clear(); } - Error extract(DWARFDataExtractor Data, uint32_t HeaderOffset, uint32_t End, - uint32_t *OffsetPtr, StringRef SectionName, + Error extract(DWARFDataExtractor Data, uint64_t HeaderOffset, uint64_t End, + uint64_t *OffsetPtr, StringRef SectionName, StringRef ListStringName); }; @@ -57,7 +57,7 @@ class DWARFListTableHeader { struct Header { /// The total length of the entries for this table, not including the length /// field itself. - uint32_t Length = 0; + uint64_t Length = 0; /// The DWARF version number. uint16_t Version; /// The size in bytes of an address on the target architecture. For @@ -75,12 +75,12 @@ class DWARFListTableHeader { /// The offset table, which contains offsets to the individual list entries. /// It is used by forms such as DW_FORM_rnglistx. /// FIXME: Generate the table and use the appropriate forms. - std::vector<uint32_t> Offsets; + std::vector<uint64_t> Offsets; /// The table's format, either DWARF32 or DWARF64. dwarf::DwarfFormat Format; /// The offset at which the header (and hence the table) is located within /// its section. - uint32_t HeaderOffset; + uint64_t HeaderOffset; /// The name of the section the list is located in. StringRef SectionName; /// A characterization of the list for dumping purposes, e.g. "range" or @@ -95,28 +95,40 @@ public: HeaderData = {}; Offsets.clear(); } - uint32_t getHeaderOffset() const { return HeaderOffset; } + uint64_t getHeaderOffset() const { return HeaderOffset; } uint8_t getAddrSize() const { return HeaderData.AddrSize; } - uint32_t getLength() const { return HeaderData.Length; } + uint64_t getLength() const { return HeaderData.Length; } uint16_t getVersion() const { return HeaderData.Version; } StringRef getSectionName() const { return SectionName; } StringRef getListTypeString() const { return ListTypeString; } dwarf::DwarfFormat getFormat() const { return Format; } + /// Return the size of the table header including the length but not including + /// the offsets. + static uint8_t getHeaderSize(dwarf::DwarfFormat Format) { + switch (Format) { + case dwarf::DwarfFormat::DWARF32: + return 12; + case dwarf::DwarfFormat::DWARF64: + return 20; + } + llvm_unreachable("Invalid DWARF format (expected DWARF32 or DWARF64"); + } + void dump(raw_ostream &OS, DIDumpOptions DumpOpts = {}) const; - Optional<uint32_t> getOffsetEntry(uint32_t Index) const { + Optional<uint64_t> getOffsetEntry(uint32_t Index) const { if (Index < Offsets.size()) return Offsets[Index]; return None; } /// Extract the table header and the array of offsets. - Error extract(DWARFDataExtractor Data, uint32_t *OffsetPtr); + Error extract(DWARFDataExtractor Data, uint64_t *OffsetPtr); /// Returns the length of the table, including the length field, or 0 if the /// length has not been determined (e.g. because the table has not yet been /// parsed, or there was a problem in parsing). - uint32_t length() const; + uint64_t length() const; }; /// A class representing a table of lists as specified in the DWARF v5 @@ -128,7 +140,7 @@ template <typename DWARFListType> class DWARFListTableBase { DWARFListTableHeader Header; /// A mapping between file offsets and lists. It is used to find a particular /// list based on an offset (obtained from DW_AT_ranges, for example). - std::map<uint32_t, DWARFListType> ListMap; + std::map<uint64_t, DWARFListType> ListMap; /// This string is displayed as a heading before the list is dumped /// (e.g. "ranges:"). StringRef HeaderString; @@ -144,17 +156,18 @@ public: ListMap.clear(); } /// Extract the table header and the array of offsets. - Error extractHeaderAndOffsets(DWARFDataExtractor Data, uint32_t *OffsetPtr) { + Error extractHeaderAndOffsets(DWARFDataExtractor Data, uint64_t *OffsetPtr) { return Header.extract(Data, OffsetPtr); } /// Extract an entire table, including all list entries. - Error extract(DWARFDataExtractor Data, uint32_t *OffsetPtr); + Error extract(DWARFDataExtractor Data, uint64_t *OffsetPtr); /// Look up a list based on a given offset. Extract it and enter it into the /// list map if necessary. - Expected<DWARFListType> findList(DWARFDataExtractor Data, uint32_t Offset); + Expected<DWARFListType> findList(DWARFDataExtractor Data, uint64_t Offset); - uint32_t getHeaderOffset() const { return Header.getHeaderOffset(); } + uint64_t getHeaderOffset() const { return Header.getHeaderOffset(); } uint8_t getAddrSize() const { return Header.getAddrSize(); } + dwarf::DwarfFormat getFormat() const { return Header.getFormat(); } void dump(raw_ostream &OS, llvm::function_ref<Optional<object::SectionedAddress>(uint32_t)> @@ -162,37 +175,31 @@ public: DIDumpOptions DumpOpts = {}) const; /// Return the contents of the offset entry designated by a given index. - Optional<uint32_t> getOffsetEntry(uint32_t Index) const { + Optional<uint64_t> getOffsetEntry(uint32_t Index) const { return Header.getOffsetEntry(Index); } /// Return the size of the table header including the length but not including /// the offsets. This is dependent on the table format, which is unambiguously /// derived from parsing the table. uint8_t getHeaderSize() const { - switch (Header.getFormat()) { - case dwarf::DwarfFormat::DWARF32: - return 12; - case dwarf::DwarfFormat::DWARF64: - return 20; - } - llvm_unreachable("Invalid DWARF format (expected DWARF32 or DWARF64"); + return DWARFListTableHeader::getHeaderSize(getFormat()); } - uint32_t length() { return Header.length(); } + uint64_t length() { return Header.length(); } }; template <typename DWARFListType> Error DWARFListTableBase<DWARFListType>::extract(DWARFDataExtractor Data, - uint32_t *OffsetPtr) { + uint64_t *OffsetPtr) { clear(); if (Error E = extractHeaderAndOffsets(Data, OffsetPtr)) return E; Data.setAddressSize(Header.getAddrSize()); - uint32_t End = getHeaderOffset() + Header.length(); + uint64_t End = getHeaderOffset() + Header.length(); while (*OffsetPtr < End) { DWARFListType CurrentList; - uint32_t Off = *OffsetPtr; + uint64_t Off = *OffsetPtr; if (Error E = CurrentList.extract(Data, getHeaderOffset(), End, OffsetPtr, Header.getSectionName(), Header.getListTypeString())) @@ -208,13 +215,13 @@ Error DWARFListTableBase<DWARFListType>::extract(DWARFDataExtractor Data, template <typename ListEntryType> Error DWARFListType<ListEntryType>::extract(DWARFDataExtractor Data, - uint32_t HeaderOffset, uint32_t End, - uint32_t *OffsetPtr, + uint64_t HeaderOffset, uint64_t End, + uint64_t *OffsetPtr, StringRef SectionName, StringRef ListTypeString) { if (*OffsetPtr < HeaderOffset || *OffsetPtr >= End) return createStringError(errc::invalid_argument, - "invalid %s list offset 0x%" PRIx32, + "invalid %s list offset 0x%" PRIx64, ListTypeString.data(), *OffsetPtr); Entries.clear(); while (*OffsetPtr < End) { @@ -227,7 +234,7 @@ Error DWARFListType<ListEntryType>::extract(DWARFDataExtractor Data, } return createStringError(errc::illegal_byte_sequence, "no end of list marker detected at end of %s table " - "starting at offset 0x%" PRIx32, + "starting at offset 0x%" PRIx64, SectionName.data(), HeaderOffset); } @@ -261,15 +268,15 @@ void DWARFListTableBase<DWARFListType>::dump( template <typename DWARFListType> Expected<DWARFListType> DWARFListTableBase<DWARFListType>::findList(DWARFDataExtractor Data, - uint32_t Offset) { + uint64_t Offset) { auto Entry = ListMap.find(Offset); if (Entry != ListMap.end()) return Entry->second; // Extract the list from the section and enter it into the list map. DWARFListType List; - uint32_t End = getHeaderOffset() + Header.length(); - uint32_t StartingOffset = Offset; + uint64_t End = getHeaderOffset() + Header.length(); + uint64_t StartingOffset = Offset; if (Error E = List.extract(Data, getHeaderOffset(), End, &Offset, Header.getSectionName(), Header.getListTypeString())) diff --git a/include/llvm/DebugInfo/DWARF/DWARFObject.h b/include/llvm/DebugInfo/DWARF/DWARFObject.h index 1bba74a25d0e..88fe3f434edc 100644 --- a/include/llvm/DebugInfo/DWARF/DWARFObject.h +++ b/include/llvm/DebugInfo/DWARF/DWARFObject.h @@ -39,20 +39,20 @@ public: virtual StringRef getAbbrevSection() const { return ""; } virtual const DWARFSection &getLocSection() const { return Dummy; } virtual const DWARFSection &getLoclistsSection() const { return Dummy; } - virtual StringRef getARangeSection() const { return ""; } - virtual StringRef getDebugFrameSection() const { return ""; } - virtual StringRef getEHFrameSection() const { return ""; } + virtual StringRef getArangesSection() const { return ""; } + virtual const DWARFSection &getFrameSection() const { return Dummy; } + virtual const DWARFSection &getEHFrameSection() const { return Dummy; } virtual const DWARFSection &getLineSection() const { return Dummy; } - virtual StringRef getLineStringSection() const { return ""; } - virtual StringRef getStringSection() const { return ""; } - virtual const DWARFSection &getRangeSection() const { return Dummy; } + virtual StringRef getLineStrSection() const { return ""; } + virtual StringRef getStrSection() const { return ""; } + virtual const DWARFSection &getRangesSection() const { return Dummy; } virtual const DWARFSection &getRnglistsSection() const { return Dummy; } virtual StringRef getMacinfoSection() const { return ""; } - virtual const DWARFSection &getPubNamesSection() const { return Dummy; } - virtual const DWARFSection &getPubTypesSection() const { return Dummy; } - virtual const DWARFSection &getGnuPubNamesSection() const { return Dummy; } - virtual const DWARFSection &getGnuPubTypesSection() const { return Dummy; } - virtual const DWARFSection &getStringOffsetSection() const { return Dummy; } + virtual const DWARFSection &getPubnamesSection() const { return Dummy; } + virtual const DWARFSection &getPubtypesSection() const { return Dummy; } + virtual const DWARFSection &getGnuPubnamesSection() const { return Dummy; } + virtual const DWARFSection &getGnuPubtypesSection() const { return Dummy; } + virtual const DWARFSection &getStrOffsetsSection() const { return Dummy; } virtual void forEachInfoDWOSections(function_ref<void(const DWARFSection &)> F) const {} virtual void @@ -60,11 +60,11 @@ public: virtual StringRef getAbbrevDWOSection() const { return ""; } virtual const DWARFSection &getLineDWOSection() const { return Dummy; } virtual const DWARFSection &getLocDWOSection() const { return Dummy; } - virtual StringRef getStringDWOSection() const { return ""; } - virtual const DWARFSection &getStringOffsetDWOSection() const { + virtual StringRef getStrDWOSection() const { return ""; } + virtual const DWARFSection &getStrOffsetsDWOSection() const { return Dummy; } - virtual const DWARFSection &getRangeDWOSection() const { return Dummy; } + virtual const DWARFSection &getRangesDWOSection() const { return Dummy; } virtual const DWARFSection &getRnglistsDWOSection() const { return Dummy; } virtual const DWARFSection &getAddrSection() const { return Dummy; } virtual const DWARFSection &getAppleNamesSection() const { return Dummy; } @@ -72,7 +72,7 @@ public: virtual const DWARFSection &getAppleNamespacesSection() const { return Dummy; } - virtual const DWARFSection &getDebugNamesSection() const { return Dummy; } + virtual const DWARFSection &getNamesSection() const { return Dummy; } virtual const DWARFSection &getAppleObjCSection() const { return Dummy; } virtual StringRef getCUIndexSection() const { return ""; } virtual StringRef getGdbIndexSection() const { return ""; } diff --git a/include/llvm/DebugInfo/DWARF/DWARFTypeUnit.h b/include/llvm/DebugInfo/DWARF/DWARFTypeUnit.h index 90d89375fd35..c95bdcbd8a43 100644 --- a/include/llvm/DebugInfo/DWARF/DWARFTypeUnit.h +++ b/include/llvm/DebugInfo/DWARF/DWARFTypeUnit.h @@ -34,7 +34,7 @@ public: LS, LE, IsDWO, UnitVector) {} uint64_t getTypeHash() const { return getHeader().getTypeHash(); } - uint32_t getTypeOffset() const { return getHeader().getTypeOffset(); } + uint64_t getTypeOffset() const { return getHeader().getTypeOffset(); } void dump(raw_ostream &OS, DIDumpOptions DumpOpts = {}) override; // Enable LLVM-style RTTI. diff --git a/include/llvm/DebugInfo/DWARF/DWARFUnit.h b/include/llvm/DebugInfo/DWARF/DWARFUnit.h index f9f90db31890..51de114a3506 100644 --- a/include/llvm/DebugInfo/DWARF/DWARFUnit.h +++ b/include/llvm/DebugInfo/DWARF/DWARFUnit.h @@ -45,7 +45,7 @@ class DWARFUnit; /// parse the header before deciding what specific kind of unit to construct. class DWARFUnitHeader { // Offset within section. - uint32_t Offset = 0; + uint64_t Offset = 0; // Version, address size, and DWARF format. dwarf::FormParams FormParams; uint64_t Length = 0; @@ -56,7 +56,7 @@ class DWARFUnitHeader { // For type units only. uint64_t TypeHash = 0; - uint32_t TypeOffset = 0; + uint64_t TypeOffset = 0; // For v5 split or skeleton compile units only. Optional<uint64_t> DWOId; @@ -70,10 +70,10 @@ class DWARFUnitHeader { public: /// Parse a unit header from \p debug_info starting at \p offset_ptr. bool extract(DWARFContext &Context, const DWARFDataExtractor &debug_info, - uint32_t *offset_ptr, DWARFSectionKind Kind = DW_SECT_INFO, + uint64_t *offset_ptr, DWARFSectionKind Kind = DW_SECT_INFO, const DWARFUnitIndex *Index = nullptr, const DWARFUnitIndex::Entry *Entry = nullptr); - uint32_t getOffset() const { return Offset; } + uint64_t getOffset() const { return Offset; } const dwarf::FormParams &getFormParams() const { return FormParams; } uint16_t getVersion() const { return FormParams.Version; } dwarf::DwarfFormat getFormat() const { return FormParams.Format; } @@ -91,16 +91,17 @@ public: } const DWARFUnitIndex::Entry *getIndexEntry() const { return IndexEntry; } uint64_t getTypeHash() const { return TypeHash; } - uint32_t getTypeOffset() const { return TypeOffset; } + uint64_t getTypeOffset() const { return TypeOffset; } uint8_t getUnitType() const { return UnitType; } bool isTypeUnit() const { return UnitType == dwarf::DW_UT_type || UnitType == dwarf::DW_UT_split_type; } uint8_t getSize() const { return Size; } - uint32_t getNextUnitOffset() const { - return Offset + Length + - (FormParams.Format == llvm::dwarf::DwarfFormat::DWARF64 ? 4 : 0) + - FormParams.getDwarfOffsetByteSize(); + uint8_t getUnitLengthFieldByteSize() const { + return dwarf::getUnitLengthFieldByteSize(FormParams.Format); + } + uint64_t getNextUnitOffset() const { + return Offset + Length + getUnitLengthFieldByteSize(); } }; @@ -110,7 +111,7 @@ const DWARFUnitIndex &getDWARFUnitIndex(DWARFContext &Context, /// Describe a collection of units. Intended to hold all units either from /// .debug_info and .debug_types, or from .debug_info.dwo and .debug_types.dwo. class DWARFUnitVector final : public SmallVector<std::unique_ptr<DWARFUnit>, 1> { - std::function<std::unique_ptr<DWARFUnit>(uint32_t, DWARFSectionKind, + std::function<std::unique_ptr<DWARFUnit>(uint64_t, DWARFSectionKind, const DWARFSection *, const DWARFUnitIndex::Entry *)> Parser; @@ -121,7 +122,7 @@ public: using iterator = typename UnitVector::iterator; using iterator_range = llvm::iterator_range<typename UnitVector::iterator>; - DWARFUnit *getUnitForOffset(uint32_t Offset) const; + DWARFUnit *getUnitForOffset(uint64_t Offset) const; DWARFUnit *getUnitForIndexEntry(const DWARFUnitIndex::Entry &E); /// Read units from a .debug_info or .debug_types section. Calls made @@ -197,7 +198,7 @@ class DWARFUnit { DWARFUnitHeader Header; const DWARFDebugAbbrev *Abbrev; const DWARFSection *RangeSection; - uint32_t RangeSectionBase; + uint64_t RangeSectionBase; /// We either keep track of the location list section or its data, depending /// on whether we are handling a split DWARF section or not. union { @@ -275,7 +276,7 @@ public: const DWARFSection &getInfoSection() const { return InfoSection; } const DWARFSection *getLocSection() const { return LocSection; } StringRef getLocSectionData() const { return LocSectionData; } - uint32_t getOffset() const { return Header.getOffset(); } + uint64_t getOffset() const { return Header.getOffset(); } const dwarf::FormParams &getFormParams() const { return Header.getFormParams(); } @@ -285,10 +286,10 @@ public: uint8_t getDwarfOffsetByteSize() const { return Header.getDwarfOffsetByteSize(); } - uint32_t getLength() const { return Header.getLength(); } + uint64_t getLength() const { return Header.getLength(); } uint8_t getUnitType() const { return Header.getUnitType(); } bool isTypeUnit() const { return Header.isTypeUnit(); } - uint32_t getNextUnitOffset() const { return Header.getNextUnitOffset(); } + uint64_t getNextUnitOffset() const { return Header.getNextUnitOffset(); } const DWARFSection &getLineSection() const { return LineSection; } StringRef getStringSection() const { return StringSection; } const DWARFSection &getStringOffsetSection() const { @@ -303,7 +304,7 @@ public: /// Recursively update address to Die map. void updateAddressDieMap(DWARFDie Die); - void setRangesSection(const DWARFSection *RS, uint32_t Base) { + void setRangesSection(const DWARFSection *RS, uint64_t Base) { RangeSection = RS; RangeSectionBase = Base; } @@ -322,7 +323,7 @@ public: /// .debug_ranges section. If the extraction is unsuccessful, an error /// is returned. Successful extraction requires that the compile unit /// has already been extracted. - Error extractRangeList(uint32_t RangeListOffset, + Error extractRangeList(uint64_t RangeListOffset, DWARFDebugRangeList &RangeList) const; void clear(); @@ -405,7 +406,7 @@ public: /// Return a vector of address ranges resulting from a (possibly encoded) /// range list starting at a given offset in the appropriate ranges section. - Expected<DWARFAddressRangesVector> findRnglistFromOffset(uint32_t Offset); + Expected<DWARFAddressRangesVector> findRnglistFromOffset(uint64_t Offset); /// Return a vector of address ranges retrieved from an encoded range /// list whose offset is found via a table lookup given an index (DWARF v5 @@ -415,7 +416,7 @@ public: /// Return a rangelist's offset based on an index. The index designates /// an entry in the rangelist table's offset array and is supplied by /// DW_FORM_rnglistx. - Optional<uint32_t> getRnglistOffset(uint32_t Index) { + Optional<uint64_t> getRnglistOffset(uint32_t Index) { if (RngListTable) return RngListTable->getOffsetEntry(Index); return None; @@ -470,7 +471,7 @@ public: /// unit's DIE vector. /// /// The unit needs to have its DIEs extracted for this method to work. - DWARFDie getDIEForOffset(uint32_t Offset) { + DWARFDie getDIEForOffset(uint64_t Offset) { extractDIEsIfNeeded(false); assert(!DieArray.empty()); auto It = @@ -495,15 +496,19 @@ public: } virtual void dump(raw_ostream &OS, DIDumpOptions DumpOpts) = 0; + + Error tryExtractDIEsIfNeeded(bool CUDieOnly); + private: /// Size in bytes of the .debug_info data associated with this compile unit. size_t getDebugInfoSize() const { - return Header.getLength() + 4 - getHeaderSize(); + return Header.getLength() + Header.getUnitLengthFieldByteSize() - + getHeaderSize(); } /// extractDIEsIfNeeded - Parses a compile unit and indexes its DIEs if it - /// hasn't already been done. Returns the number of DIEs parsed at this call. - size_t extractDIEsIfNeeded(bool CUDieOnly); + /// hasn't already been done + void extractDIEsIfNeeded(bool CUDieOnly); /// extractDIEsToVector - Appends all parsed DIEs to a vector. void extractDIEsToVector(bool AppendCUDie, bool AppendNonCUDIEs, diff --git a/include/llvm/DebugInfo/DWARF/DWARFUnitIndex.h b/include/llvm/DebugInfo/DWARF/DWARFUnitIndex.h index fc8c707c512e..684103aac2fc 100644 --- a/include/llvm/DebugInfo/DWARF/DWARFUnitIndex.h +++ b/include/llvm/DebugInfo/DWARF/DWARFUnitIndex.h @@ -37,7 +37,7 @@ class DWARFUnitIndex { uint32_t NumUnits; uint32_t NumBuckets = 0; - bool parse(DataExtractor IndexData, uint32_t *OffsetPtr); + bool parse(DataExtractor IndexData, uint64_t *OffsetPtr); void dump(raw_ostream &OS) const; }; diff --git a/include/llvm/DebugInfo/DWARF/DWARFVerifier.h b/include/llvm/DebugInfo/DWARF/DWARFVerifier.h index f1268f220272..a4a3a11d441b 100644 --- a/include/llvm/DebugInfo/DWARF/DWARFVerifier.h +++ b/include/llvm/DebugInfo/DWARF/DWARFVerifier.h @@ -94,7 +94,7 @@ private: /// A map that tracks all references (converted absolute references) so we /// can verify each reference points to a valid DIE and not an offset that /// lies between to valid DIEs. - std::map<uint64_t, std::set<uint32_t>> ReferenceToDIEOffsets; + std::map<uint64_t, std::set<uint64_t>> ReferenceToDIEOffsets; uint32_t NumDebugLineErrors = 0; // Used to relax some checks that do not currently work portably bool IsObjectFile; @@ -138,7 +138,7 @@ private: /// /// \returns true if the header is verified successfully, false otherwise. bool verifyUnitHeader(const DWARFDataExtractor DebugInfoData, - uint32_t *Offset, unsigned UnitIndex, uint8_t &UnitType, + uint64_t *Offset, unsigned UnitIndex, uint8_t &UnitType, bool &isUnitDWARF64); /// Verifies the header of a unit in a .debug_info or .debug_types section. |