LCOV - code coverage report
Current view: top level - lib/DebugInfo/PDB - PDB.cpp (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 7 8 87.5 %
Date: 2018-06-17 00:07:59 Functions: 2 2 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===- PDB.cpp - base header file for creating a PDB reader ---------------===//
       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/PDB.h"
      11             : #include "llvm/ADT/StringRef.h"
      12             : #include "llvm/Config/config.h"
      13             : #include "llvm/DebugInfo/PDB/GenericError.h"
      14             : #if LLVM_ENABLE_DIA_SDK
      15             : #include "llvm/DebugInfo/PDB/DIA/DIASession.h"
      16             : #endif
      17             : #include "llvm/DebugInfo/PDB/Native/NativeSession.h"
      18             : #include "llvm/Support/Error.h"
      19             : #include "llvm/Support/MemoryBuffer.h"
      20             : 
      21             : using namespace llvm;
      22             : using namespace llvm::pdb;
      23             : 
      24         104 : Error llvm::pdb::loadDataForPDB(PDB_ReaderType Type, StringRef Path,
      25             :                                 std::unique_ptr<IPDBSession> &Session) {
      26             :   // Create the correct concrete instance type based on the value of Type.
      27         104 :   if (Type == PDB_ReaderType::Native) {
      28             :     ErrorOr<std::unique_ptr<MemoryBuffer>> ErrorOrBuffer =
      29             :         MemoryBuffer::getFileOrSTDIN(Path, /*FileSize=*/-1,
      30         102 :                                      /*RequiresNullTerminator=*/false);
      31         102 :     if (!ErrorOrBuffer)
      32             :       return make_error<GenericError>(generic_error_code::invalid_path, Path);
      33             : 
      34         204 :     return NativeSession::createFromPdb(std::move(*ErrorOrBuffer), Session);
      35             :   }
      36             : 
      37             : #if LLVM_ENABLE_DIA_SDK
      38             :   return DIASession::createFromPdb(Path, Session);
      39             : #else
      40             :   return make_error<GenericError>("DIA is not installed on the system");
      41             : #endif
      42             : }
      43             : 
      44          24 : Error llvm::pdb::loadDataForEXE(PDB_ReaderType Type, StringRef Path,
      45             :                                 std::unique_ptr<IPDBSession> &Session) {
      46             :   // Create the correct concrete instance type based on the value of Type.
      47          24 :   if (Type == PDB_ReaderType::Native)
      48           0 :     return NativeSession::createFromExe(Path, Session);
      49             : 
      50             : #if LLVM_ENABLE_DIA_SDK
      51             :   return DIASession::createFromExe(Path, Session);
      52             : #else
      53             :   return make_error<GenericError>("DIA is not installed on the system");
      54             : #endif
      55             : }

Generated by: LCOV version 1.13