1 //===- DWARFDebugRangeList.h ------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef LLVM_DEBUGINFO_DWARF_DWARFDEBUGRANGELIST_H
11 #define LLVM_DEBUGINFO_DWARF_DWARFDEBUGRANGELIST_H
13 #include "llvm/Support/DataExtractor.h"
14 #include "llvm/DebugInfo/DWARF/DWARFRelocMap.h"
25 /// DWARFAddressRangesVector - represents a set of absolute address ranges.
26 typedef std::vector<std::pair<uint64_t, uint64_t>> DWARFAddressRangesVector;
28 class DWARFDebugRangeList {
30 struct RangeListEntry {
31 // A beginning address offset. This address offset has the size of an
32 // address and is relative to the applicable base address of the
33 // compilation unit referencing this range list. It marks the beginning
34 // of an address range.
35 uint64_t StartAddress;
36 // An ending address offset. This address offset again has the size of
37 // an address and is relative to the applicable base address of the
38 // compilation unit referencing this range list. It marks the first
39 // address past the end of the address range. The ending address must
40 // be greater than or equal to the beginning address.
43 // The end of any given range list is marked by an end of list entry,
44 // which consists of a 0 for the beginning address offset
45 // and a 0 for the ending address offset.
46 bool isEndOfListEntry() const {
47 return (StartAddress == 0) && (EndAddress == 0);
50 // A base address selection entry consists of:
51 // 1. The value of the largest representable address offset
52 // (for example, 0xffffffff when the size of an address is 32 bits).
53 // 2. An address, which defines the appropriate base address for
54 // use in interpreting the beginning and ending address offsets of
55 // subsequent entries of the location list.
56 bool isBaseAddressSelectionEntry(uint8_t AddressSize) const {
57 assert(AddressSize == 4 || AddressSize == 8);
59 return StartAddress == -1U;
61 return StartAddress == -1ULL;
66 // Offset in .debug_ranges section.
69 std::vector<RangeListEntry> Entries;
72 DWARFDebugRangeList() { clear(); }
75 void dump(raw_ostream &OS) const;
76 bool extract(DataExtractor data, uint32_t *offset_ptr, const RelocAddrMap& Relocs);
77 const std::vector<RangeListEntry> &getEntries() { return Entries; }
79 /// getAbsoluteRanges - Returns absolute address ranges defined by this range
80 /// list. Has to be passed base address of the compile unit referencing this
82 DWARFAddressRangesVector getAbsoluteRanges(uint64_t BaseAddress) const;
85 } // end namespace llvm
87 #endif // LLVM_DEBUGINFO_DWARF_DWARFDEBUGRANGELIST_H