Skip to content

Commit

Permalink
COFF: Add type server pdb files to linkrepro tar file.
Browse files Browse the repository at this point in the history
Differential Revision: https://reviews.llvm.org/D38977

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316233 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
pcc committed Oct 20, 2017
1 parent ccf5909 commit a29687c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion include/llvm/DebugInfo/PDB/Native/NativeSession.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class NativeSession : public IPDBSession {
std::unique_ptr<BumpPtrAllocator> Allocator);
~NativeSession() override;

static Error createFromPdb(StringRef Path,
static Error createFromPdb(std::unique_ptr<MemoryBuffer> MB,
std::unique_ptr<IPDBSession> &Session);
static Error createFromExe(StringRef Path,
std::unique_ptr<IPDBSession> &Session);
Expand Down
10 changes: 2 additions & 8 deletions lib/DebugInfo/PDB/Native/NativeSession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,9 @@ NativeSession::NativeSession(std::unique_ptr<PDBFile> PdbFile,

NativeSession::~NativeSession() = default;

Error NativeSession::createFromPdb(StringRef Path,
Error NativeSession::createFromPdb(std::unique_ptr<MemoryBuffer> Buffer,
std::unique_ptr<IPDBSession> &Session) {
ErrorOr<std::unique_ptr<MemoryBuffer>> ErrorOrBuffer =
MemoryBuffer::getFileOrSTDIN(Path, /*FileSize=*/-1,
/*RequiresNullTerminator=*/false);
if (!ErrorOrBuffer)
return make_error<GenericError>(generic_error_code::invalid_path);

std::unique_ptr<MemoryBuffer> Buffer = std::move(*ErrorOrBuffer);
StringRef Path = Buffer->getBufferIdentifier();
auto Stream = llvm::make_unique<MemoryBufferByteStream>(
std::move(Buffer), llvm::support::little);

Expand Down
11 changes: 9 additions & 2 deletions lib/DebugInfo/PDB/PDB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,15 @@ using namespace llvm::pdb;
Error llvm::pdb::loadDataForPDB(PDB_ReaderType Type, StringRef Path,
std::unique_ptr<IPDBSession> &Session) {
// Create the correct concrete instance type based on the value of Type.
if (Type == PDB_ReaderType::Native)
return NativeSession::createFromPdb(Path, Session);
if (Type == PDB_ReaderType::Native) {
ErrorOr<std::unique_ptr<MemoryBuffer>> ErrorOrBuffer =
MemoryBuffer::getFileOrSTDIN(Path, /*FileSize=*/-1,
/*RequiresNullTerminator=*/false);
if (!ErrorOrBuffer)
return make_error<GenericError>(generic_error_code::invalid_path, Path);

return NativeSession::createFromPdb(std::move(*ErrorOrBuffer), Session);
}

#if LLVM_ENABLE_DIA_SDK
return DIASession::createFromPdb(Path, Session);
Expand Down

0 comments on commit a29687c

Please sign in to comment.