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