LLVM  5.0.0
DWARFDebugRangeList.h
Go to the documentation of this file.
1 //===- DWARFDebugRangeList.h ------------------------------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #ifndef LLVM_DEBUGINFO_DWARF_DWARFDEBUGRANGELIST_H
11 #define LLVM_DEBUGINFO_DWARF_DWARFDEBUGRANGELIST_H
12 
15 #include <cassert>
16 #include <cstdint>
17 #include <vector>
18 
19 namespace llvm {
20 
21 class raw_ostream;
22 
24  uint64_t LowPC;
25  uint64_t HighPC;
26  uint64_t SectionIndex;
27 };
28 
29 /// DWARFAddressRangesVector - represents a set of absolute address ranges.
30 using DWARFAddressRangesVector = std::vector<DWARFAddressRange>;
31 
33 public:
34  struct RangeListEntry {
35  /// A beginning address offset. This address offset has the size of an
36  /// address and is relative to the applicable base address of the
37  /// compilation unit referencing this range list. It marks the beginning
38  /// of an address range.
39  uint64_t StartAddress;
40  /// An ending address offset. This address offset again has the size of
41  /// an address and is relative to the applicable base address of the
42  /// compilation unit referencing this range list. It marks the first
43  /// address past the end of the address range. The ending address must
44  /// be greater than or equal to the beginning address.
45  uint64_t EndAddress;
46  /// A section index this range belongs to.
47  uint64_t SectionIndex;
48 
49  /// The end of any given range list is marked by an end of list entry,
50  /// which consists of a 0 for the beginning address offset
51  /// and a 0 for the ending address offset.
52  bool isEndOfListEntry() const {
53  return (StartAddress == 0) && (EndAddress == 0);
54  }
55 
56  /// A base address selection entry consists of:
57  /// 1. The value of the largest representable address offset
58  /// (for example, 0xffffffff when the size of an address is 32 bits).
59  /// 2. An address, which defines the appropriate base address for
60  /// use in interpreting the beginning and ending address offsets of
61  /// subsequent entries of the location list.
62  bool isBaseAddressSelectionEntry(uint8_t AddressSize) const {
63  assert(AddressSize == 4 || AddressSize == 8);
64  if (AddressSize == 4)
65  return StartAddress == -1U;
66  else
67  return StartAddress == -1ULL;
68  }
69  };
70 
71 private:
72  /// Offset in .debug_ranges section.
73  uint32_t Offset;
74  uint8_t AddressSize;
75  std::vector<RangeListEntry> Entries;
76 
77 public:
79 
80  void clear();
81  void dump(raw_ostream &OS) const;
82  bool extract(const DWARFDataExtractor &data, uint32_t *offset_ptr);
83  const std::vector<RangeListEntry> &getEntries() { return Entries; }
84 
85  /// getAbsoluteRanges - Returns absolute address ranges defined by this range
86  /// list. Has to be passed base address of the compile unit referencing this
87  /// range list.
88  DWARFAddressRangesVector getAbsoluteRanges(uint64_t BaseAddress) const;
89 };
90 
91 } // end namespace llvm
92 
93 #endif // LLVM_DEBUGINFO_DWARF_DWARFDEBUGRANGELIST_H
uint64_t SectionIndex
A section index this range belongs to.
const std::vector< RangeListEntry > & getEntries()
bool isEndOfListEntry() const
The end of any given range list is marked by an end of list entry, which consists of a 0 for the begi...
bool isBaseAddressSelectionEntry(uint8_t AddressSize) const
A base address selection entry consists of:
DWARFAddressRangesVector getAbsoluteRanges(uint64_t BaseAddress) const
getAbsoluteRanges - Returns absolute address ranges defined by this range list.
void dump(raw_ostream &OS) const
A DataExtractor (typically for an in-memory copy of an object-file section) plus a relocation map for...
uint64_t EndAddress
An ending address offset.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
std::vector< DWARFAddressRange > DWARFAddressRangesVector
DWARFAddressRangesVector - represents a set of absolute address ranges.
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:44
uint64_t StartAddress
A beginning address offset.
bool extract(const DWARFDataExtractor &data, uint32_t *offset_ptr)