LLVM 20.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;
21class DWARFDataExtractor;
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.
52 Error extract(const DWARFDataExtractor &Data, uint64_t *OffsetPtr,
53 uint16_t CUVersion, uint8_t CUAddrSize,
54 std::function<void(Error)> WarnCallback);
55
56 /// Extract a DWARFv5 address table.
58 uint8_t CUAddrSize, std::function<void(Error)> WarnCallback);
59
60 /// Extract a pre-DWARFv5 address table. Such tables do not have a header
61 /// and consist only of a series of addresses.
62 /// See https://gcc.gnu.org/wiki/DebugFission for details.
64 uint16_t CUVersion, uint8_t CUAddrSize);
65
66 void dump(raw_ostream &OS, DIDumpOptions DumpOpts = {}) const;
67
68 /// Return the address based on a given index.
70
71 /// Return the full length of this table, including the length field.
72 /// Return std::nullopt if the length cannot be identified reliably.
73 std::optional<uint64_t> getFullLength() const;
74
75 /// Return the DWARF format of this table.
76 dwarf::DwarfFormat getFormat() const { return Format; }
77
78 /// Return the length of this table.
79 uint64_t getLength() const { return Length; }
80
81 /// Return the version of this table.
82 uint16_t getVersion() const { return Version; }
83
84 /// Return the address size of this table.
85 uint8_t getAddressSize() const { return AddrSize; }
86
87 /// Return the segment selector size of this table.
88 uint8_t getSegmentSelectorSize() const { return SegSize; }
89
90 /// Return the parsed addresses of this table.
91 ArrayRef<uint64_t> getAddressEntries() const { return Addrs; }
92};
93
94} // end namespace llvm
95
96#endif // LLVM_DEBUGINFO_DWARF_DWARFDEBUGADDR_H
This file contains constants used for implementing Dwarf debug support.
uint32_t Index
loop extract
raw_pwrite_stream & OS
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
A DataExtractor (typically for an in-memory copy of an object-file section) plus a relocation map for...
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.
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.
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.
dwarf::DwarfFormat getFormat() const
Return the DWARF format of this 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.
Definition: Error.h:160
Tagged union holding either a T or a Error.
Definition: Error.h:481
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:52
DwarfFormat
Constants that define the DWARF format as 32 or 64 bit.
Definition: Dwarf.h:91
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
@ Length
Definition: DWP.cpp:480
Container for dump options that control which debug information will be dumped.
Definition: DIContext.h:196