Subversion Repositories QNX 8.QNX8 LLVM/Clang compiler suite

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
14 pmbaty 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
 
12
#include "llvm/BinaryFormat/Dwarf.h"
13
#include "llvm/DebugInfo/DIContext.h"
14
#include "llvm/Support/Error.h"
15
#include <cstdint>
16
#include <vector>
17
 
18
namespace llvm {
19
 
20
class raw_ostream;
21
class 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.
26
class DWARFDebugAddrTable {
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
 
49
public:
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.
57
  Error extractV5(const DWARFDataExtractor &Data, uint64_t *OffsetPtr,
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.
63
  Error extractPreStandard(const DWARFDataExtractor &Data, uint64_t *OffsetPtr,
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.
69
  Expected<uint64_t> getAddrEntry(uint32_t Index) const;
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