blob: c4dd9820ed0a2fdda48d7b3fd08698481d0dcc66 [file] [log] [blame]
Zachary Turner0e9e6632015-02-06 20:30:52 +00001//===- 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
Zachary Turner52c9f882015-02-14 03:53:56 +000010#include "llvm/DebugInfo/PDB/PDB.h"
11
Zachary Turner0e9e6632015-02-06 20:30:52 +000012#include "llvm/ADT/StringRef.h"
Zachary Turner52c9f882015-02-14 03:53:56 +000013#include "llvm/Config/config.h"
Zachary Turner0e9e6632015-02-06 20:30:52 +000014#include "llvm/DebugInfo/PDB/IPDBSession.h"
Chandler Carruth71f308a2015-02-13 09:09:03 +000015#include "llvm/DebugInfo/PDB/PDB.h"
Zachary Turner52c9f882015-02-14 03:53:56 +000016
Zachary Turnercffff262015-02-10 21:17:52 +000017#if HAVE_DIA_SDK
18#include "llvm/DebugInfo/PDB/DIA/DIASession.h"
19#endif
Zachary Turner0a43efe2016-04-25 17:38:08 +000020#include "llvm/DebugInfo/PDB/Raw/RawSession.h"
Zachary Turner0e9e6632015-02-06 20:30:52 +000021
22using namespace llvm;
23
Zachary Turner4b083542015-04-17 22:40:36 +000024PDB_ErrorCode llvm::loadDataForPDB(PDB_ReaderType Type, StringRef Path,
25 std::unique_ptr<IPDBSession> &Session) {
Zachary Turner0e9e6632015-02-06 20:30:52 +000026 // Create the correct concrete instance type based on the value of Type.
Zachary Turner0a43efe2016-04-25 17:38:08 +000027 if (Type == PDB_ReaderType::Raw)
28 return RawSession::createFromPdb(Path, Session);
29
Zachary Turnercffff262015-02-10 21:17:52 +000030#if HAVE_DIA_SDK
Zachary Turnerccf04152015-02-28 20:23:18 +000031 return DIASession::createFromPdb(Path, Session);
Zachary Turner0a43efe2016-04-25 17:38:08 +000032#else
Daniel Sandersd41718e2016-04-22 12:04:42 +000033 return PDB_ErrorCode::NoDiaSupport;
Zachary Turner0a43efe2016-04-25 17:38:08 +000034#endif
Zachary Turner0e9e6632015-02-06 20:30:52 +000035}
Zachary Turner4b083542015-04-17 22:40:36 +000036
37PDB_ErrorCode llvm::loadDataForEXE(PDB_ReaderType Type, StringRef Path,
38 std::unique_ptr<IPDBSession> &Session) {
Dave Bartolomeoea039c12015-12-17 20:54:16 +000039 // Create the correct concrete instance type based on the value of Type.
Zachary Turner0a43efe2016-04-25 17:38:08 +000040 if (Type == PDB_ReaderType::Raw)
41 return RawSession::createFromExe(Path, Session);
42
Zachary Turner4b083542015-04-17 22:40:36 +000043#if HAVE_DIA_SDK
44 return DIASession::createFromExe(Path, Session);
Zachary Turner0a43efe2016-04-25 17:38:08 +000045#else
Daniel Sandersd41718e2016-04-22 12:04:42 +000046 return PDB_ErrorCode::NoDiaSupport;
Zachary Turner0a43efe2016-04-25 17:38:08 +000047#endif
Zachary Turner4b083542015-04-17 22:40:36 +000048}