LCOV - code coverage report
Current view: top level - include/llvm/DebugInfo/DWARF - DWARFDebugAranges.h (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 8 9 88.9 %
Date: 2017-09-14 15:23:50 Functions: 1 1 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===- DWARFDebugAranges.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             : 
      10             : #ifndef LLVM_DEBUGINFO_DWARFDEBUGARANGES_H
      11             : #define LLVM_DEBUGINFO_DWARFDEBUGARANGES_H
      12             : 
      13             : #include "llvm/ADT/DenseSet.h"
      14             : #include "llvm/Support/DataExtractor.h"
      15             : #include <cstdint>
      16             : #include <vector>
      17             : 
      18             : namespace llvm {
      19             : 
      20             : class DWARFContext;
      21             : 
      22        1384 : class DWARFDebugAranges {
      23             : public:
      24             :   void generate(DWARFContext *CTX);
      25             :   uint32_t findAddress(uint64_t Address) const;
      26             : 
      27             : private:
      28             :   void clear();
      29             :   void extract(DataExtractor DebugArangesData);
      30             : 
      31             :   /// Call appendRange multiple times and then call construct.
      32             :   void appendRange(uint32_t CUOffset, uint64_t LowPC, uint64_t HighPC);
      33             :   void construct();
      34             : 
      35             :   struct Range {
      36             :     explicit Range(uint64_t LowPC = -1ULL, uint64_t HighPC = -1ULL,
      37             :                    uint32_t CUOffset = -1U)
      38     1005366 :       : LowPC(LowPC), Length(HighPC - LowPC), CUOffset(CUOffset) {}
      39             : 
      40             :     void setHighPC(uint64_t HighPC) {
      41       99267 :       if (HighPC == -1ULL || HighPC <= LowPC)
      42           0 :         Length = 0;
      43             :       else
      44       99267 :         Length = HighPC - LowPC;
      45             :     }
      46             : 
      47             :     uint64_t HighPC() const {
      48     1104498 :       if (Length)
      49     1104498 :         return LowPC + Length;
      50             :       return -1ULL;
      51             :     }
      52             : 
      53             :     bool containsAddress(uint64_t Address) const {
      54        2520 :       return LowPC <= Address && Address < HighPC();
      55             :     }
      56             : 
      57             :     bool operator<(const Range &other) const {
      58             :       return LowPC < other.LowPC;
      59             :     }
      60             : 
      61             :     uint64_t LowPC; /// Start of address range.
      62             :     uint32_t Length; /// End of address range (not including this address).
      63             :     uint32_t CUOffset; /// Offset of the compile unit or die.
      64             :   };
      65             : 
      66             :   struct RangeEndpoint {
      67             :     uint64_t Address;
      68             :     uint32_t CUOffset;
      69             :     bool IsRangeStart;
      70             : 
      71             :     RangeEndpoint(uint64_t Address, uint32_t CUOffset, bool IsRangeStart)
      72     3156158 :         : Address(Address), CUOffset(CUOffset), IsRangeStart(IsRangeStart) {}
      73             : 
      74             :     bool operator<(const RangeEndpoint &Other) const {
      75             :       return Address < Other.Address;
      76             :     }
      77             :   };
      78             : 
      79             :   using RangeColl = std::vector<Range>;
      80             :   using RangeCollIterator = RangeColl::const_iterator;
      81             : 
      82             :   std::vector<RangeEndpoint> Endpoints;
      83             :   RangeColl Aranges;
      84             :   DenseSet<uint32_t> ParsedCUOffsets;
      85             : };
      86             : 
      87             : } // end namespace llvm
      88             : 
      89             : #endif // LLVM_DEBUGINFO_DWARFDEBUGARANGES_H

Generated by: LCOV version 1.13