/// \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
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;
/// 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.
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;
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.
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;
/// 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.
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;
};
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) {}
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
// 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.
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.
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;
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();
private:
SmallVector<NameIndex, 0> NameIndices;
- DenseMap<uint32_t, const NameIndex *> CUToNameIndex;
+ DenseMap<uint64_t, const NameIndex *> CUToNameIndex;
public:
DWARFDebugNames(const DWARFDataExtractor &AccelSection,
/// 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
/// 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.
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
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;
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;
private:
dwarf::DwarfFormat Format;
- uint32_t HeaderOffset;
+ uint64_t HeaderOffset;
Header HeaderData;
uint32_t DataSize = 0;
std::vector<uint64_t> Addrs;
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;
using DescriptorColl = std::vector<Descriptor>;
using desc_iterator_range = iterator_range<DescriptorColl::const_iterator>;
- uint32_t Offset;
+ uint64_t Offset;
Header HeaderData;
DescriptorColl ArangeDescriptors;
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; }
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 {
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 {
std::vector<RangeEndpoint> Endpoints;
RangeColl Aranges;
- DenseSet<uint32_t> ParsedCUOffsets;
+ DenseSet<uint64_t> ParsedCUOffsets;
};
} // end namespace llvm
/// 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;
/// 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.
/// 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 {
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);
};
/// 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);
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);
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;
};
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;
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.
LocationList const *getLocationListAtOffset(uint64_t Offset) const;
Optional<LocationList> parseOneLocationList(DWARFDataExtractor Data,
- uint32_t *Offset);
+ uint64_t *Offset);
};
class DWARFDebugLoclists {
};
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,
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
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;
/// 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.
private:
/// Offset in .debug_ranges section.
- uint32_t Offset;
+ uint64_t Offset;
uint8_t AddressSize;
std::vector<RangeListEntry> Entries;
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
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)>
/// 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();
}
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);
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() ||
/// 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.
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);
};
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
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; }
}
/// 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
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;
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,
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()))
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) {
}
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);
}
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()))
/// 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;
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; }
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();
/// 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;
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
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();
}
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 {
/// .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();
/// 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
/// 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 =
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;
};
/// 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;
///
/// \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.
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
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
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;
/// 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
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");
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);
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;
}
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)
// 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) {
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))
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();
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);
}
// 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);
}
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");
}
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};
}
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;
// 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;
}
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,
}
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.");
}
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);
}
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.");
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;
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,
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};
}
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);
}
// 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 &) {},
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*/;
}
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 {
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 {
}
Error DWARFDebugNames::extract() {
- uint32_t Offset = 0;
+ uint64_t Offset = 0;
while (AccelSection.isValidOffset(Offset)) {
NameIndex Next(*this, Offset);
if (Error E = Next.extract())
NI.dump(W);
}
-Optional<uint32_t>
+Optional<uint64_t>
DWARFDebugNames::ValueIterator::findEntryOffsetInCurrentIndex() {
const Header &Hdr = CurrentIndex->Hdr;
if (Hdr.BucketCount == 0) {
}
bool DWARFDebugNames::ValueIterator::findInCurrentIndex() {
- Optional<uint32_t> Offset = findEntryOffsetInCurrentIndex();
+ Optional<uint64_t> Offset = findEntryOffsetInCurrentIndex();
if (!Offset)
return false;
DataOffset = *Offset;
}
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)
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);
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) {
}
// 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
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";
}
}
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))) {
}
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);
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';
// 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);
}
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();
DWARFDataExtractor Data,
const MCRegisterInfo *MRI,
Optional<uint64_t> DumpOffset) {
- uint32_t Offset = 0;
+ uint64_t Offset = 0;
DWARFDebugLoclists Loclists;
DWARFListTableHeader Header(".debug_loclists", "locations");
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))
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 {
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;
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)) {
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);
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;
});
}
-DWARFCompileUnit *DWARFContext::getCompileUnitForOffset(uint32_t Offset) {
+DWARFCompileUnit *DWARFContext::getCompileUnitForOffset(uint64_t Offset) {
parseNormalUnits();
return dyn_cast_or_null<DWARFCompileUnit>(
NormalUnits.getUnitForOffset(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);
}
}
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;
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;
}
if (Data && CUAbbrOffset < Data->getData().size()) {
- uint32_t Offset = CUAbbrOffset;
+ uint64_t Offset = CUAbbrOffset;
DWARFAbbreviationDeclarationSet AbbrDecls;
if (!AbbrDecls.extract(*Data, &Offset))
return nullptr;
}
Error DWARFDebugAddrTable::extract(DWARFDataExtractor Data,
- uint32_t *OffsetPtr,
+ uint64_t *OffsetPtr,
uint16_t Version,
uint8_t AddrSize,
std::function<void(Error)> WarnCallback) {
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,
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);
}
// 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,
// 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);
// 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);
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);
}
}
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;
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();
// 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)
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;
}
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;
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.
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);
// 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);
}
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);
// 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);
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,
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
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);
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(),
// 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) {
}
if (Offset != EndAugmentationOffset)
- ReportError(StartOffset, "Parsing augmentation data at %lx failed");
+ ReportError(StartOffset,
+ "Parsing augmentation data at %" PRIx64 " failed");
}
} else {
InitialLocation = Data.getRelocatedAddress(&Offset);
}
if (Offset != EndStructureOffset)
- ReportError(StartOffset, "Parsing entry instructions at %lx failed");
+ ReportError(StartOffset,
+ "Parsing entry instructions at %" PRIx64 " failed");
}
}
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))
// 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) {
// 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;
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);
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,
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);
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);
}
Error DWARFDebugLine::Prologue::parse(const DWARFDataExtractor &DebugLineData,
- uint32_t *OffsetPtr,
+ uint64_t *OffsetPtr,
const DWARFContext &Ctx,
const DWARFUnit *U) {
const uint64_t PrologueOffset = *OffsetPtr;
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));
}
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();
}
}
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;
}
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);
}
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();
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.
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);
// 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) {
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);
// 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)
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))
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())
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
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";
};
}
Optional<DWARFDebugLoc::LocationList>
-DWARFDebugLoc::parseOneLocationList(DWARFDataExtractor Data, unsigned *Offset) {
+DWARFDebugLoc::parseOneLocationList(DWARFDataExtractor Data, uint64_t *Offset) {
LocationList LL;
LL.Offset = *Offset;
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));
}
Optional<DWARFDebugLoclists::LocationList>
-DWARFDebugLoclists::parseOneLocationList(DataExtractor Data, unsigned *Offset,
+DWARFDebugLoclists::parseOneLocationList(DataExtractor Data, uint64_t *Offset,
unsigned Version) {
LocationList LL;
LL.Offset = *Offset;
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));
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";
};
}
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;
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();
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);
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)
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);
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())
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(
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
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;
}
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;
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);
}
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");
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(),
}
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())
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;
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();
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(
}
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);
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 {
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 {
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;
}
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);
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);
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);
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
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";
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);
// 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> {
// 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)) {
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)
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)
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,
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,
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) {
// 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;
}
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);
}
// 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;
// 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);
}
}
Expected<DWARFAddressRangesVector>
-DWARFUnit::findRnglistFromOffset(uint32_t Offset) {
+DWARFUnit::findRnglistFromOffset(uint64_t Offset) {
if (getVersion() <= 4) {
DWARFDebugRangeList RangeList;
if (Error E = extractRangeList(Offset, RangeList))
// 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");
// 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");
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;
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;
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);
}
bool DWARFUnitIndex::parseImpl(DataExtractor IndexData) {
- uint32_t Offset = 0;
+ uint64_t Offset = 0;
if (!Header.parse(IndexData, &Offset))
return false;
}
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;
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);
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 "
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;
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 {
// 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;
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;
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';
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) {
}
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 =
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);
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())
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()) {
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)) {
++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) {
// 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)
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;
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)
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;
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;
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)) {
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 {
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());
// 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?
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;
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,
"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);
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[] = {
};
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>(
}
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;
}
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
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:
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);
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);
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();
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();
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;
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.
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 &&
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);
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());
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;
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 &&
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);
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());
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;
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;
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);
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);
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());
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();
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();
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();
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();
//
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
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();
}
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();
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.
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:
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;
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;
}
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 ||
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;
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;
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.
"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();
// 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);
/// 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;
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;
/// 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())
/// 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());
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);
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);
// 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()) {
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;
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
///
/// \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.");
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
// 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;
}
DWARFFormValue Val(AttrSpec.Form);
- uint32_t AttrSize = Offset;
+ uint64_t AttrSize = Offset;
Val.extractValue(Data, &Offset, U.getFormParams(), &U);
AttrSize = Offset - AttrSize;
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));
// 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());
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);
/// 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) {}
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);
};
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.
/// 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();
// 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);
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);
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));
/// 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);
uint32_t RangesSectionSize;
uint32_t LocSectionSize;
- uint32_t LineSectionSize;
+ uint64_t LineSectionSize;
uint32_t FrameSectionSize;
/// Keep track of emitted CUs and their Unique ID.
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);
Out.SwitchSection(StrOffsetSection);
- uint32_t Offset = 0;
+ uint64_t Offset = 0;
uint64_t Size = CurStrOffsetSection.size();
while (Offset < Size) {
auto OldOffset = Data.getU32(&Offset);
}
}
-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
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)
"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);
}
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);
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");
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;
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);
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)
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())
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)) {
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);
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))
}
}
-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())
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;
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";
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();
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();