[lld] r291724 - [CodeView] Finish decoupling TypeDatabase from TypeDumper.

Zachary Turner via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 11 15:24:23 PST 2017


Author: zturner
Date: Wed Jan 11 17:24:22 2017
New Revision: 291724

URL: http://llvm.org/viewvc/llvm-project?rev=291724&view=rev
Log:
[CodeView] Finish decoupling TypeDatabase from TypeDumper.

Previously the type dumper itself was passed around to a lot of different
places and manipulated in ways that were more appropriate on the type
database. For example, the entire TypeDumper was passed into the symbol
dumper, when all the symbol dumper wanted to do was lookup the name of a
TypeIndex so it could print it. That's what the TypeDatabase is for --
mapping type indices to names.

Another example is how if the user runs llvm-pdbdump with the option to
dump symbols but not types, we still have to visit all types so that we
can print minimal information about the type of a symbol, but just without
dumping full symbol records. The way we did this before is by hacking it
up so that we run everything through the type dumper with a null printer,
so that the output goes to /dev/null. But really, we don't need to dump
anything, all we want to do is build the type database. Since
TypeDatabaseVisitor now exists independently of TypeDumper, we can do
this. We just build a custom visitor callback pipeline that includes a
database visitor but not a dumper.

All the hackery around printers etc goes away. After this patch, we could
probably even delete the entire CVTypeDumper class since really all it is
at this point is a thin wrapper that hides the details of how to build a
useful visitation pipeline. It's not a priority though, so CVTypeDumper
remains for now.

After this patch we will be able to easily plug in a different style of
type dumper by only implementing the proper visitation methods to dump
one-line output and then sticking it on the pipeline.

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

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=291724&r1=291723&r2=291724&view=diff
==============================================================================
--- lld/trunk/COFF/PDB.cpp (original)
+++ lld/trunk/COFF/PDB.cpp Wed Jan 11 17:24:22 2017
@@ -16,6 +16,8 @@
 #include "llvm/DebugInfo/CodeView/CVDebugRecord.h"
 #include "llvm/DebugInfo/CodeView/CVTypeDumper.h"
 #include "llvm/DebugInfo/CodeView/SymbolDumper.h"
+#include "llvm/DebugInfo/CodeView/TypeDatabase.h"
+#include "llvm/DebugInfo/CodeView/TypeDumpVisitor.h"
 #include "llvm/DebugInfo/MSF/ByteStream.h"
 #include "llvm/DebugInfo/MSF/MSFBuilder.h"
 #include "llvm/DebugInfo/MSF/MSFCommon.h"
@@ -80,9 +82,10 @@ static void dumpDebugT(ScopedPrinter &W,
   if (Data.empty())
     return;
 
-  msf::ByteStream Stream(Data);
-  CVTypeDumper TypeDumper(&W, false);
-  if (auto EC = TypeDumper.dump(Data))
+  TypeDatabase TDB;
+  TypeDumpVisitor TDV(TDB, &W, false);
+  CVTypeDumper TypeDumper(TDB);
+  if (auto EC = TypeDumper.dump(Data, TDV))
     fatal(EC, "CVTypeDumper::dump failed");
 }
 
@@ -97,8 +100,8 @@ static void dumpDebugS(ScopedPrinter &W,
   if (auto EC = Reader.readArray(Symbols, Reader.getLength()))
     fatal(EC, "StreamReader.readArray<CVSymbolArray> failed");
 
-  CVTypeDumper TypeDumper(&W, false);
-  CVSymbolDumper SymbolDumper(W, TypeDumper, nullptr, false);
+  TypeDatabase TDB;
+  CVSymbolDumper SymbolDumper(W, TDB, nullptr, false);
   if (auto EC = SymbolDumper.dump(Symbols))
     fatal(EC, "CVSymbolDumper::dump failed");
 }




More information about the llvm-commits mailing list