34 std::memset(&HeaderData, 0,
sizeof(
Header));
35 ArangeDescriptors.clear();
42 ArangeDescriptors.clear();
69 std::tie(HeaderData.Length, HeaderData.Format) =
70 data.getInitialLength(offset_ptr, &Err);
71 HeaderData.Version =
data.getU16(offset_ptr, &Err);
72 HeaderData.CuOffset =
data.getUnsigned(
74 HeaderData.AddrSize =
data.getU8(offset_ptr, &Err);
75 HeaderData.SegSize =
data.getU8(offset_ptr, &Err);
78 "parsing address ranges table at offset 0x%" PRIx64
86 if (!
data.isValidOffsetForDataOfSize(Offset, full_length))
88 "the length of address range table at offset "
89 "0x%" PRIx64
" exceeds section size",
93 "address range table at offset 0x%" PRIx64, Offset))
95 if (HeaderData.SegSize != 0)
97 "non-zero segment selector size in address range "
98 "table at offset 0x%" PRIx64
" is not supported",
105 const uint32_t tuple_size = HeaderData.AddrSize * 2;
106 if (full_length % tuple_size != 0)
109 "address range table at offset 0x%" PRIx64
110 " has length that is not a multiple of the tuple size",
114 const uint32_t header_size = *offset_ptr - Offset;
116 while (first_tuple_offset < header_size)
117 first_tuple_offset += tuple_size;
120 if (full_length <= first_tuple_offset)
123 "address range table at offset 0x%" PRIx64
124 " has an insufficient length to contain any entries",
127 *offset_ptr = Offset + first_tuple_offset;
131 static_assert(
sizeof(arangeDescriptor.
Address) ==
132 sizeof(arangeDescriptor.
Length),
133 "Different datatypes for addresses and sizes!");
134 assert(
sizeof(arangeDescriptor.
Address) >= HeaderData.AddrSize);
136 uint64_t end_offset = Offset + full_length;
137 while (*offset_ptr < end_offset) {
139 arangeDescriptor.
Address =
data.getUnsigned(offset_ptr, HeaderData.AddrSize);
140 arangeDescriptor.
Length =
data.getUnsigned(offset_ptr, HeaderData.AddrSize);
144 if (arangeDescriptor.
Length == 0 && arangeDescriptor.
Address == 0) {
145 if (*offset_ptr == end_offset)
147 if (WarningHandler) {
150 "address range table at offset 0x%" PRIx64
151 " has a premature terminator entry at offset 0x%" PRIx64,
152 Offset, EntryOffset));
156 ArangeDescriptors.push_back(arangeDescriptor);
160 "address range table at offset 0x%" PRIx64
161 " is not terminated by null entry",
167 OS <<
"Address Range Header: "
168 <<
format(
"length = 0x%0*" PRIx64
", ", OffsetDumpWidth, HeaderData.Length)
170 <<
format(
"version = 0x%4.4x, ", HeaderData.Version)
171 <<
format(
"cu_offset = 0x%0*" PRIx64
", ", OffsetDumpWidth,
173 <<
format(
"addr_size = 0x%2.2x, ", HeaderData.AddrSize)
174 <<
format(
"seg_size = 0x%2.2x\n", HeaderData.SegSize);
176 for (
const auto &
Desc : ArangeDescriptors) {
177 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.
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
std::string toString(const APInt &I, unsigned Radix, bool Signed, bool formatAsCLiteral=false, bool UpperCase=true, bool InsertSeparators=false)
uint64_t getEndAddress() const
LLVM_ABI void dump(raw_ostream &OS, uint32_t AddressSize) const