Home | History | Annotate | Line # | Download | only in DWARF
      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_DWARF_DWARFDEBUGRNGLISTS_H
     10 #define LLVM_DEBUGINFO_DWARF_DWARFDEBUGRNGLISTS_H
     11 
     12 #include "llvm/ADT/Optional.h"
     13 #include "llvm/ADT/STLExtras.h"
     14 #include "llvm/BinaryFormat/Dwarf.h"
     15 #include "llvm/DebugInfo/DIContext.h"
     16 #include "llvm/DebugInfo/DWARF/DWARFDataExtractor.h"
     17 #include "llvm/DebugInfo/DWARF/DWARFDebugRangeList.h"
     18 #include "llvm/DebugInfo/DWARF/DWARFListTable.h"
     19 #include <cstdint>
     20 
     21 namespace llvm {
     22 
     23 class Error;
     24 class raw_ostream;
     25 class DWARFUnit;
     26 
     27 /// A class representing a single range list entry.
     28 struct RangeListEntry : public DWARFListEntryBase {
     29   /// The values making up the range list entry. Most represent a range with
     30   /// a start and end address or a start address and a length. Others are
     31   /// single value base addresses or end-of-list with no values. The unneeded
     32   /// values are semantically undefined, but initialized to 0.
     33   uint64_t Value0;
     34   uint64_t Value1;
     35 
     36   Error extract(DWARFDataExtractor Data, uint64_t *OffsetPtr);
     37   void dump(raw_ostream &OS, uint8_t AddrSize, uint8_t MaxEncodingStringLength,
     38             uint64_t &CurrentBase, DIDumpOptions DumpOpts,
     39             llvm::function_ref<Optional<object::SectionedAddress>(uint32_t)>
     40                 LookupPooledAddress) const;
     41   bool isSentinel() const { return EntryKind == dwarf::DW_RLE_end_of_list; }
     42 };
     43 
     44 /// A class representing a single rangelist.
     45 class DWARFDebugRnglist : public DWARFListType<RangeListEntry> {
     46 public:
     47   /// Build a DWARFAddressRangesVector from a rangelist.
     48   DWARFAddressRangesVector
     49   getAbsoluteRanges(Optional<object::SectionedAddress> BaseAddr,
     50                     uint8_t AddressByteSize,
     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_DWARF_DWARFDEBUGRNGLISTS_H
     71