LLVM API Documentation

DWARFDebugRangeList.h
Go to the documentation of this file.
00001 //===-- DWARFDebugRangeList.h -----------------------------------*- C++ -*-===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 
00010 #ifndef LLVM_LIB_DEBUGINFO_DWARFDEBUGRANGELIST_H
00011 #define LLVM_LIB_DEBUGINFO_DWARFDEBUGRANGELIST_H
00012 
00013 #include "llvm/Support/DataExtractor.h"
00014 #include <vector>
00015 
00016 namespace llvm {
00017 
00018 class raw_ostream;
00019 
00020 /// DWARFAddressRangesVector - represents a set of absolute address ranges.
00021 typedef std::vector<std::pair<uint64_t, uint64_t>> DWARFAddressRangesVector;
00022 
00023 class DWARFDebugRangeList {
00024 public:
00025   struct RangeListEntry {
00026     // A beginning address offset. This address offset has the size of an
00027     // address and is relative to the applicable base address of the
00028     // compilation unit referencing this range list. It marks the beginning
00029     // of an address range.
00030     uint64_t StartAddress;
00031     // An ending address offset. This address offset again has the size of
00032     // an address and is relative to the applicable base address of the
00033     // compilation unit referencing this range list. It marks the first
00034     // address past the end of the address range. The ending address must
00035     // be greater than or equal to the beginning address.
00036     uint64_t EndAddress;
00037     // The end of any given range list is marked by an end of list entry,
00038     // which consists of a 0 for the beginning address offset
00039     // and a 0 for the ending address offset.
00040     bool isEndOfListEntry() const {
00041       return (StartAddress == 0) && (EndAddress == 0);
00042     }
00043     // A base address selection entry consists of:
00044     // 1. The value of the largest representable address offset
00045     // (for example, 0xffffffff when the size of an address is 32 bits).
00046     // 2. An address, which defines the appropriate base address for
00047     // use in interpreting the beginning and ending address offsets of
00048     // subsequent entries of the location list.
00049     bool isBaseAddressSelectionEntry(uint8_t AddressSize) const {
00050       assert(AddressSize == 4 || AddressSize == 8);
00051       if (AddressSize == 4)
00052         return StartAddress == -1U;
00053       else
00054         return StartAddress == -1ULL;
00055     }
00056   };
00057 
00058 private:
00059   // Offset in .debug_ranges section.
00060   uint32_t Offset;
00061   uint8_t AddressSize;
00062   std::vector<RangeListEntry> Entries;
00063 
00064 public:
00065   DWARFDebugRangeList() { clear(); }
00066   void clear();
00067   void dump(raw_ostream &OS) const;
00068   bool extract(DataExtractor data, uint32_t *offset_ptr);
00069   /// getAbsoluteRanges - Returns absolute address ranges defined by this range
00070   /// list. Has to be passed base address of the compile unit referencing this
00071   /// range list.
00072   DWARFAddressRangesVector getAbsoluteRanges(uint64_t BaseAddress) const;
00073 };
00074 
00075 }  // namespace llvm
00076 
00077 #endif  // LLVM_DEBUGINFO_DWARFDEBUGRANGELIST_H