blob: 4ee3bdad329999d434ba12568f6c5eb3882216f7 [file] [log] [blame]
Alexey Samsonov034e57a2012-08-27 07:17:47 +00001//===-- 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
Benjamin Kramera7c40ef2014-08-13 16:26:38 +000010#ifndef LLVM_LIB_DEBUGINFO_DWARFDEBUGRANGELIST_H
11#define LLVM_LIB_DEBUGINFO_DWARFDEBUGRANGELIST_H
Alexey Samsonov034e57a2012-08-27 07:17:47 +000012
13#include "llvm/Support/DataExtractor.h"
14#include <vector>
15
16namespace llvm {
17
18class raw_ostream;
19
Alexey Samsonov762343d2014-04-18 17:25:46 +000020/// DWARFAddressRangesVector - represents a set of absolute address ranges.
21typedef std::vector<std::pair<uint64_t, uint64_t>> DWARFAddressRangesVector;
22
Alexey Samsonov034e57a2012-08-27 07:17:47 +000023class DWARFDebugRangeList {
24public:
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;
Alexey Samsonovc942e6b2012-09-04 08:12:33 +000037 // The end of any given range list is marked by an end of list entry,
38 // which consists of a 0 for the beginning address offset
39 // and a 0 for the ending address offset.
40 bool isEndOfListEntry() const {
41 return (StartAddress == 0) && (EndAddress == 0);
42 }
43 // A base address selection entry consists of:
44 // 1. The value of the largest representable address offset
45 // (for example, 0xffffffff when the size of an address is 32 bits).
46 // 2. An address, which defines the appropriate base address for
47 // use in interpreting the beginning and ending address offsets of
48 // subsequent entries of the location list.
49 bool isBaseAddressSelectionEntry(uint8_t AddressSize) const {
50 assert(AddressSize == 4 || AddressSize == 8);
51 if (AddressSize == 4)
52 return StartAddress == -1U;
53 else
54 return StartAddress == -1ULL;
55 }
Alexey Samsonov034e57a2012-08-27 07:17:47 +000056 };
57
58private:
59 // Offset in .debug_ranges section.
60 uint32_t Offset;
61 uint8_t AddressSize;
62 std::vector<RangeListEntry> Entries;
63
64public:
65 DWARFDebugRangeList() { clear(); }
66 void clear();
67 void dump(raw_ostream &OS) const;
68 bool extract(DataExtractor data, uint32_t *offset_ptr);
Alexey Samsonov762343d2014-04-18 17:25:46 +000069 /// getAbsoluteRanges - Returns absolute address ranges defined by this range
70 /// list. Has to be passed base address of the compile unit referencing this
71 /// range list.
72 DWARFAddressRangesVector getAbsoluteRanges(uint64_t BaseAddress) const;
Alexey Samsonov034e57a2012-08-27 07:17:47 +000073};
74
75} // namespace llvm
76
77#endif // LLVM_DEBUGINFO_DWARFDEBUGRANGELIST_H