Index: llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h =================================================================== --- llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h +++ llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h @@ -130,11 +130,11 @@ /// \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 getAttributeValue(const uint32_t DIEOffset, + Optional 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 Index: llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h =================================================================== --- llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h +++ llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h @@ -96,7 +96,7 @@ using AtomType = uint16_t; using Form = dwarf::Form; - uint32_t DIEOffsetBase; + uint64_t DIEOffsetBase; SmallVector, 3> Atoms; Optional extractOffset(Optional Value) const; @@ -109,7 +109,7 @@ /// 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 &AtomForms, - uint32_t *DataOffset) const; + uint64_t *DataOffset) const; public: /// Apple-specific implementation of an Accelerator Entry. @@ -119,7 +119,7 @@ Entry(const HeaderData &Data); Entry() = default; - void extract(const AppleAcceleratorTable &AccelTable, uint32_t *Offset); + void extract(const AppleAcceleratorTable &AccelTable, uint64_t *Offset); public: Optional getCUOffset() const override; @@ -143,7 +143,7 @@ class ValueIterator : public std::iterator { 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 @@ 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 @@ /// 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 readAtoms(uint32_t &HashDataOffset); + std::pair 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 @@ 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 @@ 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 @@ 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 @@ // 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 Hash) const; void dumpBucket(ScopedPrinter &W, uint32_t Bucket) const; - Expected extractAttributeEncoding(uint32_t *Offset); + Expected extractAttributeEncoding(uint64_t *Offset); Expected> - extractAttributeEncodings(uint32_t *Offset); + extractAttributeEncodings(uint64_t *Offset); - Expected extractAbbrev(uint32_t *Offset); + Expected 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,6 +451,10 @@ return Abbrevs; } + Expected getEntry(uint64_t *Offset) const; + + // A temporarily method to preserve compatibility with existing code. + // Will be removed when the migration to 64-bit offsets is finished. Expected getEntry(uint32_t *Offset) const; /// Look up all entries in this Name Index matching \c Key. @@ -460,8 +464,8 @@ 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 +483,12 @@ bool IsLocal; Optional 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 Hash; ///< Hash of Key, if it has been computed. bool getEntryAtCurrentOffset(); - Optional findEntryOffsetInCurrentIndex(); + Optional findEntryOffsetInCurrentIndex(); bool findInCurrentIndex(); void searchFromStartOfCurrentIndex(); void next(); @@ -572,7 +576,7 @@ private: SmallVector NameIndices; - DenseMap CUToNameIndex; + DenseMap CUToNameIndex; public: DWARFDebugNames(const DWARFDataExtractor &AccelSection, @@ -591,7 +595,7 @@ /// 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 Index: llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFAttribute.h =================================================================== --- llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFAttribute.h +++ llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFAttribute.h @@ -23,7 +23,7 @@ /// 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. Index: llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFContext.h =================================================================== --- llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFContext.h +++ llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFContext.h @@ -225,10 +225,10 @@ 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 Index: llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h =================================================================== --- llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h +++ llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h @@ -20,7 +20,7 @@ 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 @@ 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; Index: llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDebugAddr.h =================================================================== --- llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDebugAddr.h +++ llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDebugAddr.h @@ -45,7 +45,7 @@ private: dwarf::DwarfFormat Format; - uint32_t HeaderOffset; + uint64_t HeaderOffset; Header HeaderData; uint32_t DataSize = 0; std::vector Addrs; @@ -54,11 +54,11 @@ 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 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; Index: llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDebugArangeSet.h =================================================================== --- llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDebugArangeSet.h +++ llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDebugArangeSet.h @@ -49,7 +49,7 @@ using DescriptorColl = std::vector; using desc_iterator_range = iterator_range; - uint32_t Offset; + uint64_t Offset; Header HeaderData; DescriptorColl ArangeDescriptors; @@ -57,7 +57,7 @@ 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; } Index: llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDebugAranges.h =================================================================== --- llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDebugAranges.h +++ llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDebugAranges.h @@ -28,7 +28,7 @@ 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 @@ 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 @@ std::vector Endpoints; RangeColl Aranges; - DenseSet ParsedCUOffsets; + DenseSet ParsedCUOffsets; }; } // end namespace llvm Index: llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDebugFrame.h =================================================================== --- llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDebugFrame.h +++ llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDebugFrame.h @@ -69,7 +69,7 @@ /// 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(DWARFDataExtractor 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; Index: llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDebugInfoEntry.h =================================================================== --- llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDebugInfoEntry.h +++ llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDebugInfoEntry.h @@ -22,7 +22,7 @@ /// 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 @@ /// 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 { Index: llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDebugLine.h =================================================================== --- llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDebugLine.h +++ llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDebugLine.h @@ -134,7 +134,7 @@ 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 +278,7 @@ /// 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 RecoverableErrorCallback, raw_ostream *OS = nullptr); @@ -305,9 +305,9 @@ std::vector &Result) const; }; - const LineTable *getLineTable(uint32_t Offset) const; + const LineTable *getLineTable(uint64_t Offset) const; Expected getOrParseLineTable( - DWARFDataExtractor &DebugLineData, uint32_t Offset, + DWARFDataExtractor &DebugLineData, uint64_t Offset, const DWARFContext &Ctx, const DWARFUnit *U, std::function RecoverableErrorCallback); @@ -350,17 +350,17 @@ 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 +377,7 @@ struct Sequence Sequence; }; - using LineTableMapTy = std::map; + using LineTableMapTy = std::map; using LineTableIter = LineTableMapTy::iterator; using LineTableConstIter = LineTableMapTy::const_iterator; Index: llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDebugLoc.h =================================================================== --- llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDebugLoc.h +++ llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDebugLoc.h @@ -36,7 +36,7 @@ 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 Entries; /// Dump this list on OS. @@ -69,7 +69,7 @@ LocationList const *getLocationListAtOffset(uint64_t Offset) const; Optional parseOneLocationList(DWARFDataExtractor Data, - uint32_t *Offset); + uint64_t *Offset); }; class DWARFDebugLoclists { @@ -82,7 +82,7 @@ }; struct LocationList { - unsigned Offset; + uint64_t Offset; SmallVector Entries; void dump(raw_ostream &OS, uint64_t BaseAddr, bool IsLittleEndian, unsigned AddressSize, const MCRegisterInfo *RegInfo, @@ -107,7 +107,7 @@ LocationList const *getLocationListAtOffset(uint64_t Offset) const; static Optional - parseOneLocationList(DataExtractor Data, unsigned *Offset, unsigned Version); + parseOneLocationList(DataExtractor Data, uint64_t *Offset, unsigned Version); }; } // end namespace llvm Index: llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDebugPubTable.h =================================================================== --- llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDebugPubTable.h +++ llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDebugPubTable.h @@ -25,7 +25,7 @@ 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 @@ /// 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. Index: llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDebugRangeList.h =================================================================== --- llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDebugRangeList.h +++ llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDebugRangeList.h @@ -60,7 +60,7 @@ private: /// Offset in .debug_ranges section. - uint32_t Offset; + uint64_t Offset; uint8_t AddressSize; std::vector Entries; @@ -69,7 +69,7 @@ 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 &getEntries() { return Entries; } /// getAbsoluteRanges - Returns absolute address ranges defined by this range Index: llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDebugRnglists.h =================================================================== --- llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDebugRnglists.h +++ llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDebugRnglists.h @@ -34,7 +34,7 @@ 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(uint32_t)> Index: llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDie.h =================================================================== --- llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDie.h +++ llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDie.h @@ -63,7 +63,7 @@ /// 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(); } Index: llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFExpression.h =================================================================== --- llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFExpression.h +++ llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFExpression.h @@ -77,18 +77,18 @@ uint8_t Opcode; ///< The Op Opcode, DW_OP_. 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 @@ 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() || Index: llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFListTable.h =================================================================== --- llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFListTable.h +++ llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFListTable.h @@ -26,7 +26,7 @@ /// 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 @@ 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); }; @@ -80,7 +80,7 @@ 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,7 +95,7 @@ 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; } uint16_t getVersion() const { return HeaderData.Version; } @@ -111,7 +111,7 @@ } /// 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 @@ -128,7 +128,7 @@ 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 ListMap; + std::map ListMap; /// This string is displayed as a heading before the list is dumped /// (e.g. "ranges:"). StringRef HeaderString; @@ -144,16 +144,16 @@ 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 findList(DWARFDataExtractor Data, uint32_t Offset); + Expected 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(); } void dump(raw_ostream &OS, @@ -183,16 +183,16 @@ template Error DWARFListTableBase::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 +208,13 @@ template Error DWARFListType::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 +227,7 @@ } 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 +261,15 @@ template Expected DWARFListTableBase::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())) Index: llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFUnit.h =================================================================== --- llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFUnit.h +++ llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFUnit.h @@ -45,7 +45,7 @@ /// 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; @@ -70,10 +70,10 @@ 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; } @@ -97,7 +97,7 @@ return UnitType == dwarf::DW_UT_type || UnitType == dwarf::DW_UT_split_type; } uint8_t getSize() const { return Size; } - uint32_t getNextUnitOffset() const { + uint64_t getNextUnitOffset() const { return Offset + Length + (FormParams.Format == llvm::dwarf::DwarfFormat::DWARF64 ? 4 : 0) + FormParams.getDwarfOffsetByteSize(); @@ -110,7 +110,7 @@ /// 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, 1> { - std::function(uint32_t, DWARFSectionKind, + std::function(uint64_t, DWARFSectionKind, const DWARFSection *, const DWARFUnitIndex::Entry *)> Parser; @@ -121,7 +121,7 @@ using iterator = typename UnitVector::iterator; using iterator_range = llvm::iterator_range; - 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 @@ -275,7 +275,7 @@ 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(); } @@ -288,7 +288,7 @@ uint32_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 { @@ -322,7 +322,7 @@ /// .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 +405,7 @@ /// Return a vector of address ranges resulting from a (possibly encoded) /// range list starting at a given offset in the appropriate ranges section. - Expected findRnglistFromOffset(uint32_t Offset); + Expected 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 @@ -470,7 +470,7 @@ /// 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 = Index: llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFUnitIndex.h =================================================================== --- llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFUnitIndex.h +++ llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFUnitIndex.h @@ -37,7 +37,7 @@ 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; }; Index: llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFVerifier.h =================================================================== --- llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFVerifier.h +++ llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFVerifier.h @@ -94,7 +94,7 @@ /// 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> ReferenceToDIEOffsets; + std::map> ReferenceToDIEOffsets; uint32_t NumDebugLineErrors = 0; // Used to relax some checks that do not currently work portably bool IsObjectFile; @@ -138,7 +138,7 @@ /// /// \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. Index: llvm/trunk/include/llvm/XRay/FDRRecordProducer.h =================================================================== --- llvm/trunk/include/llvm/XRay/FDRRecordProducer.h +++ llvm/trunk/include/llvm/XRay/FDRRecordProducer.h @@ -27,7 +27,7 @@ class FileBasedRecordProducer : public RecordProducer { const XRayFileHeader &Header; DataExtractor &E; - uint32_t &OffsetPtr; + uint64_t &OffsetPtr; uint32_t CurrentBufferBytes = 0; // Helper function which gets the next record by speculatively reading through @@ -36,7 +36,7 @@ public: FileBasedRecordProducer(const XRayFileHeader &FH, DataExtractor &DE, - uint32_t &OP) + uint64_t &OP) : Header(FH), E(DE), OffsetPtr(OP) {} /// This producer encapsulates the logic for loading a File-backed Index: llvm/trunk/include/llvm/XRay/FDRRecords.h =================================================================== --- llvm/trunk/include/llvm/XRay/FDRRecords.h +++ llvm/trunk/include/llvm/XRay/FDRRecords.h @@ -417,16 +417,16 @@ class RecordInitializer : public RecordVisitor { DataExtractor &E; - uint32_t &OffsetPtr; + uint64_t &OffsetPtr; uint16_t Version; public: static constexpr uint16_t DefaultVersion = 5u; - explicit RecordInitializer(DataExtractor &DE, uint32_t &OP, uint16_t V) + explicit RecordInitializer(DataExtractor &DE, uint64_t &OP, uint16_t V) : RecordVisitor(), E(DE), OffsetPtr(OP), Version(V) {} - explicit RecordInitializer(DataExtractor &DE, uint32_t &OP) + explicit RecordInitializer(DataExtractor &DE, uint64_t &OP) : RecordInitializer(DE, OP, DefaultVersion) {} Error visit(BufferExtents &) override; Index: llvm/trunk/include/llvm/XRay/FileHeaderReader.h =================================================================== --- llvm/trunk/include/llvm/XRay/FileHeaderReader.h +++ llvm/trunk/include/llvm/XRay/FileHeaderReader.h @@ -24,7 +24,7 @@ /// Convenience function for loading the file header given a data extractor at a /// specified offset. Expected readBinaryFormatHeader(DataExtractor &HeaderExtractor, - uint32_t &OffsetPtr); + uint64_t &OffsetPtr); } // namespace xray } // namespace llvm Index: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp =================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -2151,7 +2151,7 @@ DWARFExpression Expr(Data, getDwarfVersion(), PtrSize); using Encoding = DWARFExpression::Operation::Encoding; - uint32_t Offset = 0; + uint64_t Offset = 0; for (auto &Op : Expr) { assert(Op.getCode() != dwarf::DW_OP_const_type && "3 operand ops not yet supported"); @@ -2174,7 +2174,7 @@ if (Comment != End) Comment++; } else { - for (uint32_t J = Offset; J < Op.getOperandEndOffset(I); ++J) + for (uint64_t J = Offset; J < Op.getOperandEndOffset(I); ++J) Streamer.EmitInt8(Data.getData()[J], Comment != End ? *(Comment++) : ""); } Offset = Op.getOperandEndOffset(I); Index: llvm/trunk/lib/DebugInfo/DWARF/DWARFAbbreviationDeclaration.cpp =================================================================== --- llvm/trunk/lib/DebugInfo/DWARF/DWARFAbbreviationDeclaration.cpp +++ llvm/trunk/lib/DebugInfo/DWARF/DWARFAbbreviationDeclaration.cpp @@ -38,9 +38,9 @@ bool DWARFAbbreviationDeclaration::extract(DataExtractor Data, - uint32_t* OffsetPtr) { + uint64_t* OffsetPtr) { clear(); - const uint32_t Offset = *OffsetPtr; + const uint64_t Offset = *OffsetPtr; Code = Data.getULEB128(OffsetPtr); if (Code == 0) { return false; @@ -148,7 +148,7 @@ } Optional DWARFAbbreviationDeclaration::getAttributeValue( - const uint32_t DIEOffset, const dwarf::Attribute Attr, + const uint64_t DIEOffset, const dwarf::Attribute Attr, const DWARFUnit &U) const { Optional MatchAttrIndex = findAttributeIndex(Attr); if (!MatchAttrIndex) @@ -158,7 +158,7 @@ // Add the byte size of ULEB that for the abbrev Code so we can start // skipping the attribute data. - uint32_t Offset = DIEOffset + CodeByteSize; + uint64_t Offset = DIEOffset + CodeByteSize; uint32_t AttrIndex = 0; for (const auto &Spec : AttributeSpecs) { if (*MatchAttrIndex == AttrIndex) { Index: llvm/trunk/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp =================================================================== --- llvm/trunk/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp +++ llvm/trunk/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp @@ -42,7 +42,7 @@ DWARFAcceleratorTable::~DWARFAcceleratorTable() = default; Error AppleAcceleratorTable::extract() { - uint32_t Offset = 0; + uint64_t Offset = 0; // Check that we can at least read the header. if (!AccelSection.isValidOffset(offsetof(Header, HeaderDataLength) + 4)) @@ -111,15 +111,15 @@ return true; } -std::pair -AppleAcceleratorTable::readAtoms(uint32_t &HashDataOffset) { - uint32_t DieOffset = dwarf::DW_INVALID_OFFSET; +std::pair +AppleAcceleratorTable::readAtoms(uint64_t *HashDataOffset) { + uint64_t DieOffset = dwarf::DW_INVALID_OFFSET; dwarf::Tag DieTag = dwarf::DW_TAG_null; dwarf::FormParams FormParams = {Hdr.Version, 0, dwarf::DwarfFormat::DWARF32}; for (auto Atom : getAtomsDesc()) { DWARFFormValue FormValue(Atom.second); - FormValue.extractValue(AccelSection, &HashDataOffset, FormParams); + FormValue.extractValue(AccelSection, HashDataOffset, FormParams); switch (Atom.first) { case dwarf::DW_ATOM_die_offset: DieOffset = *FormValue.getAsUnsignedConstant(); @@ -163,19 +163,19 @@ bool AppleAcceleratorTable::dumpName(ScopedPrinter &W, SmallVectorImpl &AtomForms, - uint32_t *DataOffset) const { + uint64_t *DataOffset) const { dwarf::FormParams FormParams = {Hdr.Version, 0, dwarf::DwarfFormat::DWARF32}; - uint32_t NameOffset = *DataOffset; + uint64_t NameOffset = *DataOffset; if (!AccelSection.isValidOffsetForDataOfSize(*DataOffset, 4)) { W.printString("Incorrectly terminated list."); return false; } - unsigned StringOffset = AccelSection.getRelocatedValue(4, DataOffset); + uint64_t StringOffset = AccelSection.getRelocatedValue(4, DataOffset); if (!StringOffset) return false; // End of list DictScope NameScope(W, ("Name@0x" + Twine::utohexstr(NameOffset)).str()); - W.startLine() << format("String: 0x%08x", StringOffset); + W.startLine() << format("String: 0x%08" PRIx64, StringOffset); W.getOStream() << " \"" << StringSection.getCStr(&StringOffset) << "\"\n"; unsigned NumData = AccelSection.getU32(DataOffset); @@ -223,9 +223,9 @@ } // Now go through the actual tables and dump them. - uint32_t Offset = sizeof(Hdr) + Hdr.HeaderDataLength; - unsigned HashesBase = Offset + Hdr.BucketCount * 4; - unsigned OffsetsBase = HashesBase + Hdr.HashCount * 4; + uint64_t Offset = sizeof(Hdr) + Hdr.HeaderDataLength; + uint64_t HashesBase = Offset + Hdr.BucketCount * 4; + uint64_t OffsetsBase = HashesBase + Hdr.HashCount * 4; for (unsigned Bucket = 0; Bucket < Hdr.BucketCount; ++Bucket) { unsigned Index = AccelSection.getU32(&Offset); @@ -237,14 +237,14 @@ } for (unsigned HashIdx = Index; HashIdx < Hdr.HashCount; ++HashIdx) { - unsigned HashOffset = HashesBase + HashIdx*4; - unsigned OffsetsOffset = OffsetsBase + HashIdx*4; + uint64_t HashOffset = HashesBase + HashIdx*4; + uint64_t OffsetsOffset = OffsetsBase + HashIdx*4; uint32_t Hash = AccelSection.getU32(&HashOffset); if (Hash % Hdr.BucketCount != Bucket) break; - unsigned DataOffset = AccelSection.getU32(&OffsetsOffset); + uint64_t DataOffset = AccelSection.getU32(&OffsetsOffset); ListScope HashScope(W, ("Hash 0x" + Twine::utohexstr(Hash)).str()); if (!AccelSection.isValidOffset(DataOffset)) { W.printString("Invalid section offset"); @@ -265,7 +265,7 @@ } void AppleAcceleratorTable::Entry::extract( - const AppleAcceleratorTable &AccelTable, uint32_t *Offset) { + const AppleAcceleratorTable &AccelTable, uint64_t *Offset) { dwarf::FormParams FormParams = {AccelTable.Hdr.Version, 0, dwarf::DwarfFormat::DWARF32}; @@ -302,7 +302,7 @@ } AppleAcceleratorTable::ValueIterator::ValueIterator( - const AppleAcceleratorTable &AccelTable, unsigned Offset) + const AppleAcceleratorTable &AccelTable, uint64_t Offset) : AccelTable(&AccelTable), Current(AccelTable.HdrData), DataOffset(Offset) { if (!AccelTable.AccelSection.isValidOffsetForDataOfSize(DataOffset, 4)) return; @@ -333,25 +333,25 @@ // Find the bucket. unsigned HashValue = djbHash(Key); unsigned Bucket = HashValue % Hdr.BucketCount; - unsigned BucketBase = sizeof(Hdr) + Hdr.HeaderDataLength; - unsigned HashesBase = BucketBase + Hdr.BucketCount * 4; - unsigned OffsetsBase = HashesBase + Hdr.HashCount * 4; + uint64_t BucketBase = sizeof(Hdr) + Hdr.HeaderDataLength; + uint64_t HashesBase = BucketBase + Hdr.BucketCount * 4; + uint64_t OffsetsBase = HashesBase + Hdr.HashCount * 4; - unsigned BucketOffset = BucketBase + Bucket * 4; + uint64_t BucketOffset = BucketBase + Bucket * 4; unsigned Index = AccelSection.getU32(&BucketOffset); // Search through all hashes in the bucket. for (unsigned HashIdx = Index; HashIdx < Hdr.HashCount; ++HashIdx) { - unsigned HashOffset = HashesBase + HashIdx * 4; - unsigned OffsetsOffset = OffsetsBase + HashIdx * 4; + uint64_t HashOffset = HashesBase + HashIdx * 4; + uint64_t OffsetsOffset = OffsetsBase + HashIdx * 4; uint32_t Hash = AccelSection.getU32(&HashOffset); if (Hash % Hdr.BucketCount != Bucket) // We are already in the next bucket. break; - unsigned DataOffset = AccelSection.getU32(&OffsetsOffset); - unsigned StringOffset = AccelSection.getRelocatedValue(4, &DataOffset); + uint64_t DataOffset = AccelSection.getU32(&OffsetsOffset); + uint64_t StringOffset = AccelSection.getRelocatedValue(4, &DataOffset); if (!StringOffset) break; @@ -377,7 +377,7 @@ } Error DWARFDebugNames::Header::extract(const DWARFDataExtractor &AS, - uint32_t *Offset) { + uint64_t *Offset) { // Check that we can read the fixed-size part. if (!AS.isValidOffset(*Offset + sizeof(HeaderPOD) - 1)) return createStringError(errc::illegal_byte_sequence, @@ -437,7 +437,7 @@ } Expected -DWARFDebugNames::NameIndex::extractAttributeEncoding(uint32_t *Offset) { +DWARFDebugNames::NameIndex::extractAttributeEncoding(uint64_t *Offset) { if (*Offset >= EntriesBase) { return createStringError(errc::illegal_byte_sequence, "Incorrectly terminated abbreviation table."); @@ -449,7 +449,7 @@ } Expected> -DWARFDebugNames::NameIndex::extractAttributeEncodings(uint32_t *Offset) { +DWARFDebugNames::NameIndex::extractAttributeEncodings(uint64_t *Offset) { std::vector Result; for (;;) { auto AttrEncOr = extractAttributeEncoding(Offset); @@ -463,7 +463,7 @@ } Expected -DWARFDebugNames::NameIndex::extractAbbrev(uint32_t *Offset) { +DWARFDebugNames::NameIndex::extractAbbrev(uint64_t *Offset) { if (*Offset >= EntriesBase) { return createStringError(errc::illegal_byte_sequence, "Incorrectly terminated abbreviation table."); @@ -482,7 +482,7 @@ Error DWARFDebugNames::NameIndex::extract() { const DWARFDataExtractor &AS = Section.AccelSection; - uint32_t Offset = Base; + uint64_t Offset = Base; if (Error E = Hdr.extract(AS, &Offset)) return E; @@ -577,27 +577,27 @@ return inconvertibleErrorCode(); } -uint32_t DWARFDebugNames::NameIndex::getCUOffset(uint32_t CU) const { +uint64_t DWARFDebugNames::NameIndex::getCUOffset(uint32_t CU) const { assert(CU < Hdr.CompUnitCount); - uint32_t Offset = CUsBase + 4 * CU; + uint64_t Offset = CUsBase + 4 * CU; return Section.AccelSection.getRelocatedValue(4, &Offset); } -uint32_t DWARFDebugNames::NameIndex::getLocalTUOffset(uint32_t TU) const { +uint64_t DWARFDebugNames::NameIndex::getLocalTUOffset(uint32_t TU) const { assert(TU < Hdr.LocalTypeUnitCount); - uint32_t Offset = CUsBase + 4 * (Hdr.CompUnitCount + TU); + uint64_t Offset = CUsBase + 4 * (Hdr.CompUnitCount + TU); return Section.AccelSection.getRelocatedValue(4, &Offset); } uint64_t DWARFDebugNames::NameIndex::getForeignTUSignature(uint32_t TU) const { assert(TU < Hdr.ForeignTypeUnitCount); - uint32_t Offset = + uint64_t Offset = CUsBase + 4 * (Hdr.CompUnitCount + Hdr.LocalTypeUnitCount) + 8 * TU; return Section.AccelSection.getU64(&Offset); } Expected -DWARFDebugNames::NameIndex::getEntry(uint32_t *Offset) const { +DWARFDebugNames::NameIndex::getEntry(uint64_t *Offset) const { const DWARFDataExtractor &AS = Section.AccelSection; if (!AS.isValidOffset(*Offset)) return createStringError(errc::illegal_byte_sequence, @@ -622,15 +622,25 @@ return std::move(E); } +// A temporarily method to preserve compatibility with existing code. +// Will be removed when the migration to 64-bit offsets is finished. +Expected +DWARFDebugNames::NameIndex::getEntry(uint32_t *Offset) const { + uint64_t Offset64 = *Offset; + auto Result = getEntry(&Offset64); + *Offset = Offset64; + return std::move(Result); +} + DWARFDebugNames::NameTableEntry DWARFDebugNames::NameIndex::getNameTableEntry(uint32_t Index) const { assert(0 < Index && Index <= Hdr.NameCount); - uint32_t StringOffsetOffset = StringOffsetsBase + 4 * (Index - 1); - uint32_t EntryOffsetOffset = EntryOffsetsBase + 4 * (Index - 1); + uint64_t StringOffsetOffset = StringOffsetsBase + 4 * (Index - 1); + uint64_t EntryOffsetOffset = EntryOffsetsBase + 4 * (Index - 1); const DWARFDataExtractor &AS = Section.AccelSection; - uint32_t StringOffset = AS.getRelocatedValue(4, &StringOffsetOffset); - uint32_t EntryOffset = AS.getU32(&EntryOffsetOffset); + uint64_t StringOffset = AS.getRelocatedValue(4, &StringOffsetOffset); + uint64_t EntryOffset = AS.getU32(&EntryOffsetOffset); EntryOffset += EntriesBase; return {Section.StringSection, Index, StringOffset, EntryOffset}; } @@ -638,13 +648,13 @@ uint32_t DWARFDebugNames::NameIndex::getBucketArrayEntry(uint32_t Bucket) const { assert(Bucket < Hdr.BucketCount); - uint32_t BucketOffset = BucketsBase + 4 * Bucket; + uint64_t BucketOffset = BucketsBase + 4 * Bucket; return Section.AccelSection.getU32(&BucketOffset); } uint32_t DWARFDebugNames::NameIndex::getHashArrayEntry(uint32_t Index) const { assert(0 < Index && Index <= Hdr.NameCount); - uint32_t HashOffset = HashesBase + 4 * (Index - 1); + uint64_t HashOffset = HashesBase + 4 * (Index - 1); return Section.AccelSection.getU32(&HashOffset); } @@ -653,8 +663,8 @@ // it's not possible to recover this entry list (but the other lists may still // parse OK). bool DWARFDebugNames::NameIndex::dumpEntry(ScopedPrinter &W, - uint32_t *Offset) const { - uint32_t EntryId = *Offset; + uint64_t *Offset) const { + uint64_t EntryId = *Offset; auto EntryOr = getEntry(Offset); if (!EntryOr) { handleAllErrors(EntryOr.takeError(), [](const SentinelError &) {}, @@ -674,10 +684,10 @@ if (Hash) W.printHex("Hash", *Hash); - W.startLine() << format("String: 0x%08x", NTE.getStringOffset()); + W.startLine() << format("String: 0x%08" PRIx64, NTE.getStringOffset()); W.getOStream() << " \"" << NTE.getString() << "\"\n"; - uint32_t EntryOffset = NTE.getEntryOffset(); + uint64_t EntryOffset = NTE.getEntryOffset(); while (dumpEntry(W, &EntryOffset)) /*empty*/; } @@ -685,7 +695,7 @@ void DWARFDebugNames::NameIndex::dumpCUs(ScopedPrinter &W) const { ListScope CUScope(W, "Compilation Unit offsets"); for (uint32_t CU = 0; CU < Hdr.CompUnitCount; ++CU) - W.startLine() << format("CU[%u]: 0x%08x\n", CU, getCUOffset(CU)); + W.startLine() << format("CU[%u]: 0x%08" PRIx64 "\n", CU, getCUOffset(CU)); } void DWARFDebugNames::NameIndex::dumpLocalTUs(ScopedPrinter &W) const { @@ -694,7 +704,8 @@ ListScope TUScope(W, "Local Type Unit offsets"); for (uint32_t TU = 0; TU < Hdr.LocalTypeUnitCount; ++TU) - W.startLine() << format("LocalTU[%u]: 0x%08x\n", TU, getLocalTUOffset(TU)); + W.startLine() << format("LocalTU[%u]: 0x%08" PRIx64 "\n", TU, + getLocalTUOffset(TU)); } void DWARFDebugNames::NameIndex::dumpForeignTUs(ScopedPrinter &W) const { @@ -756,7 +767,7 @@ } Error DWARFDebugNames::extract() { - uint32_t Offset = 0; + uint64_t Offset = 0; while (AccelSection.isValidOffset(Offset)) { NameIndex Next(*this, Offset); if (Error E = Next.extract()) @@ -778,7 +789,7 @@ NI.dump(W); } -Optional +Optional DWARFDebugNames::ValueIterator::findEntryOffsetInCurrentIndex() { const Header &Hdr = CurrentIndex->Hdr; if (Hdr.BucketCount == 0) { @@ -822,7 +833,7 @@ } bool DWARFDebugNames::ValueIterator::findInCurrentIndex() { - Optional Offset = findEntryOffsetInCurrentIndex(); + Optional Offset = findEntryOffsetInCurrentIndex(); if (!Offset) return false; DataOffset = *Offset; @@ -877,7 +888,7 @@ } const DWARFDebugNames::NameIndex * -DWARFDebugNames::getCUNameIndex(uint32_t CUOffset) { +DWARFDebugNames::getCUNameIndex(uint64_t CUOffset) { if (CUToNameIndex.size() == 0 && NameIndices.size() > 0) { for (const auto &NI : *this) { for (uint32_t CU = 0; CU < NI.getCUCount(); ++CU) Index: llvm/trunk/lib/DebugInfo/DWARF/DWARFCompileUnit.cpp =================================================================== --- llvm/trunk/lib/DebugInfo/DWARF/DWARFCompileUnit.cpp +++ llvm/trunk/lib/DebugInfo/DWARF/DWARFCompileUnit.cpp @@ -15,16 +15,18 @@ using namespace llvm; void DWARFCompileUnit::dump(raw_ostream &OS, DIDumpOptions DumpOpts) { - OS << format("0x%08x", getOffset()) << ": Compile Unit:" + OS << format("0x%08" PRIx64, getOffset()) << ": Compile Unit:" << " length = " << format("0x%08x", getLength()) << " version = " << format("0x%04x", getVersion()); if (getVersion() >= 5) OS << " unit_type = " << dwarf::UnitTypeString(getUnitType()); - OS << " abbr_offset = " << format("0x%04x", getAbbreviations()->getOffset()) + OS << " abbr_offset = " + << format("0x%04" PRIx64, getAbbreviations()->getOffset()) << " addr_size = " << format("0x%02x", getAddressByteSize()); if (getVersion() >= 5 && getUnitType() != dwarf::DW_UT_compile) OS << " DWO_id = " << format("0x%016" PRIx64, *getDWOId()); - OS << " (next unit at " << format("0x%08x", getNextUnitOffset()) << ")\n"; + OS << " (next unit at " << format("0x%08" PRIx64, getNextUnitOffset()) + << ")\n"; if (DWARFDie CUDie = getUnitDIE(false)) CUDie.dump(OS, 0, DumpOpts); Index: llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp =================================================================== --- llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp +++ llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp @@ -138,7 +138,7 @@ DWARFDataExtractor StrOffsetExt(Obj, StringOffsetsSection, LittleEndian, 0); DataExtractor StrData(StringSection, LittleEndian, 0); uint64_t SectionSize = StringOffsetsSection.Data.size(); - uint32_t Offset = 0; + uint64_t Offset = 0; for (auto &Contribution : Contributions) { // Report an ill-formed contribution. if (!Contribution) { @@ -166,10 +166,10 @@ } // Report a gap in the table. if (Offset < ContributionHeader) { - OS << format("0x%8.8x: Gap, length = ", Offset); + OS << format("0x%8.8" PRIx64 ": Gap, length = ", Offset); OS << (ContributionHeader - Offset) << "\n"; } - OS << format("0x%8.8x: ", (uint32_t)ContributionHeader); + OS << format("0x%8.8" PRIx64 ": ", ContributionHeader); // In DWARF v5 the contribution size in the descriptor does not equal // the originally encoded length (it does not contain the length of the // version field and the padding, a total of 4 bytes). Add them back in @@ -181,26 +181,19 @@ Offset = Contribution->Base; unsigned EntrySize = Contribution->getDwarfOffsetByteSize(); while (Offset - Contribution->Base < Contribution->Size) { - OS << format("0x%8.8x: ", Offset); - // FIXME: We can only extract strings if the offset fits in 32 bits. + OS << format("0x%8.8" PRIx64 ": ", Offset); uint64_t StringOffset = StrOffsetExt.getRelocatedValue(EntrySize, &Offset); - // Extract the string if we can and display it. Otherwise just report - // the offset. - if (StringOffset <= std::numeric_limits::max()) { - uint32_t StringOffset32 = (uint32_t)StringOffset; - OS << format("%8.8x ", StringOffset32); - const char *S = StrData.getCStr(&StringOffset32); - if (S) - OS << format("\"%s\"", S); - } else - OS << format("%16.16" PRIx64 " ", StringOffset); + OS << format("%8.8" PRIx64 " ", StringOffset); + const char *S = StrData.getCStr(&StringOffset); + if (S) + OS << format("\"%s\"", S); OS << "\n"; } } // Report a gap at the end of the table. if (Offset < SectionSize) { - OS << format("0x%8.8x: Gap, length = ", Offset); + OS << format("0x%8.8" PRIx64 ": Gap, length = ", Offset); OS << (SectionSize - Offset) << "\n"; } } @@ -225,7 +218,7 @@ StringSection, Units, LittleEndian); else { DataExtractor strOffsetExt(StringOffsetsSection.Data, LittleEndian, 0); - uint32_t offset = 0; + uint64_t offset = 0; uint64_t size = StringOffsetsSection.Data.size(); // Ensure that size is a multiple of the size of an entry. if (size & ((uint64_t)(sizeof(uint32_t) - 1))) { @@ -235,9 +228,9 @@ } DataExtractor StrData(StringSection, LittleEndian, 0); while (offset < size) { - OS << format("0x%8.8x: ", offset); - uint32_t StringOffset = strOffsetExt.getU32(&offset); - OS << format("%8.8x ", StringOffset); + OS << format("0x%8.8" PRIx64 ": ", offset); + uint64_t StringOffset = strOffsetExt.getU32(&offset); + OS << format("%8.8" PRIx64 " ", StringOffset); const char *S = StrData.getCStr(&StringOffset); if (S) OS << format("\"%s\"", S); @@ -250,10 +243,10 @@ static void dumpAddrSection(raw_ostream &OS, DWARFDataExtractor &AddrData, DIDumpOptions DumpOpts, uint16_t Version, uint8_t AddrSize) { - uint32_t Offset = 0; + uint64_t Offset = 0; while (AddrData.isValidOffset(Offset)) { DWARFDebugAddrTable AddrTable; - uint32_t TableOffset = Offset; + uint64_t TableOffset = Offset; if (Error Err = AddrTable.extract(AddrData, &Offset, Version, AddrSize, DWARFContext::dumpWarning)) { WithColor::error() << toString(std::move(Err)) << '\n'; @@ -261,8 +254,7 @@ // could be read. If it couldn't, stop reading the section. if (!AddrTable.hasValidLength()) break; - uint64_t Length = AddrTable.getLength(); - Offset = TableOffset + Length; + Offset = TableOffset + AddrTable.getLength(); } else { AddrTable.dump(OS, DumpOpts); } @@ -275,10 +267,10 @@ llvm::function_ref(uint32_t)> LookupPooledAddress, DIDumpOptions DumpOpts) { - uint32_t Offset = 0; + uint64_t Offset = 0; while (rnglistData.isValidOffset(Offset)) { llvm::DWARFDebugRnglistTable Rnglists; - uint32_t TableOffset = Offset; + uint64_t TableOffset = Offset; if (Error Err = Rnglists.extract(rnglistData, &Offset)) { WithColor::error() << toString(std::move(Err)) << '\n'; uint64_t Length = Rnglists.length(); @@ -297,7 +289,7 @@ DWARFDataExtractor Data, const MCRegisterInfo *MRI, Optional DumpOffset) { - uint32_t Offset = 0; + uint64_t Offset = 0; DWARFDebugLoclists Loclists; DWARFListTableHeader Header(".debug_loclists", "locations"); @@ -418,7 +410,7 @@ if (shouldDump(Explicit, ".debug_aranges", DIDT_ID_DebugAranges, DObj->getARangeSection())) { - uint32_t offset = 0; + uint64_t offset = 0; DataExtractor arangesData(DObj->getARangeSection(), isLittleEndian(), 0); DWARFDebugArangeSet set; while (set.extract(arangesData, &offset)) @@ -433,7 +425,8 @@ Parser.skip(dumpWarning); continue; } - OS << "debug_line[" << format("0x%8.8x", Parser.getOffset()) << "]\n"; + OS << "debug_line[" << format("0x%8.8" PRIx64, Parser.getOffset()) + << "]\n"; if (DumpOpts.Verbose) { Parser.parseNext(dumpWarning, dumpWarning, &OS); } else { @@ -476,30 +469,30 @@ if (shouldDump(Explicit, ".debug_str", DIDT_ID_DebugStr, DObj->getStringSection())) { DataExtractor strData(DObj->getStringSection(), isLittleEndian(), 0); - uint32_t offset = 0; - uint32_t strOffset = 0; + uint64_t offset = 0; + uint64_t strOffset = 0; while (const char *s = strData.getCStr(&offset)) { - OS << format("0x%8.8x: \"%s\"\n", strOffset, s); + OS << format("0x%8.8" PRIx64 ": \"%s\"\n", strOffset, s); strOffset = offset; } } if (shouldDump(ExplicitDWO, ".debug_str.dwo", DIDT_ID_DebugStr, DObj->getStringDWOSection())) { DataExtractor strDWOData(DObj->getStringDWOSection(), isLittleEndian(), 0); - uint32_t offset = 0; - uint32_t strDWOOffset = 0; + uint64_t offset = 0; + uint64_t strDWOOffset = 0; while (const char *s = strDWOData.getCStr(&offset)) { - OS << format("0x%8.8x: \"%s\"\n", strDWOOffset, s); + OS << format("0x%8.8" PRIx64 ": \"%s\"\n", strDWOOffset, s); strDWOOffset = offset; } } if (shouldDump(Explicit, ".debug_line_str", DIDT_ID_DebugLineStr, DObj->getLineStringSection())) { DataExtractor strData(DObj->getLineStringSection(), isLittleEndian(), 0); - uint32_t offset = 0; - uint32_t strOffset = 0; + uint64_t offset = 0; + uint64_t strOffset = 0; while (const char *s = strData.getCStr(&offset)) { - OS << format("0x%8.8x: \"", strOffset); + OS << format("0x%8.8" PRIx64 ": \"", strOffset); OS.write_escaped(s); OS << "\"\n"; strOffset = offset; @@ -518,7 +511,7 @@ uint8_t savedAddressByteSize = getCUAddrSize(); DWARFDataExtractor rangesData(*DObj, DObj->getRangeSection(), isLittleEndian(), savedAddressByteSize); - uint32_t offset = 0; + uint64_t offset = 0; DWARFDebugRangeList rangeList; while (rangesData.isValidOffset(offset)) { if (Error E = rangeList.extract(rangesData, &offset)) { @@ -641,7 +634,7 @@ return nullptr; } -DWARFDie DWARFContext::getDIEForOffset(uint32_t Offset) { +DWARFDie DWARFContext::getDIEForOffset(uint64_t Offset) { parseNormalUnits(); if (auto *CU = NormalUnits.getUnitForOffset(Offset)) return CU->getDIEForOffset(Offset); @@ -858,7 +851,7 @@ if (!Offset) return nullptr; // No line table for this compile unit. - uint32_t stmtOffset = *Offset + U->getLineTableOffset(); + uint64_t stmtOffset = *Offset + U->getLineTableOffset(); // See if the line table is cached. if (const DWARFLineTable *lt = Line->getLineTable(stmtOffset)) return lt; @@ -898,7 +891,7 @@ }); } -DWARFCompileUnit *DWARFContext::getCompileUnitForOffset(uint32_t Offset) { +DWARFCompileUnit *DWARFContext::getCompileUnitForOffset(uint64_t Offset) { parseNormalUnits(); return dyn_cast_or_null( NormalUnits.getUnitForOffset(Offset)); @@ -906,7 +899,7 @@ DWARFCompileUnit *DWARFContext::getCompileUnitForAddress(uint64_t Address) { // First, get the offset of the compile unit. - uint32_t CUOffset = getDebugAranges()->findAddress(Address); + uint64_t CUOffset = getDebugAranges()->findAddress(Address); // Retrieve the compile unit. return getCompileUnitForOffset(CUOffset); } Index: llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugAbbrev.cpp =================================================================== --- llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugAbbrev.cpp +++ llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugAbbrev.cpp @@ -26,9 +26,9 @@ } bool DWARFAbbreviationDeclarationSet::extract(DataExtractor Data, - uint32_t *OffsetPtr) { + uint64_t *OffsetPtr) { clear(); - const uint32_t BeginOffset = *OffsetPtr; + const uint64_t BeginOffset = *OffsetPtr; Offset = BeginOffset; DWARFAbbreviationDeclaration AbbrDecl; uint32_t PrevAbbrCode = 0; @@ -82,12 +82,12 @@ void DWARFDebugAbbrev::parse() const { if (!Data) return; - uint32_t Offset = 0; + uint64_t Offset = 0; auto I = AbbrDeclSets.begin(); while (Data->isValidOffset(Offset)) { while (I != AbbrDeclSets.end() && I->first < Offset) ++I; - uint32_t CUAbbrOffset = Offset; + uint64_t CUAbbrOffset = Offset; DWARFAbbreviationDeclarationSet AbbrDecls; if (!AbbrDecls.extract(*Data, &Offset)) break; @@ -124,7 +124,7 @@ } if (Data && CUAbbrOffset < Data->getData().size()) { - uint32_t Offset = CUAbbrOffset; + uint64_t Offset = CUAbbrOffset; DWARFAbbreviationDeclarationSet AbbrDecls; if (!AbbrDecls.extract(*Data, &Offset)) return nullptr; Index: llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugAddr.cpp =================================================================== --- llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugAddr.cpp +++ llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugAddr.cpp @@ -19,7 +19,7 @@ } Error DWARFDebugAddrTable::extract(DWARFDataExtractor Data, - uint32_t *OffsetPtr, + uint64_t *OffsetPtr, uint16_t Version, uint8_t AddrSize, std::function WarnCallback) { @@ -30,7 +30,7 @@ return createStringError(errc::invalid_argument, "section is not large enough to contain a " ".debug_addr table length at offset 0x%" - PRIx32, *OffsetPtr); + PRIx64, *OffsetPtr); uint16_t UnitVersion; if (Version == 0) { WarnCallback(createStringError(errc::invalid_argument, @@ -47,25 +47,25 @@ if (HeaderData.Length == dwarf::DW_LENGTH_DWARF64) { invalidateLength(); return createStringError(errc::not_supported, - "DWARF64 is not supported in .debug_addr at offset 0x%" PRIx32, + "DWARF64 is not supported in .debug_addr at offset 0x%" PRIx64, HeaderOffset); } if (HeaderData.Length + sizeof(uint32_t) < sizeof(Header)) { uint32_t TmpLength = getLength(); invalidateLength(); return createStringError(errc::invalid_argument, - ".debug_addr table at offset 0x%" PRIx32 + ".debug_addr table at offset 0x%" PRIx64 " has too small length (0x%" PRIx32 ") to contain a complete header", HeaderOffset, TmpLength); } - uint32_t End = HeaderOffset + getLength(); + uint64_t End = HeaderOffset + getLength(); if (!Data.isValidOffsetForDataOfSize(HeaderOffset, End - HeaderOffset)) { uint32_t TmpLength = getLength(); invalidateLength(); return createStringError(errc::invalid_argument, "section is not large enough to contain a .debug_addr table " - "of length 0x%" PRIx32 " at offset 0x%" PRIx32, + "of length 0x%" PRIx32 " at offset 0x%" PRIx64, TmpLength, HeaderOffset); } @@ -88,7 +88,7 @@ // and consists only of a series of addresses. if (HeaderData.Version > 5) { return createStringError(errc::not_supported, "version %" PRIu16 - " of .debug_addr section at offset 0x%" PRIx32 " is not supported", + " of .debug_addr section at offset 0x%" PRIx64 " is not supported", HeaderData.Version, HeaderOffset); } // FIXME: For now we just treat version mismatch as an error, @@ -97,19 +97,19 @@ // attribute in the info table. if (HeaderData.Version != UnitVersion) return createStringError(errc::invalid_argument, - ".debug_addr table at offset 0x%" PRIx32 + ".debug_addr table at offset 0x%" PRIx64 " has version %" PRIu16 " which is different from the version suggested" " by the DWARF unit header: %" PRIu16, HeaderOffset, HeaderData.Version, UnitVersion); if (HeaderData.AddrSize != 4 && HeaderData.AddrSize != 8) return createStringError(errc::not_supported, - ".debug_addr table at offset 0x%" PRIx32 + ".debug_addr table at offset 0x%" PRIx64 " has unsupported address size %" PRIu8, HeaderOffset, HeaderData.AddrSize); if (HeaderData.AddrSize != AddrSize && AddrSize != 0) return createStringError(errc::invalid_argument, - ".debug_addr table at offset 0x%" PRIx32 + ".debug_addr table at offset 0x%" PRIx64 " has address size %" PRIu8 " which is different from CU address size %" PRIu8, HeaderOffset, HeaderData.AddrSize, AddrSize); @@ -117,13 +117,13 @@ // TODO: add support for non-zero segment selector size. if (HeaderData.SegSize != 0) return createStringError(errc::not_supported, - ".debug_addr table at offset 0x%" PRIx32 + ".debug_addr table at offset 0x%" PRIx64 " has unsupported segment selector size %" PRIu8, HeaderOffset, HeaderData.SegSize); if (DataSize % HeaderData.AddrSize != 0) { invalidateLength(); return createStringError(errc::invalid_argument, - ".debug_addr table at offset 0x%" PRIx32 + ".debug_addr table at offset 0x%" PRIx64 " contains data of size %" PRIu32 " which is not a multiple of addr size %" PRIu8, HeaderOffset, DataSize, HeaderData.AddrSize); @@ -162,7 +162,7 @@ return Addrs[Index]; return createStringError(errc::invalid_argument, "Index %" PRIu32 " is out of range of the " - ".debug_addr table at offset 0x%" PRIx32, + ".debug_addr table at offset 0x%" PRIx64, Index, HeaderOffset); } Index: llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugArangeSet.cpp =================================================================== --- llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugArangeSet.cpp +++ llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugArangeSet.cpp @@ -24,13 +24,13 @@ } void DWARFDebugArangeSet::clear() { - Offset = -1U; + Offset = -1ULL; std::memset(&HeaderData, 0, sizeof(Header)); ArangeDescriptors.clear(); } bool -DWARFDebugArangeSet::extract(DataExtractor data, uint32_t *offset_ptr) { +DWARFDebugArangeSet::extract(DataExtractor data, uint64_t *offset_ptr) { if (data.isValidOffset(*offset_ptr)) { ArangeDescriptors.clear(); Offset = *offset_ptr; Index: llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugAranges.cpp =================================================================== --- llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugAranges.cpp +++ llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugAranges.cpp @@ -23,11 +23,11 @@ void DWARFDebugAranges::extract(DataExtractor DebugArangesData) { if (!DebugArangesData.isValidOffset(0)) return; - uint32_t Offset = 0; + uint64_t Offset = 0; DWARFDebugArangeSet Set; while (Set.extract(DebugArangesData, &Offset)) { - uint32_t CUOffset = Set.getCompileUnitDIEOffset(); + uint64_t CUOffset = Set.getCompileUnitDIEOffset(); for (const auto &Desc : Set.descriptors()) { uint64_t LowPC = Desc.Address; uint64_t HighPC = Desc.getEndAddress(); @@ -51,7 +51,7 @@ // it may describe only a small subset of compilation units, so we need to // manually build aranges for the rest of them. for (const auto &CU : CTX->compile_units()) { - uint32_t CUOffset = CU->getOffset(); + uint64_t CUOffset = CU->getOffset(); if (ParsedCUOffsets.insert(CUOffset).second) { Expected CURanges = CU->collectAddressRanges(); if (!CURanges) @@ -71,7 +71,7 @@ ParsedCUOffsets.clear(); } -void DWARFDebugAranges::appendRange(uint32_t CUOffset, uint64_t LowPC, +void DWARFDebugAranges::appendRange(uint64_t CUOffset, uint64_t LowPC, uint64_t HighPC) { if (LowPC >= HighPC) return; @@ -80,7 +80,7 @@ } void DWARFDebugAranges::construct() { - std::multiset ValidCUs; // Maintain the set of CUs describing + std::multiset ValidCUs; // Maintain the set of CUs describing // a current address range. llvm::sort(Endpoints); uint64_t PrevAddress = -1ULL; Index: llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp =================================================================== --- llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp +++ llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp @@ -34,8 +34,8 @@ const uint8_t DWARF_CFI_PRIMARY_OPCODE_MASK = 0xc0; const uint8_t DWARF_CFI_PRIMARY_OPERAND_MASK = 0x3f; -Error CFIProgram::parse(DWARFDataExtractor Data, uint32_t *Offset, - uint32_t EndOffset) { +Error CFIProgram::parse(DWARFDataExtractor Data, uint64_t *Offset, + uint64_t EndOffset) { while (*Offset < EndOffset) { uint8_t Opcode = Data.getRelocatedValue(1, Offset); // Some instructions have a primary opcode encoded in the top bits. @@ -331,7 +331,7 @@ DWARFDebugFrame::~DWARFDebugFrame() = default; static void LLVM_ATTRIBUTE_UNUSED dumpDataAux(DataExtractor Data, - uint32_t Offset, int Length) { + uint64_t Offset, int Length) { errs() << "DUMP: "; for (int i = 0; i < Length; ++i) { uint8_t c = Data.getU8(&Offset); @@ -344,7 +344,7 @@ // noreturn attribute usage in lambdas. Once the support for those // compilers are phased out, we can remove this and return back to // a ReportError lambda: [StartOffset](const char *ErrorMsg). -static void LLVM_ATTRIBUTE_NORETURN ReportError(uint32_t StartOffset, +static void LLVM_ATTRIBUTE_NORETURN ReportError(uint64_t StartOffset, const char *ErrorMsg) { std::string Str; raw_string_ostream OS(Str); @@ -354,11 +354,11 @@ } void DWARFDebugFrame::parse(DWARFDataExtractor Data) { - uint32_t Offset = 0; - DenseMap CIEs; + uint64_t Offset = 0; + DenseMap CIEs; while (Data.isValidOffset(Offset)) { - uint32_t StartOffset = Offset; + uint64_t StartOffset = Offset; bool IsDWARF64 = false; uint64_t Length = Data.getRelocatedValue(4, &Offset); @@ -376,10 +376,8 @@ // Length is the structure size excluding itself. Compute an offset one // past the end of the structure (needed to know how many instructions to // read). - // TODO: For honest DWARF64 support, DataExtractor will have to treat - // offset_ptr as uint64_t* - uint32_t StartStructureOffset = Offset; - uint32_t EndStructureOffset = Offset + static_cast(Length); + uint64_t StartStructureOffset = Offset; + uint64_t EndStructureOffset = Offset + Length; // The Id field's size depends on the DWARF format Id = Data.getUnsigned(&Offset, (IsDWARF64 && !IsEH) ? 8 : 4); @@ -407,22 +405,23 @@ Optional PersonalityEncoding; if (IsEH) { Optional AugmentationLength; - uint32_t StartAugmentationOffset; - uint32_t EndAugmentationOffset; + uint64_t StartAugmentationOffset; + uint64_t EndAugmentationOffset; // Walk the augmentation string to get all the augmentation data. for (unsigned i = 0, e = AugmentationString.size(); i != e; ++i) { switch (AugmentationString[i]) { default: - ReportError(StartOffset, - "Unknown augmentation character in entry at %lx"); + ReportError( + StartOffset, + "Unknown augmentation character in entry at %" PRIx64); case 'L': LSDAPointerEncoding = Data.getU8(&Offset); break; case 'P': { if (Personality) ReportError(StartOffset, - "Duplicate personality in entry at %lx"); + "Duplicate personality in entry at %" PRIx64); PersonalityEncoding = Data.getU8(&Offset); Personality = Data.getEncodedPointer( &Offset, *PersonalityEncoding, @@ -438,13 +437,12 @@ case 'z': if (i) ReportError(StartOffset, - "'z' must be the first character at %lx"); + "'z' must be the first character at %" PRIx64); // Parse the augmentation length first. We only parse it if // the string contains a 'z'. AugmentationLength = Data.getULEB128(&Offset); StartAugmentationOffset = Offset; - EndAugmentationOffset = Offset + - static_cast(*AugmentationLength); + EndAugmentationOffset = Offset + *AugmentationLength; break; case 'B': // B-Key is used for signing functions associated with this @@ -455,7 +453,8 @@ if (AugmentationLength.hasValue()) { if (Offset != EndAugmentationOffset) - ReportError(StartOffset, "Parsing augmentation data at %lx failed"); + ReportError(StartOffset, + "Parsing augmentation data at %" PRIx64 " failed"); AugmentationData = Data.getData().slice(StartAugmentationOffset, EndAugmentationOffset); @@ -480,8 +479,8 @@ if (IsEH) { // The address size is encoded in the CIE we reference. if (!Cie) - ReportError(StartOffset, - "Parsing FDE data at %lx failed due to missing CIE"); + ReportError(StartOffset, "Parsing FDE data at %" PRIx64 + " failed due to missing CIE"); if (auto Val = Data.getEncodedPointer( &Offset, Cie->getFDEPointerEncoding(), @@ -498,8 +497,7 @@ // Parse the augmentation length and data for this FDE. uint64_t AugmentationLength = Data.getULEB128(&Offset); - uint32_t EndAugmentationOffset = - Offset + static_cast(AugmentationLength); + uint64_t EndAugmentationOffset = Offset + AugmentationLength; // Decode the LSDA if the CIE augmentation string said we should. if (Cie->getLSDAPointerEncoding() != DW_EH_PE_omit) { @@ -509,7 +507,8 @@ } if (Offset != EndAugmentationOffset) - ReportError(StartOffset, "Parsing augmentation data at %lx failed"); + ReportError(StartOffset, + "Parsing augmentation data at %" PRIx64 " failed"); } } else { InitialLocation = Data.getRelocatedAddress(&Offset); @@ -527,7 +526,8 @@ } if (Offset != EndStructureOffset) - ReportError(StartOffset, "Parsing entry instructions at %lx failed"); + ReportError(StartOffset, + "Parsing entry instructions at %" PRIx64 " failed"); } } Index: llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugInfoEntry.cpp =================================================================== --- llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugInfoEntry.cpp +++ llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugInfoEntry.cpp @@ -19,15 +19,15 @@ using namespace dwarf; bool DWARFDebugInfoEntry::extractFast(const DWARFUnit &U, - uint32_t *OffsetPtr) { + uint64_t *OffsetPtr) { DWARFDataExtractor DebugInfoData = U.getDebugInfoExtractor(); - const uint32_t UEndOffset = U.getNextUnitOffset(); + const uint64_t UEndOffset = U.getNextUnitOffset(); return extractFast(U, OffsetPtr, DebugInfoData, UEndOffset, 0); } -bool DWARFDebugInfoEntry::extractFast(const DWARFUnit &U, uint32_t *OffsetPtr, +bool DWARFDebugInfoEntry::extractFast(const DWARFUnit &U, uint64_t *OffsetPtr, const DWARFDataExtractor &DebugInfoData, - uint32_t UEndOffset, uint32_t D) { + uint64_t UEndOffset, uint32_t D) { Offset = *OffsetPtr; Depth = D; if (Offset >= UEndOffset || !DebugInfoData.isValidOffset(Offset)) Index: llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugLine.cpp =================================================================== --- llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugLine.cpp +++ llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugLine.cpp @@ -156,7 +156,7 @@ // Parse v2-v4 directory and file tables. static void parseV2DirFileTables(const DWARFDataExtractor &DebugLineData, - uint32_t *OffsetPtr, uint64_t EndPrologueOffset, + uint64_t *OffsetPtr, uint64_t EndPrologueOffset, DWARFDebugLine::ContentTypeTracker &ContentTypes, std::vector &IncludeDirectories, std::vector &FileNames) { @@ -190,7 +190,7 @@ // Returns the descriptors, or an error if we did not find a path or ran off // the end of the prologue. static llvm::Expected -parseV5EntryFormat(const DWARFDataExtractor &DebugLineData, uint32_t *OffsetPtr, +parseV5EntryFormat(const DWARFDataExtractor &DebugLineData, uint64_t *OffsetPtr, uint64_t EndPrologueOffset, DWARFDebugLine::ContentTypeTracker *ContentTypes) { ContentDescriptors Descriptors; @@ -201,7 +201,7 @@ return createStringError( errc::invalid_argument, "failed to parse entry content descriptions at offset " - "0x%8.8" PRIx32 + "0x%8.8" PRIx64 " because offset extends beyond the prologue end at offset " "0x%8.8" PRIx64, *OffsetPtr, EndPrologueOffset); @@ -225,7 +225,7 @@ static Error parseV5DirFileTables(const DWARFDataExtractor &DebugLineData, - uint32_t *OffsetPtr, uint64_t EndPrologueOffset, + uint64_t *OffsetPtr, uint64_t EndPrologueOffset, const dwarf::FormParams &FormParams, const DWARFContext &Ctx, const DWARFUnit *U, DWARFDebugLine::ContentTypeTracker &ContentTypes, @@ -244,7 +244,7 @@ return createStringError( errc::invalid_argument, "failed to parse directory entry at offset " - "0x%8.8" PRIx32 + "0x%8.8" PRIx64 " because offset extends beyond the prologue end at offset " "0x%8.8" PRIx64, *OffsetPtr, EndPrologueOffset); @@ -280,7 +280,7 @@ return createStringError( errc::invalid_argument, "failed to parse file entry at offset " - "0x%8.8" PRIx32 + "0x%8.8" PRIx64 " because offset extends beyond the prologue end at offset " "0x%8.8" PRIx64, *OffsetPtr, EndPrologueOffset); @@ -325,7 +325,7 @@ } Error DWARFDebugLine::Prologue::parse(const DWARFDataExtractor &DebugLineData, - uint32_t *OffsetPtr, + uint64_t *OffsetPtr, const DWARFContext &Ctx, const DWARFUnit *U) { const uint64_t PrologueOffset = *OffsetPtr; @@ -382,7 +382,7 @@ errc::invalid_argument, "parsing line table prologue at 0x%8.8" PRIx64 " found an invalid directory or file table description at" - " 0x%8.8" PRIx32, + " 0x%8.8" PRIx64, PrologueOffset, *OffsetPtr), std::move(e)); } @@ -394,7 +394,7 @@ return createStringError(errc::invalid_argument, "parsing line table prologue at 0x%8.8" PRIx64 " should have ended at 0x%8.8" PRIx64 - " but it ended at 0x%8.8" PRIx32, + " but it ended at 0x%8.8" PRIx64, PrologueOffset, EndPrologueOffset, *OffsetPtr); return Error::success(); } @@ -502,7 +502,7 @@ } const DWARFDebugLine::LineTable * -DWARFDebugLine::getLineTable(uint32_t Offset) const { +DWARFDebugLine::getLineTable(uint64_t Offset) const { LineTableConstIter Pos = LineTableMap.find(Offset); if (Pos != LineTableMap.end()) return &Pos->second; @@ -510,10 +510,10 @@ } Expected DWARFDebugLine::getOrParseLineTable( - DWARFDataExtractor &DebugLineData, uint32_t Offset, const DWARFContext &Ctx, + DWARFDataExtractor &DebugLineData, uint64_t Offset, const DWARFContext &Ctx, const DWARFUnit *U, std::function RecoverableErrorCallback) { if (!DebugLineData.isValidOffset(Offset)) - return createStringError(errc::invalid_argument, "offset 0x%8.8" PRIx32 + return createStringError(errc::invalid_argument, "offset 0x%8.8" PRIx64 " is not a valid debug line section offset", Offset); @@ -530,10 +530,10 @@ } Error DWARFDebugLine::LineTable::parse( - DWARFDataExtractor &DebugLineData, uint32_t *OffsetPtr, + DWARFDataExtractor &DebugLineData, uint64_t *OffsetPtr, const DWARFContext &Ctx, const DWARFUnit *U, std::function RecoverableErrorCallback, raw_ostream *OS) { - const uint32_t DebugLineOffset = *OffsetPtr; + const uint64_t DebugLineOffset = *OffsetPtr; clear(); @@ -549,7 +549,7 @@ if (PrologueErr) return PrologueErr; - const uint32_t EndOffset = + const uint64_t EndOffset = DebugLineOffset + Prologue.TotalLength + Prologue.sizeofTotalLength(); // See if we should tell the data extractor the address size. @@ -563,7 +563,7 @@ while (*OffsetPtr < EndOffset) { if (OS) - *OS << format("0x%08.08" PRIx32 ": ", *OffsetPtr); + *OS << format("0x%08.08" PRIx64 ": ", *OffsetPtr); uint8_t Opcode = DebugLineData.getU8(OffsetPtr); @@ -574,7 +574,7 @@ // Extended Opcodes always start with a zero opcode followed by // a uleb128 length so you can skip ones you don't know about uint64_t Len = DebugLineData.getULEB128(OffsetPtr); - uint32_t ExtOffset = *OffsetPtr; + uint64_t ExtOffset = *OffsetPtr; // Tolerate zero-length; assume length is correct and soldier on. if (Len == 0) { @@ -619,7 +619,7 @@ DebugLineData.setAddressSize(Len - 1); else if (DebugLineData.getAddressSize() != Len - 1) { return createStringError(errc::invalid_argument, - "mismatching address size at offset 0x%8.8" PRIx32 + "mismatching address size at offset 0x%8.8" PRIx64 " expected 0x%2.2" PRIx8 " found 0x%2.2" PRIx64, ExtOffset, DebugLineData.getAddressSize(), Len - 1); @@ -686,8 +686,8 @@ // Otherwise we have an unparseable line-number program. if (*OffsetPtr - ExtOffset != Len) return createStringError(errc::illegal_byte_sequence, - "unexpected line op length at offset 0x%8.8" PRIx32 - " expected 0x%2.2" PRIx64 " found 0x%2.2" PRIx32, + "unexpected line op length at offset 0x%8.8" PRIx64 + " expected 0x%2.2" PRIx64 " found 0x%2.2" PRIx64, ExtOffset, Len, *OffsetPtr - ExtOffset); } else if (Opcode < Prologue.OpcodeBase) { if (OS) @@ -1136,7 +1136,7 @@ assert(DebugLineData.isValidOffset(Offset) && "parsing should have terminated"); DWARFUnit *U = prepareToParse(Offset); - uint32_t OldOffset = Offset; + uint64_t OldOffset = Offset; LineTable LT; if (Error Err = LT.parse(DebugLineData, &Offset, Context, U, RecoverableErrorCallback, OS)) @@ -1150,14 +1150,14 @@ assert(DebugLineData.isValidOffset(Offset) && "parsing should have terminated"); DWARFUnit *U = prepareToParse(Offset); - uint32_t OldOffset = Offset; + uint64_t OldOffset = Offset; LineTable LT; if (Error Err = LT.Prologue.parse(DebugLineData, &Offset, Context, U)) ErrorCallback(std::move(Err)); moveToNextTable(OldOffset, LT.Prologue); } -DWARFUnit *DWARFDebugLine::SectionParser::prepareToParse(uint32_t Offset) { +DWARFUnit *DWARFDebugLine::SectionParser::prepareToParse(uint64_t Offset) { DWARFUnit *U = nullptr; auto It = LineToUnit.find(Offset); if (It != LineToUnit.end()) @@ -1166,7 +1166,7 @@ return U; } -void DWARFDebugLine::SectionParser::moveToNextTable(uint32_t OldOffset, +void DWARFDebugLine::SectionParser::moveToNextTable(uint64_t OldOffset, const Prologue &P) { // If the length field is not valid, we don't know where the next table is, so // cannot continue to parse. Mark the parser as done, and leave the Offset Index: llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugLoc.cpp =================================================================== --- llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugLoc.cpp +++ llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugLoc.cpp @@ -67,7 +67,7 @@ void DWARFDebugLoc::dump(raw_ostream &OS, const MCRegisterInfo *MRI, Optional Offset) const { auto DumpLocationList = [&](const LocationList &L) { - OS << format("0x%8.8x: ", L.Offset); + OS << format("0x%8.8" PRIx64 ": ", L.Offset); L.dump(OS, IsLittleEndian, AddressSize, MRI, nullptr, 0, 12); OS << "\n\n"; }; @@ -84,7 +84,7 @@ } Optional -DWARFDebugLoc::parseOneLocationList(DWARFDataExtractor Data, unsigned *Offset) { +DWARFDebugLoc::parseOneLocationList(DWARFDataExtractor Data, uint64_t *Offset) { LocationList LL; LL.Offset = *Offset; @@ -132,7 +132,7 @@ IsLittleEndian = data.isLittleEndian(); AddressSize = data.getAddressSize(); - uint32_t Offset = 0; + uint64_t Offset = 0; while (data.isValidOffset(Offset + data.getAddressSize() - 1)) { if (auto LL = parseOneLocationList(data, &Offset)) Locations.push_back(std::move(*LL)); @@ -144,7 +144,7 @@ } Optional -DWARFDebugLoclists::parseOneLocationList(DataExtractor Data, unsigned *Offset, +DWARFDebugLoclists::parseOneLocationList(DataExtractor Data, uint64_t *Offset, unsigned Version) { LocationList LL; LL.Offset = *Offset; @@ -201,7 +201,7 @@ IsLittleEndian = data.isLittleEndian(); AddressSize = data.getAddressSize(); - uint32_t Offset = 0; + uint64_t Offset = 0; while (data.isValidOffset(Offset)) { if (auto LL = parseOneLocationList(data, &Offset, Version)) Locations.push_back(std::move(*LL)); @@ -261,7 +261,7 @@ const MCRegisterInfo *MRI, Optional Offset) const { auto DumpLocationList = [&](const LocationList &L) { - OS << format("0x%8.8x: ", L.Offset); + OS << format("0x%8.8" PRIx64 ": ", L.Offset); L.dump(OS, BaseAddr, IsLittleEndian, AddressSize, MRI, nullptr, /*Indent=*/12); OS << "\n\n"; }; Index: llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugMacro.cpp =================================================================== --- llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugMacro.cpp +++ llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugMacro.cpp @@ -53,7 +53,7 @@ } void DWARFDebugMacro::parse(DataExtractor data) { - uint32_t Offset = 0; + uint64_t Offset = 0; while (data.isValidOffset(Offset)) { // A macro list entry consists of: Entry E; Index: llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugPubTable.cpp =================================================================== --- llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugPubTable.cpp +++ llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugPubTable.cpp @@ -23,7 +23,7 @@ bool LittleEndian, bool GnuStyle) : GnuStyle(GnuStyle) { DWARFDataExtractor PubNames(Obj, Sec, LittleEndian, 0); - uint32_t Offset = 0; + uint64_t Offset = 0; while (PubNames.isValidOffset(Offset)) { Sets.push_back({}); Set &SetData = Sets.back(); @@ -49,13 +49,13 @@ for (const Set &S : Sets) { OS << "length = " << format("0x%08x", S.Length); OS << " version = " << format("0x%04x", S.Version); - OS << " unit_offset = " << format("0x%08x", S.Offset); + OS << " unit_offset = " << format("0x%08" PRIx64, S.Offset); OS << " unit_size = " << format("0x%08x", S.Size) << '\n'; OS << (GnuStyle ? "Offset Linkage Kind Name\n" : "Offset Name\n"); for (const Entry &E : S.Entries) { - OS << format("0x%8.8x ", E.SecOffset); + OS << format("0x%8.8" PRIx64 " ", E.SecOffset); if (GnuStyle) { StringRef EntryLinkage = GDBIndexEntryLinkageString(E.Descriptor.Linkage); Index: llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugRangeList.cpp =================================================================== --- llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugRangeList.cpp +++ llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugRangeList.cpp @@ -17,17 +17,17 @@ using namespace llvm; void DWARFDebugRangeList::clear() { - Offset = -1U; + Offset = -1ULL; AddressSize = 0; Entries.clear(); } Error DWARFDebugRangeList::extract(const DWARFDataExtractor &data, - uint32_t *offset_ptr) { + uint64_t *offset_ptr) { clear(); if (!data.isValidOffset(*offset_ptr)) return createStringError(errc::invalid_argument, - "invalid range list offset 0x%" PRIx32, *offset_ptr); + "invalid range list offset 0x%" PRIx64, *offset_ptr); AddressSize = data.getAddressSize(); if (AddressSize != 4 && AddressSize != 8) @@ -38,7 +38,7 @@ RangeListEntry Entry; Entry.SectionIndex = -1ULL; - uint32_t prev_offset = *offset_ptr; + uint64_t prev_offset = *offset_ptr; Entry.StartAddress = data.getRelocatedAddress(offset_ptr); Entry.EndAddress = data.getRelocatedAddress(offset_ptr, &Entry.SectionIndex); @@ -47,7 +47,7 @@ if (*offset_ptr != prev_offset + 2 * AddressSize) { clear(); return createStringError(errc::invalid_argument, - "invalid range list entry at offset 0x%" PRIx32, + "invalid range list entry at offset 0x%" PRIx64, prev_offset); } if (Entry.isEndOfListEntry()) @@ -59,12 +59,12 @@ void DWARFDebugRangeList::dump(raw_ostream &OS) const { for (const RangeListEntry &RLE : Entries) { - const char *format_str = (AddressSize == 4 - ? "%08x %08" PRIx64 " %08" PRIx64 "\n" - : "%08x %016" PRIx64 " %016" PRIx64 "\n"); + const char *format_str = + (AddressSize == 4 ? "%08" PRIx64 " %08" PRIx64 " %08" PRIx64 "\n" + : "%08" PRIx64 " %016" PRIx64 " %016" PRIx64 "\n"); OS << format(format_str, Offset, RLE.StartAddress, RLE.EndAddress); } - OS << format("%08x \n", Offset); + OS << format("%08" PRIx64 " \n", Offset); } DWARFAddressRangesVector DWARFDebugRangeList::getAbsoluteRanges( Index: llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugRnglists.cpp =================================================================== --- llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugRnglists.cpp +++ llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugRnglists.cpp @@ -16,8 +16,8 @@ using namespace llvm; -Error RangeListEntry::extract(DWARFDataExtractor Data, uint32_t End, - uint32_t *OffsetPtr) { +Error RangeListEntry::extract(DWARFDataExtractor Data, uint64_t End, + uint64_t *OffsetPtr) { Offset = *OffsetPtr; SectionIndex = -1ULL; // The caller should guarantee that we have at least 1 byte available, so @@ -32,41 +32,41 @@ break; // TODO: Support other encodings. case dwarf::DW_RLE_base_addressx: { - uint32_t PreviousOffset = *OffsetPtr - 1; + uint64_t PreviousOffset = *OffsetPtr - 1; Value0 = Data.getULEB128(OffsetPtr); if (End < *OffsetPtr) return createStringError( errc::invalid_argument, "read past end of table when reading " - "DW_RLE_base_addressx encoding at offset 0x%" PRIx32, + "DW_RLE_base_addressx encoding at offset 0x%" PRIx64, PreviousOffset); break; } case dwarf::DW_RLE_startx_endx: return createStringError(errc::not_supported, "unsupported rnglists encoding DW_RLE_startx_endx at " - "offset 0x%" PRIx32, + "offset 0x%" PRIx64, *OffsetPtr - 1); case dwarf::DW_RLE_startx_length: { - uint32_t PreviousOffset = *OffsetPtr - 1; + uint64_t PreviousOffset = *OffsetPtr - 1; Value0 = Data.getULEB128(OffsetPtr); Value1 = Data.getULEB128(OffsetPtr); if (End < *OffsetPtr) return createStringError( errc::invalid_argument, "read past end of table when reading " - "DW_RLE_startx_length encoding at offset 0x%" PRIx32, + "DW_RLE_startx_length encoding at offset 0x%" PRIx64, PreviousOffset); break; } case dwarf::DW_RLE_offset_pair: { - uint32_t PreviousOffset = *OffsetPtr - 1; + uint64_t PreviousOffset = *OffsetPtr - 1; Value0 = Data.getULEB128(OffsetPtr); Value1 = Data.getULEB128(OffsetPtr); if (End < *OffsetPtr) return createStringError(errc::invalid_argument, "read past end of table when reading " - "DW_RLE_offset_pair encoding at offset 0x%" PRIx32, + "DW_RLE_offset_pair encoding at offset 0x%" PRIx64, PreviousOffset); break; } @@ -74,7 +74,7 @@ if ((End - *OffsetPtr) < Data.getAddressSize()) return createStringError(errc::invalid_argument, "insufficient space remaining in table for " - "DW_RLE_base_address encoding at offset 0x%" PRIx32, + "DW_RLE_base_address encoding at offset 0x%" PRIx64, *OffsetPtr - 1); Value0 = Data.getRelocatedAddress(OffsetPtr, &SectionIndex); break; @@ -84,27 +84,27 @@ return createStringError(errc::invalid_argument, "insufficient space remaining in table for " "DW_RLE_start_end encoding " - "at offset 0x%" PRIx32, + "at offset 0x%" PRIx64, *OffsetPtr - 1); Value0 = Data.getRelocatedAddress(OffsetPtr, &SectionIndex); Value1 = Data.getRelocatedAddress(OffsetPtr); break; } case dwarf::DW_RLE_start_length: { - uint32_t PreviousOffset = *OffsetPtr - 1; + uint64_t PreviousOffset = *OffsetPtr - 1; Value0 = Data.getRelocatedAddress(OffsetPtr, &SectionIndex); Value1 = Data.getULEB128(OffsetPtr); if (End < *OffsetPtr) return createStringError(errc::invalid_argument, "read past end of table when reading " - "DW_RLE_start_length encoding at offset 0x%" PRIx32, + "DW_RLE_start_length encoding at offset 0x%" PRIx64, PreviousOffset); break; } default: return createStringError(errc::not_supported, "unknown rnglists encoding 0x%" PRIx32 - " at offset 0x%" PRIx32, + " at offset 0x%" PRIx64, uint32_t(Encoding), *OffsetPtr - 1); } @@ -187,7 +187,7 @@ if (DumpOpts.Verbose) { // Print the section offset in verbose mode. - OS << format("0x%8.8" PRIx32 ":", Offset); + OS << format("0x%8.8" PRIx64 ":", Offset); auto EncodingString = dwarf::RangeListEncodingString(EntryKind); // Unsupported encodings should have been reported during parsing. assert(!EncodingString.empty() && "Unknown range entry encoding"); Index: llvm/trunk/lib/DebugInfo/DWARF/DWARFDie.cpp =================================================================== --- llvm/trunk/lib/DebugInfo/DWARF/DWARFDie.cpp +++ llvm/trunk/lib/DebugInfo/DWARF/DWARFDie.cpp @@ -92,7 +92,7 @@ FormValue.dump(OS, DumpOpts); if (FormValue.isFormClass(DWARFFormValue::FC_SectionOffset)) { - uint32_t Offset = *FormValue.getAsSectionOffset(); + uint64_t Offset = *FormValue.getAsSectionOffset(); if (!U->isDWOUnit() && !U->getLocSection()->Data.empty()) { DWARFDebugLoc DebugLoc; DWARFDataExtractor Data(Obj, *U->getLocSection(), Ctx.isLittleEndian(), @@ -264,7 +264,7 @@ } static void dumpAttribute(raw_ostream &OS, const DWARFDie &Die, - uint32_t *OffsetPtr, dwarf::Attribute Attr, + uint64_t *OffsetPtr, dwarf::Attribute Attr, dwarf::Form Form, unsigned Indent, DIDumpOptions DumpOpts) { if (!Die.isValid()) @@ -568,8 +568,8 @@ if (!isValid()) return; DWARFDataExtractor debug_info_data = U->getDebugInfoExtractor(); - const uint32_t Offset = getOffset(); - uint32_t offset = Offset; + const uint64_t Offset = getOffset(); + uint64_t offset = Offset; if (DumpOpts.ShowParents) { DIDumpOptions ParentDumpOpts = DumpOpts; ParentDumpOpts.ShowParents = false; @@ -581,7 +581,7 @@ uint32_t abbrCode = debug_info_data.getULEB128(&offset); if (DumpOpts.ShowAddresses) WithColor(OS, HighlightColor::Address).get() - << format("\n0x%8.8x: ", Offset); + << format("\n0x%8.8" PRIx64 ": ", Offset); if (abbrCode) { auto AbbrevDecl = getAbbreviationDeclarationPtr(); @@ -685,7 +685,7 @@ AttrValue.Attr = AbbrDecl.getAttrByIndex(Index); // Add the previous byte size of any previous attribute value. AttrValue.Offset += AttrValue.ByteSize; - uint32_t ParseOffset = AttrValue.Offset; + uint64_t ParseOffset = AttrValue.Offset; auto U = Die.getDwarfUnit(); assert(U && "Die must have valid DWARF unit"); AttrValue.Value = DWARFFormValue::createFromUnit( Index: llvm/trunk/lib/DebugInfo/DWARF/DWARFExpression.cpp =================================================================== --- llvm/trunk/lib/DebugInfo/DWARF/DWARFExpression.cpp +++ llvm/trunk/lib/DebugInfo/DWARF/DWARFExpression.cpp @@ -119,7 +119,7 @@ } bool DWARFExpression::Operation::extract(DataExtractor Data, uint16_t Version, - uint8_t AddressSize, uint32_t Offset) { + uint8_t AddressSize, uint64_t Offset) { Opcode = Data.getU8(&Offset); Desc = getOpDesc(Opcode); @@ -263,7 +263,7 @@ if (Size == Operation::BaseTypeRef && U) { auto Die = U->getDIEForOffset(U->getOffset() + Operands[Operand]); if (Die && Die.getTag() == dwarf::DW_TAG_base_type) { - OS << format(" (0x%08x)", U->getOffset() + Operands[Operand]); + OS << format(" (0x%08" PRIx64 ")", U->getOffset() + Operands[Operand]); if (auto Name = Die.find(dwarf::DW_AT_name)) OS << " \"" << Name->getAsCString() << "\""; } else { @@ -271,7 +271,7 @@ Operands[Operand]); } } else if (Size == Operation::SizeBlock) { - uint32_t Offset = Operands[Operand]; + uint64_t Offset = Operands[Operand]; for (unsigned i = 0; i < Operands[Operand - 1]; ++i) OS << format(" 0x%02x", Expr->Data.getU8(&Offset)); } else { @@ -290,7 +290,7 @@ uint32_t EntryValExprSize = 0; for (auto &Op : *this) { if (!Op.print(OS, this, RegInfo, U, IsEH)) { - uint32_t FailOffset = Op.getEndOffset(); + uint64_t FailOffset = Op.getEndOffset(); while (FailOffset < Data.getData().size()) OS << format(" %02x", Data.getU8(&FailOffset)); return; Index: llvm/trunk/lib/DebugInfo/DWARF/DWARFGdbIndex.cpp =================================================================== --- llvm/trunk/lib/DebugInfo/DWARF/DWARFGdbIndex.cpp +++ llvm/trunk/lib/DebugInfo/DWARF/DWARFGdbIndex.cpp @@ -112,7 +112,7 @@ } bool DWARFGdbIndex::parseImpl(DataExtractor Data) { - uint32_t Offset = 0; + uint64_t Offset = 0; // Only version 7 is supported at this moment. Version = Data.getU32(&Offset); Index: llvm/trunk/lib/DebugInfo/DWARF/DWARFListTable.cpp =================================================================== --- llvm/trunk/lib/DebugInfo/DWARF/DWARFListTable.cpp +++ llvm/trunk/lib/DebugInfo/DWARF/DWARFListTable.cpp @@ -16,32 +16,32 @@ using namespace llvm; Error DWARFListTableHeader::extract(DWARFDataExtractor Data, - uint32_t *OffsetPtr) { + uint64_t *OffsetPtr) { HeaderOffset = *OffsetPtr; // Read and verify the length field. if (!Data.isValidOffsetForDataOfSize(*OffsetPtr, sizeof(uint32_t))) return createStringError(errc::invalid_argument, "section is not large enough to contain a " - "%s table length at offset 0x%" PRIx32, + "%s table length at offset 0x%" PRIx64, SectionName.data(), *OffsetPtr); // TODO: Add support for DWARF64. HeaderData.Length = Data.getRelocatedValue(4, OffsetPtr); if (HeaderData.Length == dwarf::DW_LENGTH_DWARF64) return createStringError(errc::not_supported, - "DWARF64 is not supported in %s at offset 0x%" PRIx32, + "DWARF64 is not supported in %s at offset 0x%" PRIx64, SectionName.data(), HeaderOffset); Format = dwarf::DwarfFormat::DWARF32; if (HeaderData.Length + sizeof(uint32_t) < sizeof(Header)) return createStringError(errc::invalid_argument, - "%s table at offset 0x%" PRIx32 + "%s table at offset 0x%" PRIx64 " has too small length (0x%" PRIx32 ") to contain a complete header", SectionName.data(), HeaderOffset, length()); - uint32_t End = HeaderOffset + length(); + uint64_t End = HeaderOffset + length(); if (!Data.isValidOffsetForDataOfSize(HeaderOffset, End - HeaderOffset)) return createStringError(errc::invalid_argument, "section is not large enough to contain a %s table " - "of length 0x%" PRIx32 " at offset 0x%" PRIx32, + "of length 0x%" PRIx32 " at offset 0x%" PRIx64, SectionName.data(), length(), HeaderOffset); HeaderData.Version = Data.getU16(OffsetPtr); @@ -53,22 +53,22 @@ if (HeaderData.Version != 5) return createStringError(errc::invalid_argument, "unrecognised %s table version %" PRIu16 - " in table at offset 0x%" PRIx32, + " in table at offset 0x%" PRIx64, SectionName.data(), HeaderData.Version, HeaderOffset); if (HeaderData.AddrSize != 4 && HeaderData.AddrSize != 8) return createStringError(errc::not_supported, - "%s table at offset 0x%" PRIx32 + "%s table at offset 0x%" PRIx64 " has unsupported address size %" PRIu8, SectionName.data(), HeaderOffset, HeaderData.AddrSize); if (HeaderData.SegSize != 0) return createStringError(errc::not_supported, - "%s table at offset 0x%" PRIx32 + "%s table at offset 0x%" PRIx64 " has unsupported segment selector size %" PRIu8, SectionName.data(), HeaderOffset, HeaderData.SegSize); if (End < HeaderOffset + sizeof(HeaderData) + HeaderData.OffsetEntryCount * sizeof(uint32_t)) return createStringError(errc::invalid_argument, - "%s table at offset 0x%" PRIx32 " has more offset entries (%" PRIu32 + "%s table at offset 0x%" PRIx64 " has more offset entries (%" PRIu32 ") than there is space for", SectionName.data(), HeaderOffset, HeaderData.OffsetEntryCount); Data.setAddressSize(HeaderData.AddrSize); @@ -79,7 +79,7 @@ void DWARFListTableHeader::dump(raw_ostream &OS, DIDumpOptions DumpOpts) const { if (DumpOpts.Verbose) - OS << format("0x%8.8" PRIx32 ": ", HeaderOffset); + OS << format("0x%8.8" PRIx64 ": ", HeaderOffset); OS << format( "%s list header: length = 0x%8.8" PRIx32 ", version = 0x%4.4" PRIx16 ", " "addr_size = 0x%2.2" PRIx8 ", seg_size = 0x%2.2" PRIx8 @@ -93,7 +93,7 @@ for (const auto &Off : Offsets) { OS << format("\n0x%8.8" PRIx32, Off); if (DumpOpts.Verbose) - OS << format(" => 0x%8.8" PRIx32, + OS << format(" => 0x%8.8" PRIx64, Off + HeaderOffset + sizeof(HeaderData)); } OS << "\n]\n"; Index: llvm/trunk/lib/DebugInfo/DWARF/DWARFTypeUnit.cpp =================================================================== --- llvm/trunk/lib/DebugInfo/DWARF/DWARFTypeUnit.cpp +++ llvm/trunk/lib/DebugInfo/DWARF/DWARFTypeUnit.cpp @@ -28,17 +28,19 @@ return; } - OS << format("0x%08x", getOffset()) << ": Type Unit:" + OS << format("0x%08" PRIx64, getOffset()) << ": Type Unit:" << " length = " << format("0x%08x", getLength()) << " version = " << format("0x%04x", getVersion()); if (getVersion() >= 5) OS << " unit_type = " << dwarf::UnitTypeString(getUnitType()); - OS << " abbr_offset = " << format("0x%04x", getAbbreviations()->getOffset()) + OS << " abbr_offset = " + << format("0x%04" PRIx64, getAbbreviations()->getOffset()) << " addr_size = " << format("0x%02x", getAddressByteSize()) << " name = '" << Name << "'" << " type_signature = " << format("0x%016" PRIx64, getTypeHash()) << " type_offset = " << format("0x%04x", getTypeOffset()) - << " (next unit at " << format("0x%08x", getNextUnitOffset()) << ")\n"; + << " (next unit at " << format("0x%08" PRIx64, getNextUnitOffset()) + << ")\n"; if (DWARFDie TU = getUnitDIE(false)) TU.dump(OS, 0, DumpOpts); Index: llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp =================================================================== --- llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp +++ llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp @@ -66,7 +66,7 @@ // Lazy initialization of Parser, now that we have all section info. if (!Parser) { Parser = [=, &Context, &Obj, &Section, &SOS, - &LS](uint32_t Offset, DWARFSectionKind SectionKind, + &LS](uint64_t Offset, DWARFSectionKind SectionKind, const DWARFSection *CurSection, const DWARFUnitIndex::Entry *IndexEntry) -> std::unique_ptr { @@ -101,7 +101,7 @@ // within a section, although not necessarily within the object file, // even if we do lazy parsing. auto I = this->begin(); - uint32_t Offset = 0; + uint64_t Offset = 0; while (Data.isValidOffset(Offset)) { if (I != this->end() && (&(*I)->getInfoSection() != &Section || (*I)->getOffset() == Offset)) { @@ -126,11 +126,11 @@ return this->insert(I, std::move(Unit))->get(); } -DWARFUnit *DWARFUnitVector::getUnitForOffset(uint32_t Offset) const { +DWARFUnit *DWARFUnitVector::getUnitForOffset(uint64_t Offset) const { auto end = begin() + getNumInfoUnits(); auto *CU = std::upper_bound(begin(), end, Offset, - [](uint32_t LHS, const std::unique_ptr &RHS) { + [](uint64_t LHS, const std::unique_ptr &RHS) { return LHS < RHS->getNextUnitOffset(); }); if (CU != end && (*CU)->getOffset() <= Offset) @@ -149,7 +149,7 @@ auto *CU = std::upper_bound(begin(), end, CUOff->Offset, - [](uint32_t LHS, const std::unique_ptr &RHS) { + [](uint64_t LHS, const std::unique_ptr &RHS) { return LHS < RHS->getNextUnitOffset(); }); if (CU != end && (*CU)->getOffset() <= Offset) @@ -209,7 +209,7 @@ if (I != R.end() && std::next(I) == R.end()) return (*I)->getAddrOffsetSectionItem(Index); } - uint32_t Offset = AddrOffsetSectionBase + Index * getAddressByteSize(); + uint64_t Offset = AddrOffsetSectionBase + Index * getAddressByteSize(); if (AddrOffsetSection->Data.size() < Offset + getAddressByteSize()) return None; DWARFDataExtractor DA(Context.getDWARFObj(), *AddrOffsetSection, @@ -223,7 +223,7 @@ if (!StringOffsetsTableContribution) return None; unsigned ItemSize = getDwarfStringOffsetsByteSize(); - uint32_t Offset = getStringOffsetsBase() + Index * ItemSize; + uint64_t Offset = getStringOffsetsBase() + Index * ItemSize; if (StringOffsetSection.Data.size() < Offset + ItemSize) return None; DWARFDataExtractor DA(Context.getDWARFObj(), StringOffsetSection, @@ -233,7 +233,7 @@ bool DWARFUnitHeader::extract(DWARFContext &Context, const DWARFDataExtractor &debug_info, - uint32_t *offset_ptr, + uint64_t *offset_ptr, DWARFSectionKind SectionKind, const DWARFUnitIndex *Index, const DWARFUnitIndex::Entry *Entry) { @@ -306,14 +306,14 @@ // Parse the rangelist table header, including the optional array of offsets // following it (DWARF v5 and later). static Expected -parseRngListTableHeader(DWARFDataExtractor &DA, uint32_t Offset) { +parseRngListTableHeader(DWARFDataExtractor &DA, uint64_t Offset) { // TODO: Support DWARF64 // We are expected to be called with Offset 0 or pointing just past the table // header, which is 12 bytes long for DWARF32. if (Offset > 0) { if (Offset < 12U) return createStringError(errc::invalid_argument, "Did not detect a valid" - " range list table with base = 0x%" PRIu32, + " range list table with base = 0x%" PRIx64, Offset); Offset -= 12U; } @@ -323,13 +323,13 @@ return Table; } -Error DWARFUnit::extractRangeList(uint32_t RangeListOffset, +Error DWARFUnit::extractRangeList(uint64_t RangeListOffset, DWARFDebugRangeList &RangeList) const { // Require that compile unit is extracted. assert(!DieArray.empty()); DWARFDataExtractor RangesData(Context.getDWARFObj(), *RangeSection, isLittleEndian, getAddressByteSize()); - uint32_t ActualRangeListOffset = RangeSectionBase + RangeListOffset; + uint64_t ActualRangeListOffset = RangeSectionBase + RangeListOffset; return RangeList.extract(RangesData, &ActualRangeListOffset); } @@ -354,8 +354,8 @@ // Set the offset to that of the first DIE and calculate the start of the // next compilation unit header. - uint32_t DIEOffset = getOffset() + getHeaderSize(); - uint32_t NextCUOffset = getNextUnitOffset(); + uint64_t DIEOffset = getOffset() + getHeaderSize(); + uint64_t NextCUOffset = getNextUnitOffset(); DWARFDebugInfoEntry DIE; DWARFDataExtractor DebugInfoData = getDebugInfoExtractor(); uint32_t Depth = 0; @@ -396,7 +396,8 @@ // unit header). if (DIEOffset > NextCUOffset) WithColor::warning() << format("DWARF compile unit extends beyond its " - "bounds cu 0x%8.8x at 0x%8.8x\n", + "bounds cu 0x%8.8" PRIx64 " " + "at 0x%8.8" PRIx64 "\n", getOffset(), DIEOffset); } @@ -541,7 +542,7 @@ } Expected -DWARFUnit::findRnglistFromOffset(uint32_t Offset) { +DWARFUnit::findRnglistFromOffset(uint64_t Offset) { if (getVersion() <= 4) { DWARFDebugRangeList RangeList; if (Error E = extractRangeList(Offset, RangeList)) @@ -780,7 +781,7 @@ // Look for a DWARF64-formatted contribution to the string offsets table // starting at a given offset and record it in a descriptor. static Expected -parseDWARF64StringOffsetsTableHeader(DWARFDataExtractor &DA, uint32_t Offset) { +parseDWARF64StringOffsetsTableHeader(DWARFDataExtractor &DA, uint64_t Offset) { if (!DA.isValidOffsetForDataOfSize(Offset, 16)) return createStringError(errc::invalid_argument, "section offset exceeds section size"); @@ -798,7 +799,7 @@ // Look for a DWARF32-formatted contribution to the string offsets table // starting at a given offset and record it in a descriptor. static Expected -parseDWARF32StringOffsetsTableHeader(DWARFDataExtractor &DA, uint32_t Offset) { +parseDWARF32StringOffsetsTableHeader(DWARFDataExtractor &DA, uint64_t Offset) { if (!DA.isValidOffsetForDataOfSize(Offset, 8)) return createStringError(errc::invalid_argument, "section offset exceeds section size"); @@ -823,7 +824,7 @@ case dwarf::DwarfFormat::DWARF64: { if (Offset < 16) return createStringError(errc::invalid_argument, "insufficient space for 64 bit header prefix"); - auto DescOrError = parseDWARF64StringOffsetsTableHeader(DA, (uint32_t)Offset - 16); + auto DescOrError = parseDWARF64StringOffsetsTableHeader(DA, Offset - 16); if (!DescOrError) return DescOrError.takeError(); Desc = *DescOrError; @@ -832,7 +833,7 @@ case dwarf::DwarfFormat::DWARF32: { if (Offset < 8) return createStringError(errc::invalid_argument, "insufficient space for 32 bit header prefix"); - auto DescOrError = parseDWARF32StringOffsetsTableHeader(DA, (uint32_t)Offset - 8); + auto DescOrError = parseDWARF32StringOffsetsTableHeader(DA, Offset - 8); if (!DescOrError) return DescOrError.takeError(); Desc = *DescOrError; Index: llvm/trunk/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp =================================================================== --- llvm/trunk/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp +++ llvm/trunk/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp @@ -18,7 +18,7 @@ using namespace llvm; bool DWARFUnitIndex::Header::parse(DataExtractor IndexData, - uint32_t *OffsetPtr) { + uint64_t *OffsetPtr) { if (!IndexData.isValidOffsetForDataOfSize(*OffsetPtr, 16)) return false; Version = IndexData.getU32(OffsetPtr); @@ -45,7 +45,7 @@ } bool DWARFUnitIndex::parseImpl(DataExtractor IndexData) { - uint32_t Offset = 0; + uint64_t Offset = 0; if (!Header.parse(IndexData, &Offset)) return false; Index: llvm/trunk/lib/DebugInfo/DWARF/DWARFVerifier.cpp =================================================================== --- llvm/trunk/lib/DebugInfo/DWARF/DWARFVerifier.cpp +++ llvm/trunk/lib/DebugInfo/DWARF/DWARFVerifier.cpp @@ -98,7 +98,7 @@ } bool DWARFVerifier::verifyUnitHeader(const DWARFDataExtractor DebugInfoData, - uint32_t *Offset, unsigned UnitIndex, + uint64_t *Offset, unsigned UnitIndex, uint8_t &UnitType, bool &isUnitDWARF64) { uint64_t AbbrOffset, Length; uint8_t AddrSize = 0; @@ -111,7 +111,7 @@ bool ValidType = true; bool ValidAbbrevOffset = true; - uint32_t OffsetStart = *Offset; + uint64_t OffsetStart = *Offset; Length = DebugInfoData.getU32(Offset); if (Length == dwarf::DW_LENGTH_DWARF64) { Length = DebugInfoData.getU64(Offset); @@ -139,7 +139,7 @@ if (!ValidLength || !ValidVersion || !ValidAddrSize || !ValidAbbrevOffset || !ValidType) { Success = false; - error() << format("Units[%d] - start offset: 0x%08x \n", UnitIndex, + error() << format("Units[%d] - start offset: 0x%08" PRIx64 " \n", UnitIndex, OffsetStart); if (!ValidLength) note() << "The length for this unit is too " @@ -273,7 +273,7 @@ const DWARFObject &DObj = DCtx.getDWARFObj(); DWARFDataExtractor DebugInfoData(DObj, S, DCtx.isLittleEndian(), 0); unsigned NumDebugInfoErrors = 0; - uint32_t OffsetStart = 0, Offset = 0, UnitIdx = 0; + uint64_t OffsetStart = 0, Offset = 0, UnitIdx = 0; uint8_t UnitType = 0; bool isUnitDWARF64 = false; bool isHeaderChainValid = true; @@ -545,7 +545,7 @@ error() << FormEncodingString(Form) << " CU offset " << format("0x%08" PRIx64, CUOffset) << " is invalid (must be less than CU size of " - << format("0x%08" PRIx32, CUSize) << "):\n"; + << format("0x%08" PRIx64, CUSize) << "):\n"; Die.dump(OS, 0, DumpOpts); dump(Die) << '\n'; } else { @@ -635,7 +635,7 @@ // getting the DIE by offset and emitting an error OS << "Verifying .debug_info references...\n"; unsigned NumErrors = 0; - for (const std::pair> &Pair : + for (const std::pair> &Pair : ReferenceToDIEOffsets) { if (DCtx.getDIEForOffset(Pair.first)) continue; @@ -659,12 +659,12 @@ auto StmtSectionOffset = toSectionOffset(Die.find(DW_AT_stmt_list)); if (!StmtSectionOffset) continue; - const uint32_t LineTableOffset = *StmtSectionOffset; + const uint64_t LineTableOffset = *StmtSectionOffset; auto LineTable = DCtx.getLineTableForUnit(CU.get()); if (LineTableOffset < DCtx.getDWARFObj().getLineSection().Data.size()) { if (!LineTable) { ++NumDebugLineErrors; - error() << ".debug_line[" << format("0x%08" PRIx32, LineTableOffset) + error() << ".debug_line[" << format("0x%08" PRIx64, LineTableOffset) << "] was not able to be parsed for CU:\n"; dump(Die) << '\n'; continue; @@ -680,8 +680,8 @@ if (Iter != StmtListToDie.end()) { ++NumDebugLineErrors; error() << "two compile unit DIEs, " - << format("0x%08" PRIx32, Iter->second.getOffset()) << " and " - << format("0x%08" PRIx32, Die.getOffset()) + << format("0x%08" PRIx64, Iter->second.getOffset()) << " and " + << format("0x%08" PRIx64, Die.getOffset()) << ", have the same DW_AT_stmt_list section offset:\n"; dump(Iter->second); dump(Die) << '\n'; @@ -826,10 +826,10 @@ uint32_t NumBuckets = AccelTable.getNumBuckets(); uint32_t NumHashes = AccelTable.getNumHashes(); - uint32_t BucketsOffset = + uint64_t BucketsOffset = AccelTable.getSizeHdr() + AccelTable.getHeaderDataLength(); - uint32_t HashesBase = BucketsOffset + NumBuckets * 4; - uint32_t OffsetsBase = HashesBase + NumHashes * 4; + uint64_t HashesBase = BucketsOffset + NumBuckets * 4; + uint64_t OffsetsBase = HashesBase + NumHashes * 4; for (uint32_t BucketIdx = 0; BucketIdx < NumBuckets; ++BucketIdx) { uint32_t HashIdx = AccelSectionData.getU32(&BucketsOffset); if (HashIdx >= NumHashes && HashIdx != UINT32_MAX) { @@ -849,28 +849,29 @@ } for (uint32_t HashIdx = 0; HashIdx < NumHashes; ++HashIdx) { - uint32_t HashOffset = HashesBase + 4 * HashIdx; - uint32_t DataOffset = OffsetsBase + 4 * HashIdx; + uint64_t HashOffset = HashesBase + 4 * HashIdx; + uint64_t DataOffset = OffsetsBase + 4 * HashIdx; uint32_t Hash = AccelSectionData.getU32(&HashOffset); - uint32_t HashDataOffset = AccelSectionData.getU32(&DataOffset); + uint64_t HashDataOffset = AccelSectionData.getU32(&DataOffset); if (!AccelSectionData.isValidOffsetForDataOfSize(HashDataOffset, sizeof(uint64_t))) { - error() << format("Hash[%d] has invalid HashData offset: 0x%08x.\n", + error() << format("Hash[%d] has invalid HashData offset: " + "0x%08" PRIx64 ".\n", HashIdx, HashDataOffset); ++NumErrors; } - uint32_t StrpOffset; - uint32_t StringOffset; + uint64_t StrpOffset; + uint64_t StringOffset; uint32_t StringCount = 0; - unsigned Offset; + uint64_t Offset; unsigned Tag; while ((StrpOffset = AccelSectionData.getU32(&HashDataOffset)) != 0) { const uint32_t NumHashDataObjects = AccelSectionData.getU32(&HashDataOffset); for (uint32_t HashDataIdx = 0; HashDataIdx < NumHashDataObjects; ++HashDataIdx) { - std::tie(Offset, Tag) = AccelTable.readAtoms(HashDataOffset); + std::tie(Offset, Tag) = AccelTable.readAtoms(&HashDataOffset); auto Die = DCtx.getDIEForOffset(Offset); if (!Die) { const uint32_t BucketIdx = @@ -882,8 +883,8 @@ error() << format( "%s Bucket[%d] Hash[%d] = 0x%08x " - "Str[%u] = 0x%08x " - "DIE[%d] = 0x%08x is not a valid DIE offset for \"%s\".\n", + "Str[%u] = 0x%08" PRIx64 " DIE[%d] = 0x%08" PRIx64 " " + "is not a valid DIE offset for \"%s\".\n", SectionName, BucketIdx, HashIdx, Hash, StringCount, StrpOffset, HashDataIdx, Offset, Name); @@ -908,8 +909,8 @@ DWARFVerifier::verifyDebugNamesCULists(const DWARFDebugNames &AccelTable) { // A map from CU offset to the (first) Name Index offset which claims to index // this CU. - DenseMap CUMap; - const uint32_t NotIndexed = std::numeric_limits::max(); + DenseMap CUMap; + const uint64_t NotIndexed = std::numeric_limits::max(); CUMap.reserve(DCtx.getNumCompileUnits()); for (const auto &CU : DCtx.compile_units()) @@ -924,7 +925,7 @@ continue; } for (uint32_t CU = 0, End = NI.getCUCount(); CU < End; ++CU) { - uint32_t Offset = NI.getCUOffset(CU); + uint64_t Offset = NI.getCUOffset(CU); auto Iter = CUMap.find(Offset); if (Iter == CUMap.end()) { @@ -1205,8 +1206,8 @@ unsigned NumErrors = 0; unsigned NumEntries = 0; - uint32_t EntryID = NTE.getEntryOffset(); - uint32_t NextEntryID = EntryID; + uint64_t EntryID = NTE.getEntryOffset(); + uint64_t NextEntryID = EntryID; Expected EntryOr = NI.getEntry(&NextEntryID); for (; EntryOr; ++NumEntries, EntryID = NextEntryID, EntryOr = NI.getEntry(&NextEntryID)) { @@ -1218,7 +1219,7 @@ ++NumErrors; continue; } - uint32_t CUOffset = NI.getCUOffset(CUIndex); + uint64_t CUOffset = NI.getCUOffset(CUIndex); uint64_t DIEOffset = CUOffset + *EntryOr->getDIEUnitOffset(); DWARFDie DIE = DCtx.getDIEForOffset(DIEOffset); if (!DIE) { Index: llvm/trunk/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp =================================================================== --- llvm/trunk/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp +++ llvm/trunk/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp @@ -188,10 +188,8 @@ // For the purposes of symbolization, pretend the symbol's address is that // of the function's code, not the descriptor. uint64_t OpdOffset = SymbolAddress - OpdAddress; - uint32_t OpdOffset32 = OpdOffset; - if (OpdOffset == OpdOffset32 && - OpdExtractor->isValidOffsetForAddress(OpdOffset32)) - SymbolAddress = OpdExtractor->getAddress(&OpdOffset32); + if (OpdExtractor->isValidOffsetForAddress(OpdOffset)) + SymbolAddress = OpdExtractor->getAddress(&OpdOffset); } Expected SymbolNameOrErr = Symbol.getName(); if (!SymbolNameOrErr) Index: llvm/trunk/lib/DebugInfo/Symbolize/Symbolize.cpp =================================================================== --- llvm/trunk/lib/DebugInfo/Symbolize/Symbolize.cpp +++ llvm/trunk/lib/DebugInfo/Symbolize/Symbolize.cpp @@ -268,7 +268,7 @@ return false; } DataExtractor DE(*ContentsOrErr, Obj->isLittleEndian(), 0); - uint32_t Offset = 0; + uint64_t Offset = 0; if (const char *DebugNameStr = DE.getCStr(&Offset)) { // 4-byte align the offset. Offset = (Offset + 3) & ~0x3; Index: llvm/trunk/lib/Object/Decompressor.cpp =================================================================== --- llvm/trunk/lib/Object/Decompressor.cpp +++ llvm/trunk/lib/Object/Decompressor.cpp @@ -56,7 +56,7 @@ return createError("corrupted compressed section header"); DataExtractor Extractor(SectionData, IsLittleEndian, 0); - uint32_t Offset = 0; + uint64_t Offset = 0; if (Extractor.getUnsigned(&Offset, Is64Bit ? sizeof(Elf64_Word) : sizeof(Elf32_Word)) != ELFCOMPRESS_ZLIB) Index: llvm/trunk/lib/Object/MachOObjectFile.cpp =================================================================== --- llvm/trunk/lib/Object/MachOObjectFile.cpp +++ llvm/trunk/lib/Object/MachOObjectFile.cpp @@ -4612,7 +4612,7 @@ SmallVectorImpl &Out) const { DataExtractor extractor(ObjectFile::getData(), true, 0); - uint32_t offset = Index; + uint64_t offset = Index; uint64_t data = 0; while (uint64_t delta = extractor.getULEB128(&offset)) { data += delta; Index: llvm/trunk/lib/XRay/FDRRecordProducer.cpp =================================================================== --- llvm/trunk/lib/XRay/FDRRecordProducer.cpp +++ llvm/trunk/lib/XRay/FDRRecordProducer.cpp @@ -89,7 +89,7 @@ if (OffsetPtr == PreReadOffset) return createStringError( std::make_error_code(std::errc::executable_format_error), - "Failed reading one byte from offset %d.", OffsetPtr); + "Failed reading one byte from offset %" PRId64 ".", OffsetPtr); if (isMetadataIntroducer(FirstByte)) { auto LoadedType = FirstByte >> 1; @@ -151,7 +151,7 @@ if (OffsetPtr == PreReadOffset) return createStringError( std::make_error_code(std::errc::executable_format_error), - "Failed reading one byte from offset %d.", OffsetPtr); + "Failed reading one byte from offset %" PRId64 ".", OffsetPtr); // For metadata records, handle especially here. if (isMetadataIntroducer(FirstByte)) { @@ -162,7 +162,8 @@ MetadataRecordOrErr.takeError(), createStringError( std::make_error_code(std::errc::executable_format_error), - "Encountered an unsupported metadata record (%d) at offset %d.", + "Encountered an unsupported metadata record (%d) " + "at offset %" PRId64 ".", LoadedType, PreReadOffset)); R = std::move(MetadataRecordOrErr.get()); } else { @@ -182,8 +183,8 @@ if (OffsetPtr - PreReadOffset > CurrentBufferBytes) return createStringError( std::make_error_code(std::errc::executable_format_error), - "Buffer over-read at offset %d (over-read by %d bytes); Record Type " - "= %s.", + "Buffer over-read at offset %" PRId64 " (over-read by %" PRId64 + " bytes); Record Type = %s.", OffsetPtr, (OffsetPtr - PreReadOffset) - CurrentBufferBytes, Record::kindToString(R->getRecordType()).data()); Index: llvm/trunk/lib/XRay/FileHeaderReader.cpp =================================================================== --- llvm/trunk/lib/XRay/FileHeaderReader.cpp +++ llvm/trunk/lib/XRay/FileHeaderReader.cpp @@ -12,7 +12,7 @@ // Populates the FileHeader reference by reading the first 32 bytes of the file. Expected readBinaryFormatHeader(DataExtractor &HeaderExtractor, - uint32_t &OffsetPtr) { + uint64_t &OffsetPtr) { // FIXME: Maybe deduce whether the data is little or big-endian using some // magic bytes in the beginning of the file? @@ -30,21 +30,24 @@ if (OffsetPtr == PreReadOffset) return createStringError( std::make_error_code(std::errc::invalid_argument), - "Failed reading version from file header at offset %d.", OffsetPtr); + "Failed reading version from file header at offset %" PRId64 ".", + OffsetPtr); PreReadOffset = OffsetPtr; FileHeader.Type = HeaderExtractor.getU16(&OffsetPtr); if (OffsetPtr == PreReadOffset) return createStringError( std::make_error_code(std::errc::invalid_argument), - "Failed reading file type from file header at offset %d.", OffsetPtr); + "Failed reading file type from file header at offset %" PRId64 ".", + OffsetPtr); PreReadOffset = OffsetPtr; uint32_t Bitfield = HeaderExtractor.getU32(&OffsetPtr); if (OffsetPtr == PreReadOffset) return createStringError( std::make_error_code(std::errc::invalid_argument), - "Failed reading flag bits from file header at offset %d.", OffsetPtr); + "Failed reading flag bits from file header at offset %" PRId64 ".", + OffsetPtr); FileHeader.ConstantTSC = Bitfield & 1uL; FileHeader.NonstopTSC = Bitfield & 1uL << 1; @@ -53,7 +56,8 @@ if (OffsetPtr == PreReadOffset) return createStringError( std::make_error_code(std::errc::invalid_argument), - "Failed reading cycle frequency from file header at offset %d.", + "Failed reading cycle frequency from file header at offset %" PRId64 + ".", OffsetPtr); std::memcpy(&FileHeader.FreeFormData, Index: llvm/trunk/lib/XRay/InstrumentationMap.cpp =================================================================== --- llvm/trunk/lib/XRay/InstrumentationMap.cpp +++ llvm/trunk/lib/XRay/InstrumentationMap.cpp @@ -118,7 +118,7 @@ "an XRay sled entry in ELF64."), std::make_error_code(std::errc::executable_format_error)); - auto RelocateOrElse = [&](uint32_t Offset, uint64_t Address) { + auto RelocateOrElse = [&](uint64_t Offset, uint64_t Address) { if (!Address) { uint64_t A = I->getAddress() + C - Contents.bytes_begin() + Offset; RelocMap::const_iterator R = Relocs.find(A); @@ -136,10 +136,10 @@ 8); Sleds.push_back({}); auto &Entry = Sleds.back(); - uint32_t OffsetPtr = 0; - uint32_t AddrOff = OffsetPtr; + uint64_t OffsetPtr = 0; + uint64_t AddrOff = OffsetPtr; Entry.Address = RelocateOrElse(AddrOff, Extractor.getU64(&OffsetPtr)); - uint32_t FuncOff = OffsetPtr; + uint64_t FuncOff = OffsetPtr; Entry.Function = RelocateOrElse(FuncOff, Extractor.getU64(&OffsetPtr)); auto Kind = Extractor.getU8(&OffsetPtr); static constexpr SledEntry::FunctionKinds Kinds[] = { Index: llvm/trunk/lib/XRay/Profile.cpp =================================================================== --- llvm/trunk/lib/XRay/Profile.cpp +++ llvm/trunk/lib/XRay/Profile.cpp @@ -49,9 +49,9 @@ }; static Expected readBlockHeader(DataExtractor &Extractor, - uint32_t &Offset) { + uint64_t &Offset) { BlockHeader H; - uint32_t CurrentOffset = Offset; + uint64_t CurrentOffset = Offset; H.Size = Extractor.getU32(&Offset); if (Offset == CurrentOffset) return make_error( @@ -76,7 +76,7 @@ } static Expected> readPath(DataExtractor &Extractor, - uint32_t &Offset) { + uint64_t &Offset) { // We're reading a sequence of int32_t's until we find a 0. std::vector Path; auto CurrentOffset = Offset; @@ -94,7 +94,7 @@ } static Expected readData(DataExtractor &Extractor, - uint32_t &Offset) { + uint64_t &Offset) { // We expect a certain number of elements for Data: // - A 64-bit CallCount // - A 64-bit CumulativeLocalTime counter @@ -280,7 +280,7 @@ StringRef Data(MappedFile.data(), MappedFile.size()); Profile P; - uint32_t Offset = 0; + uint64_t Offset = 0; DataExtractor Extractor(Data, true, 8); // For each block we get from the file: Index: llvm/trunk/lib/XRay/RecordInitializer.cpp =================================================================== --- llvm/trunk/lib/XRay/RecordInitializer.cpp +++ llvm/trunk/lib/XRay/RecordInitializer.cpp @@ -12,15 +12,15 @@ Error RecordInitializer::visit(BufferExtents &R) { if (!E.isValidOffsetForDataOfSize(OffsetPtr, sizeof(uint64_t))) - return createStringError(std::make_error_code(std::errc::bad_address), - "Invalid offset for a buffer extent (%d).", - OffsetPtr); + return createStringError( + std::make_error_code(std::errc::bad_address), + "Invalid offset for a buffer extent (%" PRId64 ").", OffsetPtr); auto PreReadOffset = OffsetPtr; R.Size = E.getU64(&OffsetPtr); if (PreReadOffset == OffsetPtr) return createStringError(std::make_error_code(std::errc::invalid_argument), - "Cannot read buffer extent at offset %d.", + "Cannot read buffer extent at offset %" PRId64 ".", OffsetPtr); OffsetPtr += MetadataRecord::kMetadataBodySize - (OffsetPtr - PreReadOffset); @@ -30,23 +30,25 @@ Error RecordInitializer::visit(WallclockRecord &R) { if (!E.isValidOffsetForDataOfSize(OffsetPtr, MetadataRecord::kMetadataBodySize)) - return createStringError(std::make_error_code(std::errc::bad_address), - "Invalid offset for a wallclock record (%d).", - OffsetPtr); + return createStringError( + std::make_error_code(std::errc::bad_address), + "Invalid offset for a wallclock record (%" PRId64 ").", OffsetPtr); auto BeginOffset = OffsetPtr; auto PreReadOffset = OffsetPtr; R.Seconds = E.getU64(&OffsetPtr); if (OffsetPtr == PreReadOffset) return createStringError( std::make_error_code(std::errc::invalid_argument), - "Cannot read wall clock 'seconds' field at offset %d.", OffsetPtr); + "Cannot read wall clock 'seconds' field at offset %" PRId64 ".", + OffsetPtr); PreReadOffset = OffsetPtr; R.Nanos = E.getU32(&OffsetPtr); if (OffsetPtr == PreReadOffset) return createStringError( std::make_error_code(std::errc::invalid_argument), - "Cannot read wall clock 'nanos' field at offset %d.", OffsetPtr); + "Cannot read wall clock 'nanos' field at offset %" PRId64 ".", + OffsetPtr); // Align to metadata record size boundary. assert(OffsetPtr - BeginOffset <= MetadataRecord::kMetadataBodySize); @@ -57,21 +59,23 @@ Error RecordInitializer::visit(NewCPUIDRecord &R) { if (!E.isValidOffsetForDataOfSize(OffsetPtr, MetadataRecord::kMetadataBodySize)) - return createStringError(std::make_error_code(std::errc::bad_address), - "Invalid offset for a new cpu id record (%d).", - OffsetPtr); + return createStringError( + std::make_error_code(std::errc::bad_address), + "Invalid offset for a new cpu id record (%" PRId64 ").", OffsetPtr); auto BeginOffset = OffsetPtr; auto PreReadOffset = OffsetPtr; R.CPUId = E.getU16(&OffsetPtr); if (OffsetPtr == PreReadOffset) return createStringError(std::make_error_code(std::errc::invalid_argument), - "Cannot read CPU id at offset %d.", OffsetPtr); + "Cannot read CPU id at offset %" PRId64 ".", + OffsetPtr); PreReadOffset = OffsetPtr; R.TSC = E.getU64(&OffsetPtr); if (OffsetPtr == PreReadOffset) return createStringError(std::make_error_code(std::errc::invalid_argument), - "Cannot read CPU TSC at offset %d.", OffsetPtr); + "Cannot read CPU TSC at offset %" PRId64 ".", + OffsetPtr); OffsetPtr += MetadataRecord::kMetadataBodySize - (OffsetPtr - BeginOffset); return Error::success(); @@ -80,16 +84,16 @@ Error RecordInitializer::visit(TSCWrapRecord &R) { if (!E.isValidOffsetForDataOfSize(OffsetPtr, MetadataRecord::kMetadataBodySize)) - return createStringError(std::make_error_code(std::errc::bad_address), - "Invalid offset for a new TSC wrap record (%d).", - OffsetPtr); + return createStringError( + std::make_error_code(std::errc::bad_address), + "Invalid offset for a new TSC wrap record (%" PRId64 ").", OffsetPtr); auto PreReadOffset = OffsetPtr; R.BaseTSC = E.getU64(&OffsetPtr); if (PreReadOffset == OffsetPtr) - return createStringError(std::make_error_code(std::errc::invalid_argument), - "Cannot read TSC wrap record at offset %d.", - OffsetPtr); + return createStringError( + std::make_error_code(std::errc::invalid_argument), + "Cannot read TSC wrap record at offset %" PRId64 ".", OffsetPtr); OffsetPtr += MetadataRecord::kMetadataBodySize - (OffsetPtr - PreReadOffset); return Error::success(); @@ -98,9 +102,9 @@ Error RecordInitializer::visit(CustomEventRecord &R) { if (!E.isValidOffsetForDataOfSize(OffsetPtr, MetadataRecord::kMetadataBodySize)) - return createStringError(std::make_error_code(std::errc::bad_address), - "Invalid offset for a custom event record (%d).", - OffsetPtr); + return createStringError( + std::make_error_code(std::errc::bad_address), + "Invalid offset for a custom event record (%" PRId64 ").", OffsetPtr); auto BeginOffset = OffsetPtr; auto PreReadOffset = OffsetPtr; @@ -108,20 +112,22 @@ if (PreReadOffset == OffsetPtr) return createStringError( std::make_error_code(std::errc::invalid_argument), - "Cannot read a custom event record size field offset %d.", OffsetPtr); + "Cannot read a custom event record size field offset %" PRId64 ".", + OffsetPtr); if (R.Size <= 0) return createStringError( std::make_error_code(std::errc::bad_address), - "Invalid size for custom event (size = %d) at offset %d.", R.Size, - OffsetPtr); + "Invalid size for custom event (size = %d) at offset %" PRId64 ".", + R.Size, OffsetPtr); PreReadOffset = OffsetPtr; R.TSC = E.getU64(&OffsetPtr); if (PreReadOffset == OffsetPtr) return createStringError( std::make_error_code(std::errc::invalid_argument), - "Cannot read a custom event TSC field at offset %d.", OffsetPtr); + "Cannot read a custom event TSC field at offset %" PRId64 ".", + OffsetPtr); // For version 4 onwards, of the FDR log, we want to also capture the CPU ID // of the custom event. @@ -131,7 +137,7 @@ if (PreReadOffset == OffsetPtr) return createStringError( std::make_error_code(std::errc::invalid_argument), - "Missing CPU field at offset %d", OffsetPtr); + "Missing CPU field at offset %" PRId64 ".", OffsetPtr); } assert(OffsetPtr > BeginOffset && @@ -142,8 +148,8 @@ if (!E.isValidOffsetForDataOfSize(OffsetPtr, R.Size)) return createStringError( std::make_error_code(std::errc::bad_address), - "Cannot read %d bytes of custom event data from offset %d.", R.Size, - OffsetPtr); + "Cannot read %d bytes of custom event data from offset %" PRId64 ".", + R.Size, OffsetPtr); std::vector Buffer; Buffer.resize(R.Size); @@ -151,15 +157,15 @@ if (E.getU8(&OffsetPtr, Buffer.data(), R.Size) != Buffer.data()) return createStringError( std::make_error_code(std::errc::invalid_argument), - "Failed reading data into buffer of size %d at offset %d.", R.Size, - OffsetPtr); + "Failed reading data into buffer of size %d at offset %" PRId64 ".", + R.Size, OffsetPtr); assert(OffsetPtr >= PreReadOffset); if (OffsetPtr - PreReadOffset != static_cast(R.Size)) return createStringError( std::make_error_code(std::errc::invalid_argument), - "Failed reading enough bytes for the custom event payload -- read %d " - "expecting %d bytes at offset %d.", + "Failed reading enough bytes for the custom event payload -- read " + "%" PRId64 " expecting %d bytes at offset %" PRId64 ".", OffsetPtr - PreReadOffset, R.Size, PreReadOffset); R.Data.assign(Buffer.begin(), Buffer.end()); @@ -169,9 +175,9 @@ Error RecordInitializer::visit(CustomEventRecordV5 &R) { if (!E.isValidOffsetForDataOfSize(OffsetPtr, MetadataRecord::kMetadataBodySize)) - return createStringError(std::make_error_code(std::errc::bad_address), - "Invalid offset for a custom event record (%d).", - OffsetPtr); + return createStringError( + std::make_error_code(std::errc::bad_address), + "Invalid offset for a custom event record (%" PRId64 ").", OffsetPtr); auto BeginOffset = OffsetPtr; auto PreReadOffset = OffsetPtr; @@ -180,20 +186,22 @@ if (PreReadOffset == OffsetPtr) return createStringError( std::make_error_code(std::errc::invalid_argument), - "Cannot read a custom event record size field offset %d.", OffsetPtr); + "Cannot read a custom event record size field offset %" PRId64 ".", + OffsetPtr); if (R.Size <= 0) return createStringError( std::make_error_code(std::errc::bad_address), - "Invalid size for custom event (size = %d) at offset %d.", R.Size, - OffsetPtr); + "Invalid size for custom event (size = %d) at offset %" PRId64 ".", + R.Size, OffsetPtr); PreReadOffset = OffsetPtr; R.Delta = E.getSigned(&OffsetPtr, sizeof(int32_t)); if (PreReadOffset == OffsetPtr) return createStringError( std::make_error_code(std::errc::invalid_argument), - "Cannot read a custom event record TSC delta field at offset %d.", + "Cannot read a custom event record TSC delta field at offset " + "%" PRId64 ".", OffsetPtr); assert(OffsetPtr > BeginOffset && @@ -204,8 +212,8 @@ if (!E.isValidOffsetForDataOfSize(OffsetPtr, R.Size)) return createStringError( std::make_error_code(std::errc::bad_address), - "Cannot read %d bytes of custom event data from offset %d.", R.Size, - OffsetPtr); + "Cannot read %d bytes of custom event data from offset %" PRId64 ".", + R.Size, OffsetPtr); std::vector Buffer; Buffer.resize(R.Size); @@ -213,15 +221,15 @@ if (E.getU8(&OffsetPtr, Buffer.data(), R.Size) != Buffer.data()) return createStringError( std::make_error_code(std::errc::invalid_argument), - "Failed reading data into buffer of size %d at offset %d.", R.Size, - OffsetPtr); + "Failed reading data into buffer of size %d at offset %" PRId64 ".", + R.Size, OffsetPtr); assert(OffsetPtr >= PreReadOffset); if (OffsetPtr - PreReadOffset != static_cast(R.Size)) return createStringError( std::make_error_code(std::errc::invalid_argument), - "Failed reading enough bytes for the custom event payload -- read %d " - "expecting %d bytes at offset %d.", + "Failed reading enough bytes for the custom event payload -- read " + "%" PRId64 " expecting %d bytes at offset %" PRId64 ".", OffsetPtr - PreReadOffset, R.Size, PreReadOffset); R.Data.assign(Buffer.begin(), Buffer.end()); @@ -231,9 +239,9 @@ Error RecordInitializer::visit(TypedEventRecord &R) { if (!E.isValidOffsetForDataOfSize(OffsetPtr, MetadataRecord::kMetadataBodySize)) - return createStringError(std::make_error_code(std::errc::bad_address), - "Invalid offset for a typed event record (%d).", - OffsetPtr); + return createStringError( + std::make_error_code(std::errc::bad_address), + "Invalid offset for a typed event record (%" PRId64 ").", OffsetPtr); auto BeginOffset = OffsetPtr; auto PreReadOffset = OffsetPtr; @@ -242,20 +250,22 @@ if (PreReadOffset == OffsetPtr) return createStringError( std::make_error_code(std::errc::invalid_argument), - "Cannot read a typed event record size field offset %d.", OffsetPtr); + "Cannot read a typed event record size field offset %" PRId64 ".", + OffsetPtr); if (R.Size <= 0) return createStringError( std::make_error_code(std::errc::bad_address), - "Invalid size for typed event (size = %d) at offset %d.", R.Size, - OffsetPtr); + "Invalid size for typed event (size = %d) at offset %" PRId64 ".", + R.Size, OffsetPtr); PreReadOffset = OffsetPtr; R.Delta = E.getSigned(&OffsetPtr, sizeof(int32_t)); if (PreReadOffset == OffsetPtr) return createStringError( std::make_error_code(std::errc::invalid_argument), - "Cannot read a typed event record TSC delta field at offset %d.", + "Cannot read a typed event record TSC delta field at offset " + "%" PRId64 ".", OffsetPtr); PreReadOffset = OffsetPtr; @@ -263,7 +273,8 @@ if (PreReadOffset == OffsetPtr) return createStringError( std::make_error_code(std::errc::invalid_argument), - "Cannot read a typed event record type field at offset %d.", OffsetPtr); + "Cannot read a typed event record type field at offset %" PRId64 ".", + OffsetPtr); assert(OffsetPtr > BeginOffset && OffsetPtr - BeginOffset <= MetadataRecord::kMetadataBodySize); @@ -273,8 +284,8 @@ if (!E.isValidOffsetForDataOfSize(OffsetPtr, R.Size)) return createStringError( std::make_error_code(std::errc::bad_address), - "Cannot read %d bytes of custom event data from offset %d.", R.Size, - OffsetPtr); + "Cannot read %d bytes of custom event data from offset %" PRId64 ".", + R.Size, OffsetPtr); std::vector Buffer; Buffer.resize(R.Size); @@ -282,15 +293,15 @@ if (E.getU8(&OffsetPtr, Buffer.data(), R.Size) != Buffer.data()) return createStringError( std::make_error_code(std::errc::invalid_argument), - "Failed reading data into buffer of size %d at offset %d.", R.Size, - OffsetPtr); + "Failed reading data into buffer of size %d at offset %" PRId64 ".", + R.Size, OffsetPtr); assert(OffsetPtr >= PreReadOffset); if (OffsetPtr - PreReadOffset != static_cast(R.Size)) return createStringError( std::make_error_code(std::errc::invalid_argument), - "Failed reading enough bytes for the typed event payload -- read %d " - "expecting %d bytes at offset %d.", + "Failed reading enough bytes for the typed event payload -- read " + "%" PRId64 " expecting %d bytes at offset %" PRId64 ".", OffsetPtr - PreReadOffset, R.Size, PreReadOffset); R.Data.assign(Buffer.begin(), Buffer.end()); @@ -300,16 +311,17 @@ Error RecordInitializer::visit(CallArgRecord &R) { if (!E.isValidOffsetForDataOfSize(OffsetPtr, MetadataRecord::kMetadataBodySize)) - return createStringError(std::make_error_code(std::errc::bad_address), - "Invalid offset for a call argument record (%d).", - OffsetPtr); + return createStringError( + std::make_error_code(std::errc::bad_address), + "Invalid offset for a call argument record (%" PRId64 ").", + OffsetPtr); auto PreReadOffset = OffsetPtr; R.Arg = E.getU64(&OffsetPtr); if (PreReadOffset == OffsetPtr) - return createStringError(std::make_error_code(std::errc::invalid_argument), - "Cannot read a call arg record at offset %d.", - OffsetPtr); + return createStringError( + std::make_error_code(std::errc::invalid_argument), + "Cannot read a call arg record at offset %" PRId64 ".", OffsetPtr); OffsetPtr += MetadataRecord::kMetadataBodySize - (OffsetPtr - PreReadOffset); return Error::success(); @@ -318,16 +330,16 @@ Error RecordInitializer::visit(PIDRecord &R) { if (!E.isValidOffsetForDataOfSize(OffsetPtr, MetadataRecord::kMetadataBodySize)) - return createStringError(std::make_error_code(std::errc::bad_address), - "Invalid offset for a process ID record (%d).", - OffsetPtr); + return createStringError( + std::make_error_code(std::errc::bad_address), + "Invalid offset for a process ID record (%" PRId64 ").", OffsetPtr); auto PreReadOffset = OffsetPtr; R.PID = E.getSigned(&OffsetPtr, 4); if (PreReadOffset == OffsetPtr) - return createStringError(std::make_error_code(std::errc::invalid_argument), - "Cannot read a process ID record at offset %d.", - OffsetPtr); + return createStringError( + std::make_error_code(std::errc::invalid_argument), + "Cannot read a process ID record at offset %" PRId64 ".", OffsetPtr); OffsetPtr += MetadataRecord::kMetadataBodySize - (OffsetPtr - PreReadOffset); return Error::success(); @@ -336,16 +348,16 @@ Error RecordInitializer::visit(NewBufferRecord &R) { if (!E.isValidOffsetForDataOfSize(OffsetPtr, MetadataRecord::kMetadataBodySize)) - return createStringError(std::make_error_code(std::errc::bad_address), - "Invalid offset for a new buffer record (%d).", - OffsetPtr); + return createStringError( + std::make_error_code(std::errc::bad_address), + "Invalid offset for a new buffer record (%" PRId64 ").", OffsetPtr); auto PreReadOffset = OffsetPtr; R.TID = E.getSigned(&OffsetPtr, sizeof(int32_t)); if (PreReadOffset == OffsetPtr) - return createStringError(std::make_error_code(std::errc::invalid_argument), - "Cannot read a new buffer record at offset %d.", - OffsetPtr); + return createStringError( + std::make_error_code(std::errc::invalid_argument), + "Cannot read a new buffer record at offset %" PRId64 ".", OffsetPtr); OffsetPtr += MetadataRecord::kMetadataBodySize - (OffsetPtr - PreReadOffset); return Error::success(); @@ -354,9 +366,10 @@ Error RecordInitializer::visit(EndBufferRecord &R) { if (!E.isValidOffsetForDataOfSize(OffsetPtr, MetadataRecord::kMetadataBodySize)) - return createStringError(std::make_error_code(std::errc::bad_address), - "Invalid offset for an end-of-buffer record (%d).", - OffsetPtr); + return createStringError( + std::make_error_code(std::errc::bad_address), + "Invalid offset for an end-of-buffer record (%" PRId64 ").", + OffsetPtr); OffsetPtr += MetadataRecord::kMetadataBodySize; return Error::success(); @@ -373,17 +386,17 @@ // if (OffsetPtr == 0 || !E.isValidOffsetForDataOfSize( --OffsetPtr, FunctionRecord::kFunctionRecordSize)) - return createStringError(std::make_error_code(std::errc::bad_address), - "Invalid offset for a function record (%d).", - OffsetPtr); + return createStringError( + std::make_error_code(std::errc::bad_address), + "Invalid offset for a function record (%" PRId64 ").", OffsetPtr); auto BeginOffset = OffsetPtr; auto PreReadOffset = BeginOffset; uint32_t Buffer = E.getU32(&OffsetPtr); if (PreReadOffset == OffsetPtr) - return createStringError(std::make_error_code(std::errc::bad_address), - "Cannot read function id field from offset %d.", - OffsetPtr); + return createStringError( + std::make_error_code(std::errc::bad_address), + "Cannot read function id field from offset %" PRId64 ".", OffsetPtr); // To get the function record type, we shift the buffer one to the right // (truncating the function record indicator) then take the three bits @@ -397,18 +410,19 @@ R.Kind = static_cast(FunctionType); break; default: - return createStringError(std::make_error_code(std::errc::invalid_argument), - "Unknown function record type '%d' at offset %d.", - FunctionType, BeginOffset); + return createStringError( + std::make_error_code(std::errc::invalid_argument), + "Unknown function record type '%d' at offset %" PRId64 ".", + FunctionType, BeginOffset); } R.FuncId = Buffer >> 4; PreReadOffset = OffsetPtr; R.Delta = E.getU32(&OffsetPtr); if (OffsetPtr == PreReadOffset) - return createStringError(std::make_error_code(std::errc::invalid_argument), - "Failed reading TSC delta from offset %d.", - OffsetPtr); + return createStringError( + std::make_error_code(std::errc::invalid_argument), + "Failed reading TSC delta from offset %" PRId64 ".", OffsetPtr); assert(FunctionRecord::kFunctionRecordSize == (OffsetPtr - BeginOffset)); return Error::success(); } Index: llvm/trunk/lib/XRay/Trace.cpp =================================================================== --- llvm/trunk/lib/XRay/Trace.cpp +++ llvm/trunk/lib/XRay/Trace.cpp @@ -47,7 +47,7 @@ std::make_error_code(std::errc::invalid_argument)); DataExtractor Reader(Data, IsLittleEndian, 8); - uint32_t OffsetPtr = 0; + uint64_t OffsetPtr = 0; auto FileHeaderOrError = readBinaryFormatHeader(Reader, OffsetPtr); if (!FileHeaderOrError) return FileHeaderOrError.takeError(); @@ -67,13 +67,14 @@ if (!Reader.isValidOffsetForDataOfSize(OffsetPtr, 32)) return createStringError( std::make_error_code(std::errc::executable_format_error), - "Not enough bytes to read a full record at offset %d.", OffsetPtr); + "Not enough bytes to read a full record at offset %" PRId64 ".", + OffsetPtr); auto PreReadOffset = OffsetPtr; auto RecordType = Reader.getU16(&OffsetPtr); if (OffsetPtr == PreReadOffset) return createStringError( std::make_error_code(std::errc::executable_format_error), - "Failed reading record type at offset %d.", OffsetPtr); + "Failed reading record type at offset %" PRId64 ".", OffsetPtr); switch (RecordType) { case 0: { // Normal records. @@ -86,14 +87,15 @@ if (OffsetPtr == PreReadOffset) return createStringError( std::make_error_code(std::errc::executable_format_error), - "Failed reading CPU field at offset %d.", OffsetPtr); + "Failed reading CPU field at offset %" PRId64 ".", OffsetPtr); PreReadOffset = OffsetPtr; auto Type = Reader.getU8(&OffsetPtr); if (OffsetPtr == PreReadOffset) return createStringError( std::make_error_code(std::errc::executable_format_error), - "Failed reading record type field at offset %d.", OffsetPtr); + "Failed reading record type field at offset %" PRId64 ".", + OffsetPtr); switch (Type) { case 0: @@ -111,7 +113,7 @@ default: return createStringError( std::make_error_code(std::errc::executable_format_error), - "Unknown record type '%d' at offset %d.", Type, OffsetPtr); + "Unknown record type '%d' at offset %" PRId64 ".", Type, OffsetPtr); } PreReadOffset = OffsetPtr; @@ -119,28 +121,29 @@ if (OffsetPtr == PreReadOffset) return createStringError( std::make_error_code(std::errc::executable_format_error), - "Failed reading function id field at offset %d.", OffsetPtr); + "Failed reading function id field at offset %" PRId64 ".", + OffsetPtr); PreReadOffset = OffsetPtr; Record.TSC = Reader.getU64(&OffsetPtr); if (OffsetPtr == PreReadOffset) return createStringError( std::make_error_code(std::errc::executable_format_error), - "Failed reading TSC field at offset %d.", OffsetPtr); + "Failed reading TSC field at offset %" PRId64 ".", OffsetPtr); PreReadOffset = OffsetPtr; Record.TId = Reader.getU32(&OffsetPtr); if (OffsetPtr == PreReadOffset) return createStringError( std::make_error_code(std::errc::executable_format_error), - "Failed reading thread id field at offset %d.", OffsetPtr); + "Failed reading thread id field at offset %" PRId64 ".", OffsetPtr); PreReadOffset = OffsetPtr; Record.PId = Reader.getU32(&OffsetPtr); if (OffsetPtr == PreReadOffset) return createStringError( std::make_error_code(std::errc::executable_format_error), - "Failed reading process id at offset %d.", OffsetPtr); + "Failed reading process id at offset %" PRId64 ".", OffsetPtr); break; } @@ -155,21 +158,23 @@ if (OffsetPtr == PreReadOffset) return createStringError( std::make_error_code(std::errc::executable_format_error), - "Failed reading function id field at offset %d.", OffsetPtr); + "Failed reading function id field at offset %" PRId64 ".", + OffsetPtr); PreReadOffset = OffsetPtr; auto TId = Reader.getU32(&OffsetPtr); if (OffsetPtr == PreReadOffset) return createStringError( std::make_error_code(std::errc::executable_format_error), - "Failed reading thread id field at offset %d.", OffsetPtr); + "Failed reading thread id field at offset %" PRId64 ".", OffsetPtr); PreReadOffset = OffsetPtr; auto PId = Reader.getU32(&OffsetPtr); if (OffsetPtr == PreReadOffset) return createStringError( std::make_error_code(std::errc::executable_format_error), - "Failed reading process id field at offset %d.", OffsetPtr); + "Failed reading process id field at offset %" PRId64 ".", + OffsetPtr); // Make a check for versions above 3 for the Pid field if (Record.FuncId != FuncId || Record.TId != TId || @@ -178,7 +183,7 @@ std::make_error_code(std::errc::executable_format_error), "Corrupted log, found arg payload following non-matching " "function+thread record. Record for function %d != %d at offset " - "%d", + "%" PRId64 ".", Record.FuncId, FuncId, OffsetPtr); PreReadOffset = OffsetPtr; @@ -186,7 +191,8 @@ if (OffsetPtr == PreReadOffset) return createStringError( std::make_error_code(std::errc::executable_format_error), - "Failed reading argument payload at offset %d.", OffsetPtr); + "Failed reading argument payload at offset %" PRId64 ".", + OffsetPtr); Record.CallArgs.push_back(Arg); break; @@ -194,7 +200,8 @@ default: return createStringError( std::make_error_code(std::errc::executable_format_error), - "Unknown record type '%d' at offset %d.", RecordType, OffsetPtr); + "Unknown record type '%d' at offset %" PRId64 ".", RecordType, + OffsetPtr); } // Advance the offset pointer enough bytes to align to 32-byte records for // basic mode logs. @@ -265,7 +272,7 @@ "Not enough bytes for an XRay FDR log."); DataExtractor DE(Data, IsLittleEndian, 8); - uint32_t OffsetPtr = 0; + uint64_t OffsetPtr = 0; auto FileHeaderOrError = readBinaryFormatHeader(DE, OffsetPtr); if (!FileHeaderOrError) return FileHeaderOrError.takeError(); @@ -424,7 +431,7 @@ // Only if we can't load either the binary or the YAML format will we yield an // error. DataExtractor HeaderExtractor(DE.getData(), DE.isLittleEndian(), 8); - uint32_t OffsetPtr = 0; + uint64_t OffsetPtr = 0; uint16_t Version = HeaderExtractor.getU16(&OffsetPtr); uint16_t Type = HeaderExtractor.getU16(&OffsetPtr); Index: llvm/trunk/tools/dsymutil/DwarfLinker.h =================================================================== --- llvm/trunk/tools/dsymutil/DwarfLinker.h +++ llvm/trunk/tools/dsymutil/DwarfLinker.h @@ -82,12 +82,12 @@ /// Keeps track of relocations. class RelocationManager { struct ValidReloc { - uint32_t Offset; + uint64_t Offset; uint32_t Size; uint64_t Addend; const DebugMapObject::DebugMapEntry *Mapping; - ValidReloc(uint32_t Offset, uint32_t Size, uint64_t Addend, + ValidReloc(uint64_t Offset, uint32_t Size, uint64_t Addend, const DebugMapObject::DebugMapEntry *Mapping) : Offset(Offset), Size(Size), Addend(Addend), Mapping(Mapping) {} @@ -132,10 +132,10 @@ const DebugMapObject &DMO); /// @} - bool hasValidRelocation(uint32_t StartOffset, uint32_t EndOffset, + bool hasValidRelocation(uint64_t StartOffset, uint64_t EndOffset, CompileUnit::DIEInfo &Info); - bool applyValidRelocs(MutableArrayRef Data, uint32_t BaseOffset, + bool applyValidRelocs(MutableArrayRef Data, uint64_t BaseOffset, bool IsLittleEndian); }; Index: llvm/trunk/tools/dsymutil/DwarfLinker.cpp =================================================================== --- llvm/trunk/tools/dsymutil/DwarfLinker.cpp +++ llvm/trunk/tools/dsymutil/DwarfLinker.cpp @@ -105,10 +105,10 @@ /// Similar to DWARFUnitSection::getUnitForOffset(), but returning our /// CompileUnit object instead. -static CompileUnit *getUnitForOffset(const UnitListTy &Units, unsigned Offset) { +static CompileUnit *getUnitForOffset(const UnitListTy &Units, uint64_t Offset) { auto CU = std::upper_bound( Units.begin(), Units.end(), Offset, - [](uint32_t LHS, const std::unique_ptr &RHS) { + [](uint64_t LHS, const std::unique_ptr &RHS) { return LHS < RHS->getOrigUnit().getNextUnitOffset(); }); return CU != Units.end() ? CU->get() : nullptr; @@ -469,9 +469,9 @@ DMO); continue; } - uint32_t Offset = Offset64; + uint64_t OffsetCopy = Offset64; // Mach-o uses REL relocations, the addend is at the relocation offset. - uint64_t Addend = Data.getUnsigned(&Offset, RelocSize); + uint64_t Addend = Data.getUnsigned(&OffsetCopy, RelocSize); uint64_t SymAddress; int64_t SymOffset; @@ -554,7 +554,7 @@ /// order because it never looks back at relocations it already 'went past'. /// \returns true and sets Info.InDebugMap if it is the case. bool DwarfLinker::RelocationManager::hasValidRelocation( - uint32_t StartOffset, uint32_t EndOffset, CompileUnit::DIEInfo &Info) { + uint64_t StartOffset, uint64_t EndOffset, CompileUnit::DIEInfo &Info) { assert(NextValidReloc == 0 || StartOffset > ValidRelocs[NextValidReloc - 1].Offset); if (NextValidReloc >= ValidRelocs.size()) @@ -595,16 +595,16 @@ /// supposed to point to the position of the first attribute described /// by \p Abbrev. /// \return [StartOffset, EndOffset) as a pair. -static std::pair +static std::pair getAttributeOffsets(const DWARFAbbreviationDeclaration *Abbrev, unsigned Idx, - unsigned Offset, const DWARFUnit &Unit) { + uint64_t Offset, const DWARFUnit &Unit) { DataExtractor Data = Unit.getDebugInfoExtractor(); for (unsigned i = 0; i < Idx; ++i) DWARFFormValue::skipValue(Abbrev->getFormByIndex(i), Data, &Offset, Unit.getFormParams()); - uint32_t End = Offset; + uint64_t End = Offset; DWARFFormValue::skipValue(Abbrev->getFormByIndex(Idx), Data, &End, Unit.getFormParams()); @@ -632,9 +632,9 @@ if (!LocationIdx) return Flags; - uint32_t Offset = DIE.getOffset() + getULEB128Size(Abbrev->getCode()); + uint64_t Offset = DIE.getOffset() + getULEB128Size(Abbrev->getCode()); const DWARFUnit &OrigUnit = Unit.getOrigUnit(); - uint32_t LocationOffset, LocationEndOffset; + uint64_t LocationOffset, LocationEndOffset; std::tie(LocationOffset, LocationEndOffset) = getAttributeOffsets(Abbrev, *LocationIdx, Offset, OrigUnit); @@ -671,9 +671,9 @@ if (!LowPcIdx) return Flags; - uint32_t Offset = DIE.getOffset() + getULEB128Size(Abbrev->getCode()); + uint64_t Offset = DIE.getOffset() + getULEB128Size(Abbrev->getCode()); DWARFUnit &OrigUnit = Unit.getOrigUnit(); - uint32_t LowPcOffset, LowPcEndOffset; + uint64_t LowPcOffset, LowPcEndOffset; std::tie(LowPcOffset, LowPcEndOffset) = getAttributeOffsets(Abbrev, *LowPcIdx, Offset, OrigUnit); @@ -784,7 +784,7 @@ // attributes as kept. DWARFDataExtractor Data = Unit.getDebugInfoExtractor(); const auto *Abbrev = Die.getAbbreviationDeclarationPtr(); - uint32_t Offset = Die.getOffset() + getULEB128Size(Abbrev->getCode()); + uint64_t Offset = Die.getOffset() + getULEB128Size(Abbrev->getCode()); // Mark all DIEs referenced through attributes as kept. for (const auto &AttrSpec : Abbrev->attributes()) { @@ -1029,7 +1029,7 @@ unsigned AttrSize, const DWARFFormValue &Val, const DebugMapObject &DMO, CompileUnit &Unit) { const DWARFUnit &U = Unit.getOrigUnit(); - uint32_t Ref = *Val.getAsReference(); + uint64_t Ref = *Val.getAsReference(); DIE *NewRefDie = nullptr; CompileUnit *RefUnit = nullptr; DeclContext *Ctxt = nullptr; @@ -1100,7 +1100,7 @@ CompileUnit &Unit, SmallVectorImpl &OutputBuffer) { using Encoding = DWARFExpression::Operation::Encoding; - uint32_t OpOffset = 0; + uint64_t OpOffset = 0; for (auto &Op : Expression) { auto Description = Op.getDescription(); // DW_OP_const_type is variable-length and has 3 @@ -1385,7 +1385,7 @@ /// /// \returns whether any reloc has been applied. bool DwarfLinker::RelocationManager::applyValidRelocs( - MutableArrayRef Data, uint32_t BaseOffset, bool IsLittleEndian) { + MutableArrayRef Data, uint64_t BaseOffset, bool IsLittleEndian) { assert((NextValidReloc == 0 || BaseOffset > ValidRelocs[NextValidReloc - 1].Offset) && "BaseOffset should only be increasing."); @@ -1503,7 +1503,7 @@ if (!Unit.getInfo(Idx).Keep) return nullptr; - uint32_t Offset = InputDIE.getOffset(); + uint64_t Offset = InputDIE.getOffset(); assert(!(Die && Info.Clone) && "Can't supply a DIE and a cloned DIE"); if (!Die) { // The DIE might have been already created by a forward reference @@ -1530,7 +1530,7 @@ // Point to the next DIE (generally there is always at least a NULL // entry after the current one). If this is a lone // DW_TAG_compile_unit without any children, point to the next unit. - uint32_t NextOffset = (Idx + 1 < U.getNumDIEs()) + uint64_t NextOffset = (Idx + 1 < U.getNumDIEs()) ? U.getDIEAtIndex(Idx + 1).getOffset() : U.getNextUnitOffset(); AttributesInfo AttrInfo; @@ -1595,7 +1595,7 @@ } DWARFFormValue Val(AttrSpec.Form); - uint32_t AttrSize = Offset; + uint64_t AttrSize = Offset; Val.extractValue(Data, &Offset, U.getFormParams(), &U); AttrSize = Offset - AttrSize; @@ -1712,7 +1712,7 @@ UnitPcOffset = int64_t(OrigLowPc) - Unit.getLowPc(); for (const auto &RangeAttribute : Unit.getRangesAttributes()) { - uint32_t Offset = RangeAttribute.get(); + uint64_t Offset = RangeAttribute.get(); RangeAttribute.set(Streamer->getRangesSectionSize()); if (Error E = RangeList.extract(RangeExtractor, &Offset)) { llvm::consumeError(std::move(E)); @@ -1813,7 +1813,7 @@ // Parse the original line info for the unit. DWARFDebugLine::LineTable LineTable; - uint32_t StmtOffset = *StmtList; + uint64_t StmtOffset = *StmtList; DWARFDataExtractor LineExtractor( OrigDwarf.getDWARFObj(), OrigDwarf.getDWARFObj().getLineSection(), OrigDwarf.isLittleEndian(), Unit.getOrigUnit().getAddressByteSize()); @@ -2008,14 +2008,14 @@ return; DataExtractor Data(FrameData, OrigDwarf.isLittleEndian(), 0); - uint32_t InputOffset = 0; + uint64_t InputOffset = 0; // Store the data of the CIEs defined in this object, keyed by their // offsets. - DenseMap LocalCIES; + DenseMap LocalCIES; while (Data.isValidOffset(InputOffset)) { - uint32_t EntryOffset = InputOffset; + uint64_t EntryOffset = InputOffset; uint32_t InitialLength = Data.getU32(&InputOffset); if (InitialLength == 0xFFFFFFFF) return reportWarning("Dwarf64 bits no supported", DMO); Index: llvm/trunk/tools/dsymutil/DwarfStreamer.h =================================================================== --- llvm/trunk/tools/dsymutil/DwarfStreamer.h +++ llvm/trunk/tools/dsymutil/DwarfStreamer.h @@ -107,12 +107,12 @@ /// Copy the debug_line over to the updated binary while unobfuscating the /// file names and directories. - void translateLineTable(DataExtractor LineData, uint32_t Offset); + void translateLineTable(DataExtractor LineData, uint64_t Offset); /// Copy over the debug sections that are not modified when updating. void copyInvariantDebugSection(const object::ObjectFile &Obj); - uint32_t getLineSectionSize() const { return LineSectionSize; } + uint64_t getLineSectionSize() const { return LineSectionSize; } /// Emit the .debug_pubnames contribution for \p Unit. void emitPubNamesForUnit(const CompileUnit &Unit); @@ -168,7 +168,7 @@ uint32_t RangesSectionSize; uint32_t LocSectionSize; - uint32_t LineSectionSize; + uint64_t LineSectionSize; uint32_t FrameSectionSize; /// Keep track of emitted CUs and their Unique ID. Index: llvm/trunk/tools/dsymutil/DwarfStreamer.cpp =================================================================== --- llvm/trunk/tools/dsymutil/DwarfStreamer.cpp +++ llvm/trunk/tools/dsymutil/DwarfStreamer.cpp @@ -405,7 +405,7 @@ SmallVector Buffer; for (const auto &Attr : Attributes) { - uint32_t Offset = Attr.first.get(); + uint64_t Offset = Attr.first.get(); Attr.first.set(LocSectionSize); // This is the quantity to add to the old location address to get // the correct address for the new one. @@ -584,7 +584,7 @@ /// Copy the debug_line over to the updated binary while unobfuscating the file /// names and directories. -void DwarfStreamer::translateLineTable(DataExtractor Data, uint32_t Offset) { +void DwarfStreamer::translateLineTable(DataExtractor Data, uint64_t Offset) { MS->SwitchSection(MC->getObjectFileInfo()->getDwarfLineSection()); StringRef Contents = Data.getData(); @@ -592,7 +592,7 @@ // length fields that will need to be updated when we change the length of // the files and directories in there. unsigned UnitLength = Data.getU32(&Offset); - unsigned UnitEnd = Offset + UnitLength; + uint64_t UnitEnd = Offset + UnitLength; MCSymbol *BeginLabel = MC->createTempSymbol(); MCSymbol *EndLabel = MC->createTempSymbol(); unsigned Version = Data.getU16(&Offset); @@ -615,7 +615,7 @@ Offset += 4; LineSectionSize += 4; - uint32_t AfterHeaderLengthOffset = Offset; + uint64_t AfterHeaderLengthOffset = Offset; // Skip to the directories. Offset += (Version >= 4) ? 5 : 4; unsigned OpcodeBase = Data.getU8(&Offset); @@ -645,7 +645,7 @@ Asm->emitInt8(0); LineSectionSize += Translated.size() + 1; - uint32_t OffsetBeforeLEBs = Offset; + uint64_t OffsetBeforeLEBs = Offset; Asm->EmitULEB128(Data.getULEB128(&Offset)); Asm->EmitULEB128(Data.getULEB128(&Offset)); Asm->EmitULEB128(Data.getULEB128(&Offset)); Index: llvm/trunk/tools/llvm-dwp/llvm-dwp.cpp =================================================================== --- llvm/trunk/tools/llvm-dwp/llvm-dwp.cpp +++ llvm/trunk/tools/llvm-dwp/llvm-dwp.cpp @@ -70,11 +70,11 @@ if (CurStrSection.empty() || CurStrOffsetSection.empty()) return; - DenseMap OffsetRemapping; + DenseMap OffsetRemapping; DataExtractor Data(CurStrSection, true, 0); - uint32_t LocalOffset = 0; - uint32_t PrevOffset = 0; + uint64_t LocalOffset = 0; + uint64_t PrevOffset = 0; while (const char *s = Data.getCStr(&LocalOffset)) { OffsetRemapping[PrevOffset] = Strings.getOffset(s, LocalOffset - PrevOffset); @@ -85,7 +85,7 @@ Out.SwitchSection(StrOffsetSection); - uint32_t Offset = 0; + uint64_t Offset = 0; uint64_t Size = CurStrOffsetSection.size(); while (Offset < Size) { auto OldOffset = Data.getU32(&Offset); @@ -94,9 +94,9 @@ } } -static uint32_t getCUAbbrev(StringRef Abbrev, uint64_t AbbrCode) { +static uint64_t getCUAbbrev(StringRef Abbrev, uint64_t AbbrCode) { uint64_t CurCode; - uint32_t Offset = 0; + uint64_t Offset = 0; DataExtractor AbbrevData(Abbrev, true, 0); while ((CurCode = AbbrevData.getULEB128(&Offset)) != AbbrCode) { // Tag @@ -118,7 +118,7 @@ static Expected getIndexedString(dwarf::Form Form, DataExtractor InfoData, - uint32_t &InfoOffset, StringRef StrOffsets, StringRef Str) { + uint64_t &InfoOffset, StringRef StrOffsets, StringRef Str) { if (Form == dwarf::DW_FORM_string) return InfoData.getCStr(&InfoOffset); if (Form != dwarf::DW_FORM_GNU_str_index) @@ -126,8 +126,8 @@ "string field encoded without DW_FORM_string or DW_FORM_GNU_str_index"); auto StrIndex = InfoData.getULEB128(&InfoOffset); DataExtractor StrOffsetsData(StrOffsets, true, 0); - uint32_t StrOffsetsOffset = 4 * StrIndex; - uint32_t StrOffset = StrOffsetsData.getU32(&StrOffsetsOffset); + uint64_t StrOffsetsOffset = 4 * StrIndex; + uint64_t StrOffset = StrOffsetsData.getU32(&StrOffsetsOffset); DataExtractor StrData(Str, true, 0); return StrData.getCStr(&StrOffset); } @@ -136,7 +136,7 @@ StringRef Info, StringRef StrOffsets, StringRef Str) { - uint32_t Offset = 0; + uint64_t Offset = 0; DataExtractor InfoData(Info, true, 0); dwarf::DwarfFormat Format = dwarf::DwarfFormat::DWARF32; uint64_t Length = InfoData.getU32(&Offset); @@ -153,7 +153,7 @@ uint32_t AbbrCode = InfoData.getULEB128(&Offset); DataExtractor AbbrevData(Abbrev, true, 0); - uint32_t AbbrevOffset = getCUAbbrev(Abbrev, AbbrCode); + uint64_t AbbrevOffset = getCUAbbrev(Abbrev, AbbrCode); auto Tag = static_cast(AbbrevData.getULEB128(&AbbrevOffset)); if (Tag != dwarf::DW_TAG_compile_unit) return make_error("top level DIE is not a compile unit"); @@ -250,7 +250,7 @@ const UnitIndexEntry &CUEntry, uint32_t &TypesOffset) { for (StringRef Types : TypesSections) { Out.SwitchSection(OutputTypes); - uint32_t Offset = 0; + uint64_t Offset = 0; DataExtractor Data(Types, true, 0); while (Data.isValidOffset(Offset)) { UnitIndexEntry Entry = CUEntry; Index: llvm/trunk/tools/llvm-readobj/DwarfCFIEHPrinter.h =================================================================== --- llvm/trunk/tools/llvm-readobj/DwarfCFIEHPrinter.h +++ llvm/trunk/tools/llvm-readobj/DwarfCFIEHPrinter.h @@ -119,7 +119,7 @@ ELFT::Is64Bits ? 8 : 4); DictScope D(W, "Header"); - uint32_t Offset = 0; + uint64_t Offset = 0; auto Version = DE.getU8(&Offset); W.printNumber("version", Version); Index: llvm/trunk/tools/llvm-xray/xray-fdr-dump.cpp =================================================================== --- llvm/trunk/tools/llvm-xray/xray-fdr-dump.cpp +++ llvm/trunk/tools/llvm-xray/xray-fdr-dump.cpp @@ -51,7 +51,7 @@ sys::fs::closeFile(*FDOrErr); DataExtractor DE(StringRef(MappedFile.data(), MappedFile.size()), true, 8); - uint32_t OffsetPtr = 0; + uint64_t OffsetPtr = 0; auto FileHeaderOrError = readBinaryFormatHeader(DE, OffsetPtr); if (!FileHeaderOrError) Index: llvm/trunk/tools/obj2yaml/dwarf2yaml.cpp =================================================================== --- llvm/trunk/tools/obj2yaml/dwarf2yaml.cpp +++ llvm/trunk/tools/obj2yaml/dwarf2yaml.cpp @@ -16,7 +16,7 @@ using namespace llvm; -void dumpInitialLength(DataExtractor &Data, uint32_t &Offset, +void dumpInitialLength(DataExtractor &Data, uint64_t &Offset, DWARFYAML::InitialLength &InitialLength) { InitialLength.TotalLength = Data.getU32(&Offset); if (InitialLength.isDWARF64()) @@ -59,7 +59,7 @@ void dumpDebugARanges(DWARFContext &DCtx, DWARFYAML::Data &Y) { DataExtractor ArangesData(DCtx.getDWARFObj().getARangeSection(), DCtx.isLittleEndian(), 0); - uint32_t Offset = 0; + uint64_t Offset = 0; DWARFDebugArangeSet Set; while (Set.extract(ArangesData, &Offset)) { @@ -83,7 +83,7 @@ DWARFSection Section) { DWARFDataExtractor PubSectionData(DCtx.getDWARFObj(), Section, DCtx.isLittleEndian(), 0); - uint32_t Offset = 0; + uint64_t Offset = 0; dumpInitialLength(PubSectionData, Offset, Y.Length); Y.Version = PubSectionData.getU16(&Offset); Y.UnitOffset = PubSectionData.getU32(&Offset); @@ -125,7 +125,7 @@ for (auto DIE : CU->dies()) { DWARFYAML::Entry NewEntry; DataExtractor EntryData = CU->getDebugInfoExtractor(); - uint32_t offset = DIE.getOffset(); + uint64_t offset = DIE.getOffset(); assert(EntryData.isValidOffset(offset) && "Invalid DIE Offset"); if (!EntryData.isValidOffset(offset)) @@ -226,7 +226,7 @@ } } -bool dumpFileEntry(DataExtractor &Data, uint32_t &Offset, +bool dumpFileEntry(DataExtractor &Data, uint64_t &Offset, DWARFYAML::File &File) { File.Name = Data.getCStr(&Offset); if (File.Name.empty()) @@ -247,7 +247,7 @@ DWARFYAML::LineTable DebugLines; DataExtractor LineData(DCtx.getDWARFObj().getLineSection().Data, DCtx.isLittleEndian(), CU->getAddressByteSize()); - uint32_t Offset = *StmtOffset; + uint64_t Offset = *StmtOffset; dumpInitialLength(LineData, Offset, DebugLines.Length); uint64_t LineTableLength = DebugLines.Length.getLength(); uint64_t SizeOfPrologueLength = DebugLines.Length.isDWARF64() ? 8 : 4; Index: llvm/trunk/unittests/Support/DataExtractorTest.cpp =================================================================== --- llvm/trunk/unittests/Support/DataExtractorTest.cpp +++ llvm/trunk/unittests/Support/DataExtractorTest.cpp @@ -17,7 +17,7 @@ class DataExtractorTest : public ::testing::Test { }; // Test DataExtractor with both types which can be used for offsets. -typedef ::testing::Types TestTypes; +typedef ::testing::Types TestTypes; TYPED_TEST_CASE(DataExtractorTest, TestTypes); const char numberData[] = "\x80\x90\xFF\xFF\x80\x00\x00\x00"; Index: llvm/trunk/unittests/XRay/FDRProducerConsumerTest.cpp =================================================================== --- llvm/trunk/unittests/XRay/FDRProducerConsumerTest.cpp +++ llvm/trunk/unittests/XRay/FDRProducerConsumerTest.cpp @@ -131,7 +131,7 @@ this->OS.flush(); DataExtractor DE(this->Data, sys::IsLittleEndianHost, 8); - uint32_t OffsetPtr = 0; + uint64_t OffsetPtr = 0; auto HeaderOrErr = readBinaryFormatHeader(DE, OffsetPtr); if (!HeaderOrErr) FAIL() << HeaderOrErr.takeError(); @@ -172,7 +172,7 @@ this->OS.flush(); DataExtractor DE(this->Data, sys::IsLittleEndianHost, 8); - uint32_t OffsetPtr = 0; + uint64_t OffsetPtr = 0; auto HeaderOrErr = readBinaryFormatHeader(DE, OffsetPtr); if (!HeaderOrErr) FAIL() << HeaderOrErr.takeError();