LCOV - code coverage report
Current view: top level - lib/DebugInfo/PDB/Native - NativeExeSymbol.cpp (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 40 54 74.1 %
Date: 2018-10-20 13:21:21 Functions: 8 8 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===- NativeExeSymbol.cpp - native impl for PDBSymbolExe -------*- 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             : #include "llvm/DebugInfo/PDB/Native/NativeExeSymbol.h"
      11             : 
      12             : #include "llvm/ADT/STLExtras.h"
      13             : #include "llvm/DebugInfo/PDB/Native/DbiStream.h"
      14             : #include "llvm/DebugInfo/PDB/Native/InfoStream.h"
      15             : #include "llvm/DebugInfo/PDB/Native/NativeCompilandSymbol.h"
      16             : #include "llvm/DebugInfo/PDB/Native/NativeEnumModules.h"
      17             : #include "llvm/DebugInfo/PDB/Native/PDBFile.h"
      18             : #include "llvm/DebugInfo/PDB/Native/SymbolCache.h"
      19             : #include "llvm/DebugInfo/PDB/PDBSymbolCompiland.h"
      20             : 
      21             : using namespace llvm;
      22             : using namespace llvm::pdb;
      23             : 
      24          17 : static DbiStream *getDbiStreamPtr(NativeSession &Session) {
      25          17 :   Expected<DbiStream &> DbiS = Session.getPDBFile().getPDBDbiStream();
      26          17 :   if (DbiS)
      27          17 :     return &DbiS.get();
      28             : 
      29           0 :   consumeError(DbiS.takeError());
      30           0 :   return nullptr;
      31             : }
      32             : 
      33          17 : NativeExeSymbol::NativeExeSymbol(NativeSession &Session, SymIndexId SymbolId)
      34             :     : NativeRawSymbol(Session, PDB_SymType::Exe, SymbolId),
      35          17 :       Dbi(getDbiStreamPtr(Session)) {}
      36             : 
      37             : std::unique_ptr<IPDBEnumSymbols>
      38          16 : NativeExeSymbol::findChildren(PDB_SymType Type) const {
      39          16 :   switch (Type) {
      40           6 :   case PDB_SymType::Compiland: {
      41           6 :     return std::unique_ptr<IPDBEnumSymbols>(new NativeEnumModules(Session));
      42             :     break;
      43             :   }
      44           0 :   case PDB_SymType::ArrayType:
      45           0 :     return Session.getSymbolCache().createTypeEnumerator(codeview::LF_ARRAY);
      46           2 :   case PDB_SymType::Enum:
      47           4 :     return Session.getSymbolCache().createTypeEnumerator(codeview::LF_ENUM);
      48           2 :   case PDB_SymType::PointerType:
      49           4 :     return Session.getSymbolCache().createTypeEnumerator(codeview::LF_POINTER);
      50           2 :   case PDB_SymType::UDT:
      51           2 :     return Session.getSymbolCache().createTypeEnumerator(
      52             :         {codeview::LF_STRUCTURE, codeview::LF_CLASS, codeview::LF_UNION,
      53           4 :          codeview::LF_INTERFACE});
      54           0 :   case PDB_SymType::VTableShape:
      55           0 :     return Session.getSymbolCache().createTypeEnumerator(codeview::LF_VTSHAPE);
      56           2 :   case PDB_SymType::FunctionSig:
      57           2 :     return Session.getSymbolCache().createTypeEnumerator(
      58           4 :         {codeview::LF_PROCEDURE, codeview::LF_MFUNCTION});
      59           2 :   case PDB_SymType::Typedef:
      60           4 :     return Session.getSymbolCache().createGlobalsEnumerator(codeview::S_UDT);
      61             : 
      62             :   default:
      63             :     break;
      64             :   }
      65             :   return nullptr;
      66             : }
      67             : 
      68           8 : uint32_t NativeExeSymbol::getAge() const {
      69          16 :   auto IS = Session.getPDBFile().getPDBInfoStream();
      70           8 :   if (IS)
      71           8 :     return IS->getAge();
      72           0 :   consumeError(IS.takeError());
      73           0 :   return 0;
      74             : }
      75             : 
      76           8 : std::string NativeExeSymbol::getSymbolsFileName() const {
      77          16 :   return Session.getPDBFile().getFilePath();
      78             : }
      79             : 
      80           8 : codeview::GUID NativeExeSymbol::getGuid() const {
      81          16 :   auto IS = Session.getPDBFile().getPDBInfoStream();
      82           8 :   if (IS)
      83           8 :     return IS->getGuid();
      84           0 :   consumeError(IS.takeError());
      85           0 :   return codeview::GUID{{0}};
      86             : }
      87             : 
      88           8 : bool NativeExeSymbol::hasCTypes() const {
      89          16 :   auto Dbi = Session.getPDBFile().getPDBDbiStream();
      90           8 :   if (Dbi)
      91           8 :     return Dbi->hasCTypes();
      92           0 :   consumeError(Dbi.takeError());
      93           0 :   return false;
      94             : }
      95             : 
      96           8 : bool NativeExeSymbol::hasPrivateSymbols() const {
      97          16 :   auto Dbi = Session.getPDBFile().getPDBDbiStream();
      98           8 :   if (Dbi)
      99           8 :     return !Dbi->isStripped();
     100           0 :   consumeError(Dbi.takeError());
     101           0 :   return false;
     102             : }

Generated by: LCOV version 1.13