1//===- DWARFDebugAddr.cpp -------------------------------------------------===// 3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4// See https://llvm.org/LICENSE.txt for license information. 5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 7//===----------------------------------------------------------------------===// 19assert(EndOffset >= *OffsetPtr);
20uint64_t DataSize = EndOffset - *OffsetPtr;
21assert(
Data.isValidOffsetForDataOfSize(*OffsetPtr, DataSize));
26if (DataSize % AddrSize != 0) {
29"address table at offset 0x%" PRIx64
30" contains data of size 0x%" PRIx64
31" which is not a multiple of addr size %" PRIu8,
32 Offset, DataSize, AddrSize);
35size_t Count = DataSize / AddrSize;
38 Addrs.push_back(
Data.getRelocatedValue(AddrSize, OffsetPtr));
44 std::function<
void(
Error)> WarnCallback) {
47 std::tie(Length, Format) =
Data.getInitialLength(OffsetPtr, &Err);
51"parsing address table at offset 0x%" PRIx64
56if (!
Data.isValidOffsetForDataOfSize(*OffsetPtr, Length)) {
61"section is not large enough to contain an address table " 62"at offset 0x%" PRIx64
" with a unit_length value of 0x%" PRIx64,
63 Offset, DiagnosticLength);
65uint64_t EndOffset = *OffsetPtr + Length;
66// Ensure that we can read the remaining header fields. 72"address table at offset 0x%" PRIx64
73" has a unit_length value of 0x%" PRIx64
74", which is too small to contain a complete header",
75 Offset, DiagnosticLength);
78 Version =
Data.getU16(OffsetPtr);
79 AddrSize =
Data.getU8(OffsetPtr);
80 SegSize =
Data.getU8(OffsetPtr);
82// Perform a basic validation of the header fields. 85"address table at offset 0x%" PRIx64
86" has unsupported version %" PRIu16,
88// TODO: add support for non-zero segment selector size. 91"address table at offset 0x%" PRIx64
92" has unsupported segment selector size %" PRIu8,
95if (
Error Err = extractAddresses(
Data, OffsetPtr, EndOffset))
97if (CUAddrSize && AddrSize != CUAddrSize) {
100"address table at offset 0x%" PRIx64
" has address size %" PRIu8
101" which is different from CU address size %" PRIu8,
102 Offset, AddrSize, CUAddrSize));
111assert(CUVersion > 0 && CUVersion < 5);
116 AddrSize = CUAddrSize;
119return extractAddresses(
Data, OffsetPtr,
Data.size());
126 std::function<
void(
Error)> WarnCallback) {
127if (CUVersion > 0 && CUVersion < 5)
131"DWARF version is not defined in CU," 132" assuming version 5"));
138OS <<
format(
"0x%8.8" PRIx64
": ", Offset);
141OS <<
"Address table header: " 142 <<
format(
"length = 0x%0*" PRIx64, OffsetDumpWidth, Length)
144 <<
format(
", version = 0x%4.4" PRIx16, Version)
145 <<
format(
", addr_size = 0x%2.2" PRIx8, AddrSize)
146 <<
format(
", seg_size = 0x%2.2" PRIx8, SegSize) <<
"\n";
149if (Addrs.size() > 0) {
153 AddrFmt =
"0x%4.4" PRIx64
"\n";
156 AddrFmt =
"0x%8.8" PRIx64
"\n";
159 AddrFmt =
"0x%16.16" PRIx64
"\n";
172if (Index < Addrs.size())
175"Index %" PRIu32
" is out of range of the " 176"address table at offset 0x%" PRIx64,
This file contains constants used for implementing Dwarf debug support.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static Error checkAddressSizeSupported(unsigned AddressSize, std::error_code EC, char const *Fmt, const Ts &...Vals)
A DataExtractor (typically for an in-memory copy of an object-file section) plus a relocation map for...
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.
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)
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.
const char * toString(DWARFSectionKind Kind)
Container for dump options that control which debug information will be dumped.