21 assert(EndOffset >= *OffsetPtr);
22 uint64_t
DataSize = EndOffset - *OffsetPtr;
31 "address table at offset 0x%" PRIx64
32 " contains data of size 0x%" PRIx64
33 " which is not a multiple of addr size %" PRIu8,
40 Addrs.push_back(
Data.getRelocatedValue(AddrSize, OffsetPtr));
46 std::function<
void(
Error)> WarnCallback) {
49 std::tie(Length, Format) =
Data.getInitialLength(OffsetPtr, &Err);
53 "parsing address table at offset 0x%" PRIx64
58 if (!
Data.isValidOffsetForDataOfSize(*OffsetPtr, Length)) {
63 "section is not large enough to contain an address table "
64 "at offset 0x%" PRIx64
" with a unit_length value of 0x%" PRIx64,
65 Offset, DiagnosticLength);
67 uint64_t EndOffset = *OffsetPtr + Length;
74 "address table at offset 0x%" PRIx64
75 " has a unit_length value of 0x%" PRIx64
76 ", which is too small to contain a complete header",
77 Offset, DiagnosticLength);
80 Version =
Data.getU16(OffsetPtr);
81 AddrSize =
Data.getU8(OffsetPtr);
82 SegSize =
Data.getU8(OffsetPtr);
87 "address table at offset 0x%" PRIx64
88 " has unsupported version %" PRIu16,
93 "address table at offset 0x%" PRIx64
94 " has unsupported segment selector size %" PRIu8,
97 if (
Error Err = extractAddresses(
Data, OffsetPtr, EndOffset))
99 if (CUAddrSize && AddrSize != CUAddrSize) {
102 "address table at offset 0x%" PRIx64
" has address size %" PRIu8
103 " which is different from CU address size %" PRIu8,
104 Offset, AddrSize, CUAddrSize));
113 assert(CUVersion > 0 && CUVersion < 5);
118 AddrSize = CUAddrSize;
121 return extractAddresses(
Data, OffsetPtr,
Data.size());
128 std::function<
void(
Error)> WarnCallback) {
129 if (CUVersion > 0 && CUVersion < 5)
133 "DWARF version is not defined in CU,"
134 " assuming version 5"));
140 OS <<
formatv(
"{0:x+8}: ", Offset);
143 OS <<
"Address table header: "
144 <<
formatv(
"length = 0x{0:x-}",
147 <<
formatv(
", version = {0:x+4}", Version)
148 <<
formatv(
", addr_size = {0:x+2}", AddrSize)
149 <<
formatv(
", seg_size = {0:x+2}", SegSize) <<
"\n";
152 if (Addrs.size() > 0) {
156 AddrFmt =
"{0:x+4}\n";
159 AddrFmt =
"{0:x+8}\n";
162 AddrFmt =
"{0:x+16}\n";
175 if (Index < Addrs.size())
178 "Index %" PRIu32
" is out of range of the "
179 "address table at offset 0x%" PRIx64,
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file contains constants used for implementing Dwarf debug support.
static Error checkAddressSizeSupported(unsigned AddressSize, std::error_code EC, char const *Fmt, const Ts &...Vals)
void dump(raw_ostream &OS, DIDumpOptions DumpOpts={}) const
Error extract(const DWARFDataExtractor &Data, uint64_t *OffsetPtr, uint16_t CUVersion, uint8_t CUAddrSize, std::function< void(Error)> WarnCallback)
Extract the entire table, including all addresses.
Error extractV5(const DWARFDataExtractor &Data, uint64_t *OffsetPtr, uint8_t CUAddrSize, std::function< void(Error)> WarnCallback)
Extract a DWARFv5 address table.
Error extractPreStandard(const DWARFDataExtractor &Data, uint64_t *OffsetPtr, uint16_t CUVersion, uint8_t CUAddrSize)
Extract a pre-DWARFv5 address table.
std::optional< uint64_t > getFullLength() const
Return the full length of this table, including the length field.
Expected< uint64_t > getAddrEntry(uint32_t Index) const
Return the address based on a given index.
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
Tagged union holding either a T or a Error.
This class implements an extremely fast bulk output stream that can only output to a stream.
LLVM_ABI StringRef FormatString(DwarfFormat Format)
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
uint8_t getUnitLengthFieldByteSize(DwarfFormat Format)
Get the byte size of the unit length field depending on the DWARF format.
uint8_t getDwarfOffsetByteSize(DwarfFormat Format)
The size of a reference determined by the DWARF 32/64-bit format.
This is an optimization pass for GlobalISel generic memory operations.
SmallVectorImpl< T >::const_pointer c_str(SmallVectorImpl< T > &str)
FunctionAddr VTableAddr uintptr_t uintptr_t DataSize
Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)
Create formatted StringError object.
auto formatv(bool Validate, const char *Fmt, Ts &&...Vals)
FunctionAddr VTableAddr Count
FunctionAddr VTableAddr uintptr_t uintptr_t Data
std::string toString(const APInt &I, unsigned Radix, bool Signed, bool formatAsCLiteral=false, bool UpperCase=true, bool InsertSeparators=false)
support::detail::AlignAdapter< T > fmt_align(T &&Item, AlignStyle Where, size_t Amount, char Fill=' ')
Container for dump options that control which debug information will be dumped.