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