LLVM 23.0.0git
DWARFDebugAddr.h
Go to the documentation of this file.
1//===- DWARFDebugAddr.h -------------------------------------*- C++ -*-===//
2//
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
6//
7//===------------------------------------------------------------------===//
8
9#ifndef LLVM_DEBUGINFO_DWARF_DWARFDEBUGADDR_H
10#define LLVM_DEBUGINFO_DWARF_DWARFDEBUGADDR_H
11
14#include "llvm/Support/Error.h"
15#include <cstdint>
16#include <vector>
17
18namespace llvm {
19
20class raw_ostream;
22
23/// A class representing an address table as specified in DWARF v5.
24/// The table consists of a header followed by an array of address values from
25/// .debug_addr section.
27 dwarf::DwarfFormat Format;
28 uint64_t Offset;
29 /// The total length of the entries for this table, not including the length
30 /// field itself.
31 uint64_t Length = 0;
32 /// The DWARF version number.
33 uint16_t Version;
34 /// The size in bytes of an address on the target architecture. For
35 /// segmented addressing, this is the size of the offset portion of the
36 /// address.
37 uint8_t AddrSize;
38 /// The size in bytes of a segment selector on the target architecture.
39 /// If the target system uses a flat address space, this value is 0.
40 uint8_t SegSize;
41 std::vector<uint64_t> Addrs;
42
43 /// Invalidate Length field to stop further processing.
44 void invalidateLength() { Length = 0; }
45
46 Error extractAddresses(const DWARFDataExtractor &Data, uint64_t *OffsetPtr,
47 uint64_t EndOffset);
48
49public:
50
51 /// Extract the entire table, including all addresses.
53 uint16_t CUVersion, uint8_t CUAddrSize,
54 std::function<void(Error)> WarnCallback);
55
56 /// Extract a DWARFv5 address table.
58 uint8_t CUAddrSize,
59 std::function<void(Error)> WarnCallback);
60
61 /// Extract a pre-DWARFv5 address table. Such tables do not have a header
62 /// and consist only of a series of addresses.
63 /// See https://gcc.gnu.org/wiki/DebugFission for details.
65 uint64_t *OffsetPtr, uint16_t CUVersion,
66 uint8_t CUAddrSize);
67
68 LLVM_ABI void dump(raw_ostream &OS, DIDumpOptions DumpOpts = {}) const;
69
70 /// Return the address based on a given index.
72
73 /// Return the full length of this table, including the length field.
74 /// Return std::nullopt if the length cannot be identified reliably.
75 LLVM_ABI std::optional<uint64_t> getFullLength() const;
76
77 /// Return the DWARF format of this table.
78 dwarf::DwarfFormat getFormat() const { return Format; }
79
80 /// Return the length of this table.
81 uint64_t getLength() const { return Length; }
82
83 /// Return the version of this table.
84 uint16_t getVersion() const { return Version; }
85
86 /// Return the address size of this table.
87 uint8_t getAddressSize() const { return AddrSize; }
88
89 /// Return the segment selector size of this table.
90 uint8_t getSegmentSelectorSize() const { return SegSize; }
91
92 /// Return the parsed addresses of this table.
93 ArrayRef<uint64_t> getAddressEntries() const { return Addrs; }
94};
95
96} // end namespace llvm
97
98#endif // LLVM_DEBUGINFO_DWARF_DWARFDEBUGADDR_H
#define LLVM_ABI
Definition Compiler.h:213
This file contains constants used for implementing Dwarf debug support.
loop extract
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
A DWARFDataExtractor (typically for an in-memory copy of an object-file section) plus a relocation ma...
A class representing an address table as specified in DWARF v5.
uint16_t getVersion() const
Return the version of this table.
uint64_t getLength() const
Return the length of this table.
uint8_t getSegmentSelectorSize() const
Return the segment selector size of this table.
LLVM_ABI void dump(raw_ostream &OS, DIDumpOptions DumpOpts={}) const
uint8_t getAddressSize() const
Return the address size of this table.
ArrayRef< uint64_t > getAddressEntries() const
Return the parsed addresses of this table.
LLVM_ABI Error extractV5(const DWARFDataExtractor &Data, uint64_t *OffsetPtr, uint8_t CUAddrSize, std::function< void(Error)> WarnCallback)
Extract a DWARFv5 address table.
LLVM_ABI Error extractPreStandard(const DWARFDataExtractor &Data, uint64_t *OffsetPtr, uint16_t CUVersion, uint8_t CUAddrSize)
Extract a pre-DWARFv5 address table.
dwarf::DwarfFormat getFormat() const
Return the DWARF format of this table.
LLVM_ABI std::optional< uint64_t > getFullLength() const
Return the full length of this table, including the length field.
LLVM_ABI 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.
Definition Error.h:159
Tagged union holding either a T or a Error.
Definition Error.h:485
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
DwarfFormat
Constants that define the DWARF format as 32 or 64 bit.
Definition Dwarf.h:93
This is an optimization pass for GlobalISel generic memory operations.
FunctionAddr VTableAddr uintptr_t uintptr_t Data
Definition InstrProf.h:221
Container for dump options that control which debug information will be dumped.
Definition DIContext.h:196