1 //===- DWARFDebugRnglists.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_DWARFDEBUGRNGLISTS_H 10 #define LLVM_DEBUGINFO_DWARFDEBUGRNGLISTS_H 11 12 #include "llvm/ADT/Optional.h" 13 #include "llvm/BinaryFormat/Dwarf.h" 14 #include "llvm/DebugInfo/DIContext.h" 15 #include "llvm/DebugInfo/DWARF/DWARFDataExtractor.h" 16 #include "llvm/DebugInfo/DWARF/DWARFDebugRangeList.h" 17 #include "llvm/DebugInfo/DWARF/DWARFListTable.h" 18 #include <cstdint> 19 #include <map> 20 #include <vector> 21 22 namespace llvm { 23 24 class Error; 25 class raw_ostream; 26 class DWARFUnit; 27 28 /// A class representing a single range list entry. 29 struct RangeListEntry : public DWARFListEntryBase { 30 /// The values making up the range list entry. Most represent a range with 31 /// a start and end address or a start address and a length. Others are 32 /// single value base addresses or end-of-list with no values. The unneeded 33 /// values are semantically undefined, but initialized to 0. 34 uint64_t Value0; 35 uint64_t Value1; 36 37 Error extract(DWARFDataExtractor Data, uint64_t End, uint64_t *OffsetPtr); 38 void dump(raw_ostream &OS, uint8_t AddrSize, uint8_t MaxEncodingStringLength, 39 uint64_t &CurrentBase, DIDumpOptions DumpOpts, 40 llvm::function_ref<Optional<object::SectionedAddress>(uint32_t)> 41 LookupPooledAddress) const; 42 bool isSentinel() const { return EntryKind == dwarf::DW_RLE_end_of_list; } 43 }; 44 45 /// A class representing a single rangelist. 46 class DWARFDebugRnglist : public DWARFListType<RangeListEntry> { 47 public: 48 /// Build a DWARFAddressRangesVector from a rangelist. 49 DWARFAddressRangesVector 50 getAbsoluteRanges(Optional<object::SectionedAddress> BaseAddr, 51 function_ref<Optional<object::SectionedAddress>(uint32_t)> 52 LookupPooledAddress) const; 53 54 /// Build a DWARFAddressRangesVector from a rangelist. 55 DWARFAddressRangesVector 56 getAbsoluteRanges(llvm::Optional<object::SectionedAddress> BaseAddr, 57 DWARFUnit &U) const; 58 }; 59 60 class DWARFDebugRnglistTable : public DWARFListTableBase<DWARFDebugRnglist> { 61 public: 62 DWARFDebugRnglistTable() 63 : DWARFListTableBase(/* SectionName = */ ".debug_rnglists", 64 /* HeaderString = */ "ranges:", 65 /* ListTypeString = */ "range") {} 66 }; 67 68 } // end namespace llvm 69 70 #endif // LLVM_DEBUGINFO_DWARFDEBUGRNGLISTS_H 71