[lld] r295382 - [pdb] Add the ability to resolve TypeServer PDBs.

Zachary Turner via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 16 15:35:46 PST 2017


Author: zturner
Date: Thu Feb 16 17:35:45 2017
New Revision: 295382

URL: http://llvm.org/viewvc/llvm-project?rev=295382&view=rev
Log:
[pdb] Add the ability to resolve TypeServer PDBs.

Some PDBs or object files can contain references to other PDBs
where the real type information lives.  When this happens,
all type indices in the original PDB are meaningless because
their records are not there.

With this patch we add the ability to pull type info from those
secondary PDBs.

Differential Revision: https://reviews.llvm.org/D29973

Modified:
    lld/trunk/COFF/PDB.cpp

Modified: lld/trunk/COFF/PDB.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/PDB.cpp?rev=295382&r1=295381&r2=295382&view=diff
==============================================================================
--- lld/trunk/COFF/PDB.cpp (original)
+++ lld/trunk/COFF/PDB.cpp Thu Feb 16 17:35:45 2017
@@ -29,12 +29,14 @@
 #include "llvm/DebugInfo/PDB/Native/InfoStreamBuilder.h"
 #include "llvm/DebugInfo/PDB/Native/PDBFile.h"
 #include "llvm/DebugInfo/PDB/Native/PDBFileBuilder.h"
+#include "llvm/DebugInfo/PDB/Native/PDBTypeServerHandler.h"
 #include "llvm/DebugInfo/PDB/Native/StringTableBuilder.h"
 #include "llvm/DebugInfo/PDB/Native/TpiStream.h"
 #include "llvm/DebugInfo/PDB/Native/TpiStreamBuilder.h"
 #include "llvm/Object/COFF.h"
 #include "llvm/Support/Endian.h"
 #include "llvm/Support/FileOutputBuffer.h"
+#include "llvm/Support/Path.h"
 #include "llvm/Support/ScopedPrinter.h"
 #include <memory>
 
@@ -94,9 +96,15 @@ static std::vector<uint8_t> mergeDebugT(
     msf::ByteStream Stream(Data);
     codeview::CVTypeArray Types;
     msf::StreamReader Reader(Stream);
+    // Follow type servers.  If the same type server is encountered more than
+    // once for this instance of `PDBTypeServerHandler` (for example if many
+    // object files reference the same TypeServer), the types from the
+    // TypeServer will only be visited once.
+    pdb::PDBTypeServerHandler Handler;
+    Handler.addSearchPath(llvm::sys::path::parent_path(File->getName()));
     if (auto EC = Reader.readArray(Types, Reader.getLength()))
       fatal(EC, "Reader::readArray failed");
-    if (auto Err = codeview::mergeTypeStreams(Builder, Types))
+    if (auto Err = codeview::mergeTypeStreams(Builder, &Handler, Types))
       fatal(Err, "codeview::mergeTypeStreams failed");
   }
 
@@ -116,6 +124,8 @@ static void dumpDebugT(ScopedPrinter &W,
 
   TypeDatabase TDB;
   TypeDumpVisitor TDV(TDB, &W, false);
+  // Use a default implementation that does not follow type servers and instead
+  // just dumps the contents of the TypeServer2 record.
   CVTypeDumper TypeDumper(TDB);
   if (auto EC = TypeDumper.dump(Data, TDV))
     fatal(EC, "CVTypeDumper::dump failed");




More information about the llvm-commits mailing list