LCOV - code coverage report
Current view: top level - include/llvm/DebugInfo/DWARF - DWARFDebugAranges.h (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 7 15 46.7 %
Date: 2018-10-20 13:21:21 Functions: 0 4 0.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             : 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       68182 :       : LowPC(LowPC), Length(HighPC - LowPC), CUOffset(CUOffset) {}
      39             : 
      40           0 :     void setHighPC(uint64_t HighPC) {
      41        2983 :       if (HighPC == -1ULL || HighPC <= LowPC)
      42           0 :         Length = 0;
      43             :       else
      44        2983 :         Length = HighPC - LowPC;
      45           0 :     }
      46             : 
      47           0 :     uint64_t HighPC() const {
      48       71002 :       if (Length)
      49       71899 :         return LowPC + Length;
      50             :       return -1ULL;
      51             :     }
      52             : 
      53             :     bool containsAddress(uint64_t Address) const {
      54        2572 :       return LowPC <= Address && Address < HighPC();
      55             :     }
      56             : 
      57           0 :     bool operator<(const Range &other) const {
      58           0 :       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      145058 :         : Address(Address), CUOffset(CUOffset), IsRangeStart(IsRangeStart) {}
      73             : 
      74           0 :     bool operator<(const RangeEndpoint &Other) const {
      75           0 :       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