36 std::memset(&HeaderData, 0,
sizeof(
Header));
37 ArangeDescriptors.clear();
44 ArangeDescriptors.clear();
71 std::tie(HeaderData.Length, HeaderData.Format) =
72 data.getInitialLength(offset_ptr, &Err);
73 HeaderData.Version =
data.getU16(offset_ptr, &Err);
74 HeaderData.CuOffset =
data.getUnsigned(
76 HeaderData.AddrSize =
data.getU8(offset_ptr, &Err);
77 HeaderData.SegSize =
data.getU8(offset_ptr, &Err);
80 "parsing address ranges table at offset 0x%" PRIx64
88 if (!
data.isValidOffsetForDataOfSize(Offset, full_length))
90 "the length of address range table at offset "
91 "0x%" PRIx64
" exceeds section size",
95 "address range table at offset 0x%" PRIx64, Offset))
97 if (HeaderData.SegSize != 0)
99 "non-zero segment selector size in address range "
100 "table at offset 0x%" PRIx64
" is not supported",
107 const uint32_t tuple_size = HeaderData.AddrSize * 2;
108 if (full_length % tuple_size != 0)
111 "address range table at offset 0x%" PRIx64
112 " has length that is not a multiple of the tuple size",
116 const uint32_t header_size = *offset_ptr - Offset;
118 while (first_tuple_offset < header_size)
119 first_tuple_offset += tuple_size;
122 if (full_length <= first_tuple_offset)
125 "address range table at offset 0x%" PRIx64
126 " has an insufficient length to contain any entries",
129 *offset_ptr = Offset + first_tuple_offset;
133 static_assert(
sizeof(arangeDescriptor.
Address) ==
134 sizeof(arangeDescriptor.
Length),
135 "Different datatypes for addresses and sizes!");
136 assert(
sizeof(arangeDescriptor.
Address) >= HeaderData.AddrSize);
138 uint64_t end_offset = Offset + full_length;
139 while (*offset_ptr < end_offset) {
141 arangeDescriptor.
Address =
data.getUnsigned(offset_ptr, HeaderData.AddrSize);
142 arangeDescriptor.
Length =
data.getUnsigned(offset_ptr, HeaderData.AddrSize);
146 if (arangeDescriptor.
Length == 0 && arangeDescriptor.
Address == 0) {
147 if (*offset_ptr == end_offset)
149 if (WarningHandler) {
152 "address range table at offset 0x%" PRIx64
153 " has a premature terminator entry at offset 0x%" PRIx64,
154 Offset, EntryOffset));
158 ArangeDescriptors.push_back(arangeDescriptor);
162 "address range table at offset 0x%" PRIx64
163 " is not terminated by null entry",
169 OS <<
"Address Range Header: "
170 <<
formatv(
"length = 0x{0:x-}, ",
174 <<
formatv(
"version = {0:x+4}, ", HeaderData.Version)
175 <<
formatv(
"cu_offset = 0x{0:x-}, ",
177 OffsetDumpWidth,
'0'))
178 <<
formatv(
"addr_size = {0:x+2}, ", HeaderData.AddrSize)
179 <<
formatv(
"seg_size = {0:x+2}\n", HeaderData.SegSize);
181 for (
const auto &
Desc : ArangeDescriptors) {
182 Desc.dump(OS, HeaderData.AddrSize);
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)
LLVM_ABI void dump(raw_ostream &OS) const
LLVM_ABI Error extract(DWARFDataExtractor data, uint64_t *offset_ptr, function_ref< void(Error)> WarningHandler=nullptr)
Subclass of Error for the sole purpose of identifying the success path in the type system.
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
An efficient, type-erasing, non-owning reference to a callable.
This class implements an extremely fast bulk output stream that can only output to a stream.
LLVM_ABI StringRef FormatString(DwarfFormat Format)
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)
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)
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=' ')
uint64_t getEndAddress() const
LLVM_ABI void dump(raw_ostream &OS, uint32_t AddressSize) const