2015-02-07 04:30:52 +08:00
|
|
|
//===- PDB.cpp - base header file for creating a PDB reader -----*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2015-02-14 11:53:56 +08:00
|
|
|
#include "llvm/DebugInfo/PDB/PDB.h"
|
|
|
|
|
2015-02-07 04:30:52 +08:00
|
|
|
#include "llvm/ADT/StringRef.h"
|
2015-02-14 11:53:56 +08:00
|
|
|
#include "llvm/Config/config.h"
|
2016-05-07 04:59:35 +08:00
|
|
|
#include "llvm/DebugInfo/PDB/GenericError.h"
|
2015-02-07 04:30:52 +08:00
|
|
|
#include "llvm/DebugInfo/PDB/IPDBSession.h"
|
2015-02-13 17:09:03 +08:00
|
|
|
#include "llvm/DebugInfo/PDB/PDB.h"
|
2017-01-03 02:19:35 +08:00
|
|
|
#if LLVM_ENABLE_DIA_SDK
|
2015-02-11 05:17:52 +08:00
|
|
|
#include "llvm/DebugInfo/PDB/DIA/DIASession.h"
|
|
|
|
#endif
|
2016-04-26 01:38:08 +08:00
|
|
|
#include "llvm/DebugInfo/PDB/Raw/RawSession.h"
|
2016-05-07 04:51:57 +08:00
|
|
|
#include "llvm/Support/ErrorHandling.h"
|
|
|
|
#include "llvm/Support/ManagedStatic.h"
|
2015-02-07 04:30:52 +08:00
|
|
|
|
|
|
|
using namespace llvm;
|
2016-05-05 04:32:13 +08:00
|
|
|
using namespace llvm::pdb;
|
2015-02-07 04:30:52 +08:00
|
|
|
|
2016-05-07 04:51:57 +08:00
|
|
|
Error llvm::pdb::loadDataForPDB(PDB_ReaderType Type, StringRef Path,
|
|
|
|
std::unique_ptr<IPDBSession> &Session) {
|
2015-02-07 04:30:52 +08:00
|
|
|
// Create the correct concrete instance type based on the value of Type.
|
2016-04-26 01:38:08 +08:00
|
|
|
if (Type == PDB_ReaderType::Raw)
|
2016-05-05 04:32:13 +08:00
|
|
|
return RawSession::createFromPdb(Path, Session);
|
2016-04-26 01:38:08 +08:00
|
|
|
|
2017-01-03 02:19:35 +08:00
|
|
|
#if LLVM_ENABLE_DIA_SDK
|
2015-03-01 04:23:18 +08:00
|
|
|
return DIASession::createFromPdb(Path, Session);
|
2016-04-26 01:38:08 +08:00
|
|
|
#else
|
2016-05-07 04:51:57 +08:00
|
|
|
return llvm::make_error<GenericError>("DIA is not installed on the system");
|
2016-04-26 01:38:08 +08:00
|
|
|
#endif
|
2015-02-07 04:30:52 +08:00
|
|
|
}
|
2015-04-18 06:40:36 +08:00
|
|
|
|
2016-05-07 04:51:57 +08:00
|
|
|
Error llvm::pdb::loadDataForEXE(PDB_ReaderType Type, StringRef Path,
|
|
|
|
std::unique_ptr<IPDBSession> &Session) {
|
2015-12-18 04:54:16 +08:00
|
|
|
// Create the correct concrete instance type based on the value of Type.
|
2016-04-26 01:38:08 +08:00
|
|
|
if (Type == PDB_ReaderType::Raw)
|
2016-05-05 04:32:13 +08:00
|
|
|
return RawSession::createFromExe(Path, Session);
|
2016-04-26 01:38:08 +08:00
|
|
|
|
2017-01-03 02:19:35 +08:00
|
|
|
#if LLVM_ENABLE_DIA_SDK
|
2015-04-18 06:40:36 +08:00
|
|
|
return DIASession::createFromExe(Path, Session);
|
2016-04-26 01:38:08 +08:00
|
|
|
#else
|
2016-05-07 04:51:57 +08:00
|
|
|
return llvm::make_error<GenericError>("DIA is not installed on the system");
|
2016-04-26 01:38:08 +08:00
|
|
|
#endif
|
2015-04-18 06:40:36 +08:00
|
|
|
}
|