1 //===- PDB.cpp - base header file for creating a PDB reader ---------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
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"
17 #include "llvm/DebugInfo/PDB/Native/NativeSession.h"
18 #include "llvm/Support/Error.h"
21 using namespace llvm::pdb;
23 Error llvm::pdb::loadDataForPDB(PDB_ReaderType Type, StringRef Path,
24 std::unique_ptr<IPDBSession> &Session) {
25 // Create the correct concrete instance type based on the value of Type.
26 if (Type == PDB_ReaderType::Native)
27 return NativeSession::createFromPdb(Path, Session);
29 #if LLVM_ENABLE_DIA_SDK
30 return DIASession::createFromPdb(Path, Session);
32 return make_error<GenericError>("DIA is not installed on the system");
36 Error llvm::pdb::loadDataForEXE(PDB_ReaderType Type, StringRef Path,
37 std::unique_ptr<IPDBSession> &Session) {
38 // Create the correct concrete instance type based on the value of Type.
39 if (Type == PDB_ReaderType::Native)
40 return NativeSession::createFromExe(Path, Session);
42 #if LLVM_ENABLE_DIA_SDK
43 return DIASession::createFromExe(Path, Session);
45 return make_error<GenericError>("DIA is not installed on the system");