LLVM API Documentation

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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_DWARFDEBUGRANGELIST_H
11 #define LLVM_DEBUGINFO_DWARFDEBUGRANGELIST_H
12 
14 #include <vector>
15 
16 namespace llvm {
17 
18 class raw_ostream;
19 
21 public:
22  struct RangeListEntry {
23  // A beginning address offset. This address offset has the size of an
24  // address and is relative to the applicable base address of the
25  // compilation unit referencing this range list. It marks the beginning
26  // of an address range.
27  uint64_t StartAddress;
28  // An ending address offset. This address offset again has the size of
29  // an address and is relative to the applicable base address of the
30  // compilation unit referencing this range list. It marks the first
31  // address past the end of the address range. The ending address must
32  // be greater than or equal to the beginning address.
33  uint64_t EndAddress;
34  // The end of any given range list is marked by an end of list entry,
35  // which consists of a 0 for the beginning address offset
36  // and a 0 for the ending address offset.
37  bool isEndOfListEntry() const {
38  return (StartAddress == 0) && (EndAddress == 0);
39  }
40  // A base address selection entry consists of:
41  // 1. The value of the largest representable address offset
42  // (for example, 0xffffffff when the size of an address is 32 bits).
43  // 2. An address, which defines the appropriate base address for
44  // use in interpreting the beginning and ending address offsets of
45  // subsequent entries of the location list.
46  bool isBaseAddressSelectionEntry(uint8_t AddressSize) const {
47  assert(AddressSize == 4 || AddressSize == 8);
48  if (AddressSize == 4)
49  return StartAddress == -1U;
50  else
51  return StartAddress == -1ULL;
52  }
53  bool containsAddress(uint64_t BaseAddress, uint64_t Address) const {
54  return (BaseAddress + StartAddress <= Address) &&
55  (Address < BaseAddress + EndAddress);
56  }
57  };
58 
59 private:
60  // Offset in .debug_ranges section.
61  uint32_t Offset;
62  uint8_t AddressSize;
63  std::vector<RangeListEntry> Entries;
64 
65 public:
67  void clear();
68  void dump(raw_ostream &OS) const;
69  bool extract(DataExtractor data, uint32_t *offset_ptr);
70  /// containsAddress - Returns true if range list contains the given
71  /// address. Has to be passed base address of the compile unit that
72  /// references this range list.
73  bool containsAddress(uint64_t BaseAddress, uint64_t Address) const;
74 };
75 
76 } // namespace llvm
77 
78 #endif // LLVM_DEBUGINFO_DWARFDEBUGRANGELIST_H
bool isBaseAddressSelectionEntry(uint8_t AddressSize) const
bool extract(DataExtractor data, uint32_t *offset_ptr)
void dump(raw_ostream &OS) const
bool containsAddress(uint64_t BaseAddress, uint64_t Address) const
bool containsAddress(uint64_t BaseAddress, uint64_t Address) const