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