]> granicus.if.org Git - llvm/commitdiff
COFF: Add type server pdb files to linkrepro tar file.
authorPeter Collingbourne <peter@pcc.me.uk>
Fri, 20 Oct 2017 19:48:26 +0000 (19:48 +0000)
committerPeter Collingbourne <peter@pcc.me.uk>
Fri, 20 Oct 2017 19:48:26 +0000 (19:48 +0000)
Differential Revision: https://reviews.llvm.org/D38977

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316233 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/DebugInfo/PDB/Native/NativeSession.h
lib/DebugInfo/PDB/Native/NativeSession.cpp
lib/DebugInfo/PDB/PDB.cpp

index 770673115506b337e8efe249b3ac45726b860ef9..c2344d5648e35ff463c5dcda8ad6445d3fb648fb 100644 (file)
@@ -31,7 +31,7 @@ public:
                 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);
index d7be2d576c2dd7c67913a6f464529eb45d41f4dc..7be4c762b02ec7f95623ff5ff2ce82d3f17252df 100644 (file)
@@ -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);
 
index 501d4f5985b7d30f3a597503460c1199ee8d2049..c1b21c12036214b46485c3103058f80dfa6deeba 100644 (file)
@@ -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);