forked from OSchip/llvm-project
Switch LLVM to use 64-bit offsets (2/5)
This updates all libraries and tools in LLVM Core to use 64-bit offsets which directly or indirectly come to DataExtractor. Differential Revision: https://reviews.llvm.org/D65638 llvm-svn: 368014
This commit is contained in:
parent
f5f35c5cd1
commit
f26a70a5e7
|
@ -130,11 +130,11 @@ public:
|
|||
/// \param Attr DWARF attribute to search for.
|
||||
/// \param U the DWARFUnit the contains the DIE.
|
||||
/// \returns Optional DWARF form value if the attribute was extracted.
|
||||
Optional<DWARFFormValue> getAttributeValue(const uint32_t DIEOffset,
|
||||
Optional<DWARFFormValue> getAttributeValue(const uint64_t DIEOffset,
|
||||
const dwarf::Attribute Attr,
|
||||
const DWARFUnit &U) const;
|
||||
|
||||
bool extract(DataExtractor Data, uint32_t* OffsetPtr);
|
||||
bool extract(DataExtractor Data, uint64_t* OffsetPtr);
|
||||
void dump(raw_ostream &OS) const;
|
||||
|
||||
// Return an optional byte size of all attribute data in this abbreviation
|
||||
|
|
|
@ -96,7 +96,7 @@ class AppleAcceleratorTable : public DWARFAcceleratorTable {
|
|||
using AtomType = uint16_t;
|
||||
using Form = dwarf::Form;
|
||||
|
||||
uint32_t DIEOffsetBase;
|
||||
uint64_t DIEOffsetBase;
|
||||
SmallVector<std::pair<AtomType, Form>, 3> Atoms;
|
||||
|
||||
Optional<uint64_t> extractOffset(Optional<DWARFFormValue> Value) const;
|
||||
|
@ -109,7 +109,7 @@ class AppleAcceleratorTable : public DWARFAcceleratorTable {
|
|||
/// Returns true if we should continue scanning for entries or false if we've
|
||||
/// reached the last (sentinel) entry of encountered a parsing error.
|
||||
bool dumpName(ScopedPrinter &W, SmallVectorImpl<DWARFFormValue> &AtomForms,
|
||||
uint32_t *DataOffset) const;
|
||||
uint64_t *DataOffset) const;
|
||||
|
||||
public:
|
||||
/// Apple-specific implementation of an Accelerator Entry.
|
||||
|
@ -119,7 +119,7 @@ public:
|
|||
Entry(const HeaderData &Data);
|
||||
Entry() = default;
|
||||
|
||||
void extract(const AppleAcceleratorTable &AccelTable, uint32_t *Offset);
|
||||
void extract(const AppleAcceleratorTable &AccelTable, uint64_t *Offset);
|
||||
|
||||
public:
|
||||
Optional<uint64_t> getCUOffset() const override;
|
||||
|
@ -143,7 +143,7 @@ public:
|
|||
class ValueIterator : public std::iterator<std::input_iterator_tag, Entry> {
|
||||
const AppleAcceleratorTable *AccelTable = nullptr;
|
||||
Entry Current; ///< The current entry.
|
||||
unsigned DataOffset = 0; ///< Offset into the section.
|
||||
uint64_t DataOffset = 0; ///< Offset into the section.
|
||||
unsigned Data = 0; ///< Current data entry.
|
||||
unsigned NumData = 0; ///< Number of data entries.
|
||||
|
||||
|
@ -151,7 +151,7 @@ public:
|
|||
void Next();
|
||||
public:
|
||||
/// Construct a new iterator for the entries at \p DataOffset.
|
||||
ValueIterator(const AppleAcceleratorTable &AccelTable, unsigned DataOffset);
|
||||
ValueIterator(const AppleAcceleratorTable &AccelTable, uint64_t DataOffset);
|
||||
/// End marker.
|
||||
ValueIterator() = default;
|
||||
|
||||
|
@ -193,7 +193,7 @@ public:
|
|||
/// DieOffset is the offset into the .debug_info section for the DIE
|
||||
/// related to the input hash data offset.
|
||||
/// DieTag is the tag of the DIE
|
||||
std::pair<uint32_t, dwarf::Tag> readAtoms(uint32_t &HashDataOffset);
|
||||
std::pair<uint64_t, dwarf::Tag> readAtoms(uint64_t *HashDataOffset);
|
||||
void dump(raw_ostream &OS) const override;
|
||||
|
||||
/// Look up all entries in the accelerator table matching \c Key.
|
||||
|
@ -245,7 +245,7 @@ public:
|
|||
struct Header : public HeaderPOD {
|
||||
SmallString<8> AugmentationString;
|
||||
|
||||
Error extract(const DWARFDataExtractor &AS, uint32_t *Offset);
|
||||
Error extract(const DWARFDataExtractor &AS, uint64_t *Offset);
|
||||
void dump(ScopedPrinter &W) const;
|
||||
};
|
||||
|
||||
|
@ -354,12 +354,12 @@ public:
|
|||
DataExtractor StrData;
|
||||
|
||||
uint32_t Index;
|
||||
uint32_t StringOffset;
|
||||
uint32_t EntryOffset;
|
||||
uint64_t StringOffset;
|
||||
uint64_t EntryOffset;
|
||||
|
||||
public:
|
||||
NameTableEntry(const DataExtractor &StrData, uint32_t Index,
|
||||
uint32_t StringOffset, uint32_t EntryOffset)
|
||||
uint64_t StringOffset, uint64_t EntryOffset)
|
||||
: StrData(StrData), Index(Index), StringOffset(StringOffset),
|
||||
EntryOffset(EntryOffset) {}
|
||||
|
||||
|
@ -367,17 +367,17 @@ public:
|
|||
uint32_t getIndex() const { return Index; }
|
||||
|
||||
/// Returns the offset of the name of the described entities.
|
||||
uint32_t getStringOffset() const { return StringOffset; }
|
||||
uint64_t getStringOffset() const { return StringOffset; }
|
||||
|
||||
/// Return the string referenced by this name table entry or nullptr if the
|
||||
/// string offset is not valid.
|
||||
const char *getString() const {
|
||||
uint32_t Off = StringOffset;
|
||||
uint64_t Off = StringOffset;
|
||||
return StrData.getCStr(&Off);
|
||||
}
|
||||
|
||||
/// Returns the offset of the first Entry in the list.
|
||||
uint32_t getEntryOffset() const { return EntryOffset; }
|
||||
uint64_t getEntryOffset() const { return EntryOffset; }
|
||||
};
|
||||
|
||||
/// Represents a single accelerator table within the DWARF v5 .debug_names
|
||||
|
@ -389,40 +389,40 @@ public:
|
|||
|
||||
// Base of the whole unit and of various important tables, as offsets from
|
||||
// the start of the section.
|
||||
uint32_t Base;
|
||||
uint32_t CUsBase;
|
||||
uint32_t BucketsBase;
|
||||
uint32_t HashesBase;
|
||||
uint32_t StringOffsetsBase;
|
||||
uint32_t EntryOffsetsBase;
|
||||
uint32_t EntriesBase;
|
||||
uint64_t Base;
|
||||
uint64_t CUsBase;
|
||||
uint64_t BucketsBase;
|
||||
uint64_t HashesBase;
|
||||
uint64_t StringOffsetsBase;
|
||||
uint64_t EntryOffsetsBase;
|
||||
uint64_t EntriesBase;
|
||||
|
||||
void dumpCUs(ScopedPrinter &W) const;
|
||||
void dumpLocalTUs(ScopedPrinter &W) const;
|
||||
void dumpForeignTUs(ScopedPrinter &W) const;
|
||||
void dumpAbbreviations(ScopedPrinter &W) const;
|
||||
bool dumpEntry(ScopedPrinter &W, uint32_t *Offset) const;
|
||||
bool dumpEntry(ScopedPrinter &W, uint64_t *Offset) const;
|
||||
void dumpName(ScopedPrinter &W, const NameTableEntry &NTE,
|
||||
Optional<uint32_t> Hash) const;
|
||||
void dumpBucket(ScopedPrinter &W, uint32_t Bucket) const;
|
||||
|
||||
Expected<AttributeEncoding> extractAttributeEncoding(uint32_t *Offset);
|
||||
Expected<AttributeEncoding> extractAttributeEncoding(uint64_t *Offset);
|
||||
|
||||
Expected<std::vector<AttributeEncoding>>
|
||||
extractAttributeEncodings(uint32_t *Offset);
|
||||
extractAttributeEncodings(uint64_t *Offset);
|
||||
|
||||
Expected<Abbrev> extractAbbrev(uint32_t *Offset);
|
||||
Expected<Abbrev> extractAbbrev(uint64_t *Offset);
|
||||
|
||||
public:
|
||||
NameIndex(const DWARFDebugNames &Section, uint32_t Base)
|
||||
NameIndex(const DWARFDebugNames &Section, uint64_t Base)
|
||||
: Section(Section), Base(Base) {}
|
||||
|
||||
/// Reads offset of compilation unit CU. CU is 0-based.
|
||||
uint32_t getCUOffset(uint32_t CU) const;
|
||||
uint64_t getCUOffset(uint32_t CU) const;
|
||||
uint32_t getCUCount() const { return Hdr.CompUnitCount; }
|
||||
|
||||
/// Reads offset of local type unit TU, TU is 0-based.
|
||||
uint32_t getLocalTUOffset(uint32_t TU) const;
|
||||
uint64_t getLocalTUOffset(uint32_t TU) const;
|
||||
uint32_t getLocalTUCount() const { return Hdr.LocalTypeUnitCount; }
|
||||
|
||||
/// Reads signature of foreign type unit TU. TU is 0-based.
|
||||
|
@ -451,6 +451,10 @@ public:
|
|||
return Abbrevs;
|
||||
}
|
||||
|
||||
Expected<Entry> 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<Entry> getEntry(uint32_t *Offset) const;
|
||||
|
||||
/// Look up all entries in this Name Index matching \c Key.
|
||||
|
@ -460,8 +464,8 @@ public:
|
|||
NameIterator end() const { return NameIterator(this, getNameCount() + 1); }
|
||||
|
||||
Error extract();
|
||||
uint32_t getUnitOffset() const { return Base; }
|
||||
uint32_t getNextUnitOffset() const { return Base + 4 + Hdr.UnitLength; }
|
||||
uint64_t getUnitOffset() const { return Base; }
|
||||
uint64_t getNextUnitOffset() const { return Base + 4 + Hdr.UnitLength; }
|
||||
void dump(ScopedPrinter &W) const;
|
||||
|
||||
friend class DWARFDebugNames;
|
||||
|
@ -479,12 +483,12 @@ public:
|
|||
bool IsLocal;
|
||||
|
||||
Optional<Entry> CurrentEntry;
|
||||
unsigned DataOffset = 0; ///< Offset into the section.
|
||||
uint64_t DataOffset = 0; ///< Offset into the section.
|
||||
std::string Key; ///< The Key we are searching for.
|
||||
Optional<uint32_t> Hash; ///< Hash of Key, if it has been computed.
|
||||
|
||||
bool getEntryAtCurrentOffset();
|
||||
Optional<uint32_t> findEntryOffsetInCurrentIndex();
|
||||
Optional<uint64_t> findEntryOffsetInCurrentIndex();
|
||||
bool findInCurrentIndex();
|
||||
void searchFromStartOfCurrentIndex();
|
||||
void next();
|
||||
|
@ -572,7 +576,7 @@ public:
|
|||
|
||||
private:
|
||||
SmallVector<NameIndex, 0> NameIndices;
|
||||
DenseMap<uint32_t, const NameIndex *> CUToNameIndex;
|
||||
DenseMap<uint64_t, const NameIndex *> CUToNameIndex;
|
||||
|
||||
public:
|
||||
DWARFDebugNames(const DWARFDataExtractor &AccelSection,
|
||||
|
@ -591,7 +595,7 @@ public:
|
|||
|
||||
/// Return the Name Index covering the compile unit at CUOffset, or nullptr if
|
||||
/// there is no Name Index covering that unit.
|
||||
const NameIndex *getCUNameIndex(uint32_t CUOffset);
|
||||
const NameIndex *getCUNameIndex(uint64_t CUOffset);
|
||||
};
|
||||
|
||||
} // end namespace llvm
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace llvm {
|
|||
/// attributes in a DWARFDie.
|
||||
struct DWARFAttribute {
|
||||
/// The debug info/types offset for this attribute.
|
||||
uint32_t Offset = 0;
|
||||
uint64_t Offset = 0;
|
||||
/// The debug info/types section byte size of the data for this attribute.
|
||||
uint32_t ByteSize = 0;
|
||||
/// The attribute enumeration of this attribute.
|
||||
|
|
|
@ -225,10 +225,10 @@ public:
|
|||
DWARFCompileUnit *getDWOCompileUnitForHash(uint64_t Hash);
|
||||
|
||||
/// Return the compile unit that includes an offset (relative to .debug_info).
|
||||
DWARFCompileUnit *getCompileUnitForOffset(uint32_t Offset);
|
||||
DWARFCompileUnit *getCompileUnitForOffset(uint64_t Offset);
|
||||
|
||||
/// Get a DIE given an exact offset.
|
||||
DWARFDie getDIEForOffset(uint32_t Offset);
|
||||
DWARFDie getDIEForOffset(uint64_t Offset);
|
||||
|
||||
unsigned getMaxVersion() {
|
||||
// Ensure info units have been parsed to discover MaxVersion
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace llvm {
|
|||
class raw_ostream;
|
||||
|
||||
class DWARFAbbreviationDeclarationSet {
|
||||
uint32_t Offset;
|
||||
uint64_t Offset;
|
||||
/// Code of the first abbreviation, if all abbreviations in the set have
|
||||
/// consecutive codes. UINT32_MAX otherwise.
|
||||
uint32_t FirstAbbrCode;
|
||||
|
@ -32,9 +32,9 @@ class DWARFAbbreviationDeclarationSet {
|
|||
public:
|
||||
DWARFAbbreviationDeclarationSet();
|
||||
|
||||
uint32_t getOffset() const { return Offset; }
|
||||
uint64_t getOffset() const { return Offset; }
|
||||
void dump(raw_ostream &OS) const;
|
||||
bool extract(DataExtractor Data, uint32_t *OffsetPtr);
|
||||
bool extract(DataExtractor Data, uint64_t *OffsetPtr);
|
||||
|
||||
const DWARFAbbreviationDeclaration *
|
||||
getAbbreviationDeclaration(uint32_t AbbrCode) const;
|
||||
|
|
|
@ -45,7 +45,7 @@ public:
|
|||
|
||||
private:
|
||||
dwarf::DwarfFormat Format;
|
||||
uint32_t HeaderOffset;
|
||||
uint64_t HeaderOffset;
|
||||
Header HeaderData;
|
||||
uint32_t DataSize = 0;
|
||||
std::vector<uint64_t> Addrs;
|
||||
|
@ -54,11 +54,11 @@ public:
|
|||
void clear();
|
||||
|
||||
/// Extract an entire table, including all addresses.
|
||||
Error extract(DWARFDataExtractor Data, uint32_t *OffsetPtr,
|
||||
Error extract(DWARFDataExtractor Data, uint64_t *OffsetPtr,
|
||||
uint16_t Version, uint8_t AddrSize,
|
||||
std::function<void(Error)> WarnCallback);
|
||||
|
||||
uint32_t getHeaderOffset() const { return HeaderOffset; }
|
||||
uint64_t getHeaderOffset() const { return HeaderOffset; }
|
||||
uint8_t getAddrSize() const { return HeaderData.AddrSize; }
|
||||
void dump(raw_ostream &OS, DIDumpOptions DumpOpts = {}) const;
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ private:
|
|||
using DescriptorColl = std::vector<Descriptor>;
|
||||
using desc_iterator_range = iterator_range<DescriptorColl::const_iterator>;
|
||||
|
||||
uint32_t Offset;
|
||||
uint64_t Offset;
|
||||
Header HeaderData;
|
||||
DescriptorColl ArangeDescriptors;
|
||||
|
||||
|
@ -57,7 +57,7 @@ public:
|
|||
DWARFDebugArangeSet() { clear(); }
|
||||
|
||||
void clear();
|
||||
bool extract(DataExtractor data, uint32_t *offset_ptr);
|
||||
bool extract(DataExtractor data, uint64_t *offset_ptr);
|
||||
void dump(raw_ostream &OS) const;
|
||||
|
||||
uint32_t getCompileUnitDIEOffset() const { return HeaderData.CuOffset; }
|
||||
|
|
|
@ -28,7 +28,7 @@ private:
|
|||
void extract(DataExtractor DebugArangesData);
|
||||
|
||||
/// Call appendRange multiple times and then call construct.
|
||||
void appendRange(uint32_t CUOffset, uint64_t LowPC, uint64_t HighPC);
|
||||
void appendRange(uint64_t CUOffset, uint64_t LowPC, uint64_t HighPC);
|
||||
void construct();
|
||||
|
||||
struct Range {
|
||||
|
@ -60,10 +60,10 @@ private:
|
|||
|
||||
struct RangeEndpoint {
|
||||
uint64_t Address;
|
||||
uint32_t CUOffset;
|
||||
uint64_t CUOffset;
|
||||
bool IsRangeStart;
|
||||
|
||||
RangeEndpoint(uint64_t Address, uint32_t CUOffset, bool IsRangeStart)
|
||||
RangeEndpoint(uint64_t Address, uint64_t CUOffset, bool IsRangeStart)
|
||||
: Address(Address), CUOffset(CUOffset), IsRangeStart(IsRangeStart) {}
|
||||
|
||||
bool operator<(const RangeEndpoint &Other) const {
|
||||
|
@ -76,7 +76,7 @@ private:
|
|||
|
||||
std::vector<RangeEndpoint> Endpoints;
|
||||
RangeColl Aranges;
|
||||
DenseSet<uint32_t> ParsedCUOffsets;
|
||||
DenseSet<uint64_t> ParsedCUOffsets;
|
||||
};
|
||||
|
||||
} // end namespace llvm
|
||||
|
|
|
@ -69,7 +69,7 @@ public:
|
|||
/// starting at *Offset and ending at EndOffset. *Offset is updated
|
||||
/// to EndOffset upon successful parsing, or indicates the offset
|
||||
/// where a problem occurred in case an error is returned.
|
||||
Error parse(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;
|
||||
|
|
|
@ -22,7 +22,7 @@ class DWARFUnit;
|
|||
/// DWARFDebugInfoEntry - A DIE with only the minimum required data.
|
||||
class DWARFDebugInfoEntry {
|
||||
/// Offset within the .debug_info of the start of this entry.
|
||||
uint32_t Offset = 0;
|
||||
uint64_t Offset = 0;
|
||||
|
||||
/// The integer depth of this DIE within the compile unit DIEs where the
|
||||
/// compile/type unit DIE has a depth of zero.
|
||||
|
@ -36,14 +36,14 @@ public:
|
|||
/// Extracts a debug info entry, which is a child of a given unit,
|
||||
/// starting at a given offset. If DIE can't be extracted, returns false and
|
||||
/// doesn't change OffsetPtr.
|
||||
bool extractFast(const DWARFUnit &U, uint32_t *OffsetPtr);
|
||||
bool extractFast(const DWARFUnit &U, uint64_t *OffsetPtr);
|
||||
|
||||
/// High performance extraction should use this call.
|
||||
bool extractFast(const DWARFUnit &U, uint32_t *OffsetPtr,
|
||||
const DWARFDataExtractor &DebugInfoData, uint32_t UEndOffset,
|
||||
bool extractFast(const DWARFUnit &U, uint64_t *OffsetPtr,
|
||||
const DWARFDataExtractor &DebugInfoData, uint64_t UEndOffset,
|
||||
uint32_t Depth);
|
||||
|
||||
uint32_t getOffset() const { return Offset; }
|
||||
uint64_t getOffset() const { return Offset; }
|
||||
uint32_t getDepth() const { return Depth; }
|
||||
|
||||
dwarf::Tag getTag() const {
|
||||
|
|
|
@ -134,7 +134,7 @@ public:
|
|||
|
||||
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 @@ public:
|
|||
|
||||
/// Parse prologue and all rows.
|
||||
Error parse(
|
||||
DWARFDataExtractor &DebugLineData, uint32_t *OffsetPtr,
|
||||
DWARFDataExtractor &DebugLineData, uint64_t *OffsetPtr,
|
||||
const DWARFContext &Ctx, const DWARFUnit *U,
|
||||
std::function<void(Error)> RecoverableErrorCallback,
|
||||
raw_ostream *OS = nullptr);
|
||||
|
@ -305,9 +305,9 @@ public:
|
|||
std::vector<uint32_t> &Result) const;
|
||||
};
|
||||
|
||||
const LineTable *getLineTable(uint32_t Offset) const;
|
||||
const LineTable *getLineTable(uint64_t Offset) const;
|
||||
Expected<const LineTable *> getOrParseLineTable(
|
||||
DWARFDataExtractor &DebugLineData, uint32_t Offset,
|
||||
DWARFDataExtractor &DebugLineData, uint64_t Offset,
|
||||
const DWARFContext &Ctx, const DWARFUnit *U,
|
||||
std::function<void(Error)> RecoverableErrorCallback);
|
||||
|
||||
|
@ -350,17 +350,17 @@ public:
|
|||
bool done() const { return Done; }
|
||||
|
||||
/// Get the offset the parser has reached.
|
||||
uint32_t getOffset() const { return Offset; }
|
||||
uint64_t getOffset() const { return Offset; }
|
||||
|
||||
private:
|
||||
DWARFUnit *prepareToParse(uint32_t Offset);
|
||||
void moveToNextTable(uint32_t OldOffset, const Prologue &P);
|
||||
DWARFUnit *prepareToParse(uint64_t Offset);
|
||||
void moveToNextTable(uint64_t OldOffset, const Prologue &P);
|
||||
|
||||
LineToUnitMap LineToUnit;
|
||||
|
||||
DWARFDataExtractor &DebugLineData;
|
||||
const DWARFContext &Context;
|
||||
uint32_t Offset = 0;
|
||||
uint64_t Offset = 0;
|
||||
bool Done = false;
|
||||
};
|
||||
|
||||
|
@ -377,7 +377,7 @@ private:
|
|||
struct Sequence Sequence;
|
||||
};
|
||||
|
||||
using LineTableMapTy = std::map<uint32_t, LineTable>;
|
||||
using LineTableMapTy = std::map<uint64_t, LineTable>;
|
||||
using LineTableIter = LineTableMapTy::iterator;
|
||||
using LineTableConstIter = LineTableMapTy::const_iterator;
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ public:
|
|||
struct LocationList {
|
||||
/// The beginning offset where this location list is stored in the debug_loc
|
||||
/// section.
|
||||
unsigned Offset;
|
||||
uint64_t Offset;
|
||||
/// All the locations in which the variable is stored.
|
||||
SmallVector<Entry, 2> Entries;
|
||||
/// Dump this list on OS.
|
||||
|
@ -69,7 +69,7 @@ public:
|
|||
LocationList const *getLocationListAtOffset(uint64_t Offset) const;
|
||||
|
||||
Optional<LocationList> parseOneLocationList(DWARFDataExtractor Data,
|
||||
uint32_t *Offset);
|
||||
uint64_t *Offset);
|
||||
};
|
||||
|
||||
class DWARFDebugLoclists {
|
||||
|
@ -82,7 +82,7 @@ public:
|
|||
};
|
||||
|
||||
struct LocationList {
|
||||
unsigned Offset;
|
||||
uint64_t Offset;
|
||||
SmallVector<Entry, 2> Entries;
|
||||
void dump(raw_ostream &OS, uint64_t BaseAddr, bool IsLittleEndian,
|
||||
unsigned AddressSize, const MCRegisterInfo *RegInfo,
|
||||
|
@ -107,7 +107,7 @@ public:
|
|||
LocationList const *getLocationListAtOffset(uint64_t Offset) const;
|
||||
|
||||
static Optional<LocationList>
|
||||
parseOneLocationList(DataExtractor Data, unsigned *Offset, unsigned Version);
|
||||
parseOneLocationList(DataExtractor Data, uint64_t *Offset, unsigned Version);
|
||||
};
|
||||
|
||||
} // end namespace llvm
|
||||
|
|
|
@ -25,7 +25,7 @@ class DWARFDebugPubTable {
|
|||
public:
|
||||
struct Entry {
|
||||
/// Section offset from the beginning of the compilation unit.
|
||||
uint32_t SecOffset;
|
||||
uint64_t SecOffset;
|
||||
|
||||
/// An entry of the various gnu_pub* debug sections.
|
||||
dwarf::PubIndexEntryDescriptor Descriptor;
|
||||
|
@ -50,7 +50,7 @@ public:
|
|||
|
||||
/// The offset from the beginning of the .debug_info section of the
|
||||
/// compilation unit header referenced by the set.
|
||||
uint32_t Offset;
|
||||
uint64_t Offset;
|
||||
|
||||
/// The size in bytes of the contents of the .debug_info section generated
|
||||
/// to represent that compilation unit.
|
||||
|
|
|
@ -60,7 +60,7 @@ public:
|
|||
|
||||
private:
|
||||
/// Offset in .debug_ranges section.
|
||||
uint32_t Offset;
|
||||
uint64_t Offset;
|
||||
uint8_t AddressSize;
|
||||
std::vector<RangeListEntry> Entries;
|
||||
|
||||
|
@ -69,7 +69,7 @@ public:
|
|||
|
||||
void clear();
|
||||
void dump(raw_ostream &OS) const;
|
||||
Error extract(const DWARFDataExtractor &data, uint32_t *offset_ptr);
|
||||
Error extract(const DWARFDataExtractor &data, uint64_t *offset_ptr);
|
||||
const std::vector<RangeListEntry> &getEntries() { return Entries; }
|
||||
|
||||
/// getAbsoluteRanges - Returns absolute address ranges defined by this range
|
||||
|
|
|
@ -34,7 +34,7 @@ struct RangeListEntry : public DWARFListEntryBase {
|
|||
uint64_t Value0;
|
||||
uint64_t Value1;
|
||||
|
||||
Error extract(DWARFDataExtractor Data, uint32_t End, uint32_t *OffsetPtr);
|
||||
Error extract(DWARFDataExtractor Data, uint64_t End, uint64_t *OffsetPtr);
|
||||
void dump(raw_ostream &OS, uint8_t AddrSize, uint8_t MaxEncodingStringLength,
|
||||
uint64_t &CurrentBase, DIDumpOptions DumpOpts,
|
||||
llvm::function_ref<Optional<object::SectionedAddress>(uint32_t)>
|
||||
|
|
|
@ -63,7 +63,7 @@ public:
|
|||
/// Get the absolute offset into the debug info or types section.
|
||||
///
|
||||
/// \returns the DIE offset or -1U if invalid.
|
||||
uint32_t getOffset() const {
|
||||
uint64_t getOffset() const {
|
||||
assert(isValid() && "must check validity prior to calling");
|
||||
return Die->getOffset();
|
||||
}
|
||||
|
|
|
@ -77,18 +77,18 @@ public:
|
|||
uint8_t Opcode; ///< The Op Opcode, DW_OP_<something>.
|
||||
Description Desc;
|
||||
bool Error;
|
||||
uint32_t EndOffset;
|
||||
uint64_t EndOffset;
|
||||
uint64_t Operands[2];
|
||||
uint32_t OperandEndOffsets[2];
|
||||
uint64_t OperandEndOffsets[2];
|
||||
|
||||
public:
|
||||
Description &getDescription() { return Desc; }
|
||||
uint8_t getCode() { return Opcode; }
|
||||
uint64_t getRawOperand(unsigned Idx) { return Operands[Idx]; }
|
||||
uint32_t getOperandEndOffset(unsigned Idx) { return OperandEndOffsets[Idx]; }
|
||||
uint32_t getEndOffset() { return EndOffset; }
|
||||
uint64_t getOperandEndOffset(unsigned Idx) { return OperandEndOffsets[Idx]; }
|
||||
uint64_t getEndOffset() { return EndOffset; }
|
||||
bool extract(DataExtractor Data, uint16_t Version, uint8_t AddressSize,
|
||||
uint32_t Offset);
|
||||
uint64_t Offset);
|
||||
bool isError() { return Error; }
|
||||
bool print(raw_ostream &OS, const DWARFExpression *Expr,
|
||||
const MCRegisterInfo *RegInfo, DWARFUnit *U, bool isEH);
|
||||
|
@ -101,9 +101,9 @@ public:
|
|||
Operation> {
|
||||
friend class DWARFExpression;
|
||||
const DWARFExpression *Expr;
|
||||
uint32_t Offset;
|
||||
uint64_t Offset;
|
||||
Operation Op;
|
||||
iterator(const DWARFExpression *Expr, uint32_t Offset)
|
||||
iterator(const DWARFExpression *Expr, uint64_t Offset)
|
||||
: Expr(Expr), Offset(Offset) {
|
||||
Op.Error =
|
||||
Offset >= Expr->Data.getData().size() ||
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace llvm {
|
|||
/// entries.
|
||||
struct DWARFListEntryBase {
|
||||
/// The offset at which the entry is located in the section.
|
||||
uint32_t Offset;
|
||||
uint64_t Offset;
|
||||
/// The DWARF encoding (DW_RLE_* or DW_LLE_*).
|
||||
uint8_t EntryKind;
|
||||
/// The index of the section this entry belongs to.
|
||||
|
@ -46,8 +46,8 @@ public:
|
|||
const ListEntries &getEntries() const { return Entries; }
|
||||
bool empty() const { return Entries.empty(); }
|
||||
void clear() { Entries.clear(); }
|
||||
Error extract(DWARFDataExtractor Data, uint32_t HeaderOffset, uint32_t End,
|
||||
uint32_t *OffsetPtr, StringRef SectionName,
|
||||
Error extract(DWARFDataExtractor Data, uint64_t HeaderOffset, uint64_t End,
|
||||
uint64_t *OffsetPtr, StringRef SectionName,
|
||||
StringRef ListStringName);
|
||||
};
|
||||
|
||||
|
@ -80,7 +80,7 @@ class DWARFListTableHeader {
|
|||
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 @@ public:
|
|||
HeaderData = {};
|
||||
Offsets.clear();
|
||||
}
|
||||
uint32_t getHeaderOffset() const { return HeaderOffset; }
|
||||
uint64_t getHeaderOffset() const { return HeaderOffset; }
|
||||
uint8_t getAddrSize() const { return HeaderData.AddrSize; }
|
||||
uint32_t getLength() const { return HeaderData.Length; }
|
||||
uint16_t getVersion() const { return HeaderData.Version; }
|
||||
|
@ -111,7 +111,7 @@ public:
|
|||
}
|
||||
|
||||
/// 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 @@ template <typename DWARFListType> class DWARFListTableBase {
|
|||
DWARFListTableHeader Header;
|
||||
/// A mapping between file offsets and lists. It is used to find a particular
|
||||
/// list based on an offset (obtained from DW_AT_ranges, for example).
|
||||
std::map<uint32_t, DWARFListType> ListMap;
|
||||
std::map<uint64_t, DWARFListType> ListMap;
|
||||
/// This string is displayed as a heading before the list is dumped
|
||||
/// (e.g. "ranges:").
|
||||
StringRef HeaderString;
|
||||
|
@ -144,16 +144,16 @@ public:
|
|||
ListMap.clear();
|
||||
}
|
||||
/// Extract the table header and the array of offsets.
|
||||
Error extractHeaderAndOffsets(DWARFDataExtractor Data, uint32_t *OffsetPtr) {
|
||||
Error extractHeaderAndOffsets(DWARFDataExtractor Data, uint64_t *OffsetPtr) {
|
||||
return Header.extract(Data, OffsetPtr);
|
||||
}
|
||||
/// Extract an entire table, including all list entries.
|
||||
Error extract(DWARFDataExtractor Data, uint32_t *OffsetPtr);
|
||||
Error extract(DWARFDataExtractor Data, uint64_t *OffsetPtr);
|
||||
/// Look up a list based on a given offset. Extract it and enter it into the
|
||||
/// list map if necessary.
|
||||
Expected<DWARFListType> findList(DWARFDataExtractor Data, uint32_t Offset);
|
||||
Expected<DWARFListType> findList(DWARFDataExtractor Data, uint64_t Offset);
|
||||
|
||||
uint32_t getHeaderOffset() const { return Header.getHeaderOffset(); }
|
||||
uint64_t getHeaderOffset() const { return Header.getHeaderOffset(); }
|
||||
uint8_t getAddrSize() const { return Header.getAddrSize(); }
|
||||
|
||||
void dump(raw_ostream &OS,
|
||||
|
@ -183,16 +183,16 @@ public:
|
|||
|
||||
template <typename DWARFListType>
|
||||
Error DWARFListTableBase<DWARFListType>::extract(DWARFDataExtractor Data,
|
||||
uint32_t *OffsetPtr) {
|
||||
uint64_t *OffsetPtr) {
|
||||
clear();
|
||||
if (Error E = extractHeaderAndOffsets(Data, OffsetPtr))
|
||||
return E;
|
||||
|
||||
Data.setAddressSize(Header.getAddrSize());
|
||||
uint32_t End = getHeaderOffset() + Header.length();
|
||||
uint64_t End = getHeaderOffset() + Header.length();
|
||||
while (*OffsetPtr < End) {
|
||||
DWARFListType CurrentList;
|
||||
uint32_t Off = *OffsetPtr;
|
||||
uint64_t Off = *OffsetPtr;
|
||||
if (Error E = CurrentList.extract(Data, getHeaderOffset(), End, OffsetPtr,
|
||||
Header.getSectionName(),
|
||||
Header.getListTypeString()))
|
||||
|
@ -208,13 +208,13 @@ Error DWARFListTableBase<DWARFListType>::extract(DWARFDataExtractor Data,
|
|||
|
||||
template <typename ListEntryType>
|
||||
Error DWARFListType<ListEntryType>::extract(DWARFDataExtractor Data,
|
||||
uint32_t HeaderOffset, uint32_t End,
|
||||
uint32_t *OffsetPtr,
|
||||
uint64_t HeaderOffset, uint64_t End,
|
||||
uint64_t *OffsetPtr,
|
||||
StringRef SectionName,
|
||||
StringRef ListTypeString) {
|
||||
if (*OffsetPtr < HeaderOffset || *OffsetPtr >= End)
|
||||
return createStringError(errc::invalid_argument,
|
||||
"invalid %s list offset 0x%" PRIx32,
|
||||
"invalid %s list offset 0x%" PRIx64,
|
||||
ListTypeString.data(), *OffsetPtr);
|
||||
Entries.clear();
|
||||
while (*OffsetPtr < End) {
|
||||
|
@ -227,7 +227,7 @@ Error DWARFListType<ListEntryType>::extract(DWARFDataExtractor Data,
|
|||
}
|
||||
return createStringError(errc::illegal_byte_sequence,
|
||||
"no end of list marker detected at end of %s table "
|
||||
"starting at offset 0x%" PRIx32,
|
||||
"starting at offset 0x%" PRIx64,
|
||||
SectionName.data(), HeaderOffset);
|
||||
}
|
||||
|
||||
|
@ -261,15 +261,15 @@ void DWARFListTableBase<DWARFListType>::dump(
|
|||
template <typename DWARFListType>
|
||||
Expected<DWARFListType>
|
||||
DWARFListTableBase<DWARFListType>::findList(DWARFDataExtractor Data,
|
||||
uint32_t Offset) {
|
||||
uint64_t Offset) {
|
||||
auto Entry = ListMap.find(Offset);
|
||||
if (Entry != ListMap.end())
|
||||
return Entry->second;
|
||||
|
||||
// Extract the list from the section and enter it into the list map.
|
||||
DWARFListType List;
|
||||
uint32_t End = getHeaderOffset() + Header.length();
|
||||
uint32_t StartingOffset = Offset;
|
||||
uint64_t End = getHeaderOffset() + Header.length();
|
||||
uint64_t StartingOffset = Offset;
|
||||
if (Error E =
|
||||
List.extract(Data, getHeaderOffset(), End, &Offset,
|
||||
Header.getSectionName(), Header.getListTypeString()))
|
||||
|
|
|
@ -45,7 +45,7 @@ class DWARFUnit;
|
|||
/// parse the header before deciding what specific kind of unit to construct.
|
||||
class DWARFUnitHeader {
|
||||
// Offset within section.
|
||||
uint32_t Offset = 0;
|
||||
uint64_t Offset = 0;
|
||||
// Version, address size, and DWARF format.
|
||||
dwarf::FormParams FormParams;
|
||||
uint64_t Length = 0;
|
||||
|
@ -70,10 +70,10 @@ class DWARFUnitHeader {
|
|||
public:
|
||||
/// Parse a unit header from \p debug_info starting at \p offset_ptr.
|
||||
bool extract(DWARFContext &Context, const DWARFDataExtractor &debug_info,
|
||||
uint32_t *offset_ptr, DWARFSectionKind Kind = DW_SECT_INFO,
|
||||
uint64_t *offset_ptr, DWARFSectionKind Kind = DW_SECT_INFO,
|
||||
const DWARFUnitIndex *Index = nullptr,
|
||||
const DWARFUnitIndex::Entry *Entry = nullptr);
|
||||
uint32_t getOffset() const { return Offset; }
|
||||
uint64_t getOffset() const { return Offset; }
|
||||
const dwarf::FormParams &getFormParams() const { return FormParams; }
|
||||
uint16_t getVersion() const { return FormParams.Version; }
|
||||
dwarf::DwarfFormat getFormat() const { return FormParams.Format; }
|
||||
|
@ -97,7 +97,7 @@ public:
|
|||
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 @@ const DWARFUnitIndex &getDWARFUnitIndex(DWARFContext &Context,
|
|||
/// Describe a collection of units. Intended to hold all units either from
|
||||
/// .debug_info and .debug_types, or from .debug_info.dwo and .debug_types.dwo.
|
||||
class DWARFUnitVector final : public SmallVector<std::unique_ptr<DWARFUnit>, 1> {
|
||||
std::function<std::unique_ptr<DWARFUnit>(uint32_t, DWARFSectionKind,
|
||||
std::function<std::unique_ptr<DWARFUnit>(uint64_t, DWARFSectionKind,
|
||||
const DWARFSection *,
|
||||
const DWARFUnitIndex::Entry *)>
|
||||
Parser;
|
||||
|
@ -121,7 +121,7 @@ public:
|
|||
using iterator = typename UnitVector::iterator;
|
||||
using iterator_range = llvm::iterator_range<typename UnitVector::iterator>;
|
||||
|
||||
DWARFUnit *getUnitForOffset(uint32_t Offset) const;
|
||||
DWARFUnit *getUnitForOffset(uint64_t Offset) const;
|
||||
DWARFUnit *getUnitForIndexEntry(const DWARFUnitIndex::Entry &E);
|
||||
|
||||
/// Read units from a .debug_info or .debug_types section. Calls made
|
||||
|
@ -275,7 +275,7 @@ public:
|
|||
const DWARFSection &getInfoSection() const { return InfoSection; }
|
||||
const DWARFSection *getLocSection() const { return LocSection; }
|
||||
StringRef getLocSectionData() const { return LocSectionData; }
|
||||
uint32_t getOffset() const { return Header.getOffset(); }
|
||||
uint64_t getOffset() const { return Header.getOffset(); }
|
||||
const dwarf::FormParams &getFormParams() const {
|
||||
return Header.getFormParams();
|
||||
}
|
||||
|
@ -288,7 +288,7 @@ public:
|
|||
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 @@ public:
|
|||
/// .debug_ranges section. If the extraction is unsuccessful, an error
|
||||
/// is returned. Successful extraction requires that the compile unit
|
||||
/// has already been extracted.
|
||||
Error extractRangeList(uint32_t RangeListOffset,
|
||||
Error extractRangeList(uint64_t RangeListOffset,
|
||||
DWARFDebugRangeList &RangeList) const;
|
||||
void clear();
|
||||
|
||||
|
@ -405,7 +405,7 @@ public:
|
|||
|
||||
/// Return a vector of address ranges resulting from a (possibly encoded)
|
||||
/// range list starting at a given offset in the appropriate ranges section.
|
||||
Expected<DWARFAddressRangesVector> findRnglistFromOffset(uint32_t Offset);
|
||||
Expected<DWARFAddressRangesVector> findRnglistFromOffset(uint64_t Offset);
|
||||
|
||||
/// Return a vector of address ranges retrieved from an encoded range
|
||||
/// list whose offset is found via a table lookup given an index (DWARF v5
|
||||
|
@ -470,7 +470,7 @@ public:
|
|||
/// unit's DIE vector.
|
||||
///
|
||||
/// The unit needs to have its DIEs extracted for this method to work.
|
||||
DWARFDie getDIEForOffset(uint32_t Offset) {
|
||||
DWARFDie getDIEForOffset(uint64_t Offset) {
|
||||
extractDIEsIfNeeded(false);
|
||||
assert(!DieArray.empty());
|
||||
auto It =
|
||||
|
|
|
@ -37,7 +37,7 @@ class DWARFUnitIndex {
|
|||
uint32_t NumUnits;
|
||||
uint32_t NumBuckets = 0;
|
||||
|
||||
bool parse(DataExtractor IndexData, uint32_t *OffsetPtr);
|
||||
bool parse(DataExtractor IndexData, uint64_t *OffsetPtr);
|
||||
void dump(raw_ostream &OS) const;
|
||||
};
|
||||
|
||||
|
|
|
@ -94,7 +94,7 @@ private:
|
|||
/// A map that tracks all references (converted absolute references) so we
|
||||
/// can verify each reference points to a valid DIE and not an offset that
|
||||
/// lies between to valid DIEs.
|
||||
std::map<uint64_t, std::set<uint32_t>> ReferenceToDIEOffsets;
|
||||
std::map<uint64_t, std::set<uint64_t>> ReferenceToDIEOffsets;
|
||||
uint32_t NumDebugLineErrors = 0;
|
||||
// Used to relax some checks that do not currently work portably
|
||||
bool IsObjectFile;
|
||||
|
@ -138,7 +138,7 @@ private:
|
|||
///
|
||||
/// \returns true if the header is verified successfully, false otherwise.
|
||||
bool verifyUnitHeader(const DWARFDataExtractor DebugInfoData,
|
||||
uint32_t *Offset, unsigned UnitIndex, uint8_t &UnitType,
|
||||
uint64_t *Offset, unsigned UnitIndex, uint8_t &UnitType,
|
||||
bool &isUnitDWARF64);
|
||||
|
||||
/// Verifies the header of a unit in a .debug_info or .debug_types section.
|
||||
|
|
|
@ -27,7 +27,7 @@ public:
|
|||
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 @@ class FileBasedRecordProducer : public RecordProducer {
|
|||
|
||||
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
|
||||
|
|
|
@ -417,16 +417,16 @@ public:
|
|||
|
||||
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;
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace xray {
|
|||
/// Convenience function for loading the file header given a data extractor at a
|
||||
/// specified offset.
|
||||
Expected<XRayFileHeader> readBinaryFormatHeader(DataExtractor &HeaderExtractor,
|
||||
uint32_t &OffsetPtr);
|
||||
uint64_t &OffsetPtr);
|
||||
|
||||
} // namespace xray
|
||||
} // namespace llvm
|
||||
|
|
|
@ -2151,7 +2151,7 @@ void DwarfDebug::emitDebugLocEntry(ByteStreamer &Streamer,
|
|||
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 @@ void DwarfDebug::emitDebugLocEntry(ByteStreamer &Streamer,
|
|||
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);
|
||||
|
|
|
@ -38,9 +38,9 @@ DWARFAbbreviationDeclaration::DWARFAbbreviationDeclaration() {
|
|||
|
||||
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 @@ DWARFAbbreviationDeclaration::findAttributeIndex(dwarf::Attribute Attr) const {
|
|||
}
|
||||
|
||||
Optional<DWARFFormValue> DWARFAbbreviationDeclaration::getAttributeValue(
|
||||
const uint32_t DIEOffset, const dwarf::Attribute Attr,
|
||||
const uint64_t DIEOffset, const dwarf::Attribute Attr,
|
||||
const DWARFUnit &U) const {
|
||||
Optional<uint32_t> MatchAttrIndex = findAttributeIndex(Attr);
|
||||
if (!MatchAttrIndex)
|
||||
|
@ -158,7 +158,7 @@ Optional<DWARFFormValue> DWARFAbbreviationDeclaration::getAttributeValue(
|
|||
|
||||
// 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) {
|
||||
|
|
|
@ -42,7 +42,7 @@ static Atom formatAtom(unsigned Atom) { return {Atom}; }
|
|||
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 @@ bool AppleAcceleratorTable::validateForms() {
|
|||
return true;
|
||||
}
|
||||
|
||||
std::pair<uint32_t, dwarf::Tag>
|
||||
AppleAcceleratorTable::readAtoms(uint32_t &HashDataOffset) {
|
||||
uint32_t DieOffset = dwarf::DW_INVALID_OFFSET;
|
||||
std::pair<uint64_t, dwarf::Tag>
|
||||
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 @@ Optional<uint64_t> AppleAcceleratorTable::HeaderData::extractOffset(
|
|||
|
||||
bool AppleAcceleratorTable::dumpName(ScopedPrinter &W,
|
||||
SmallVectorImpl<DWARFFormValue> &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 @@ LLVM_DUMP_METHOD void AppleAcceleratorTable::dump(raw_ostream &OS) const {
|
|||
}
|
||||
|
||||
// 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 @@ LLVM_DUMP_METHOD void AppleAcceleratorTable::dump(raw_ostream &OS) const {
|
|||
}
|
||||
|
||||
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 @@ AppleAcceleratorTable::Entry::Entry(
|
|||
}
|
||||
|
||||
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 @@ Optional<dwarf::Tag> AppleAcceleratorTable::Entry::getTag() const {
|
|||
}
|
||||
|
||||
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 @@ AppleAcceleratorTable::equal_range(StringRef Key) const {
|
|||
// 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 @@ void DWARFDebugNames::Header::dump(ScopedPrinter &W) const {
|
|||
}
|
||||
|
||||
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 @@ DWARFDebugNames::Abbrev DWARFDebugNames::AbbrevMapInfo::getTombstoneKey() {
|
|||
}
|
||||
|
||||
Expected<DWARFDebugNames::AttributeEncoding>
|
||||
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 @@ DWARFDebugNames::NameIndex::extractAttributeEncoding(uint32_t *Offset) {
|
|||
}
|
||||
|
||||
Expected<std::vector<DWARFDebugNames::AttributeEncoding>>
|
||||
DWARFDebugNames::NameIndex::extractAttributeEncodings(uint32_t *Offset) {
|
||||
DWARFDebugNames::NameIndex::extractAttributeEncodings(uint64_t *Offset) {
|
||||
std::vector<AttributeEncoding> Result;
|
||||
for (;;) {
|
||||
auto AttrEncOr = extractAttributeEncoding(Offset);
|
||||
|
@ -463,7 +463,7 @@ DWARFDebugNames::NameIndex::extractAttributeEncodings(uint32_t *Offset) {
|
|||
}
|
||||
|
||||
Expected<DWARFDebugNames::Abbrev>
|
||||
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 @@ DWARFDebugNames::NameIndex::extractAbbrev(uint32_t *Offset) {
|
|||
|
||||
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 @@ std::error_code DWARFDebugNames::SentinelError::convertToErrorCode() const {
|
|||
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::Entry>
|
||||
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 @@ DWARFDebugNames::NameIndex::getEntry(uint32_t *Offset) const {
|
|||
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::Entry>
|
||||
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 @@ DWARFDebugNames::NameIndex::getNameTableEntry(uint32_t Index) const {
|
|||
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 @@ uint32_t DWARFDebugNames::NameIndex::getHashArrayEntry(uint32_t Index) const {
|
|||
// 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 @@ void DWARFDebugNames::NameIndex::dumpName(ScopedPrinter &W,
|
|||
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::dumpName(ScopedPrinter &W,
|
|||
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 @@ void DWARFDebugNames::NameIndex::dumpLocalTUs(ScopedPrinter &W) const {
|
|||
|
||||
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 @@ LLVM_DUMP_METHOD void DWARFDebugNames::NameIndex::dump(ScopedPrinter &W) const {
|
|||
}
|
||||
|
||||
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 @@ LLVM_DUMP_METHOD void DWARFDebugNames::dump(raw_ostream &OS) const {
|
|||
NI.dump(W);
|
||||
}
|
||||
|
||||
Optional<uint32_t>
|
||||
Optional<uint64_t>
|
||||
DWARFDebugNames::ValueIterator::findEntryOffsetInCurrentIndex() {
|
||||
const Header &Hdr = CurrentIndex->Hdr;
|
||||
if (Hdr.BucketCount == 0) {
|
||||
|
@ -822,7 +833,7 @@ bool DWARFDebugNames::ValueIterator::getEntryAtCurrentOffset() {
|
|||
}
|
||||
|
||||
bool DWARFDebugNames::ValueIterator::findInCurrentIndex() {
|
||||
Optional<uint32_t> Offset = findEntryOffsetInCurrentIndex();
|
||||
Optional<uint64_t> Offset = findEntryOffsetInCurrentIndex();
|
||||
if (!Offset)
|
||||
return false;
|
||||
DataOffset = *Offset;
|
||||
|
@ -877,7 +888,7 @@ DWARFDebugNames::equal_range(StringRef Key) const {
|
|||
}
|
||||
|
||||
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)
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -138,7 +138,7 @@ static void dumpDWARFv5StringOffsetsSection(
|
|||
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 @@ static void dumpDWARFv5StringOffsetsSection(
|
|||
}
|
||||
// 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 @@ static void dumpDWARFv5StringOffsetsSection(
|
|||
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<uint32_t>::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 @@ static void dumpStringOffsetsSection(raw_ostream &OS, StringRef SectionName,
|
|||
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 @@ static void dumpStringOffsetsSection(raw_ostream &OS, StringRef SectionName,
|
|||
}
|
||||
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 dumpStringOffsetsSection(raw_ostream &OS, StringRef SectionName,
|
|||
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 @@ static void dumpAddrSection(raw_ostream &OS, DWARFDataExtractor &AddrData,
|
|||
// 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 @@ static void dumpRnglistsSection(
|
|||
llvm::function_ref<Optional<object::SectionedAddress>(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 @@ static void dumpLoclistsSection(raw_ostream &OS, DIDumpOptions DumpOpts,
|
|||
DWARFDataExtractor Data,
|
||||
const MCRegisterInfo *MRI,
|
||||
Optional<uint64_t> DumpOffset) {
|
||||
uint32_t Offset = 0;
|
||||
uint64_t Offset = 0;
|
||||
DWARFDebugLoclists Loclists;
|
||||
|
||||
DWARFListTableHeader Header(".debug_loclists", "locations");
|
||||
|
@ -418,7 +410,7 @@ void DWARFContext::dump(
|
|||
|
||||
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 @@ void DWARFContext::dump(
|
|||
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 @@ void DWARFContext::dump(
|
|||
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 @@ void DWARFContext::dump(
|
|||
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 @@ DWARFCompileUnit *DWARFContext::getDWOCompileUnitForHash(uint64_t Hash) {
|
|||
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 @@ Expected<const DWARFDebugLine::LineTable *> DWARFContext::getLineTableForUnit(
|
|||
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 @@ void DWARFContext::parseDWOUnits(bool Lazy) {
|
|||
});
|
||||
}
|
||||
|
||||
DWARFCompileUnit *DWARFContext::getCompileUnitForOffset(uint32_t Offset) {
|
||||
DWARFCompileUnit *DWARFContext::getCompileUnitForOffset(uint64_t Offset) {
|
||||
parseNormalUnits();
|
||||
return dyn_cast_or_null<DWARFCompileUnit>(
|
||||
NormalUnits.getUnitForOffset(Offset));
|
||||
|
@ -906,7 +899,7 @@ DWARFCompileUnit *DWARFContext::getCompileUnitForOffset(uint32_t Offset) {
|
|||
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -26,9 +26,9 @@ void DWARFAbbreviationDeclarationSet::clear() {
|
|||
}
|
||||
|
||||
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::extract(DataExtractor Data) {
|
|||
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 @@ DWARFDebugAbbrev::getAbbreviationDeclarationSet(uint64_t CUAbbrOffset) const {
|
|||
}
|
||||
|
||||
if (Data && CUAbbrOffset < Data->getData().size()) {
|
||||
uint32_t Offset = CUAbbrOffset;
|
||||
uint64_t Offset = CUAbbrOffset;
|
||||
DWARFAbbreviationDeclarationSet AbbrDecls;
|
||||
if (!AbbrDecls.extract(*Data, &Offset))
|
||||
return nullptr;
|
||||
|
|
|
@ -19,7 +19,7 @@ void DWARFDebugAddrTable::clear() {
|
|||
}
|
||||
|
||||
Error DWARFDebugAddrTable::extract(DWARFDataExtractor Data,
|
||||
uint32_t *OffsetPtr,
|
||||
uint64_t *OffsetPtr,
|
||||
uint16_t Version,
|
||||
uint8_t AddrSize,
|
||||
std::function<void(Error)> WarnCallback) {
|
||||
|
@ -30,7 +30,7 @@ Error DWARFDebugAddrTable::extract(DWARFDataExtractor Data,
|
|||
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 @@ Error DWARFDebugAddrTable::extract(DWARFDataExtractor Data,
|
|||
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 @@ Error DWARFDebugAddrTable::extract(DWARFDataExtractor Data,
|
|||
// 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 @@ Error DWARFDebugAddrTable::extract(DWARFDataExtractor Data,
|
|||
// 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 @@ Error DWARFDebugAddrTable::extract(DWARFDataExtractor Data,
|
|||
// 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 @@ Expected<uint64_t> DWARFDebugAddrTable::getAddrEntry(uint32_t Index) const {
|
|||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -24,13 +24,13 @@ void DWARFDebugArangeSet::Descriptor::dump(raw_ostream &OS,
|
|||
}
|
||||
|
||||
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;
|
||||
|
|
|
@ -23,11 +23,11 @@ using namespace llvm;
|
|||
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 @@ void DWARFDebugAranges::generate(DWARFContext *CTX) {
|
|||
// 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<DWARFAddressRangesVector> CURanges = CU->collectAddressRanges();
|
||||
if (!CURanges)
|
||||
|
@ -71,7 +71,7 @@ void DWARFDebugAranges::clear() {
|
|||
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::appendRange(uint32_t CUOffset, uint64_t LowPC,
|
|||
}
|
||||
|
||||
void DWARFDebugAranges::construct() {
|
||||
std::multiset<uint32_t> ValidCUs; // Maintain the set of CUs describing
|
||||
std::multiset<uint64_t> ValidCUs; // Maintain the set of CUs describing
|
||||
// a current address range.
|
||||
llvm::sort(Endpoints);
|
||||
uint64_t PrevAddress = -1ULL;
|
||||
|
|
|
@ -34,8 +34,8 @@ using namespace dwarf;
|
|||
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(Triple::ArchType Arch,
|
|||
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 @@ static void LLVM_ATTRIBUTE_UNUSED dumpDataAux(DataExtractor Data,
|
|||
// 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 @@ static void LLVM_ATTRIBUTE_NORETURN ReportError(uint32_t StartOffset,
|
|||
}
|
||||
|
||||
void DWARFDebugFrame::parse(DWARFDataExtractor Data) {
|
||||
uint32_t Offset = 0;
|
||||
DenseMap<uint32_t, CIE *> CIEs;
|
||||
uint64_t Offset = 0;
|
||||
DenseMap<uint64_t, CIE *> 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 @@ void DWARFDebugFrame::parse(DWARFDataExtractor Data) {
|
|||
// 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<uint32_t>(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 @@ void DWARFDebugFrame::parse(DWARFDataExtractor Data) {
|
|||
Optional<uint32_t> PersonalityEncoding;
|
||||
if (IsEH) {
|
||||
Optional<uint64_t> 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 @@ void DWARFDebugFrame::parse(DWARFDataExtractor Data) {
|
|||
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<uint32_t>(*AugmentationLength);
|
||||
EndAugmentationOffset = Offset + *AugmentationLength;
|
||||
break;
|
||||
case 'B':
|
||||
// B-Key is used for signing functions associated with this
|
||||
|
@ -455,7 +453,8 @@ void DWARFDebugFrame::parse(DWARFDataExtractor Data) {
|
|||
|
||||
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 @@ void DWARFDebugFrame::parse(DWARFDataExtractor Data) {
|
|||
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 @@ void DWARFDebugFrame::parse(DWARFDataExtractor Data) {
|
|||
// Parse the augmentation length and data for this FDE.
|
||||
uint64_t AugmentationLength = Data.getULEB128(&Offset);
|
||||
|
||||
uint32_t EndAugmentationOffset =
|
||||
Offset + static_cast<uint32_t>(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 @@ void DWARFDebugFrame::parse(DWARFDataExtractor Data) {
|
|||
}
|
||||
|
||||
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 @@ void DWARFDebugFrame::parse(DWARFDataExtractor Data) {
|
|||
}
|
||||
|
||||
if (Offset != EndStructureOffset)
|
||||
ReportError(StartOffset, "Parsing entry instructions at %lx failed");
|
||||
ReportError(StartOffset,
|
||||
"Parsing entry instructions at %" PRIx64 " failed");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,15 +19,15 @@ using namespace llvm;
|
|||
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))
|
||||
|
|
|
@ -156,7 +156,7 @@ void DWARFDebugLine::Prologue::dump(raw_ostream &OS,
|
|||
// 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<DWARFFormValue> &IncludeDirectories,
|
||||
std::vector<DWARFDebugLine::FileNameEntry> &FileNames) {
|
||||
|
@ -190,7 +190,7 @@ parseV2DirFileTables(const DWARFDataExtractor &DebugLineData,
|
|||
// Returns the descriptors, or an error if we did not find a path or ran off
|
||||
// the end of the prologue.
|
||||
static llvm::Expected<ContentDescriptors>
|
||||
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 @@ parseV5EntryFormat(const DWARFDataExtractor &DebugLineData, uint32_t *OffsetPtr,
|
|||
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 @@ parseV5EntryFormat(const DWARFDataExtractor &DebugLineData, uint32_t *OffsetPtr,
|
|||
|
||||
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 @@ parseV5DirFileTables(const DWARFDataExtractor &DebugLineData,
|
|||
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 @@ parseV5DirFileTables(const DWARFDataExtractor &DebugLineData,
|
|||
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 @@ parseV5DirFileTables(const DWARFDataExtractor &DebugLineData,
|
|||
}
|
||||
|
||||
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 @@ Error DWARFDebugLine::Prologue::parse(const DWARFDataExtractor &DebugLineData,
|
|||
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 @@ Error DWARFDebugLine::Prologue::parse(const DWARFDataExtractor &DebugLineData,
|
|||
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 @@ void DWARFDebugLine::ParsingState::appendRowToMatrix() {
|
|||
}
|
||||
|
||||
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 @@ DWARFDebugLine::getLineTable(uint32_t Offset) const {
|
|||
}
|
||||
|
||||
Expected<const DWARFDebugLine::LineTable *> DWARFDebugLine::getOrParseLineTable(
|
||||
DWARFDataExtractor &DebugLineData, uint32_t Offset, const DWARFContext &Ctx,
|
||||
DWARFDataExtractor &DebugLineData, uint64_t Offset, const DWARFContext &Ctx,
|
||||
const DWARFUnit *U, std::function<void(Error)> 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 @@ Expected<const DWARFDebugLine::LineTable *> DWARFDebugLine::getOrParseLineTable(
|
|||
}
|
||||
|
||||
Error DWARFDebugLine::LineTable::parse(
|
||||
DWARFDataExtractor &DebugLineData, uint32_t *OffsetPtr,
|
||||
DWARFDataExtractor &DebugLineData, uint64_t *OffsetPtr,
|
||||
const DWARFContext &Ctx, const DWARFUnit *U,
|
||||
std::function<void(Error)> RecoverableErrorCallback, raw_ostream *OS) {
|
||||
const uint32_t DebugLineOffset = *OffsetPtr;
|
||||
const uint64_t DebugLineOffset = *OffsetPtr;
|
||||
|
||||
clear();
|
||||
|
||||
|
@ -549,7 +549,7 @@ Error DWARFDebugLine::LineTable::parse(
|
|||
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 @@ Error DWARFDebugLine::LineTable::parse(
|
|||
|
||||
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 @@ Error DWARFDebugLine::LineTable::parse(
|
|||
// 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 @@ Error DWARFDebugLine::LineTable::parse(
|
|||
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 @@ Error DWARFDebugLine::LineTable::parse(
|
|||
// 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 @@ DWARFDebugLine::LineTable DWARFDebugLine::SectionParser::parseNext(
|
|||
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 @@ void DWARFDebugLine::SectionParser::skip(
|
|||
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 @@ DWARFUnit *DWARFDebugLine::SectionParser::prepareToParse(uint32_t Offset) {
|
|||
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
|
||||
|
|
|
@ -67,7 +67,7 @@ DWARFDebugLoc::getLocationListAtOffset(uint64_t Offset) const {
|
|||
void DWARFDebugLoc::dump(raw_ostream &OS, const MCRegisterInfo *MRI,
|
||||
Optional<uint64_t> 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 @@ void DWARFDebugLoc::dump(raw_ostream &OS, const MCRegisterInfo *MRI,
|
|||
}
|
||||
|
||||
Optional<DWARFDebugLoc::LocationList>
|
||||
DWARFDebugLoc::parseOneLocationList(DWARFDataExtractor Data, unsigned *Offset) {
|
||||
DWARFDebugLoc::parseOneLocationList(DWARFDataExtractor Data, uint64_t *Offset) {
|
||||
LocationList LL;
|
||||
LL.Offset = *Offset;
|
||||
|
||||
|
@ -132,7 +132,7 @@ void DWARFDebugLoc::parse(const DWARFDataExtractor &data) {
|
|||
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 @@ void DWARFDebugLoc::parse(const DWARFDataExtractor &data) {
|
|||
}
|
||||
|
||||
Optional<DWARFDebugLoclists::LocationList>
|
||||
DWARFDebugLoclists::parseOneLocationList(DataExtractor Data, unsigned *Offset,
|
||||
DWARFDebugLoclists::parseOneLocationList(DataExtractor Data, uint64_t *Offset,
|
||||
unsigned Version) {
|
||||
LocationList LL;
|
||||
LL.Offset = *Offset;
|
||||
|
@ -201,7 +201,7 @@ void DWARFDebugLoclists::parse(DataExtractor data, unsigned Version) {
|
|||
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 @@ void DWARFDebugLoclists::dump(raw_ostream &OS, uint64_t BaseAddr,
|
|||
const MCRegisterInfo *MRI,
|
||||
Optional<uint64_t> 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";
|
||||
};
|
||||
|
|
|
@ -53,7 +53,7 @@ void DWARFDebugMacro::dump(raw_ostream &OS) const {
|
|||
}
|
||||
|
||||
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;
|
||||
|
|
|
@ -23,7 +23,7 @@ DWARFDebugPubTable::DWARFDebugPubTable(const DWARFObject &Obj,
|
|||
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 @@ void DWARFDebugPubTable::dump(raw_ostream &OS) const {
|
|||
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);
|
||||
|
|
|
@ -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 @@ Error DWARFDebugRangeList::extract(const DWARFDataExtractor &data,
|
|||
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 @@ Error DWARFDebugRangeList::extract(const DWARFDataExtractor &data,
|
|||
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 @@ Error DWARFDebugRangeList::extract(const DWARFDataExtractor &data,
|
|||
|
||||
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 <End of list>\n", Offset);
|
||||
OS << format("%08" PRIx64 " <End of list>\n", Offset);
|
||||
}
|
||||
|
||||
DWARFAddressRangesVector DWARFDebugRangeList::getAbsoluteRanges(
|
||||
|
|
|
@ -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 @@ Error RangeListEntry::extract(DWARFDataExtractor Data, uint32_t End,
|
|||
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 @@ Error RangeListEntry::extract(DWARFDataExtractor Data, uint32_t End,
|
|||
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 @@ Error RangeListEntry::extract(DWARFDataExtractor Data, uint32_t End,
|
|||
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 @@ void RangeListEntry::dump(
|
|||
|
||||
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");
|
||||
|
|
|
@ -92,7 +92,7 @@ static void dumpLocation(raw_ostream &OS, DWARFFormValue &FormValue,
|
|||
|
||||
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 dumpTypeName(raw_ostream &OS, const DWARFDie &D) {
|
|||
}
|
||||
|
||||
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 @@ void DWARFDie::dump(raw_ostream &OS, unsigned Indent,
|
|||
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 @@ void DWARFDie::dump(raw_ostream &OS, unsigned Indent,
|
|||
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 @@ void DWARFDie::attribute_iterator::updateForIndex(
|
|||
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(
|
||||
|
|
|
@ -119,7 +119,7 @@ static uint8_t getRefAddrSize(uint8_t AddrSize, uint16_t Version) {
|
|||
}
|
||||
|
||||
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 @@ bool DWARFExpression::Operation::print(raw_ostream &OS,
|
|||
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 @@ bool DWARFExpression::Operation::print(raw_ostream &OS,
|
|||
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 @@ void DWARFExpression::print(raw_ostream &OS, const MCRegisterInfo *RegInfo,
|
|||
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;
|
||||
|
|
|
@ -112,7 +112,7 @@ void DWARFGdbIndex::dump(raw_ostream &OS) {
|
|||
}
|
||||
|
||||
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);
|
||||
|
|
|
@ -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 @@ Error DWARFListTableHeader::extract(DWARFDataExtractor Data,
|
|||
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 @@ Error DWARFListTableHeader::extract(DWARFDataExtractor Data,
|
|||
|
||||
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 @@ void DWARFListTableHeader::dump(raw_ostream &OS, DIDumpOptions DumpOpts) const {
|
|||
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";
|
||||
|
|
|
@ -28,17 +28,19 @@ void DWARFTypeUnit::dump(raw_ostream &OS, DIDumpOptions DumpOpts) {
|
|||
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);
|
||||
|
|
|
@ -66,7 +66,7 @@ void DWARFUnitVector::addUnitsImpl(
|
|||
// 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<DWARFUnit> {
|
||||
|
@ -101,7 +101,7 @@ void DWARFUnitVector::addUnitsImpl(
|
|||
// 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 @@ DWARFUnit *DWARFUnitVector::addUnit(std::unique_ptr<DWARFUnit> Unit) {
|
|||
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<DWARFUnit> &RHS) {
|
||||
[](uint64_t LHS, const std::unique_ptr<DWARFUnit> &RHS) {
|
||||
return LHS < RHS->getNextUnitOffset();
|
||||
});
|
||||
if (CU != end && (*CU)->getOffset() <= Offset)
|
||||
|
@ -149,7 +149,7 @@ DWARFUnitVector::getUnitForIndexEntry(const DWARFUnitIndex::Entry &E) {
|
|||
|
||||
auto *CU =
|
||||
std::upper_bound(begin(), end, CUOff->Offset,
|
||||
[](uint32_t LHS, const std::unique_ptr<DWARFUnit> &RHS) {
|
||||
[](uint64_t LHS, const std::unique_ptr<DWARFUnit> &RHS) {
|
||||
return LHS < RHS->getNextUnitOffset();
|
||||
});
|
||||
if (CU != end && (*CU)->getOffset() <= Offset)
|
||||
|
@ -209,7 +209,7 @@ DWARFUnit::getAddrOffsetSectionItem(uint32_t Index) const {
|
|||
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 @@ Optional<uint64_t> DWARFUnit::getStringOffsetSectionItem(uint32_t Index) const {
|
|||
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 @@ Optional<uint64_t> DWARFUnit::getStringOffsetSectionItem(uint32_t Index) const {
|
|||
|
||||
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 @@ bool DWARFUnitHeader::extract(DWARFContext &Context,
|
|||
// Parse the rangelist table header, including the optional array of offsets
|
||||
// following it (DWARF v5 and later).
|
||||
static Expected<DWARFDebugRnglistTable>
|
||||
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 @@ parseRngListTableHeader(DWARFDataExtractor &DA, uint32_t Offset) {
|
|||
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 @@ void DWARFUnit::extractDIEsToVector(
|
|||
|
||||
// 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 @@ void DWARFUnit::extractDIEsToVector(
|
|||
// 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 @@ void DWARFUnit::clearDIEs(bool KeepCUDie) {
|
|||
}
|
||||
|
||||
Expected<DWARFAddressRangesVector>
|
||||
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 @@ StrOffsetsContributionDescriptor::validateContributionSize(
|
|||
// Look for a DWARF64-formatted contribution to the string offsets table
|
||||
// starting at a given offset and record it in a descriptor.
|
||||
static Expected<StrOffsetsContributionDescriptor>
|
||||
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 @@ parseDWARF64StringOffsetsTableHeader(DWARFDataExtractor &DA, uint32_t Offset) {
|
|||
// Look for a DWARF32-formatted contribution to the string offsets table
|
||||
// starting at a given offset and record it in a descriptor.
|
||||
static Expected<StrOffsetsContributionDescriptor>
|
||||
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 @@ parseDWARFStringOffsetsTableHeader(DWARFDataExtractor &DA,
|
|||
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 @@ parseDWARFStringOffsetsTableHeader(DWARFDataExtractor &DA,
|
|||
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;
|
||||
|
|
|
@ -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::parse(DataExtractor IndexData) {
|
|||
}
|
||||
|
||||
bool DWARFUnitIndex::parseImpl(DataExtractor IndexData) {
|
||||
uint32_t Offset = 0;
|
||||
uint64_t Offset = 0;
|
||||
if (!Header.parse(IndexData, &Offset))
|
||||
return false;
|
||||
|
||||
|
|
|
@ -98,7 +98,7 @@ bool DWARFVerifier::DieRangeInfo::intersects(const DieRangeInfo &RHS) const {
|
|||
}
|
||||
|
||||
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 DWARFVerifier::verifyUnitHeader(const DWARFDataExtractor DebugInfoData,
|
|||
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 @@ bool DWARFVerifier::verifyUnitHeader(const DWARFDataExtractor DebugInfoData,
|
|||
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 @@ unsigned DWARFVerifier::verifyUnitSection(const DWARFSection &S,
|
|||
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 @@ unsigned DWARFVerifier::verifyDebugInfoForm(const DWARFDie &Die,
|
|||
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 @@ unsigned DWARFVerifier::verifyDebugInfoReferences() {
|
|||
// getting the DIE by offset and emitting an error
|
||||
OS << "Verifying .debug_info references...\n";
|
||||
unsigned NumErrors = 0;
|
||||
for (const std::pair<uint64_t, std::set<uint32_t>> &Pair :
|
||||
for (const std::pair<uint64_t, std::set<uint64_t>> &Pair :
|
||||
ReferenceToDIEOffsets) {
|
||||
if (DCtx.getDIEForOffset(Pair.first))
|
||||
continue;
|
||||
|
@ -659,12 +659,12 @@ void DWARFVerifier::verifyDebugLineStmtOffsets() {
|
|||
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 @@ void DWARFVerifier::verifyDebugLineStmtOffsets() {
|
|||
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 @@ unsigned DWARFVerifier::verifyAppleAccelTable(const DWARFSection *AccelSection,
|
|||
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 @@ unsigned DWARFVerifier::verifyAppleAccelTable(const DWARFSection *AccelSection,
|
|||
}
|
||||
|
||||
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 @@ unsigned DWARFVerifier::verifyAppleAccelTable(const DWARFSection *AccelSection,
|
|||
|
||||
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 @@ unsigned
|
|||
DWARFVerifier::verifyDebugNamesCULists(const DWARFDebugNames &AccelTable) {
|
||||
// A map from CU offset to the (first) Name Index offset which claims to index
|
||||
// this CU.
|
||||
DenseMap<uint32_t, uint32_t> CUMap;
|
||||
const uint32_t NotIndexed = std::numeric_limits<uint32_t>::max();
|
||||
DenseMap<uint64_t, uint64_t> CUMap;
|
||||
const uint64_t NotIndexed = std::numeric_limits<uint64_t>::max();
|
||||
|
||||
CUMap.reserve(DCtx.getNumCompileUnits());
|
||||
for (const auto &CU : DCtx.compile_units())
|
||||
|
@ -924,7 +925,7 @@ DWARFVerifier::verifyDebugNamesCULists(const DWARFDebugNames &AccelTable) {
|
|||
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 DWARFVerifier::verifyNameIndexEntries(
|
|||
|
||||
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<DWARFDebugNames::Entry> EntryOr = NI.getEntry(&NextEntryID);
|
||||
for (; EntryOr; ++NumEntries, EntryID = NextEntryID,
|
||||
EntryOr = NI.getEntry(&NextEntryID)) {
|
||||
|
@ -1218,7 +1219,7 @@ unsigned DWARFVerifier::verifyNameIndexEntries(
|
|||
++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) {
|
||||
|
|
|
@ -188,10 +188,8 @@ std::error_code SymbolizableObjectFile::addSymbol(const SymbolRef &Symbol,
|
|||
// 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<StringRef> SymbolNameOrErr = Symbol.getName();
|
||||
if (!SymbolNameOrErr)
|
||||
|
|
|
@ -268,7 +268,7 @@ bool getGNUDebuglinkContents(const ObjectFile *Obj, std::string &DebugName,
|
|||
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;
|
||||
|
|
|
@ -56,7 +56,7 @@ Error Decompressor::consumeCompressedZLibHeader(bool Is64Bit,
|
|||
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)
|
||||
|
|
|
@ -4612,7 +4612,7 @@ void MachOObjectFile::ReadULEB128s(uint64_t Index,
|
|||
SmallVectorImpl<uint64_t> &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;
|
||||
|
|
|
@ -89,7 +89,7 @@ FileBasedRecordProducer::findNextBufferExtent() {
|
|||
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 @@ Expected<std::unique_ptr<Record>> FileBasedRecordProducer::produce() {
|
|||
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 @@ Expected<std::unique_ptr<Record>> FileBasedRecordProducer::produce() {
|
|||
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 @@ Expected<std::unique_ptr<Record>> FileBasedRecordProducer::produce() {
|
|||
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());
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace xray {
|
|||
|
||||
// Populates the FileHeader reference by reading the first 32 bytes of the file.
|
||||
Expected<XRayFileHeader> 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 @@ Expected<XRayFileHeader> readBinaryFormatHeader(DataExtractor &HeaderExtractor,
|
|||
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 @@ Expected<XRayFileHeader> readBinaryFormatHeader(DataExtractor &HeaderExtractor,
|
|||
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,
|
||||
|
|
|
@ -118,7 +118,7 @@ loadObj(StringRef Filename, object::OwningBinary<object::ObjectFile> &ObjFile,
|
|||
"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 @@ loadObj(StringRef Filename, object::OwningBinary<object::ObjectFile> &ObjFile,
|
|||
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[] = {
|
||||
|
|
|
@ -49,9 +49,9 @@ struct BlockHeader {
|
|||
};
|
||||
|
||||
static Expected<BlockHeader> 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<StringError>(
|
||||
|
@ -76,7 +76,7 @@ static Expected<BlockHeader> readBlockHeader(DataExtractor &Extractor,
|
|||
}
|
||||
|
||||
static Expected<std::vector<Profile::FuncID>> 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<Profile::FuncID> Path;
|
||||
auto CurrentOffset = Offset;
|
||||
|
@ -94,7 +94,7 @@ static Expected<std::vector<Profile::FuncID>> readPath(DataExtractor &Extractor,
|
|||
}
|
||||
|
||||
static Expected<Profile::Data> 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 @@ Expected<Profile> loadProfile(StringRef Filename) {
|
|||
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:
|
||||
|
|
|
@ -12,15 +12,15 @@ namespace xray {
|
|||
|
||||
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(BufferExtents &R) {
|
|||
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(WallclockRecord &R) {
|
|||
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(NewCPUIDRecord &R) {
|
|||
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(TSCWrapRecord &R) {
|
|||
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 @@ Error RecordInitializer::visit(CustomEventRecord &R) {
|
|||
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 @@ Error RecordInitializer::visit(CustomEventRecord &R) {
|
|||
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 @@ Error RecordInitializer::visit(CustomEventRecord &R) {
|
|||
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<uint8_t> Buffer;
|
||||
Buffer.resize(R.Size);
|
||||
|
@ -151,15 +157,15 @@ Error RecordInitializer::visit(CustomEventRecord &R) {
|
|||
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<uint32_t>(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(CustomEventRecord &R) {
|
|||
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 @@ Error RecordInitializer::visit(CustomEventRecordV5 &R) {
|
|||
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 @@ Error RecordInitializer::visit(CustomEventRecordV5 &R) {
|
|||
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<uint8_t> Buffer;
|
||||
Buffer.resize(R.Size);
|
||||
|
@ -213,15 +221,15 @@ Error RecordInitializer::visit(CustomEventRecordV5 &R) {
|
|||
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<uint32_t>(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(CustomEventRecordV5 &R) {
|
|||
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 @@ Error RecordInitializer::visit(TypedEventRecord &R) {
|
|||
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 @@ Error RecordInitializer::visit(TypedEventRecord &R) {
|
|||
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 @@ Error RecordInitializer::visit(TypedEventRecord &R) {
|
|||
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<uint8_t> Buffer;
|
||||
Buffer.resize(R.Size);
|
||||
|
@ -282,15 +293,15 @@ Error RecordInitializer::visit(TypedEventRecord &R) {
|
|||
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<uint32_t>(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(TypedEventRecord &R) {
|
|||
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(CallArgRecord &R) {
|
|||
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(PIDRecord &R) {
|
|||
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(NewBufferRecord &R) {
|
|||
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 @@ Error RecordInitializer::visit(FunctionRecord &R) {
|
|||
//
|
||||
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 @@ Error RecordInitializer::visit(FunctionRecord &R) {
|
|||
R.Kind = static_cast<RecordTypes>(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();
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ Error loadNaiveFormatLog(StringRef Data, bool IsLittleEndian,
|
|||
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 @@ Error loadNaiveFormatLog(StringRef Data, bool IsLittleEndian,
|
|||
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 @@ Error loadNaiveFormatLog(StringRef Data, bool IsLittleEndian,
|
|||
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 @@ Error loadNaiveFormatLog(StringRef Data, bool IsLittleEndian,
|
|||
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 @@ Error loadNaiveFormatLog(StringRef Data, bool IsLittleEndian,
|
|||
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 @@ Error loadNaiveFormatLog(StringRef Data, bool IsLittleEndian,
|
|||
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 @@ Error loadNaiveFormatLog(StringRef Data, bool IsLittleEndian,
|
|||
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 @@ Error loadNaiveFormatLog(StringRef Data, bool IsLittleEndian,
|
|||
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 @@ Error loadNaiveFormatLog(StringRef Data, bool IsLittleEndian,
|
|||
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 @@ Error loadFDRLog(StringRef Data, bool IsLittleEndian,
|
|||
"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 @@ Expected<Trace> llvm::xray::loadTrace(const DataExtractor &DE, bool Sort) {
|
|||
// 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);
|
||||
|
||||
|
|
|
@ -105,10 +105,10 @@ namespace dsymutil {
|
|||
|
||||
/// 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<CompileUnit> &RHS) {
|
||||
[](uint64_t LHS, const std::unique_ptr<CompileUnit> &RHS) {
|
||||
return LHS < RHS->getOrigUnit().getNextUnitOffset();
|
||||
});
|
||||
return CU != Units.end() ? CU->get() : nullptr;
|
||||
|
@ -469,9 +469,9 @@ void DwarfLinker::RelocationManager::findValidRelocsMachO(
|
|||
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 @@ bool DwarfLinker::RelocationManager::findValidRelocsInDebugInfo(
|
|||
/// 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 @@ bool DwarfLinker::RelocationManager::hasValidRelocation(
|
|||
/// supposed to point to the position of the first attribute described
|
||||
/// by \p Abbrev.
|
||||
/// \return [StartOffset, EndOffset) as a pair.
|
||||
static std::pair<uint32_t, uint32_t>
|
||||
static std::pair<uint64_t, uint64_t>
|
||||
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 @@ unsigned DwarfLinker::shouldKeepVariableDIE(RelocationManager &RelocMgr,
|
|||
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 @@ unsigned DwarfLinker::shouldKeepSubprogramDIE(
|
|||
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 @@ void DwarfLinker::keepDIEAndDependencies(
|
|||
// 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 DwarfLinker::DIECloner::cloneDieReferenceAttribute(
|
|||
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 @@ void DwarfLinker::DIECloner::cloneExpression(
|
|||
CompileUnit &Unit, SmallVectorImpl<uint8_t> &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 @@ unsigned DwarfLinker::DIECloner::cloneAttribute(
|
|||
///
|
||||
/// \returns whether any reloc has been applied.
|
||||
bool DwarfLinker::RelocationManager::applyValidRelocs(
|
||||
MutableArrayRef<char> Data, uint32_t BaseOffset, bool IsLittleEndian) {
|
||||
MutableArrayRef<char> Data, uint64_t BaseOffset, bool IsLittleEndian) {
|
||||
assert((NextValidReloc == 0 ||
|
||||
BaseOffset > ValidRelocs[NextValidReloc - 1].Offset) &&
|
||||
"BaseOffset should only be increasing.");
|
||||
|
@ -1503,7 +1503,7 @@ DIE *DwarfLinker::DIECloner::cloneDIE(
|
|||
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 @@ DIE *DwarfLinker::DIECloner::cloneDIE(
|
|||
// 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 @@ DIE *DwarfLinker::DIECloner::cloneDIE(
|
|||
}
|
||||
|
||||
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 @@ void DwarfLinker::patchRangesForUnit(const CompileUnit &Unit,
|
|||
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 @@ void DwarfLinker::patchLineTableForUnit(CompileUnit &Unit,
|
|||
|
||||
// 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 @@ void DwarfLinker::patchFrameInfoForObject(const DebugMapObject &DMO,
|
|||
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<uint32_t, StringRef> LocalCIES;
|
||||
DenseMap<uint64_t, StringRef> 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);
|
||||
|
|
|
@ -82,12 +82,12 @@ private:
|
|||
/// 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 @@ private:
|
|||
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<char> Data, uint32_t BaseOffset,
|
||||
bool applyValidRelocs(MutableArrayRef<char> Data, uint64_t BaseOffset,
|
||||
bool IsLittleEndian);
|
||||
};
|
||||
|
||||
|
|
|
@ -405,7 +405,7 @@ void DwarfStreamer::emitLocationsForUnit(
|
|||
|
||||
SmallVector<uint8_t, 32> 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 @@ void DwarfStreamer::emitLineTableForUnit(MCDwarfLineTableParams Params,
|
|||
|
||||
/// 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 @@ void DwarfStreamer::translateLineTable(DataExtractor Data, uint32_t Offset) {
|
|||
// 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 @@ void DwarfStreamer::translateLineTable(DataExtractor Data, uint32_t Offset) {
|
|||
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 @@ void DwarfStreamer::translateLineTable(DataExtractor Data, uint32_t Offset) {
|
|||
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));
|
||||
|
|
|
@ -107,12 +107,12 @@ public:
|
|||
|
||||
/// 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 @@ private:
|
|||
|
||||
uint32_t RangesSectionSize;
|
||||
uint32_t LocSectionSize;
|
||||
uint32_t LineSectionSize;
|
||||
uint64_t LineSectionSize;
|
||||
uint32_t FrameSectionSize;
|
||||
|
||||
/// Keep track of emitted CUs and their Unique ID.
|
||||
|
|
|
@ -70,11 +70,11 @@ static void writeStringsAndOffsets(MCStreamer &Out, DWPStringPool &Strings,
|
|||
if (CurStrSection.empty() || CurStrOffsetSection.empty())
|
||||
return;
|
||||
|
||||
DenseMap<uint32_t, uint32_t> OffsetRemapping;
|
||||
DenseMap<uint64_t, uint32_t> 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 @@ static void writeStringsAndOffsets(MCStreamer &Out, DWPStringPool &Strings,
|
|||
|
||||
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 void writeStringsAndOffsets(MCStreamer &Out, DWPStringPool &Strings,
|
|||
}
|
||||
}
|
||||
|
||||
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 @@ struct CompileUnitIdentifiers {
|
|||
|
||||
static Expected<const char *>
|
||||
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 @@ getIndexedString(dwarf::Form Form, DataExtractor InfoData,
|
|||
"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 @@ static Expected<CompileUnitIdentifiers> getCUIdentifiers(StringRef Abbrev,
|
|||
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 @@ static Expected<CompileUnitIdentifiers> getCUIdentifiers(StringRef Abbrev,
|
|||
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<dwarf::Tag>(AbbrevData.getULEB128(&AbbrevOffset));
|
||||
if (Tag != dwarf::DW_TAG_compile_unit)
|
||||
return make_error<DWPError>("top level DIE is not a compile unit");
|
||||
|
@ -250,7 +250,7 @@ static void addAllTypes(MCStreamer &Out,
|
|||
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;
|
||||
|
|
|
@ -119,7 +119,7 @@ void PrinterContext<ELFT>::printEHFrameHdr(uint64_t EHFrameHdrOffset,
|
|||
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);
|
||||
|
|
|
@ -51,7 +51,7 @@ static CommandRegistration Unused(&Dump, []() -> Error {
|
|||
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)
|
||||
|
|
|
@ -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 dumpDebugStrings(DWARFContext &DCtx, DWARFYAML::Data &Y) {
|
|||
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 @@ void dumpPubSection(DWARFContext &DCtx, DWARFYAML::PubSection &Y,
|
|||
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 @@ void dumpDebugInfo(DWARFContext &DCtx, DWARFYAML::Data &Y) {
|
|||
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 @@ void dumpDebugInfo(DWARFContext &DCtx, DWARFYAML::Data &Y) {
|
|||
}
|
||||
}
|
||||
|
||||
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 @@ void dumpDebugLines(DWARFContext &DCtx, DWARFYAML::Data &Y) {
|
|||
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;
|
||||
|
|
|
@ -17,7 +17,7 @@ template <typename T>
|
|||
class DataExtractorTest : public ::testing::Test { };
|
||||
|
||||
// Test DataExtractor with both types which can be used for offsets.
|
||||
typedef ::testing::Types<uint32_t, uint64_t> TestTypes;
|
||||
typedef ::testing::Types</*uint32_t, */uint64_t> TestTypes;
|
||||
TYPED_TEST_CASE(DataExtractorTest, TestTypes);
|
||||
|
||||
const char numberData[] = "\x80\x90\xFF\xFF\x80\x00\x00\x00";
|
||||
|
|
|
@ -131,7 +131,7 @@ TYPED_TEST_P(RoundTripTest, RoundTripsSingleValue) {
|
|||
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 @@ TYPED_TEST_P(RoundTripTestV5, RoundTripsSingleValue) {
|
|||
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();
|
||||
|
|
Loading…
Reference in New Issue