Path: blob/main/contrib/llvm-project/llvm/lib/DebugInfo/PDB/PDB.cpp
35266 views
//===- PDB.cpp - base header file for creating a PDB reader ---------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#include "llvm/DebugInfo/PDB/PDB.h"9#include "llvm/ADT/StringRef.h"10#include "llvm/Config/config.h"11#include "llvm/DebugInfo/PDB/GenericError.h"12#if LLVM_ENABLE_DIA_SDK13#include "llvm/DebugInfo/PDB/DIA/DIASession.h"14#endif15#include "llvm/DebugInfo/PDB/Native/NativeSession.h"16#include "llvm/Support/Error.h"1718using namespace llvm;19using namespace llvm::pdb;2021Error llvm::pdb::loadDataForPDB(PDB_ReaderType Type, StringRef Path,22std::unique_ptr<IPDBSession> &Session) {23// Create the correct concrete instance type based on the value of Type.24if (Type == PDB_ReaderType::Native)25return NativeSession::createFromPdbPath(Path, Session);2627#if LLVM_ENABLE_DIA_SDK28return DIASession::createFromPdb(Path, Session);29#else30return make_error<PDBError>(pdb_error_code::dia_sdk_not_present);31#endif32}3334Error llvm::pdb::loadDataForEXE(PDB_ReaderType Type, StringRef Path,35std::unique_ptr<IPDBSession> &Session) {36// Create the correct concrete instance type based on the value of Type.37if (Type == PDB_ReaderType::Native) {38Expected<std::string> PdbPath = NativeSession::searchForPdb({Path});39if (!PdbPath)40return PdbPath.takeError();41return NativeSession::createFromPdbPath(PdbPath.get(), Session);42}4344#if LLVM_ENABLE_DIA_SDK45return DIASession::createFromExe(Path, Session);46#else47return make_error<PDBError>(pdb_error_code::dia_sdk_not_present);48#endif49}505152