LCOV - code coverage report
Current view: top level - include/llvm/DebugInfo/DWARF - DWARFUnitIndex.h (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 4 7 57.1 %
Date: 2018-10-20 13:21:21 Functions: 0 2 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===- DWARFUnitIndex.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_DWARF_DWARFUNITINDEX_H
      11             : #define LLVM_DEBUGINFO_DWARF_DWARFUNITINDEX_H
      12             : 
      13             : #include "llvm/ADT/ArrayRef.h"
      14             : #include "llvm/ADT/StringRef.h"
      15             : #include "llvm/Support/DataExtractor.h"
      16             : #include <cstdint>
      17             : #include <memory>
      18             : 
      19             : namespace llvm {
      20             : 
      21             : class raw_ostream;
      22             : 
      23             : enum DWARFSectionKind {
      24             :   DW_SECT_INFO = 1,
      25             :   DW_SECT_TYPES,
      26             :   DW_SECT_ABBREV,
      27             :   DW_SECT_LINE,
      28             :   DW_SECT_LOC,
      29             :   DW_SECT_STR_OFFSETS,
      30             :   DW_SECT_MACINFO,
      31             :   DW_SECT_MACRO,
      32             : };
      33             : 
      34             : class DWARFUnitIndex {
      35          11 :   struct Header {
      36             :     uint32_t Version;
      37             :     uint32_t NumColumns;
      38             :     uint32_t NumUnits;
      39             :     uint32_t NumBuckets = 0;
      40             : 
      41             :     bool parse(DataExtractor IndexData, uint32_t *OffsetPtr);
      42             :     void dump(raw_ostream &OS) const;
      43             :   };
      44             : 
      45             : public:
      46           0 :   class Entry {
      47             :   public:
      48             :     struct SectionContribution {
      49             :       uint32_t Offset;
      50             :       uint32_t Length;
      51             :     };
      52             : 
      53             :   private:
      54             :     const DWARFUnitIndex *Index;
      55             :     uint64_t Signature;
      56             :     std::unique_ptr<SectionContribution[]> Contributions;
      57             :     friend class DWARFUnitIndex;
      58             : 
      59             :   public:
      60             :     const SectionContribution *getOffset(DWARFSectionKind Sec) const;
      61             :     const SectionContribution *getOffset() const;
      62             : 
      63             :     const SectionContribution *getOffsets() const {
      64             :       return Contributions.get();
      65             :     }
      66             : 
      67           0 :     uint64_t getSignature() const { return Signature; }
      68             :   };
      69             : 
      70             : private:
      71             :   struct Header Header;
      72             : 
      73             :   DWARFSectionKind InfoColumnKind;
      74             :   int InfoColumn = -1;
      75             :   std::unique_ptr<DWARFSectionKind[]> ColumnKinds;
      76             :   std::unique_ptr<Entry[]> Rows;
      77             :   mutable std::vector<Entry *> OffsetLookup;
      78             : 
      79             :   static StringRef getColumnHeader(DWARFSectionKind DS);
      80             : 
      81             :   bool parseImpl(DataExtractor IndexData);
      82             : 
      83             : public:
      84             :   DWARFUnitIndex(DWARFSectionKind InfoColumnKind)
      85          11 :       : InfoColumnKind(InfoColumnKind) {}
      86             : 
      87           0 :   explicit operator bool() const { return Header.NumBuckets; }
      88             : 
      89             :   bool parse(DataExtractor IndexData);
      90             :   void dump(raw_ostream &OS) const;
      91             : 
      92             :   const Entry *getFromOffset(uint32_t Offset) const;
      93             :   const Entry *getFromHash(uint64_t Offset) const;
      94             : 
      95             :   ArrayRef<DWARFSectionKind> getColumnKinds() const {
      96          10 :     return makeArrayRef(ColumnKinds.get(), Header.NumColumns);
      97             :   }
      98             : 
      99             :   ArrayRef<Entry> getRows() const {
     100           9 :     return makeArrayRef(Rows.get(), Header.NumBuckets);
     101             :   }
     102             : };
     103             : 
     104             : } // end namespace llvm
     105             : 
     106             : #endif // LLVM_DEBUGINFO_DWARF_DWARFUNITINDEX_H

Generated by: LCOV version 1.13