1//===- DWARFDebugRnglists.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//===----------------------------------------------------------------------===// 23// The caller should guarantee that we have at least 1 byte available, so 24// we just assert instead of revalidate. 26"not enough space to extract a rangelist encoding");
31case dwarf::DW_RLE_end_of_list:
34// TODO: Support other encodings. 35case dwarf::DW_RLE_base_addressx: {
39case dwarf::DW_RLE_startx_endx:
43case dwarf::DW_RLE_startx_length: {
48case dwarf::DW_RLE_offset_pair: {
53case dwarf::DW_RLE_base_address: {
57case dwarf::DW_RLE_start_end: {
62case dwarf::DW_RLE_start_length: {
70"unknown rnglists encoding 0x%" PRIx32
71" at offset 0x%" PRIx64,
79"read past end of table when reading %s encoding at offset 0x%" PRIx64,
89 std::optional<object::SectionedAddress> BaseAddr,
DWARFUnit &U)
const{
91 BaseAddr, U.getAddressByteSize(),
92 [&](
uint32_t Index) { return U.getAddrOffsetSectionItem(Index); });
96 std::optional<object::SectionedAddress> BaseAddr,
uint8_t AddressByteSize,
98 LookupPooledAddress)
const{
102if (RLE.EntryKind == dwarf::DW_RLE_end_of_list)
104if (RLE.EntryKind == dwarf::DW_RLE_base_addressx) {
105 BaseAddr = LookupPooledAddress(RLE.Value0);
107 BaseAddr = {RLE.Value0, -1ULL};
110if (RLE.EntryKind == dwarf::DW_RLE_base_address) {
111 BaseAddr = {RLE.Value0, RLE.SectionIndex};
120switch (RLE.EntryKind) {
121case dwarf::DW_RLE_offset_pair:
122 E.
LowPC = RLE.Value0;
123if (E.
LowPC == Tombstone)
127if (BaseAddr->Address == Tombstone)
129 E.
LowPC += BaseAddr->Address;
130 E.
HighPC += BaseAddr->Address;
133case dwarf::DW_RLE_start_end:
134 E.
LowPC = RLE.Value0;
137case dwarf::DW_RLE_start_length:
138 E.
LowPC = RLE.Value0;
141case dwarf::DW_RLE_startx_length: {
142auto Start = LookupPooledAddress(RLE.Value0);
146 E.
LowPC = Start->Address;
150case dwarf::DW_RLE_startx_endx: {
151auto Start = LookupPooledAddress(RLE.Value0);
154autoEnd = LookupPooledAddress(RLE.Value1);
157// FIXME: Some error handling if Start.SectionIndex != End.SectionIndex 159 E.
LowPC = Start->Address;
164// Unsupported encodings should have been reported during extraction, 165// so we should not run into any here. 168if (E.
LowPC == Tombstone)
179 LookupPooledAddress)
const{
185 .
dump(
OS, AddrSize, DumpOpts);
191// Print the section offset in verbose mode. 194// Unsupported encodings should have been reported during parsing. 195assert(!EncodingString.empty() &&
"Unknown range entry encoding");
196OS <<
format(
" [%s%*c", EncodingString.data(),
197 MaxEncodingStringLength - EncodingString.size() + 1,
']');
198if (
EntryKind != dwarf::DW_RLE_end_of_list)
205case dwarf::DW_RLE_end_of_list:
206OS << (DumpOpts.
Verbose ?
"" :
"<End of list>");
208case dwarf::DW_RLE_base_addressx: {
209if (
auto SA = LookupPooledAddress(
Value0))
210 CurrentBase = SA->Address;
218case dwarf::DW_RLE_base_address:
219// In non-verbose mode we do not print anything for this entry. 225case dwarf::DW_RLE_start_length:
226 PrintRawEntry(
OS, *
this, AddrSize, DumpOpts);
229case dwarf::DW_RLE_offset_pair:
230 PrintRawEntry(
OS, *
this, AddrSize, DumpOpts);
231if (CurrentBase != Tombstone)
233 .
dump(
OS, AddrSize, DumpOpts);
237case dwarf::DW_RLE_start_end:
240case dwarf::DW_RLE_startx_length: {
241 PrintRawEntry(
OS, *
this, AddrSize, DumpOpts);
243if (
auto SA = LookupPooledAddress(
Value0))
248case dwarf::DW_RLE_startx_endx: {
249 PrintRawEntry(
OS, *
this, AddrSize, DumpOpts);
251if (
auto SA = LookupPooledAddress(
Value0))
254if (
auto SA = LookupPooledAddress(
Value1))
This file contains constants used for implementing Dwarf debug support.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
A DataExtractor (typically for an in-memory copy of an object-file section) plus a relocation map for...
DWARFAddressRangesVector getAbsoluteRanges(std::optional< object::SectionedAddress > BaseAddr, uint8_t AddressByteSize, function_ref< std::optional< object::SectionedAddress >(uint32_t)> LookupPooledAddress) const
Build a DWARFAddressRangesVector from a rangelist.
void dumpAddress(raw_ostream &OS, uint64_t Address) const
A class representing a position in a DataExtractor, as well as any error encountered during extractio...
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.
StringRef RangeListEncodingString(unsigned Encoding)
StringRef RLEString(unsigned RLE)
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ C
The default llvm calling convention, compatible with C.
uint64_t computeTombstoneAddress(uint8_t AddressByteSize)
This is an optimization pass for GlobalISel generic memory operations.
std::vector< DWARFAddressRange > DWARFAddressRangesVector
DWARFAddressRangesVector - represents a set of absolute address ranges.
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.
void consumeError(Error Err)
Consume a Error without doing anything.
Container for dump options that control which debug information will be dumped.
void dump(raw_ostream &OS, uint32_t AddressSize, DIDumpOptions DumpOpts={}, const DWARFObject *Obj=nullptr) const
uint64_t SectionIndex
The index of the section this entry belongs to.
uint8_t EntryKind
The DWARF encoding (DW_RLE_* or DW_LLE_*).
uint64_t Offset
The offset at which the entry is located in the section.
A class representing a single range list entry.
Error extract(DWARFDataExtractor Data, uint64_t *OffsetPtr)
void dump(raw_ostream &OS, uint8_t AddrSize, uint8_t MaxEncodingStringLength, uint64_t &CurrentBase, DIDumpOptions DumpOpts, llvm::function_ref< std::optional< object::SectionedAddress >(uint32_t)> LookupPooledAddress) const
uint64_t Value0
The values making up the range list entry.