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_DWARFDEBUGRANGELIST_H
11 #define LLVM_DEBUGINFO_DWARFDEBUGRANGELIST_H
13 #include "llvm/Support/DataExtractor.h"
20 class DWARFDebugRangeList {
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.
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);
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);
49 return StartAddress == -1U;
51 return StartAddress == -1ULL;
53 bool containsAddress(uint64_t BaseAddress, uint64_t Address) const {
54 return (BaseAddress + StartAddress <= Address) &&
55 (Address < BaseAddress + EndAddress);
60 // Offset in .debug_ranges section.
63 std::vector<RangeListEntry> Entries;
66 DWARFDebugRangeList() { 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;
78 #endif // LLVM_DEBUGINFO_DWARFDEBUGRANGELIST_H