LLVM  13.0.0git
DWARFDebugArangeSet.h
Go to the documentation of this file.
1 //===- DWARFDebugArangeSet.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_DWARFDEBUGARANGESET_H
10 #define LLVM_DEBUGINFO_DWARF_DWARFDEBUGARANGESET_H
11 
14 #include "llvm/Support/Error.h"
15 #include <cstdint>
16 #include <vector>
17 
18 namespace llvm {
19 
20 class raw_ostream;
21 
23 public:
24  struct Header {
25  /// The total length of the entries for that set, not including the length
26  /// field itself.
27  uint64_t Length;
28  /// The DWARF format of the set.
30  /// The offset from the beginning of the .debug_info section of the
31  /// compilation unit entry referenced by the table.
32  uint64_t CuOffset;
33  /// The DWARF version number.
35  /// The size in bytes of an address on the target architecture. For segmented
36  /// addressing, this is the size of the offset portion of the address.
37  uint8_t AddrSize;
38  /// The size in bytes of a segment descriptor on the target architecture.
39  /// If the target system uses a flat address space, this value is 0.
40  uint8_t SegSize;
41  };
42 
43  struct Descriptor {
44  uint64_t Address;
45  uint64_t Length;
46 
47  uint64_t getEndAddress() const { return Address + Length; }
48  void dump(raw_ostream &OS, uint32_t AddressSize) const;
49  };
50 
51 private:
52  using DescriptorColl = std::vector<Descriptor>;
53  using desc_iterator_range = iterator_range<DescriptorColl::const_iterator>;
54 
55  uint64_t Offset;
56  Header HeaderData;
57  DescriptorColl ArangeDescriptors;
58 
59 public:
61 
62  void clear();
63  Error extract(DWARFDataExtractor data, uint64_t *offset_ptr,
64  function_ref<void(Error)> WarningHandler);
65  void dump(raw_ostream &OS) const;
66 
67  uint64_t getCompileUnitDIEOffset() const { return HeaderData.CuOffset; }
68 
69  const Header &getHeader() const { return HeaderData; }
70 
72  return desc_iterator_range(ArangeDescriptors.begin(),
73  ArangeDescriptors.end());
74  }
75 };
76 
77 } // end namespace llvm
78 
79 #endif // LLVM_DEBUGINFO_DWARF_DWARFDEBUGARANGESET_H
llvm
Definition: AllocatorList.h:23
llvm::DWARFDebugArangeSet::dump
void dump(raw_ostream &OS) const
Definition: DWARFDebugArangeSet.cpp:164
llvm::DWARFDebugArangeSet::clear
void clear()
Definition: DWARFDebugArangeSet.cpp:31
llvm::DWARFDebugArangeSet::Descriptor::Address
uint64_t Address
Definition: DWARFDebugArangeSet.h:44
llvm::DWARFDebugArangeSet::Header::AddrSize
uint8_t AddrSize
The size in bytes of an address on the target architecture.
Definition: DWARFDebugArangeSet.h:37
Error.h
llvm::DWARFDebugArangeSet::Header
Definition: DWARFDebugArangeSet.h:24
llvm::DWARFDebugArangeSet::Descriptor::Length
uint64_t Length
Definition: DWARFDebugArangeSet.h:45
llvm::DWARFDataExtractor
A DataExtractor (typically for an in-memory copy of an object-file section) plus a relocation map for...
Definition: DWARFDataExtractor.h:21
llvm::DWARFDebugArangeSet::Header::CuOffset
uint64_t CuOffset
The offset from the beginning of the .debug_info section of the compilation unit entry referenced by ...
Definition: DWARFDebugArangeSet.h:32
llvm::DWARFDebugArangeSet::descriptors
desc_iterator_range descriptors() const
Definition: DWARFDebugArangeSet.h:71
llvm::DWARFDebugArangeSet::Descriptor::getEndAddress
uint64_t getEndAddress() const
Definition: DWARFDebugArangeSet.h:47
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:50
llvm::dwarf::DwarfFormat
DwarfFormat
Constants that define the DWARF format as 32 or 64 bit.
Definition: Dwarf.h:92
llvm::function_ref
An efficient, type-erasing, non-owning reference to a callable.
Definition: STLExtras.h:168
llvm::DWARFDebugArangeSet::getHeader
const Header & getHeader() const
Definition: DWARFDebugArangeSet.h:69
llvm::DWARFDebugArangeSet
Definition: DWARFDebugArangeSet.h:22
iterator_range.h
llvm::DWARFDebugArangeSet::Descriptor
Definition: DWARFDebugArangeSet.h:43
uint32_t
llvm::DWARFDebugArangeSet::getCompileUnitDIEOffset
uint64_t getCompileUnitDIEOffset() const
Definition: DWARFDebugArangeSet.h:67
llvm::DWARFDebugArangeSet::extract
Error extract(DWARFDataExtractor data, uint64_t *offset_ptr, function_ref< void(Error)> WarningHandler)
Definition: DWARFDebugArangeSet.cpp:37
llvm::DWARFDebugArangeSet::Descriptor::dump
void dump(raw_ostream &OS, uint32_t AddressSize) const
Definition: DWARFDebugArangeSet.cpp:22
llvm::DWARFDebugArangeSet::Header::SegSize
uint8_t SegSize
The size in bytes of a segment descriptor on the target architecture.
Definition: DWARFDebugArangeSet.h:40
uint16_t
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition: Error.h:157
llvm::DWARFDebugArangeSet::Header::Format
dwarf::DwarfFormat Format
The DWARF format of the set.
Definition: DWARFDebugArangeSet.h:29
llvm::iterator_range
A range adaptor for a pair of iterators.
Definition: iterator_range.h:30
llvm::DWARFDebugArangeSet::Header::Length
uint64_t Length
The total length of the entries for that set, not including the length field itself.
Definition: DWARFDebugArangeSet.h:27
llvm::DWARFDebugArangeSet::Header::Version
uint16_t Version
The DWARF version number.
Definition: DWARFDebugArangeSet.h:34
llvm::DWARFDebugArangeSet::DWARFDebugArangeSet
DWARFDebugArangeSet()
Definition: DWARFDebugArangeSet.h:60
DWARFDataExtractor.h