[llvm-shlib] Fix the version naming style of libLLVM for Windows (#85710)
[llvm-project.git] / llvm / lib / DebugInfo / PDB / PDB.cpp
blobd106ba8fefc1639ae8ccd79b2c87b390d2d69de4
1 //===- PDB.cpp - base header file for creating a PDB reader ---------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #include "llvm/DebugInfo/PDB/PDB.h"
10 #include "llvm/ADT/StringRef.h"
11 #include "llvm/Config/config.h"
12 #include "llvm/DebugInfo/PDB/GenericError.h"
13 #if LLVM_ENABLE_DIA_SDK
14 #include "llvm/DebugInfo/PDB/DIA/DIASession.h"
15 #endif
16 #include "llvm/DebugInfo/PDB/Native/NativeSession.h"
17 #include "llvm/Support/Error.h"
19 using namespace llvm;
20 using namespace llvm::pdb;
22 Error llvm::pdb::loadDataForPDB(PDB_ReaderType Type, StringRef Path,
23 std::unique_ptr<IPDBSession> &Session) {
24 // Create the correct concrete instance type based on the value of Type.
25 if (Type == PDB_ReaderType::Native)
26 return NativeSession::createFromPdbPath(Path, Session);
28 #if LLVM_ENABLE_DIA_SDK
29 return DIASession::createFromPdb(Path, Session);
30 #else
31 return make_error<PDBError>(pdb_error_code::dia_sdk_not_present);
32 #endif
35 Error llvm::pdb::loadDataForEXE(PDB_ReaderType Type, StringRef Path,
36 std::unique_ptr<IPDBSession> &Session) {
37 // Create the correct concrete instance type based on the value of Type.
38 if (Type == PDB_ReaderType::Native) {
39 Expected<std::string> PdbPath = NativeSession::searchForPdb({Path});
40 if (!PdbPath)
41 return PdbPath.takeError();
42 return NativeSession::createFromPdbPath(PdbPath.get(), Session);
45 #if LLVM_ENABLE_DIA_SDK
46 return DIASession::createFromExe(Path, Session);
47 #else
48 return make_error<PDBError>(pdb_error_code::dia_sdk_not_present);
49 #endif