1eceb5b99777ba944a0ae3748a0371e9a3aa94d56Alexey Samsonov//===-- DWARFDebugRangeList.h -----------------------------------*- C++ -*-===// 2eceb5b99777ba944a0ae3748a0371e9a3aa94d56Alexey Samsonov// 3eceb5b99777ba944a0ae3748a0371e9a3aa94d56Alexey Samsonov// The LLVM Compiler Infrastructure 4eceb5b99777ba944a0ae3748a0371e9a3aa94d56Alexey Samsonov// 5eceb5b99777ba944a0ae3748a0371e9a3aa94d56Alexey Samsonov// This file is distributed under the University of Illinois Open Source 6eceb5b99777ba944a0ae3748a0371e9a3aa94d56Alexey Samsonov// License. See LICENSE.TXT for details. 7eceb5b99777ba944a0ae3748a0371e9a3aa94d56Alexey Samsonov// 8eceb5b99777ba944a0ae3748a0371e9a3aa94d56Alexey Samsonov//===----------------------------------------------------------------------===// 9eceb5b99777ba944a0ae3748a0371e9a3aa94d56Alexey Samsonov 10eceb5b99777ba944a0ae3748a0371e9a3aa94d56Alexey Samsonov#ifndef LLVM_DEBUGINFO_DWARFDEBUGRANGELIST_H 11eceb5b99777ba944a0ae3748a0371e9a3aa94d56Alexey Samsonov#define LLVM_DEBUGINFO_DWARFDEBUGRANGELIST_H 12eceb5b99777ba944a0ae3748a0371e9a3aa94d56Alexey Samsonov 13eceb5b99777ba944a0ae3748a0371e9a3aa94d56Alexey Samsonov#include "llvm/Support/DataExtractor.h" 14eceb5b99777ba944a0ae3748a0371e9a3aa94d56Alexey Samsonov#include <vector> 15eceb5b99777ba944a0ae3748a0371e9a3aa94d56Alexey Samsonov 16eceb5b99777ba944a0ae3748a0371e9a3aa94d56Alexey Samsonovnamespace llvm { 17eceb5b99777ba944a0ae3748a0371e9a3aa94d56Alexey Samsonov 18eceb5b99777ba944a0ae3748a0371e9a3aa94d56Alexey Samsonovclass raw_ostream; 19eceb5b99777ba944a0ae3748a0371e9a3aa94d56Alexey Samsonov 20eceb5b99777ba944a0ae3748a0371e9a3aa94d56Alexey Samsonovclass DWARFDebugRangeList { 21eceb5b99777ba944a0ae3748a0371e9a3aa94d56Alexey Samsonovpublic: 22eceb5b99777ba944a0ae3748a0371e9a3aa94d56Alexey Samsonov struct RangeListEntry { 23eceb5b99777ba944a0ae3748a0371e9a3aa94d56Alexey Samsonov // A beginning address offset. This address offset has the size of an 24eceb5b99777ba944a0ae3748a0371e9a3aa94d56Alexey Samsonov // address and is relative to the applicable base address of the 25eceb5b99777ba944a0ae3748a0371e9a3aa94d56Alexey Samsonov // compilation unit referencing this range list. It marks the beginning 26eceb5b99777ba944a0ae3748a0371e9a3aa94d56Alexey Samsonov // of an address range. 27eceb5b99777ba944a0ae3748a0371e9a3aa94d56Alexey Samsonov uint64_t StartAddress; 28eceb5b99777ba944a0ae3748a0371e9a3aa94d56Alexey Samsonov // An ending address offset. This address offset again has the size of 29eceb5b99777ba944a0ae3748a0371e9a3aa94d56Alexey Samsonov // an address and is relative to the applicable base address of the 30eceb5b99777ba944a0ae3748a0371e9a3aa94d56Alexey Samsonov // compilation unit referencing this range list. It marks the first 31eceb5b99777ba944a0ae3748a0371e9a3aa94d56Alexey Samsonov // address past the end of the address range. The ending address must 32eceb5b99777ba944a0ae3748a0371e9a3aa94d56Alexey Samsonov // be greater than or equal to the beginning address. 33eceb5b99777ba944a0ae3748a0371e9a3aa94d56Alexey Samsonov uint64_t EndAddress; 345eae90d727c64ca5b4b43b110521b38dcd9f0de6Alexey Samsonov // The end of any given range list is marked by an end of list entry, 355eae90d727c64ca5b4b43b110521b38dcd9f0de6Alexey Samsonov // which consists of a 0 for the beginning address offset 365eae90d727c64ca5b4b43b110521b38dcd9f0de6Alexey Samsonov // and a 0 for the ending address offset. 375eae90d727c64ca5b4b43b110521b38dcd9f0de6Alexey Samsonov bool isEndOfListEntry() const { 385eae90d727c64ca5b4b43b110521b38dcd9f0de6Alexey Samsonov return (StartAddress == 0) && (EndAddress == 0); 395eae90d727c64ca5b4b43b110521b38dcd9f0de6Alexey Samsonov } 405eae90d727c64ca5b4b43b110521b38dcd9f0de6Alexey Samsonov // A base address selection entry consists of: 415eae90d727c64ca5b4b43b110521b38dcd9f0de6Alexey Samsonov // 1. The value of the largest representable address offset 425eae90d727c64ca5b4b43b110521b38dcd9f0de6Alexey Samsonov // (for example, 0xffffffff when the size of an address is 32 bits). 435eae90d727c64ca5b4b43b110521b38dcd9f0de6Alexey Samsonov // 2. An address, which defines the appropriate base address for 445eae90d727c64ca5b4b43b110521b38dcd9f0de6Alexey Samsonov // use in interpreting the beginning and ending address offsets of 455eae90d727c64ca5b4b43b110521b38dcd9f0de6Alexey Samsonov // subsequent entries of the location list. 465eae90d727c64ca5b4b43b110521b38dcd9f0de6Alexey Samsonov bool isBaseAddressSelectionEntry(uint8_t AddressSize) const { 475eae90d727c64ca5b4b43b110521b38dcd9f0de6Alexey Samsonov assert(AddressSize == 4 || AddressSize == 8); 485eae90d727c64ca5b4b43b110521b38dcd9f0de6Alexey Samsonov if (AddressSize == 4) 495eae90d727c64ca5b4b43b110521b38dcd9f0de6Alexey Samsonov return StartAddress == -1U; 505eae90d727c64ca5b4b43b110521b38dcd9f0de6Alexey Samsonov else 515eae90d727c64ca5b4b43b110521b38dcd9f0de6Alexey Samsonov return StartAddress == -1ULL; 525eae90d727c64ca5b4b43b110521b38dcd9f0de6Alexey Samsonov } 535eae90d727c64ca5b4b43b110521b38dcd9f0de6Alexey Samsonov bool containsAddress(uint64_t BaseAddress, uint64_t Address) const { 545eae90d727c64ca5b4b43b110521b38dcd9f0de6Alexey Samsonov return (BaseAddress + StartAddress <= Address) && 555eae90d727c64ca5b4b43b110521b38dcd9f0de6Alexey Samsonov (Address < BaseAddress + EndAddress); 565eae90d727c64ca5b4b43b110521b38dcd9f0de6Alexey Samsonov } 57eceb5b99777ba944a0ae3748a0371e9a3aa94d56Alexey Samsonov }; 58eceb5b99777ba944a0ae3748a0371e9a3aa94d56Alexey Samsonov 59eceb5b99777ba944a0ae3748a0371e9a3aa94d56Alexey Samsonovprivate: 60eceb5b99777ba944a0ae3748a0371e9a3aa94d56Alexey Samsonov // Offset in .debug_ranges section. 61eceb5b99777ba944a0ae3748a0371e9a3aa94d56Alexey Samsonov uint32_t Offset; 62eceb5b99777ba944a0ae3748a0371e9a3aa94d56Alexey Samsonov uint8_t AddressSize; 63eceb5b99777ba944a0ae3748a0371e9a3aa94d56Alexey Samsonov std::vector<RangeListEntry> Entries; 64eceb5b99777ba944a0ae3748a0371e9a3aa94d56Alexey Samsonov 65eceb5b99777ba944a0ae3748a0371e9a3aa94d56Alexey Samsonovpublic: 66eceb5b99777ba944a0ae3748a0371e9a3aa94d56Alexey Samsonov DWARFDebugRangeList() { clear(); } 67eceb5b99777ba944a0ae3748a0371e9a3aa94d56Alexey Samsonov void clear(); 68eceb5b99777ba944a0ae3748a0371e9a3aa94d56Alexey Samsonov void dump(raw_ostream &OS) const; 69eceb5b99777ba944a0ae3748a0371e9a3aa94d56Alexey Samsonov bool extract(DataExtractor data, uint32_t *offset_ptr); 705eae90d727c64ca5b4b43b110521b38dcd9f0de6Alexey Samsonov /// containsAddress - Returns true if range list contains the given 715eae90d727c64ca5b4b43b110521b38dcd9f0de6Alexey Samsonov /// address. Has to be passed base address of the compile unit that 725eae90d727c64ca5b4b43b110521b38dcd9f0de6Alexey Samsonov /// references this range list. 735eae90d727c64ca5b4b43b110521b38dcd9f0de6Alexey Samsonov bool containsAddress(uint64_t BaseAddress, uint64_t Address) const; 74eceb5b99777ba944a0ae3748a0371e9a3aa94d56Alexey Samsonov}; 75eceb5b99777ba944a0ae3748a0371e9a3aa94d56Alexey Samsonov 76eceb5b99777ba944a0ae3748a0371e9a3aa94d56Alexey Samsonov} // namespace llvm 77eceb5b99777ba944a0ae3748a0371e9a3aa94d56Alexey Samsonov 78eceb5b99777ba944a0ae3748a0371e9a3aa94d56Alexey Samsonov#endif // LLVM_DEBUGINFO_DWARFDEBUGRANGELIST_H 79