]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugRangeList.h
Merge llvm, clang, compiler-rt, libc++, lld, and lldb release_80 branch
[FreeBSD/FreeBSD.git] / contrib / llvm / include / llvm / DebugInfo / DWARF / DWARFDebugRangeList.h
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
13 #include "llvm/DebugInfo/DWARF/DWARFAddressRange.h"
14 #include "llvm/DebugInfo/DWARF/DWARFDataExtractor.h"
15 #include <cassert>
16 #include <cstdint>
17 #include <vector>
18
19 namespace llvm {
20
21 class raw_ostream;
22
23 class DWARFDebugRangeList {
24 public:
25   struct RangeListEntry {
26     /// A beginning address offset. This address offset has the size of an
27     /// address and is relative to the applicable base address of the
28     /// compilation unit referencing this range list. It marks the beginning
29     /// of an address range.
30     uint64_t StartAddress;
31     /// An ending address offset. This address offset again has the size of
32     /// an address and is relative to the applicable base address of the
33     /// compilation unit referencing this range list. It marks the first
34     /// address past the end of the address range. The ending address must
35     /// be greater than or equal to the beginning address.
36     uint64_t EndAddress;
37     /// A section index this range belongs to.
38     uint64_t SectionIndex;
39
40     /// The end of any given range list is marked by an end of list entry,
41     /// which consists of a 0 for the beginning address offset
42     /// and a 0 for the ending address offset.
43     bool isEndOfListEntry() const {
44       return (StartAddress == 0) && (EndAddress == 0);
45     }
46
47     /// A base address selection entry consists of:
48     /// 1. The value of the largest representable address offset
49     /// (for example, 0xffffffff when the size of an address is 32 bits).
50     /// 2. An address, which defines the appropriate base address for
51     /// use in interpreting the beginning and ending address offsets of
52     /// subsequent entries of the location list.
53     bool isBaseAddressSelectionEntry(uint8_t AddressSize) const {
54       assert(AddressSize == 4 || AddressSize == 8);
55       if (AddressSize == 4)
56         return StartAddress == -1U;
57       else
58         return StartAddress == -1ULL;
59     }
60   };
61
62 private:
63   /// Offset in .debug_ranges section.
64   uint32_t Offset;
65   uint8_t AddressSize;
66   std::vector<RangeListEntry> Entries;
67
68 public:
69   DWARFDebugRangeList() { clear(); }
70
71   void clear();
72   void dump(raw_ostream &OS) const;
73   Error extract(const DWARFDataExtractor &data, uint32_t *offset_ptr);
74   const std::vector<RangeListEntry> &getEntries() { return Entries; }
75
76   /// getAbsoluteRanges - Returns absolute address ranges defined by this range
77   /// list. Has to be passed base address of the compile unit referencing this
78   /// range list.
79   DWARFAddressRangesVector
80   getAbsoluteRanges(llvm::Optional<SectionedAddress> BaseAddr) const;
81 };
82
83 } // end namespace llvm
84
85 #endif // LLVM_DEBUGINFO_DWARF_DWARFDEBUGRANGELIST_H