1 //===- PDB.cpp - base header file for creating a PDB reader -----*- 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/PDB.h" 11 12 #include "llvm/ADT/StringRef.h" 13 #include "llvm/Config/config.h" 14 #include "llvm/DebugInfo/PDB/IPDBSession.h" 15 #include "llvm/DebugInfo/PDB/PDB.h" 16 #if HAVE_DIA_SDK 17 #include "llvm/DebugInfo/PDB/DIA/DIASession.h" 18 #endif 19 #include "llvm/DebugInfo/PDB/Raw/RawSession.h" 20 #include "llvm/Support/ErrorHandling.h" 21 #include "llvm/Support/ManagedStatic.h" 22 23 using namespace llvm; 24 using namespace llvm::pdb; 25 26 Error llvm::pdb::loadDataForPDB(PDB_ReaderType Type, StringRef Path, 27 std::unique_ptr<IPDBSession> &Session) { 28 // Create the correct concrete instance type based on the value of Type. 29 if (Type == PDB_ReaderType::Raw) 30 return RawSession::createFromPdb(Path, Session); 31 32 #if HAVE_DIA_SDK 33 return DIASession::createFromPdb(Path, Session); 34 #else 35 return llvm::make_error<GenericError>("DIA is not installed on the system"); 36 #endif 37 } 38 39 Error llvm::pdb::loadDataForEXE(PDB_ReaderType Type, StringRef Path, 40 std::unique_ptr<IPDBSession> &Session) { 41 // Create the correct concrete instance type based on the value of Type. 42 if (Type == PDB_ReaderType::Raw) 43 return RawSession::createFromExe(Path, Session); 44 45 #if HAVE_DIA_SDK 46 return DIASession::createFromExe(Path, Session); 47 #else 48 return llvm::make_error<GenericError>("DIA is not installed on the system"); 49 #endif 50 } 51