[llvm-pdbdump] Rewrite dumper using visitor pattern.
authorZachary Turner <zturner@google.com>
Sun, 22 Feb 2015 22:03:38 +0000 (22:03 +0000)
committerZachary Turner <zturner@google.com>
Sun, 22 Feb 2015 22:03:38 +0000 (22:03 +0000)
This increases the flexibility of how to dump different
symbol types -- necessary for context-sensitive formatting of
symbol types -- and also improves the modularity by allowing
the dumping to be implemented in the actual dumper, as opposed
to in the PDB library.

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

82 files changed:
include/llvm/DebugInfo/PDB/PDBExtras.h
include/llvm/DebugInfo/PDB/PDBSymDumper.h [new file with mode: 0644]
include/llvm/DebugInfo/PDB/PDBSymbol.h
include/llvm/DebugInfo/PDB/PDBSymbolAnnotation.h
include/llvm/DebugInfo/PDB/PDBSymbolBlock.h
include/llvm/DebugInfo/PDB/PDBSymbolCompiland.h
include/llvm/DebugInfo/PDB/PDBSymbolCompilandDetails.h
include/llvm/DebugInfo/PDB/PDBSymbolCompilandEnv.h
include/llvm/DebugInfo/PDB/PDBSymbolCustom.h
include/llvm/DebugInfo/PDB/PDBSymbolData.h
include/llvm/DebugInfo/PDB/PDBSymbolExe.h
include/llvm/DebugInfo/PDB/PDBSymbolFunc.h
include/llvm/DebugInfo/PDB/PDBSymbolFuncDebugEnd.h
include/llvm/DebugInfo/PDB/PDBSymbolFuncDebugStart.h
include/llvm/DebugInfo/PDB/PDBSymbolLabel.h
include/llvm/DebugInfo/PDB/PDBSymbolPublicSymbol.h
include/llvm/DebugInfo/PDB/PDBSymbolThunk.h
include/llvm/DebugInfo/PDB/PDBSymbolTypeArray.h
include/llvm/DebugInfo/PDB/PDBSymbolTypeBaseClass.h
include/llvm/DebugInfo/PDB/PDBSymbolTypeBuiltin.h
include/llvm/DebugInfo/PDB/PDBSymbolTypeCustom.h
include/llvm/DebugInfo/PDB/PDBSymbolTypeDimension.h
include/llvm/DebugInfo/PDB/PDBSymbolTypeEnum.h
include/llvm/DebugInfo/PDB/PDBSymbolTypeFriend.h
include/llvm/DebugInfo/PDB/PDBSymbolTypeFunctionArg.h
include/llvm/DebugInfo/PDB/PDBSymbolTypeFunctionSig.h
include/llvm/DebugInfo/PDB/PDBSymbolTypeManaged.h
include/llvm/DebugInfo/PDB/PDBSymbolTypePointer.h
include/llvm/DebugInfo/PDB/PDBSymbolTypeTypedef.h
include/llvm/DebugInfo/PDB/PDBSymbolTypeUDT.h
include/llvm/DebugInfo/PDB/PDBSymbolTypeVTable.h
include/llvm/DebugInfo/PDB/PDBSymbolTypeVTableShape.h
include/llvm/DebugInfo/PDB/PDBSymbolUnknown.h
include/llvm/DebugInfo/PDB/PDBSymbolUsingNamespace.h
include/llvm/DebugInfo/PDB/PDBTypes.h
lib/DebugInfo/PDB/CMakeLists.txt
lib/DebugInfo/PDB/PDBExtras.cpp
lib/DebugInfo/PDB/PDBSymDumper.cpp [new file with mode: 0644]
lib/DebugInfo/PDB/PDBSymbol.cpp
lib/DebugInfo/PDB/PDBSymbolAnnotation.cpp
lib/DebugInfo/PDB/PDBSymbolBlock.cpp
lib/DebugInfo/PDB/PDBSymbolCompiland.cpp
lib/DebugInfo/PDB/PDBSymbolCompilandDetails.cpp
lib/DebugInfo/PDB/PDBSymbolCompilandEnv.cpp
lib/DebugInfo/PDB/PDBSymbolCustom.cpp
lib/DebugInfo/PDB/PDBSymbolData.cpp
lib/DebugInfo/PDB/PDBSymbolExe.cpp
lib/DebugInfo/PDB/PDBSymbolFunc.cpp
lib/DebugInfo/PDB/PDBSymbolFuncDebugEnd.cpp
lib/DebugInfo/PDB/PDBSymbolFuncDebugStart.cpp
lib/DebugInfo/PDB/PDBSymbolLabel.cpp
lib/DebugInfo/PDB/PDBSymbolPublicSymbol.cpp
lib/DebugInfo/PDB/PDBSymbolThunk.cpp
lib/DebugInfo/PDB/PDBSymbolTypeArray.cpp
lib/DebugInfo/PDB/PDBSymbolTypeBaseClass.cpp
lib/DebugInfo/PDB/PDBSymbolTypeBuiltin.cpp
lib/DebugInfo/PDB/PDBSymbolTypeCustom.cpp
lib/DebugInfo/PDB/PDBSymbolTypeDimension.cpp
lib/DebugInfo/PDB/PDBSymbolTypeEnum.cpp
lib/DebugInfo/PDB/PDBSymbolTypeFriend.cpp
lib/DebugInfo/PDB/PDBSymbolTypeFunctionArg.cpp
lib/DebugInfo/PDB/PDBSymbolTypeFunctionSig.cpp
lib/DebugInfo/PDB/PDBSymbolTypeManaged.cpp
lib/DebugInfo/PDB/PDBSymbolTypePointer.cpp
lib/DebugInfo/PDB/PDBSymbolTypeTypedef.cpp
lib/DebugInfo/PDB/PDBSymbolTypeUDT.cpp
lib/DebugInfo/PDB/PDBSymbolTypeVTable.cpp
lib/DebugInfo/PDB/PDBSymbolTypeVTableShape.cpp
lib/DebugInfo/PDB/PDBSymbolUnknown.cpp
lib/DebugInfo/PDB/PDBSymbolUsingNamespace.cpp
test/DebugInfo/PDB/pdbdump-symbol-format.test
tools/llvm-pdbdump/CMakeLists.txt
tools/llvm-pdbdump/CompilandDumper.cpp [new file with mode: 0644]
tools/llvm-pdbdump/CompilandDumper.h [new file with mode: 0644]
tools/llvm-pdbdump/FunctionDumper.cpp [new file with mode: 0644]
tools/llvm-pdbdump/FunctionDumper.h [new file with mode: 0644]
tools/llvm-pdbdump/TypeDumper.cpp [new file with mode: 0644]
tools/llvm-pdbdump/TypeDumper.h [new file with mode: 0644]
tools/llvm-pdbdump/TypedefDumper.cpp [new file with mode: 0644]
tools/llvm-pdbdump/TypedefDumper.h [new file with mode: 0644]
tools/llvm-pdbdump/llvm-pdbdump.cpp
tools/llvm-pdbdump/llvm-pdbdump.h [new file with mode: 0644]

index d6e2fa2c0963fc60472cb7f7769d642f64946ef0..cbbe1716ee08d10448a6730b75046dd8135bcc6d 100644 (file)
 namespace llvm {
 typedef std::unordered_map<PDB_SymType, int> TagStats;
 
-struct stream_indent {
-  stream_indent(int IndentWidth) : Width(IndentWidth) {}
-  int Width;
-};
-raw_ostream &operator<<(raw_ostream &OS, const stream_indent &Indent);
-
 raw_ostream &operator<<(raw_ostream &OS, const PDB_VariantType &Value);
 raw_ostream &operator<<(raw_ostream &OS, const PDB_CallingConv &Conv);
 raw_ostream &operator<<(raw_ostream &OS, const PDB_DataKind &Data);
diff --git a/include/llvm/DebugInfo/PDB/PDBSymDumper.h b/include/llvm/DebugInfo/PDB/PDBSymDumper.h
new file mode 100644 (file)
index 0000000..dee601c
--- /dev/null
@@ -0,0 +1,85 @@
+//===- PDBSymDumper.h - base interface for PDB symbol dumper *- C++ -----*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_DEBUGINFO_PDB_PDBSYMDUMPER_H
+#define LLVM_DEBUGINFO_PDB_PDBSYMDUMPER_H
+
+#include "PDBTypes.h"
+
+namespace llvm {
+
+class raw_ostream;
+
+class PDBSymDumper {
+public:
+  PDBSymDumper(bool ShouldRequireImpl);
+  virtual ~PDBSymDumper();
+
+  virtual void dump(const PDBSymbolAnnotation &Symbol, raw_ostream &OS,
+                    int Indent);
+  virtual void dump(const PDBSymbolBlock &Symbol, raw_ostream &OS, int Indent);
+  virtual void dump(const PDBSymbolCompiland &Symbol, raw_ostream &OS,
+                    int Indent);
+  virtual void dump(const PDBSymbolCompilandDetails &Symbol, raw_ostream &OS,
+                    int Indent);
+  virtual void dump(const PDBSymbolCompilandEnv &Symbol, raw_ostream &OS,
+                    int Indent);
+  virtual void dump(const PDBSymbolCustom &Symbol, raw_ostream &OS, int Indent);
+  virtual void dump(const PDBSymbolData &Symbol, raw_ostream &OS, int Indent);
+  virtual void dump(const PDBSymbolExe &Symbol, raw_ostream &OS, int Indent);
+  virtual void dump(const PDBSymbolFunc &Symbol, raw_ostream &OS, int Indent);
+  virtual void dump(const PDBSymbolFuncDebugEnd &Symbol, raw_ostream &OS,
+                    int Indent);
+  virtual void dump(const PDBSymbolFuncDebugStart &Symbol, raw_ostream &OS,
+                    int Indent);
+  virtual void dump(const PDBSymbolLabel &Symbol, raw_ostream &OS, int Indent);
+  virtual void dump(const PDBSymbolPublicSymbol &Symbol, raw_ostream &OS,
+                    int Indent);
+  virtual void dump(const PDBSymbolThunk &Symbol, raw_ostream &OS, int Indent);
+  virtual void dump(const PDBSymbolTypeArray &Symbol, raw_ostream &OS,
+                    int Indent);
+  virtual void dump(const PDBSymbolTypeBaseClass &Symbol, raw_ostream &OS,
+                    int Indent);
+  virtual void dump(const PDBSymbolTypeBuiltin &Symbol, raw_ostream &OS,
+                    int Indent);
+  virtual void dump(const PDBSymbolTypeCustom &Symbol, raw_ostream &OS,
+                    int Indent);
+  virtual void dump(const PDBSymbolTypeDimension &Symbol, raw_ostream &OS,
+                    int Indent);
+  virtual void dump(const PDBSymbolTypeEnum &Symbol, raw_ostream &OS,
+                    int Indent);
+  virtual void dump(const PDBSymbolTypeFriend &Symbol, raw_ostream &OS,
+                    int Indent);
+  virtual void dump(const PDBSymbolTypeFunctionArg &Symbol, raw_ostream &OS,
+                    int Indent);
+  virtual void dump(const PDBSymbolTypeFunctionSig &Symbol, raw_ostream &OS,
+                    int Indent);
+  virtual void dump(const PDBSymbolTypeManaged &Symbol, raw_ostream &OS,
+                    int Indent);
+  virtual void dump(const PDBSymbolTypePointer &Symbol, raw_ostream &OS,
+                    int Indent);
+  virtual void dump(const PDBSymbolTypeTypedef &Symbol, raw_ostream &OS,
+                    int Indent);
+  virtual void dump(const PDBSymbolTypeUDT &Symbol, raw_ostream &OS,
+                    int Indent);
+  virtual void dump(const PDBSymbolTypeVTable &Symbol, raw_ostream &OS,
+                    int Indent);
+  virtual void dump(const PDBSymbolTypeVTableShape &Symbol, raw_ostream &OS,
+                    int Indent);
+  virtual void dump(const PDBSymbolUnknown &Symbol, raw_ostream &OS,
+                    int Indent);
+  virtual void dump(const PDBSymbolUsingNamespace &Symbol, raw_ostream &OS,
+                    int Indent);
+
+private:
+  bool RequireImpl;
+};
+}
+
+#endif
index 4f1ca5f627d86ce60ee053fac69235c54b8ffc3b..28bff142f3209e4ae8eb5413f1956223d7e3dbca 100644 (file)
@@ -53,7 +53,8 @@ public:
   /// call dump() on the underlying RawSymbol, which allows us to discover
   /// unknown properties, but individual implementations of PDBSymbol may
   /// override the behavior to only dump known fields.
-  virtual void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level, PDB_DumpFlags Flags) const = 0;
+  virtual void dump(raw_ostream &OS, int Indent,
+                    PDBSymDumper &Dumper) const = 0;
   void defaultDump(raw_ostream &OS, int Indent, PDB_DumpLevel Level) const;
 
   PDB_SymType getSymTag() const;
@@ -83,6 +84,8 @@ public:
   const IPDBRawSymbol &getRawSymbol() const { return *RawSymbol; }
   IPDBRawSymbol &getRawSymbol() { return *RawSymbol; }
 
+  const IPDBSession &getSession() const { return Session; }
+
 protected:
   std::unique_ptr<IPDBEnumSymbols> getChildStats(TagStats &Stats) const;
 
index b931b0780d8590c235dca84d47ab937303d646f3..347e30a724169435e5f745e1a62c66150f626051 100644 (file)
@@ -24,7 +24,7 @@ public:
 
   DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::Annotation)
 
-  void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level, PDB_DumpFlags Flags) const override;
+  void dump(raw_ostream &OS, int Indent, PDBSymDumper &Dumper) const override;
 
   FORWARD_SYMBOL_METHOD(getAddressOffset)
   FORWARD_SYMBOL_METHOD(getAddressSection)
index 6462159833bfaaabe2e0c22cd988af6950250772..a0091bea3dc0ebceea2acb8ef831bba62266421f 100644 (file)
@@ -24,7 +24,7 @@ public:
 
   DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::Block)
 
-  void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level, PDB_DumpFlags Flags) const override;
+  void dump(raw_ostream &OS, int Indent, PDBSymDumper &Dumper) const override;
 
   FORWARD_SYMBOL_METHOD(getAddressOffset)
   FORWARD_SYMBOL_METHOD(getAddressSection)
index 0363c8600c37b6c3ec37edd16190841ec52518a2..055e444722397bc63f0b76650d70bffc44f1717a 100644 (file)
@@ -24,7 +24,7 @@ public:
 
   DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::Compiland)
 
-  void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level, PDB_DumpFlags Flags) const override;
+  void dump(raw_ostream &OS, int Indent, PDBSymDumper &Dumper) const override;
 
   FORWARD_SYMBOL_METHOD(isEditAndContinueEnabled)
   FORWARD_SYMBOL_METHOD(getLexicalParentId)
index 83ca9b5bf6437be0dafafb3e6450adb40e448d8d..88368288872295229e1b3bcd725fb52b4e55f16a 100644 (file)
@@ -24,7 +24,7 @@ public:
 
   DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::CompilandDetails)
 
-  void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level, PDB_DumpFlags Flags) const override;
+  void dump(raw_ostream &OS, int Indent, PDBSymDumper &Dumper) const override;
 
   void getFrontEndVersion(VersionInfo &Version) const {
     RawSymbol->getFrontEndVersion(Version);
index 5f621b956a91d9361046039ed73d087937b5b0d5..c3502a0a27da4134c82113ddf489a2c621ce2e3a 100644 (file)
@@ -24,7 +24,7 @@ public:
 
   DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::CompilandEnv)
 
-  void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level, PDB_DumpFlags Flags) const override;
+  void dump(raw_ostream &OS, int Indent, PDBSymDumper &Dumper) const override;
 
   FORWARD_SYMBOL_METHOD(getLexicalParentId)
   FORWARD_SYMBOL_METHOD(getName)
index 741d073b942a1c1e94191dcf79b240d4fe275912..b433dde366f760ea9aef20ab00c200263c661438 100644 (file)
@@ -28,7 +28,7 @@ public:
 
   DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::Custom)
 
-  void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level, PDB_DumpFlags Flags) const override;
+  void dump(raw_ostream &OS, int Indent, PDBSymDumper &Dumper) const override;
 
   void getDataBytes(llvm::SmallVector<uint8_t, 32> &bytes);
   FORWARD_SYMBOL_METHOD(getSymIndexId)
index f6eca3ec61bada9c0fd35fef0bc743c3cfe5ca7e..87dd6ac4c0d883886592874bab22b9a069f7f0a7 100644 (file)
@@ -24,7 +24,7 @@ public:
 
   DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::Data)
 
-  void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level, PDB_DumpFlags Flags) const override;
+  void dump(raw_ostream &OS, int Indent, PDBSymDumper &Dumper) const override;
 
   FORWARD_SYMBOL_METHOD(getAccess)
   FORWARD_SYMBOL_METHOD(getAddressOffset)
index a5327f309b7b0bd14165ec5912957d559fe89521..33046f3e4745a7c1fa33f507a159c7e26f35e952 100644 (file)
@@ -25,7 +25,7 @@ public:
 
   DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::Exe)
 
-  void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level, PDB_DumpFlags Flags) const override;
+  void dump(raw_ostream &OS, int Indent, PDBSymDumper &Dumper) const override;
 
   FORWARD_SYMBOL_METHOD(getAge)
   FORWARD_SYMBOL_METHOD(getGuid)
index 030e57fd51a034cddd562cb1d2fc0c4e61979b66..be40af9cfdb135c5f2b75adcdaa3b7481a80f923 100644 (file)
@@ -22,7 +22,7 @@ public:
   PDBSymbolFunc(const IPDBSession &PDBSession,
                 std::unique_ptr<IPDBRawSymbol> FuncSymbol);
 
-  void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level, PDB_DumpFlags Flags) const override;
+  void dump(raw_ostream &OS, int Indent, PDBSymDumper &Dumper) const override;
 
   std::unique_ptr<PDBSymbolTypeFunctionSig> getSignature() const;
 
index 9e4697ff3cf2b7082b7c5ff0328394df94cc3354..bd49314aef8e122a89721f7ead6787412642d0b3 100644 (file)
@@ -24,7 +24,7 @@ public:
 
   DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::FuncDebugEnd)
 
-  void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level, PDB_DumpFlags Flags) const override;
+  void dump(raw_ostream &OS, int Indent, PDBSymDumper &Dumper) const override;
 
   FORWARD_SYMBOL_METHOD(getAddressOffset)
   FORWARD_SYMBOL_METHOD(getAddressSection)
index 36bc1679d8018e2dc14e50f650c4009e686ba28b..a62eadaa619e0676723c7c9329245c57992af0aa 100644 (file)
@@ -24,7 +24,7 @@ public:
 
   DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::FuncDebugStart)
 
-  void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level, PDB_DumpFlags Flags) const override;
+  void dump(raw_ostream &OS, int Indent, PDBSymDumper &Dumper) const override;
 
   FORWARD_SYMBOL_METHOD(getAddressOffset)
   FORWARD_SYMBOL_METHOD(getAddressSection)
index 21b33b0154531d2e45e92deed8f0992b5fd2b5cd..d006495ef8aa1bde42a7f9fe176f650395f59a8f 100644 (file)
@@ -24,7 +24,7 @@ public:
 
   DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::Label)
 
-  void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level, PDB_DumpFlags Flags) const override;
+  void dump(raw_ostream &OS, int Indent, PDBSymDumper &Dumper) const override;
 
   FORWARD_SYMBOL_METHOD(getAddressOffset)
   FORWARD_SYMBOL_METHOD(getAddressSection)
index 019c3e94927785fa1355fd357ad2dc91daef145c..a8de89de97744cd0a3dcaa3ce688b6097b846f95 100644 (file)
@@ -24,7 +24,7 @@ public:
 
   DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::PublicSymbol)
 
-  void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level, PDB_DumpFlags Flags) const override;
+  void dump(raw_ostream &OS, int Indent, PDBSymDumper &Dumper) const override;
 
   FORWARD_SYMBOL_METHOD(getAddressOffset)
   FORWARD_SYMBOL_METHOD(getAddressSection)
index 2ebd29cccbaee7bc52e7924d6e7afa8e6fc380d1..88588f15ff7db26b850c1cd2ef142dca9ab905c2 100644 (file)
@@ -25,7 +25,7 @@ public:
 
   DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::Thunk)
 
-  void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level, PDB_DumpFlags Flags) const override;
+  void dump(raw_ostream &OS, int Indent, PDBSymDumper &Dumper) const override;
 
   FORWARD_SYMBOL_METHOD(getAccess)
   FORWARD_SYMBOL_METHOD(getAddressOffset)
index d9e86fd510fcc86ccf5ad3278b14cb8590debde5..602d9d5878e3b67104fe217f7e4e439358733085 100644 (file)
@@ -24,7 +24,7 @@ public:
 
   DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::ArrayType)
 
-  void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level, PDB_DumpFlags Flags) const override;
+  void dump(raw_ostream &OS, int Indent, PDBSymDumper &Dumper) const override;
 
   FORWARD_SYMBOL_METHOD(getArrayIndexTypeId)
   FORWARD_SYMBOL_METHOD(isConstType)
index c0763a6f6f4e1e939a6c31ce195abe2d647dbe3e..a3dcc0208905b28037c83d7c9ccd43267391e083 100644 (file)
@@ -24,7 +24,7 @@ public:
 
   DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::BaseClass)
 
-  void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level, PDB_DumpFlags Flags) const override;
+  void dump(raw_ostream &OS, int Indent, PDBSymDumper &Dumper) const override;
 
   FORWARD_SYMBOL_METHOD(getAccess)
   FORWARD_SYMBOL_METHOD(getClassParentId)
index 3c16f133f9b8db52e6be8a760c10eb92e3fbb261..1cede08a0c71c0c51bfa90309033101d41105b60 100644 (file)
@@ -24,7 +24,7 @@ public:
 
   DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::BuiltinType)
 
-  void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level, PDB_DumpFlags Flags) const override;
+  void dump(raw_ostream &OS, int Indent, PDBSymDumper &Dumper) const override;
 
   FORWARD_SYMBOL_METHOD(getBuiltinType)
   FORWARD_SYMBOL_METHOD(isConstType)
index 0e3cff044fba7478a9dfaaa04da17e2ac78f4447..90a043fd410692ca5bf118f68282ae02be0c6ea2 100644 (file)
@@ -24,7 +24,7 @@ public:
 
   DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::CustomType)
 
-  void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level, PDB_DumpFlags Flags) const override;
+  void dump(raw_ostream &OS, int Indent, PDBSymDumper &Dumper) const override;
 
   FORWARD_SYMBOL_METHOD(getOemId)
   FORWARD_SYMBOL_METHOD(getOemSymbolId)
index 78a6ac35420bc57152a1c763e57eea15ef893dca..f8716811401ba091140107411b1339f505ce2a20 100644 (file)
@@ -24,7 +24,7 @@ public:
 
   DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::Dimension)
 
-  void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level, PDB_DumpFlags Flags) const override;
+  void dump(raw_ostream &OS, int Indent, PDBSymDumper &Dumper) const override;
 
   FORWARD_SYMBOL_METHOD(getLowerBoundId)
   FORWARD_SYMBOL_METHOD(getUpperBoundId)
index 3266c826a703245dac9b6f90b83813098fdce189..2cc1bf830e0a69870c7862f5e522733dac21cd81 100644 (file)
@@ -24,7 +24,7 @@ public:
 
   DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::Enum)
 
-  void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level, PDB_DumpFlags Flags) const override;
+  void dump(raw_ostream &OS, int Indent, PDBSymDumper &Dumper) const override;
 
   FORWARD_SYMBOL_METHOD(getBuiltinType)
   FORWARD_SYMBOL_METHOD(getClassParentId)
index e1846decc441f75efa9346ba173aef048c63fe8b..964246f50377937484e492de9c1a44fbe7338669 100644 (file)
@@ -24,7 +24,7 @@ public:
 
   DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::Friend)
 
-  void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level, PDB_DumpFlags Flags) const override;
+  void dump(raw_ostream &OS, int Indent, PDBSymDumper &Dumper) const override;
 
   FORWARD_SYMBOL_METHOD(getClassParentId)
   FORWARD_SYMBOL_METHOD(getName)
index 39504276eaac9fd3e0db08dcc5ba37f44196637b..22f1455c3b3594193b07c6778c9beee756144979 100644 (file)
@@ -24,7 +24,7 @@ public:
 
   DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::FunctionArg)
 
-  void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level, PDB_DumpFlags Flags) const override;
+  void dump(raw_ostream &OS, int Indent, PDBSymDumper &Dumper) const override;
 
   FORWARD_SYMBOL_METHOD(getClassParentId)
   FORWARD_SYMBOL_METHOD(getLexicalParentId)
index 068472c92b46cb718901e06e5d2d996c2d7354c9..b544d6b6a553e07fd3fd4994e3a19a28e9fa2769 100644 (file)
@@ -28,7 +28,7 @@ public:
   std::unique_ptr<IPDBEnumSymbols> getArguments() const;
   std::unique_ptr<PDBSymbol> getClassParent() const;
 
-  void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level, PDB_DumpFlags Flags) const override;
+  void dump(raw_ostream &OS, int Indent, PDBSymDumper &Dumper) const override;
   void dumpArgList(raw_ostream &OS) const;
 
   FORWARD_SYMBOL_METHOD(getCallingConvention)
index 4b6fad6b58709dbf405c05e43a6a858d82e4dbe5..42f58673668935eee5d955439fb39f279f9ecc4b 100644 (file)
@@ -24,7 +24,7 @@ public:
 
   DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::ManagedType)
 
-  void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level, PDB_DumpFlags Flags) const override;
+  void dump(raw_ostream &OS, int Indent, PDBSymDumper &Dumper) const override;
 
   FORWARD_SYMBOL_METHOD(getName)
   FORWARD_SYMBOL_METHOD(getSymIndexId)
index f52c47442b8e1c3846c13a1ae28a1da1d9b47e06..702ea6d8fac32814b18d8f0d93f65d6ab325f3be 100644 (file)
@@ -24,7 +24,7 @@ public:
 
   DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::PointerType)
 
-  void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level, PDB_DumpFlags Flags) const override;
+  void dump(raw_ostream &OS, int Indent, PDBSymDumper &Dumper) const override;
 
   FORWARD_SYMBOL_METHOD(isConstType)
   FORWARD_SYMBOL_METHOD(getLength)
index ddf4f46035c15d9a9b70885c3b8652ea57bb5a36..d3a9ca20f37f094f1fdf5ce9d4191dd2fe7e01b9 100644 (file)
@@ -24,7 +24,7 @@ public:
 
   DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::Typedef)
 
-  void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level, PDB_DumpFlags Flags) const override;
+  void dump(raw_ostream &OS, int Indent, PDBSymDumper &Dumper) const override;
 
   FORWARD_SYMBOL_METHOD(getBuiltinType)
   FORWARD_SYMBOL_METHOD(getClassParentId)
index aea5d92f7956ff9362dd1f95cb302ad45185ef1f..8c826330c149a3c1fa6d0fa7ec87602b997c3766 100644 (file)
@@ -24,7 +24,7 @@ public:
 
   DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::UDT)
 
-  void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level, PDB_DumpFlags Flags) const override;
+  void dump(raw_ostream &OS, int Indent, PDBSymDumper &Dumper) const override;
 
   FORWARD_SYMBOL_METHOD(getClassParentId)
   FORWARD_SYMBOL_METHOD(hasConstructor)
index 5a2a7c3bf7e36f2cc5935a6794c0d5076fbfa529..6b6d99ba122c8f2b1a0e358033c8ad1bf86ab26f 100644 (file)
@@ -24,7 +24,7 @@ public:
 
   DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::VTable)
 
-  void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level, PDB_DumpFlags Flags) const override;
+  void dump(raw_ostream &OS, int Indent, PDBSymDumper &Dumper) const override;
 
   FORWARD_SYMBOL_METHOD(getClassParentId)
   FORWARD_SYMBOL_METHOD(isConstType)
index 4676a35ad5451670e0a654342d31f68302691694..e86610605f5b32900499785484da9e7271adf735 100644 (file)
@@ -24,7 +24,7 @@ public:
 
   DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::VTableShape)
 
-  void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level, PDB_DumpFlags Flags) const override;
+  void dump(raw_ostream &OS, int Indent, PDBSymDumper &Dumper) const override;
 
   FORWARD_SYMBOL_METHOD(isConstType)
   FORWARD_SYMBOL_METHOD(getCount)
index dbcbf07af7420797fa244dfc00b13e8e7b60fa49..7f8c6f927394de3b06e5db82d8b5f22a29cf5e6d 100644 (file)
@@ -21,7 +21,7 @@ public:
   PDBSymbolUnknown(const IPDBSession &PDBSession,
                    std::unique_ptr<IPDBRawSymbol> UnknownSymbol);
 
-  void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level, PDB_DumpFlags Flags) const override;
+  void dump(raw_ostream &OS, int Indent, PDBSymDumper &Dumper) const override;
 
   static bool classof(const PDBSymbol *S) {
     return (S->getSymTag() == PDB_SymType::None ||
index d0d624d147044e9b6a5a6db35a8adb214ddad445..59ec16b76f434e08d5c599edc1215b318019962e 100644 (file)
@@ -24,7 +24,7 @@ public:
 
   DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::UsingNamespace)
 
-  void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level, PDB_DumpFlags Flags) const override;
+  void dump(raw_ostream &OS, int Indent, PDBSymDumper &Dumper) const override;
 
   FORWARD_SYMBOL_METHOD(getLexicalParentId)
   FORWARD_SYMBOL_METHOD(getName)
index 1b44a5f21d81be77be8868140a624d2d153e2e49..c797ccaf34fa903aeaaca2c38c27264e4fa173bb 100644 (file)
 
 namespace llvm {
 
+class PDBSymDumper;
 class PDBSymbol;
-class PDBSymbolCompiland;
-class PDBSymbolFunc;
-class PDBSymbolExe;
 
 class IPDBDataStream;
 template <class T> class IPDBEnumChildren;
index d86c8bdcad8269f11aac50fa2b46fe6654d650f1..ed8c67411d968af9573ca5e410c6e6894e883832 100644 (file)
@@ -66,6 +66,7 @@ add_llvm_library(LLVMDebugInfoPDB
   PDBSymbolTypeVTableShape.cpp
   PDBSymbolUnknown.cpp
   PDBSymbolUsingNamespace.cpp
+  PDBSymDumper.cpp
   ${PDB_IMPL_SOURCES}
 
   ADDITIONAL_HEADER_DIRS
index c9cc9c3aebfef6bbed6921fed008771723626c01..1002b2e2dadec35796e2891b4b11158497ed8574 100644 (file)
@@ -21,11 +21,6 @@ using namespace llvm;
 #define CASE_OUTPUT_ENUM_CLASS_NAME(Class, Value, Stream)                      \
   CASE_OUTPUT_ENUM_CLASS_STR(Class, Value, #Value, Stream)
 
-raw_ostream &llvm::operator<<(raw_ostream &OS, const stream_indent &Indent) {
-  OS.indent(Indent.Width);
-  return OS;
-}
-
 raw_ostream &llvm::operator<<(raw_ostream &OS, const PDB_VariantType &Type) {
   switch (Type) {
     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_VariantType, Bool, OS)
diff --git a/lib/DebugInfo/PDB/PDBSymDumper.cpp b/lib/DebugInfo/PDB/PDBSymDumper.cpp
new file mode 100644 (file)
index 0000000..0f29c74
--- /dev/null
@@ -0,0 +1,177 @@
+//===- PDBSymDumper.cpp - ---------------------------------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/DebugInfo/PDB/PDBSymDumper.h"
+#include "llvm/Support/ErrorHandling.h"
+
+using namespace llvm;
+
+#define PDB_SYMDUMP_UNREACHABLE(Type)                                          \
+  if (RequireImpl)                                                             \
+    llvm_unreachable("Attempt to dump " #Type " with no dump implementation");
+
+PDBSymDumper::PDBSymDumper(bool ShouldRequireImpl)
+    : RequireImpl(ShouldRequireImpl) {}
+
+PDBSymDumper::~PDBSymDumper() {}
+
+void PDBSymDumper::dump(const PDBSymbolAnnotation &Symbol, raw_ostream &OS,
+                        int Indent) {
+  PDB_SYMDUMP_UNREACHABLE(PDBSymbolAnnotation)
+}
+
+void PDBSymDumper::dump(const PDBSymbolBlock &Symbol, raw_ostream &OS,
+                        int Indent) {
+  PDB_SYMDUMP_UNREACHABLE(PDBSymbolBlock)
+}
+
+void PDBSymDumper::dump(const PDBSymbolCompiland &Symbol, raw_ostream &OS,
+                        int Indent) {
+  PDB_SYMDUMP_UNREACHABLE(PDBSymbolCompiland)
+}
+
+void PDBSymDumper::dump(const PDBSymbolCompilandDetails &Symbol,
+                        raw_ostream &OS, int Indent) {
+  PDB_SYMDUMP_UNREACHABLE(PDBSymbolCompilandDetails)
+}
+
+void PDBSymDumper::dump(const PDBSymbolCompilandEnv &Symbol, raw_ostream &OS,
+                        int Indent) {
+  PDB_SYMDUMP_UNREACHABLE(PDBSymbolCompilandEnv)
+}
+
+void PDBSymDumper::dump(const PDBSymbolCustom &Symbol, raw_ostream &OS,
+                        int Indent) {
+  PDB_SYMDUMP_UNREACHABLE(PDBSymbolCustom)
+}
+
+void PDBSymDumper::dump(const PDBSymbolData &Symbol, raw_ostream &OS,
+                        int Indent) {
+  PDB_SYMDUMP_UNREACHABLE(PDBSymbolData)
+}
+
+void PDBSymDumper::dump(const PDBSymbolExe &Symbol, raw_ostream &OS,
+                        int Indent) {
+  PDB_SYMDUMP_UNREACHABLE(PDBSymbolExe)
+}
+
+void PDBSymDumper::dump(const PDBSymbolFunc &Symbol, raw_ostream &OS,
+                        int Indent) {
+  PDB_SYMDUMP_UNREACHABLE(PDBSymbolFunc)
+}
+
+void PDBSymDumper::dump(const PDBSymbolFuncDebugEnd &Symbol, raw_ostream &OS,
+                        int Indent) {
+  PDB_SYMDUMP_UNREACHABLE(PDBSymbolFuncDebugEnd)
+}
+
+void PDBSymDumper::dump(const PDBSymbolFuncDebugStart &Symbol, raw_ostream &OS,
+                        int Indent) {
+  PDB_SYMDUMP_UNREACHABLE(PDBSymbolFuncDebugStart)
+}
+
+void PDBSymDumper::dump(const PDBSymbolLabel &Symbol, raw_ostream &OS,
+                        int Indent) {
+  PDB_SYMDUMP_UNREACHABLE(PDBSymbolLabel)
+}
+
+void PDBSymDumper::dump(const PDBSymbolPublicSymbol &Symbol, raw_ostream &OS,
+                        int Indent) {
+  PDB_SYMDUMP_UNREACHABLE(PDBSymbolPublicSymbol)
+}
+
+void PDBSymDumper::dump(const PDBSymbolThunk &Symbol, raw_ostream &OS,
+                        int Indent) {
+  PDB_SYMDUMP_UNREACHABLE(PDBSymbolThunk)
+}
+
+void PDBSymDumper::dump(const PDBSymbolTypeArray &Symbol, raw_ostream &OS,
+                        int Indent) {
+  PDB_SYMDUMP_UNREACHABLE(PDBSymbolTypeArray)
+}
+
+void PDBSymDumper::dump(const PDBSymbolTypeBaseClass &Symbol, raw_ostream &OS,
+                        int Indent) {
+  PDB_SYMDUMP_UNREACHABLE(PDBSymbolTypeBaseClass)
+}
+
+void PDBSymDumper::dump(const PDBSymbolTypeBuiltin &Symbol, raw_ostream &OS,
+                        int Indent) {
+  PDB_SYMDUMP_UNREACHABLE(PDBSymbolTypeBuiltin)
+}
+
+void PDBSymDumper::dump(const PDBSymbolTypeCustom &Symbol, raw_ostream &OS,
+                        int Indent) {
+  PDB_SYMDUMP_UNREACHABLE(PDBSymbolTypeCustom)
+}
+
+void PDBSymDumper::dump(const PDBSymbolTypeDimension &Symbol, raw_ostream &OS,
+                        int Indent) {
+  PDB_SYMDUMP_UNREACHABLE(PDBSymbolTypeDimension)
+}
+
+void PDBSymDumper::dump(const PDBSymbolTypeEnum &Symbol, raw_ostream &OS,
+                        int Indent) {
+  PDB_SYMDUMP_UNREACHABLE(PDBSymbolTypeEnum)
+}
+
+void PDBSymDumper::dump(const PDBSymbolTypeFriend &Symbol, raw_ostream &OS,
+                        int Indent) {
+  PDB_SYMDUMP_UNREACHABLE(PDBSymbolTypeFriend)
+}
+
+void PDBSymDumper::dump(const PDBSymbolTypeFunctionArg &Symbol, raw_ostream &OS,
+                        int Indent) {
+  PDB_SYMDUMP_UNREACHABLE(PDBSymbolTypeFunctionArg)
+}
+
+void PDBSymDumper::dump(const PDBSymbolTypeFunctionSig &Symbol, raw_ostream &OS,
+                        int Indent) {
+  PDB_SYMDUMP_UNREACHABLE(PDBSymbolTypeFunctionSig)
+}
+
+void PDBSymDumper::dump(const PDBSymbolTypeManaged &Symbol, raw_ostream &OS,
+                        int Indent) {
+  PDB_SYMDUMP_UNREACHABLE(PDBSymbolTypeManaged)
+}
+
+void PDBSymDumper::dump(const PDBSymbolTypePointer &Symbol, raw_ostream &OS,
+                        int Indent) {
+  PDB_SYMDUMP_UNREACHABLE(PDBSymbolTypePointer)
+}
+
+void PDBSymDumper::dump(const PDBSymbolTypeTypedef &Symbol, raw_ostream &OS,
+                        int Indent) {
+  PDB_SYMDUMP_UNREACHABLE(PDBSymbolTypeTypedef)
+}
+
+void PDBSymDumper::dump(const PDBSymbolTypeUDT &Symbol, raw_ostream &OS,
+                        int Indent) {
+  PDB_SYMDUMP_UNREACHABLE(PDBSymbolTypeUDT)
+}
+
+void PDBSymDumper::dump(const PDBSymbolTypeVTable &Symbol, raw_ostream &OS,
+                        int Indent) {
+  PDB_SYMDUMP_UNREACHABLE(PDBSymbolTypeVTable)
+}
+
+void PDBSymDumper::dump(const PDBSymbolTypeVTableShape &Symbol, raw_ostream &OS,
+                        int Indent) {
+  PDB_SYMDUMP_UNREACHABLE(PDBSymbolTypeVTableShape)
+}
+
+void PDBSymDumper::dump(const PDBSymbolUnknown &Symbol, raw_ostream &OS,
+                        int Indent) {
+  PDB_SYMDUMP_UNREACHABLE(PDBSymbolUnknown)
+}
+
+void PDBSymDumper::dump(const PDBSymbolUsingNamespace &Symbol, raw_ostream &OS,
+                        int Indent) {
+  PDB_SYMDUMP_UNREACHABLE(PDBSymbolUsingNamespace)
+}
index 9ab8b936a5dc35c60860e9e2c759250cccdf5fdb..f24e318a941c99c22417c58eb41cebd26ad1380e 100644 (file)
@@ -42,6 +42,7 @@
 #include "llvm/DebugInfo/PDB/PDBSymbolTypeVTableShape.h"
 #include "llvm/DebugInfo/PDB/PDBSymbolUnknown.h"
 #include "llvm/DebugInfo/PDB/PDBSymbolUsingNamespace.h"
+#include "llvm/DebugInfo/PDB/PDBSymDumper.h"
 #include <memory>
 #include <utility>
 
@@ -100,6 +101,12 @@ PDBSymbol::create(const IPDBSession &PDBSession,
   }
 }
 
+#define TRY_DUMP_TYPE(Type)                                                    \
+  if (const Type *DerivedThis = dyn_cast<Type>(this))                          \
+    Dumper.dump(OS, Indent, *DerivedThis);
+
+#define ELSE_TRY_DUMP_TYPE(Type, Dumper) else TRY_DUMP_TYPE(Type, Dumper)
+
 void PDBSymbol::defaultDump(raw_ostream &OS, int Indent,
                             PDB_DumpLevel Level) const {
   RawSymbol->dump(OS, Indent, Level);
index c965d1d9d6b02ab1d795080afdbc5e2021d3d958..4c76e3bc24f2e20c4cbeedbfb4d639aa18d2b275 100644 (file)
@@ -9,7 +9,7 @@
 
 #include "llvm/DebugInfo/PDB/PDBSymbolAnnotation.h"
 
-#include "llvm/DebugInfo/PDB/PDBSymbol.h"
+#include "llvm/DebugInfo/PDB/PDBSymDumper.h"
 
 #include <utility>
 
@@ -20,4 +20,6 @@ PDBSymbolAnnotation::PDBSymbolAnnotation(const IPDBSession &PDBSession,
     : PDBSymbol(PDBSession, std::move(Symbol)) {}
 
 void PDBSymbolAnnotation::dump(raw_ostream &OS, int Indent,
-                               PDB_DumpLevel Level, PDB_DumpFlags Flags) const {}
+                               PDBSymDumper &Dumper) const {
+  Dumper.dump(*this, OS, Indent);
+}
index 2e350ad2fe91fb8a6a6f27f2b35478f6b5c17647..bb159d5036deeef20969236a68449645374c62ce 100644 (file)
@@ -10,6 +10,7 @@
 #include "llvm/DebugInfo/PDB/PDBSymbolBlock.h"
 
 #include "llvm/DebugInfo/PDB/PDBSymbol.h"
+#include "llvm/DebugInfo/PDB/PDBSymDumper.h"
 
 #include <utility>
 
@@ -20,4 +21,6 @@ PDBSymbolBlock::PDBSymbolBlock(const IPDBSession &PDBSession,
     : PDBSymbol(PDBSession, std::move(Symbol)) {}
 
 void PDBSymbolBlock::dump(raw_ostream &OS, int Indent,
-                          PDB_DumpLevel Level, PDB_DumpFlags Flags) const {}
+                          PDBSymDumper &Dumper) const {
+  Dumper.dump(*this, OS, Indent);
+}
index f014b3959b0a3de63454ca38732c5dcbf5d725fc..0c9b1909e8d8cc5feec7cfcd0092ab8090fc78b7 100644 (file)
@@ -9,18 +9,9 @@
 
 #include "llvm/DebugInfo/PDB/PDBSymbolCompiland.h"
 
-#include "llvm/DebugInfo/PDB/IPDBEnumChildren.h"
-#include "llvm/DebugInfo/PDB/IPDBSession.h"
-#include "llvm/DebugInfo/PDB/IPDBSourceFile.h"
-#include "llvm/DebugInfo/PDB/PDBExtras.h"
-#include "llvm/DebugInfo/PDB/PDBSymbol.h"
-#include "llvm/DebugInfo/PDB/PDBSymbolCompilandDetails.h"
-#include "llvm/DebugInfo/PDB/PDBSymbolCompilandEnv.h"
-#include "llvm/Support/Path.h"
-#include "llvm/Support/raw_ostream.h"
+#include "llvm/DebugInfo/PDB/PDBSymDumper.h"
 
 #include <utility>
-#include <vector>
 
 using namespace llvm;
 
@@ -28,45 +19,7 @@ PDBSymbolCompiland::PDBSymbolCompiland(const IPDBSession &PDBSession,
                                        std::unique_ptr<IPDBRawSymbol> Symbol)
     : PDBSymbol(PDBSession, std::move(Symbol)) {}
 
-#define SKIP_SYMBOL_IF_FLAG_UNSET(Tag, Flag) \
-  case PDB_SymType::Tag: \
-    if ((Flags & Flag) == 0) \
-      continue;   \
-    break;
-
 void PDBSymbolCompiland::dump(raw_ostream &OS, int Indent,
-                              PDB_DumpLevel Level, PDB_DumpFlags Flags) const {
-  if (Level == PDB_DumpLevel::Detailed) {
-    std::string FullName = getName();
-    OS << stream_indent(Indent) << FullName;
-    if (Flags & PDB_DF_Children) {
-      if (Level >= PDB_DumpLevel::Detailed) {
-        auto ChildrenEnum = findAllChildren();
-        while (auto Child = ChildrenEnum->getNext()) {
-          switch (Child->getSymTag()) {
-            SKIP_SYMBOL_IF_FLAG_UNSET(Function, PDB_DF_Functions)
-            SKIP_SYMBOL_IF_FLAG_UNSET(Data, PDB_DF_Data)
-            SKIP_SYMBOL_IF_FLAG_UNSET(Label, PDB_DF_Labels)
-            SKIP_SYMBOL_IF_FLAG_UNSET(PublicSymbol, PDB_DF_PublicSyms)
-            SKIP_SYMBOL_IF_FLAG_UNSET(UDT, PDB_DF_Classes)
-            SKIP_SYMBOL_IF_FLAG_UNSET(Enum, PDB_DF_Enums)
-            SKIP_SYMBOL_IF_FLAG_UNSET(FunctionSig, PDB_DF_Funcsigs)
-            SKIP_SYMBOL_IF_FLAG_UNSET(VTable, PDB_DF_VTables)
-            SKIP_SYMBOL_IF_FLAG_UNSET(Thunk, PDB_DF_Thunks)
-            SKIP_SYMBOL_IF_FLAG_UNSET(Compiland, PDB_DF_ObjFiles)
-            default:
-              continue;
-          }
-          PDB_DumpLevel ChildLevel = (Level == PDB_DumpLevel::Detailed)
-                                         ? PDB_DumpLevel::Normal
-                                         : PDB_DumpLevel::Compact;
-          OS << "\n";
-          Child->dump(OS, Indent + 2, ChildLevel, PDB_DF_Children);
-        }
-      }
-    }
-  } else {
-    std::string FullName = getName();
-    OS << stream_indent(Indent) << "Compiland: " << FullName;
-  }
+                              PDBSymDumper &Dumper) const {
+  Dumper.dump(*this, OS, Indent);
 }
index 9194376eee05da50de99f9afe7890a81dc074a30..208d68faa6e974b4bb943f0cb44187a612b60a74 100644 (file)
@@ -10,6 +10,7 @@
 #include "llvm/DebugInfo/PDB/PDBSymbolCompilandDetails.h"
 
 #include "llvm/DebugInfo/PDB/PDBSymbol.h"
+#include "llvm/DebugInfo/PDB/PDBSymDumper.h"
 
 #include <utility>
 
@@ -20,4 +21,6 @@ PDBSymbolCompilandDetails::PDBSymbolCompilandDetails(
     : PDBSymbol(PDBSession, std::move(Symbol)) {}
 
 void PDBSymbolCompilandDetails::dump(raw_ostream &OS, int Indent,
-                                     PDB_DumpLevel Level, PDB_DumpFlags Flags) const {}
+                                     PDBSymDumper &Dumper) const {
+  Dumper.dump(*this, OS, Indent);
+}
index b44dc578ea4edff7107c7a4a695c4595bbbc50c4..c54b8fb349218c97c34f5c6af34bf153775be9d8 100644 (file)
@@ -11,6 +11,7 @@
 
 #include "llvm/DebugInfo/PDB/IPDBRawSymbol.h"
 #include "llvm/DebugInfo/PDB/PDBSymbol.h"
+#include "llvm/DebugInfo/PDB/PDBSymDumper.h"
 
 #include <utility>
 
@@ -26,4 +27,6 @@ std::string PDBSymbolCompilandEnv::getValue() const {
 }
 
 void PDBSymbolCompilandEnv::dump(raw_ostream &OS, int Indent,
-                                 PDB_DumpLevel Level, PDB_DumpFlags Flags) const {}
+                                 PDBSymDumper &Dumper) const {
+  Dumper.dump(*this, OS, Indent);
+}
index 68f2b45194cc35e02d1c4979b76c239fcac8c2a9..1b6b50b6dd0a9d181ad1e449d94580eba610b280 100644 (file)
@@ -11,6 +11,7 @@
 
 #include "llvm/DebugInfo/PDB/IPDBRawSymbol.h"
 #include "llvm/DebugInfo/PDB/PDBSymbol.h"
+#include "llvm/DebugInfo/PDB/PDBSymDumper.h"
 
 #include <utility>
 
@@ -25,4 +26,6 @@ void PDBSymbolCustom::getDataBytes(llvm::SmallVector<uint8_t, 32> &bytes) {
 }
 
 void PDBSymbolCustom::dump(raw_ostream &OS, int Indent,
-                           PDB_DumpLevel Level, PDB_DumpFlags Flags) const {}
\ No newline at end of file
+                           PDBSymDumper &Dumper) const {
+  Dumper.dump(*this, OS, Indent);
+}
\ No newline at end of file
index 9a04ecd1f438be150cc3a6526df22046cbcfcd0f..09b96bc6c9bfa4c3a9c4eb499fcfcca30d6c17d0 100644 (file)
@@ -9,11 +9,7 @@
 
 #include "llvm/DebugInfo/PDB/PDBSymbolData.h"
 
-#include "llvm/DebugInfo/PDB/IPDBSession.h"
-#include "llvm/DebugInfo/PDB/PDBExtras.h"
-#include "llvm/DebugInfo/PDB/PDBSymbolTypeUDT.h"
-#include "llvm/Support/Format.h"
-#include <utility>
+#include "llvm/DebugInfo/PDB/PDBSymDumper.h"
 
 #include <utility>
 
@@ -24,68 +20,6 @@ PDBSymbolData::PDBSymbolData(const IPDBSession &PDBSession,
     : PDBSymbol(PDBSession, std::move(DataSymbol)) {}
 
 void PDBSymbolData::dump(raw_ostream &OS, int Indent,
-                         PDB_DumpLevel Level, PDB_DumpFlags Flags) const {
-  OS << stream_indent(Indent);
-  PDB_LocType Loc = getLocationType();
-  PDB_DataKind Kind = getDataKind();
-  switch (Loc) {
-  case PDB_LocType::Static: {
-    uint32_t RVA = getRelativeVirtualAddress();
-    OS << Kind << " data[";
-    if (RVA != 0)
-      OS << format_hex(RVA, 10);
-    else
-      OS << "???";
-    break;
-  }
-  case PDB_LocType::TLS:
-    OS << "threadlocal " << Kind << " data[";
-    OS << getAddressSection() << ":" << format_hex(getAddressOffset(), 10);
-    break;
-  case PDB_LocType::RegRel:
-    OS << "regrel " << Kind << " data[";
-    OS << getRegisterId() << " + " << getOffset();
-    break;
-  case PDB_LocType::ThisRel: {
-    uint32_t Offset = getOffset();
-    OS << Kind << " data[this + " << format_hex(Offset, 4);
-    break;
-  }
-  case PDB_LocType::Enregistered:
-    OS << "register " << Kind << " data[" << getRegisterId();
-    break;
-  case PDB_LocType::BitField: {
-    OS << "bitfield data[this + ";
-    uint32_t Offset = getOffset();
-    uint32_t BitPos = getBitPosition();
-    uint32_t Length = getLength();
-    OS << format_hex(Offset, 4) << ":" << BitPos << "," << Length;
-    break;
-  }
-  case PDB_LocType::Slot:
-    OS << getSlot();
-    break;
-  case PDB_LocType::Constant: {
-    OS << "constant data[";
-    OS << getValue();
-    break;
-  }
-  case PDB_LocType::IlRel:
-  case PDB_LocType::MetaData:
-  default:
-    OS << "???";
-  }
-
-  OS << "] ";
-  if (Kind == PDB_DataKind::Member || Kind == PDB_DataKind::StaticMember) {
-    uint32_t ClassId = getClassParentId();
-    if (auto Class = Session.getSymbolById(ClassId)) {
-      if (auto UDT = dyn_cast<PDBSymbolTypeUDT>(Class.get()))
-        OS << UDT->getName();
-      else
-        OS << "{class " << Class->getSymTag() << "}";
-      OS << "::";
-    }
-  }
-  OS << getName();
+                         PDBSymDumper &Dumper) const {
+  Dumper.dump(*this, OS, Indent);
 }
\ No newline at end of file
index efd28bca4696322d0256eeda399ed186bfd29bd0..ef09193485901f1973d7f9ca781c99c80d3e1e03 100644 (file)
 
 #include "llvm/DebugInfo/PDB/PDBSymbolExe.h"
 
-#include "llvm/DebugInfo/PDB/IPDBEnumChildren.h"
-#include "llvm/DebugInfo/PDB/PDBExtras.h"
-#include "llvm/DebugInfo/PDB/PDBSymbol.h"
-#include "llvm/Support/ConvertUTF.h"
-#include "llvm/Support/FileSystem.h"
-#include "llvm/Support/raw_ostream.h"
-#include <utility>
+#include "llvm/DebugInfo/PDB/PDBSymDumper.h"
 
 #include <utility>
 
 using namespace llvm;
 
-#define SKIP_SYMBOL_IF_FLAG_UNSET(Tag, Flag)                                   \
-  case PDB_SymType::Tag:                                                       \
-    if ((Flags & Flag) == 0)                                                   \
-      continue;                                                                \
-    break;
-
 PDBSymbolExe::PDBSymbolExe(const IPDBSession &PDBSession,
                            std::unique_ptr<IPDBRawSymbol> Symbol)
     : PDBSymbol(PDBSession, std::move(Symbol)) {}
 
 void PDBSymbolExe::dump(raw_ostream &OS, int Indent,
-                        PDB_DumpLevel Level, PDB_DumpFlags Flags) const {
-  std::string FileName(getSymbolsFileName());
-
-  OS << stream_indent(Indent) << "Summary for " << FileName << "\n";
-
-  uint64_t FileSize = 0;
-  if (!llvm::sys::fs::file_size(FileName, FileSize))
-    OS << stream_indent(Indent + 2) << "Size: " << FileSize << " bytes\n";
-  else
-    OS << stream_indent(Indent + 2) << "Size: (Unable to obtain file size)\n";
-  PDB_UniqueId Guid = getGuid();
-  OS << stream_indent(Indent + 2) << "Guid: " << Guid << "\n";
-  OS << stream_indent(Indent + 2) << "Age: " << getAge() << "\n";
-  OS << stream_indent(Indent + 2) << "Attributes: ";
-  if (hasCTypes())
-    OS << "HasCTypes ";
-  if (hasPrivateSymbols())
-    OS << "HasPrivateSymbols ";
-  OS << "\n";
-
-  if (Flags & PDB_DF_Children) {
-    OS << stream_indent(Indent + 2) << "Dumping types\n";
-    if (Flags & PDB_DF_Hidden) {
-      // For some reason, for each SymTag T, this dumps more items of type T
-      // than are dumped by calling dumpChildren(T).  In other words, there are
-      // "hidden" symbols.  For example, it causes functions to be dumped which
-      // have no address information, whereas specifically dumping only
-      // functions will not find those symbols.
-      //
-      // My suspicion is that in the underlying DIA call, when you call
-      // findChildren, passing a value of SymTagNone means all children
-      // recursively, whereas passing a concrete tag value means only immediate
-      // children of the global scope.  So perhaps we need to find these
-      // mysterious missing values by recursing through the hierarchy.
-      //
-      // On the other hand, there may just be some symbols that DIA tries to
-      // hide from you because it thinks you don't care about them.  However
-      // experimentation shows that even vtables, for example, can't be found
-      // without an exhaustive search.
-      auto ChildrenEnum = findAllChildren();
-      OS << stream_indent(Indent + 2) << ChildrenEnum->getChildCount()
-         << " symbols";
-
-      while (auto Child = ChildrenEnum->getNext()) {
-        switch (Child->getSymTag()) {
-          SKIP_SYMBOL_IF_FLAG_UNSET(Function, PDB_DF_Functions)
-          SKIP_SYMBOL_IF_FLAG_UNSET(Data, PDB_DF_Data)
-          SKIP_SYMBOL_IF_FLAG_UNSET(Label, PDB_DF_Labels)
-          SKIP_SYMBOL_IF_FLAG_UNSET(PublicSymbol, PDB_DF_PublicSyms)
-          SKIP_SYMBOL_IF_FLAG_UNSET(UDT, PDB_DF_Classes)
-          SKIP_SYMBOL_IF_FLAG_UNSET(Enum, PDB_DF_Enums)
-          SKIP_SYMBOL_IF_FLAG_UNSET(FunctionSig, PDB_DF_Funcsigs)
-          SKIP_SYMBOL_IF_FLAG_UNSET(VTable, PDB_DF_VTables)
-          SKIP_SYMBOL_IF_FLAG_UNSET(Thunk, PDB_DF_Thunks)
-          SKIP_SYMBOL_IF_FLAG_UNSET(Compiland, PDB_DF_ObjFiles)
-        default:
-          continue;
-        }
-        PDB_DumpLevel ChildLevel = (Level == PDB_DumpLevel::Detailed)
-                                       ? PDB_DumpLevel::Normal
-                                       : PDB_DumpLevel::Compact;
-        OS << "\n";
-        Child->dump(OS, Indent + 4, ChildLevel, PDB_DF_Children);
-      }
-    } else {
-      if (Flags & PDB_DF_ObjFiles)
-        dumpChildren(OS, "Compilands", PDB_SymType::Compiland, Indent + 4);
-      if (Flags & PDB_DF_Functions)
-        dumpChildren(OS, "Functions", PDB_SymType::Function, Indent + 4);
-      if (Flags & PDB_DF_Data)
-        dumpChildren(OS, "Data", PDB_SymType::Data, Indent + 4);
-      if (Flags & PDB_DF_Labels)
-        dumpChildren(OS, "Labels", PDB_SymType::Label, Indent + 4);
-      if (Flags & PDB_DF_PublicSyms)
-        dumpChildren(OS, "Public Symbols", PDB_SymType::PublicSymbol,
-                     Indent + 4);
-      if (Flags & PDB_DF_Classes)
-        dumpChildren(OS, "UDTs", PDB_SymType::UDT, Indent + 4);
-      if (Flags & PDB_DF_Enums)
-        dumpChildren(OS, "Enums", PDB_SymType::Enum, Indent + 4);
-      if (Flags & PDB_DF_Funcsigs)
-        dumpChildren(OS, "Function Signatures", PDB_SymType::FunctionSig,
-                     Indent + 4);
-      if (Flags & PDB_DF_Typedefs)
-        dumpChildren(OS, "Typedefs", PDB_SymType::Typedef, Indent + 4);
-      if (Flags & PDB_DF_VTables)
-        dumpChildren(OS, "VTables", PDB_SymType::VTable, Indent + 4);
-      if (Flags & PDB_DF_Thunks)
-        dumpChildren(OS, "Thunks", PDB_SymType::Thunk, Indent + 4);
-    }
-  }
-}
-
-void PDBSymbolExe::dumpChildren(raw_ostream &OS, StringRef Label,
-                                PDB_SymType ChildType, int Indent) const {
-  auto ChildrenEnum = findAllChildren(ChildType);
-  OS << stream_indent(Indent) << Label << ": (" << ChildrenEnum->getChildCount()
-     << " items)\n";
-  while (auto Child = ChildrenEnum->getNext()) {
-    Child->dump(OS, Indent + 2, PDB_DumpLevel::Normal, PDB_DF_None);
-    OS << "\n";
-  }
+                        PDBSymDumper &Dumper) const {
+  Dumper.dump(*this, OS, Indent);
 }
index cd01423c9b7f4333d70bf3ee9f28119992a4141c..4702d6dac2103fdf0f52290aefa277a489a43cbe 100644 (file)
@@ -9,14 +9,10 @@
 
 #include "llvm/DebugInfo/PDB/PDBSymbolFunc.h"
 
-#include "llvm/DebugInfo/PDB/IPDBEnumChildren.h"
 #include "llvm/DebugInfo/PDB/IPDBSession.h"
-#include "llvm/DebugInfo/PDB/PDBSymbol.h"
-#include "llvm/DebugInfo/PDB/PDBSymbolFuncDebugEnd.h"
-#include "llvm/DebugInfo/PDB/PDBSymbolFuncDebugStart.h"
 #include "llvm/DebugInfo/PDB/PDBSymbolTypeFunctionSig.h"
-#include "llvm/DebugInfo/PDB/PDBSymbolTypeUDT.h"
-#include "llvm/Support/Format.h"
+#include "llvm/DebugInfo/PDB/PDBSymDumper.h"
+
 #include <utility>
 
 using namespace llvm;
@@ -29,58 +25,6 @@ std::unique_ptr<PDBSymbolTypeFunctionSig> PDBSymbolFunc::getSignature() const {
 }
 
 void PDBSymbolFunc::dump(raw_ostream &OS, int Indent,
-                         PDB_DumpLevel Level, PDB_DumpFlags Flags) const {
-  uint32_t FuncStart = getRelativeVirtualAddress();
-  uint32_t FuncEnd = FuncStart + getLength();
-  OS << stream_indent(Indent);
-  if (FuncStart == 0 && FuncEnd == 0) {
-    OS << "func [???] ";
-  } else {
-    OS << "func ";
-    OS << "[" << format_hex(FuncStart, 8);
-    if (auto DebugStart = findOneChild<PDBSymbolFuncDebugStart>())
-      OS << "+" << DebugStart->getRelativeVirtualAddress() - FuncStart;
-    OS << " - " << format_hex(FuncEnd, 8);
-    if (auto DebugEnd = findOneChild<PDBSymbolFuncDebugEnd>())
-      OS << "-" << FuncEnd - DebugEnd->getRelativeVirtualAddress();
-    OS << "] ";
-  }
-
-  PDB_RegisterId Reg = getLocalBasePointerRegisterId();
-  if (Reg == PDB_RegisterId::VFrame)
-    OS << "(VFrame)";
-  else if (hasFramePointer())
-    OS << "(" << Reg << ")";
-  else
-    OS << "(FPO)";
-
-  OS << " ";
-  if (isVirtual() || isPureVirtual())
-    OS << "virtual ";
-
-  if (auto FuncSig = getSignature()) {
-    // If we have a signature, dump the name with the signature.
-    if (auto ReturnType = FuncSig->getReturnType()) {
-      ReturnType->dump(OS, 0, PDB_DumpLevel::Compact, PDB_DF_Children);
-      OS << " ";
-    }
-
-    OS << FuncSig->getCallingConvention() << " ";
-
-    OS << getName();
-    FuncSig->dumpArgList(OS);
-    if (isPureVirtual())
-      OS << " = 0";
-  } else {
-    uint32_t ClassId = getClassParentId();
-    if (ClassId != 0) {
-      if (auto Class = Session.getSymbolById(ClassId)) {
-        if (auto UDT = dyn_cast<PDBSymbolTypeUDT>(Class.get()))
-          OS << UDT->getName() << "::";
-        else
-          OS << "{class " << Class->getSymTag() << "}::";
-      }
-    }
-    OS << getName();
-  }
+                         PDBSymDumper &Dumper) const {
+  Dumper.dump(*this, OS, Indent);
 }
index 8658be951fa20effec7a88a186435932427f4fa1..c20748808c571405f4b1282e136dd08fe9ee05c8 100644 (file)
@@ -10,6 +10,7 @@
 #include "llvm/DebugInfo/PDB/PDBSymbolFuncDebugEnd.h"
 
 #include "llvm/DebugInfo/PDB/PDBSymbol.h"
+#include "llvm/DebugInfo/PDB/PDBSymDumper.h"
 
 #include <utility>
 
@@ -20,4 +21,6 @@ PDBSymbolFuncDebugEnd::PDBSymbolFuncDebugEnd(
     : PDBSymbol(PDBSession, std::move(Symbol)) {}
 
 void PDBSymbolFuncDebugEnd::dump(raw_ostream &OS, int Indent,
-                                 PDB_DumpLevel Level, PDB_DumpFlags Flags) const {}
+                                 PDBSymDumper &Dumper) const {
+  Dumper.dump(*this, OS, Indent);
+}
index 64cd3e36705aabbcffdbccad58de2fa961172ecd..83df22e2cf1aea76af72315a33c3a7b2638fb3bf 100644 (file)
@@ -10,6 +10,7 @@
 #include "llvm/DebugInfo/PDB/PDBSymbolFuncDebugStart.h"
 
 #include "llvm/DebugInfo/PDB/PDBSymbol.h"
+#include "llvm/DebugInfo/PDB/PDBSymDumper.h"
 
 #include <utility>
 
@@ -20,4 +21,6 @@ PDBSymbolFuncDebugStart::PDBSymbolFuncDebugStart(
     : PDBSymbol(PDBSession, std::move(Symbol)) {}
 
 void PDBSymbolFuncDebugStart::dump(raw_ostream &OS, int Indent,
-                                   PDB_DumpLevel Level, PDB_DumpFlags Flags) const {}
+                                   PDBSymDumper &Dumper) const {
+  Dumper.dump(*this, OS, Indent);
+}
index abb516330deadd54257c479d1e196bd9f27eeb9d..ce569e2f50b2919832cfabcf39834f2c7a6321fc 100644 (file)
@@ -9,8 +9,7 @@
 
 #include "llvm/DebugInfo/PDB/PDBSymbolLabel.h"
 
-#include "llvm/DebugInfo/PDB/PDBSymbol.h"
-#include "llvm/Support/Format.h"
+#include "llvm/DebugInfo/PDB/PDBSymDumper.h"
 
 #include <utility>
 
@@ -21,8 +20,6 @@ PDBSymbolLabel::PDBSymbolLabel(const IPDBSession &PDBSession,
     : PDBSymbol(PDBSession, std::move(Symbol)) {}
 
 void PDBSymbolLabel::dump(raw_ostream &OS, int Indent,
-                          PDB_DumpLevel Level, PDB_DumpFlags Flags) const {
-  OS << stream_indent(Indent);
-  OS << "label [" << format_hex(getRelativeVirtualAddress(), 10) << "] "
-     << getName();
+                          PDBSymDumper &Dumper) const {
+  Dumper.dump(*this, OS, Indent);
 }
index a2cea8be82c343a342d578386af5b4b8a1128f3c..a7f156cc49cf14bf5b4ad6db6a2dce265ab4b67c 100644 (file)
@@ -10,6 +10,7 @@
 #include "llvm/DebugInfo/PDB/PDBSymbolPublicSymbol.h"
 
 #include "llvm/DebugInfo/PDB/PDBSymbol.h"
+#include "llvm/DebugInfo/PDB/PDBSymDumper.h"
 
 #include <utility>
 
@@ -20,7 +21,6 @@ PDBSymbolPublicSymbol::PDBSymbolPublicSymbol(
     : PDBSymbol(PDBSession, std::move(Symbol)) {}
 
 void PDBSymbolPublicSymbol::dump(raw_ostream &OS, int Indent,
-                                 PDB_DumpLevel Level, PDB_DumpFlags Flags) const {
-  OS << stream_indent(Indent);
-  OS << "public symbol: " << getName();
+                                 PDBSymDumper &Dumper) const {
+  Dumper.dump(*this, OS, Indent);
 }
index c62c96b6ae49b84baf1662f523bf48451e2ac895..edade834b71c91afd8005380dba028957c1e0ab6 100644 (file)
@@ -9,8 +9,7 @@
 
 #include "llvm/DebugInfo/PDB/PDBSymbolThunk.h"
 
-#include "llvm/DebugInfo/PDB/PDBSymbol.h"
-#include "llvm/Support/Format.h"
+#include "llvm/DebugInfo/PDB/PDBSymDumper.h"
 
 #include <utility>
 
@@ -21,22 +20,6 @@ PDBSymbolThunk::PDBSymbolThunk(const IPDBSession &PDBSession,
     : PDBSymbol(PDBSession, std::move(Symbol)) {}
 
 void PDBSymbolThunk::dump(raw_ostream &OS, int Indent,
-                          PDB_DumpLevel Level, PDB_DumpFlags Flags) const {
-  OS.indent(Indent);
-  OS << "thunk ";
-  PDB_ThunkOrdinal Ordinal = getThunkOrdinal();
-  uint32_t RVA = getRelativeVirtualAddress();
-  if (Ordinal == PDB_ThunkOrdinal::TrampIncremental) {
-    OS << format_hex(RVA, 10);
-  } else {
-    OS << "[" << format_hex(RVA, 10);
-    OS << " - " << format_hex(RVA + getLength(), 10) << "]";
-  }
-  OS << " (" << Ordinal << ")";
-  if (Ordinal == PDB_ThunkOrdinal::TrampIncremental)
-    OS << " -> " << format_hex(getTargetRelativeVirtualAddress(), 10);
-  OS << " ";
-  std::string Name = getName();
-  if (!Name.empty())
-    OS << Name;
+                          PDBSymDumper &Dumper) const {
+  Dumper.dump(*this, OS, Indent);
 }
index b418e3343f6c89fa8c80dcf4a5c909e96d210555..1759bd8ead5fb00d0a9fbaf3b52808dab6ed0cca 100644 (file)
@@ -9,8 +9,7 @@
 
 #include "llvm/DebugInfo/PDB/PDBSymbolTypeArray.h"
 
-#include "llvm/DebugInfo/PDB/IPDBSession.h"
-#include "llvm/DebugInfo/PDB/PDBSymbol.h"
+#include "llvm/DebugInfo/PDB/PDBSymDumper.h"
 
 #include <utility>
 
@@ -21,11 +20,6 @@ PDBSymbolTypeArray::PDBSymbolTypeArray(const IPDBSession &PDBSession,
     : PDBSymbol(PDBSession, std::move(Symbol)) {}
 
 void PDBSymbolTypeArray::dump(raw_ostream &OS, int Indent,
-                              PDB_DumpLevel Level, PDB_DumpFlags Flags) const {
-  OS << stream_indent(Indent);
-  if (auto ElementType = Session.getSymbolById(getTypeId()))
-    ElementType->dump(OS, 0, PDB_DumpLevel::Compact, PDB_DF_Children);
-  else
-    OS << "<unknown-element-type>";
-  OS << "[" << getLength() << "]";
+                              PDBSymDumper &Dumper) const {
+  Dumper.dump(*this, OS, Indent);
 }
index 532e8b8178f30c9bda7be12c1f50280f41c28517..c44cc527fec2258173ed0efebde9b91c8f4adbe8 100644 (file)
@@ -10,6 +10,7 @@
 #include "llvm/DebugInfo/PDB/PDBSymbolTypeBaseClass.h"
 
 #include "llvm/DebugInfo/PDB/PDBSymbol.h"
+#include "llvm/DebugInfo/PDB/PDBSymDumper.h"
 
 #include <utility>
 
@@ -20,7 +21,6 @@ PDBSymbolTypeBaseClass::PDBSymbolTypeBaseClass(
     : PDBSymbol(PDBSession, std::move(Symbol)) {}
 
 void PDBSymbolTypeBaseClass::dump(raw_ostream &OS, int Indent,
-                                  PDB_DumpLevel Level, PDB_DumpFlags Flags) const {
-  OS << stream_indent(Indent);
-  OS << "<base class> " << getName();
+                                  PDBSymDumper &Dumper) const {
+  Dumper.dump(*this, OS, Indent);
 }
index b7afdcddeb0d595ebaa5c33b9f5dd023c6ae91d5..f0c94c707de73cccc64d08fbca6cf98a05abf291 100644 (file)
@@ -9,7 +9,7 @@
 
 #include "llvm/DebugInfo/PDB/PDBSymbolTypeBuiltin.h"
 
-#include "llvm/DebugInfo/PDB/PDBSymbol.h"
+#include "llvm/DebugInfo/PDB/PDBSymDumper.h"
 
 #include <utility>
 
@@ -20,10 +20,6 @@ PDBSymbolTypeBuiltin::PDBSymbolTypeBuiltin(
     : PDBSymbol(PDBSession, std::move(Symbol)) {}
 
 void PDBSymbolTypeBuiltin::dump(raw_ostream &OS, int Indent,
-                                PDB_DumpLevel Level, PDB_DumpFlags Flags) const {
-  OS << stream_indent(Indent);
-  PDB_BuiltinType Type = getBuiltinType();
-  OS << Type;
-  if (Type == PDB_BuiltinType::UInt || Type == PDB_BuiltinType::Int)
-    OS << (8 * getLength()) << "_t";
+                                PDBSymDumper &Dumper) const {
+  Dumper.dump(*this, OS, Indent);
 }
index 0bfa8eb4e7413f761fac6dd8af73796d48fa7282..0fa8f45bfc9340fc716ba31823dd9fd3e1c9a925 100644 (file)
@@ -10,6 +10,7 @@
 #include "llvm/DebugInfo/PDB/PDBSymbolTypeCustom.h"
 
 #include "llvm/DebugInfo/PDB/PDBSymbol.h"
+#include "llvm/DebugInfo/PDB/PDBSymDumper.h"
 
 #include <utility>
 
@@ -20,4 +21,6 @@ PDBSymbolTypeCustom::PDBSymbolTypeCustom(const IPDBSession &PDBSession,
     : PDBSymbol(PDBSession, std::move(Symbol)) {}
 
 void PDBSymbolTypeCustom::dump(raw_ostream &OS, int Indent,
-                               PDB_DumpLevel Level, PDB_DumpFlags Flags) const {}
+                               PDBSymDumper &Dumper) const {
+  Dumper.dump(*this, OS, Indent);
+}
index 84f48ea4310b10a0718f166a1a729e432a3b3fb2..47fb08d6e99f2447d48a4610b62af4373cf89e3c 100644 (file)
@@ -11,6 +11,7 @@
 #include "llvm/DebugInfo/PDB/PDBSymbolTypeDimension.h"
 
 #include "llvm/DebugInfo/PDB/PDBSymbol.h"
+#include "llvm/DebugInfo/PDB/PDBSymDumper.h"
 
 #include <utility>
 
@@ -21,4 +22,6 @@ PDBSymbolTypeDimension::PDBSymbolTypeDimension(
     : PDBSymbol(PDBSession, std::move(Symbol)) {}
 
 void PDBSymbolTypeDimension::dump(raw_ostream &OS, int Indent,
-                                  PDB_DumpLevel Level, PDB_DumpFlags Flags) const {}
+                                  PDBSymDumper &Dumper) const {
+  Dumper.dump(*this, OS, Indent);
+}
index 512b602244f5f59ee43c7ec8b0658db91ec15755..121d41e522d646f05ce3700caf06bccc543040c1 100644 (file)
@@ -9,8 +9,7 @@
 
 #include "llvm/DebugInfo/PDB/PDBSymbolTypeEnum.h"
 
-#include "llvm/DebugInfo/PDB/IPDBSession.h"
-#include "llvm/DebugInfo/PDB/PDBSymbol.h"
+#include "llvm/DebugInfo/PDB/PDBSymDumper.h"
 
 #include <utility>
 
@@ -21,17 +20,6 @@ PDBSymbolTypeEnum::PDBSymbolTypeEnum(const IPDBSession &PDBSession,
     : PDBSymbol(PDBSession, std::move(Symbol)) {}
 
 void PDBSymbolTypeEnum::dump(raw_ostream &OS, int Indent,
-                             PDB_DumpLevel Level, PDB_DumpFlags Flags) const {
-  OS << stream_indent(Indent);
-  if (Level >= PDB_DumpLevel::Normal)
-    OS << "enum ";
-
-  uint32_t ClassId = getClassParentId();
-  if (ClassId != 0) {
-    if (auto ClassParent = Session.getSymbolById(ClassId)) {
-      ClassParent->dump(OS, 0, Level, PDB_DF_Children);
-      OS << "::";
-    }
-  }
-  OS << getName();
+                             PDBSymDumper &Dumper) const {
+  Dumper.dump(*this, OS, Indent);
 }
index 236304eb478b964f3e16b00f8188059b0aa6eb19..b2bf72e0f3df99015c1c4106e2153a100f71580b 100644 (file)
@@ -10,6 +10,7 @@
 #include "llvm/DebugInfo/PDB/PDBSymbolTypeFriend.h"
 
 #include "llvm/DebugInfo/PDB/PDBSymbol.h"
+#include "llvm/DebugInfo/PDB/PDBSymDumper.h"
 
 #include <utility>
 
@@ -20,4 +21,6 @@ PDBSymbolTypeFriend::PDBSymbolTypeFriend(const IPDBSession &PDBSession,
     : PDBSymbol(PDBSession, std::move(Symbol)) {}
 
 void PDBSymbolTypeFriend::dump(raw_ostream &OS, int Indent,
-                               PDB_DumpLevel Level, PDB_DumpFlags Flags) const {}
+                               PDBSymDumper &Dumper) const {
+  Dumper.dump(*this, OS, Indent);
+}
index 4b8cc26d9f74e43ed3583235f9e0ddd7a44105fb..f394c04ad69d43aee9930cafea02b0f395f7aa62 100644 (file)
@@ -9,8 +9,7 @@
 
 #include "llvm/DebugInfo/PDB/PDBSymbolTypeFunctionArg.h"
 
-#include "llvm/DebugInfo/PDB/IPDBSession.h"
-#include "llvm/DebugInfo/PDB/PDBSymbol.h"
+#include "llvm/DebugInfo/PDB/PDBSymDumper.h"
 
 #include <utility>
 
@@ -21,10 +20,6 @@ PDBSymbolTypeFunctionArg::PDBSymbolTypeFunctionArg(
     : PDBSymbol(PDBSession, std::move(Symbol)) {}
 
 void PDBSymbolTypeFunctionArg::dump(raw_ostream &OS, int Indent,
-                                    PDB_DumpLevel Level, PDB_DumpFlags Flags) const {
-  OS << stream_indent(Indent);
-  uint32_t TypeId = getTypeId();
-  if (auto Type = Session.getSymbolById(TypeId)) {
-    Type->dump(OS, 0, Level, PDB_DF_Children);
-  }
+                                    PDBSymDumper &Dumper) const {
+  Dumper.dump(*this, OS, Indent);
 }
index 13b89b235ddc996b820053be70451b58093c49f9..1ba397b50c5b9fa857712e14f4c0b143611bb9af 100644 (file)
@@ -14,6 +14,7 @@
 #include "llvm/DebugInfo/PDB/IPDBSession.h"
 #include "llvm/DebugInfo/PDB/PDBSymbol.h"
 #include "llvm/DebugInfo/PDB/PDBSymbolTypeFunctionArg.h"
+#include "llvm/DebugInfo/PDB/PDBSymDumper.h"
 
 #include <utility>
 
@@ -82,38 +83,7 @@ std::unique_ptr<PDBSymbol> PDBSymbolTypeFunctionSig::getClassParent() const {
   return Session.getSymbolById(ClassId);
 }
 
-void PDBSymbolTypeFunctionSig::dumpArgList(raw_ostream &OS) const {
-  OS << "(";
-  if (auto ChildEnum = getArguments()) {
-    uint32_t Index = 0;
-    while (auto Arg = ChildEnum->getNext()) {
-      Arg->dump(OS, 0, PDB_DumpLevel::Compact, PDB_DF_Children);
-      if (++Index < ChildEnum->getChildCount())
-        OS << ", ";
-    }
-  }
-  OS << ")";
-  if (isConstType())
-    OS << " const";
-  if (isVolatileType())
-    OS << " volatile";
-}
-
 void PDBSymbolTypeFunctionSig::dump(raw_ostream &OS, int Indent,
-                                    PDB_DumpLevel Level, PDB_DumpFlags Flags) const {
-  OS << stream_indent(Indent);
-
-  if (auto ReturnType = getReturnType()) {
-    ReturnType->dump(OS, 0, PDB_DumpLevel::Compact, PDB_DF_Children);
-    OS << " ";
-  }
-
-  OS << getCallingConvention() << " ";
-  if (auto ClassParent = getClassParent()) {
-    OS << "(";
-    ClassParent->dump(OS, 0, PDB_DumpLevel::Compact, PDB_DF_Children);
-    OS << "::*)";
-  }
-
-  dumpArgList(OS);
+                                    PDBSymDumper &Dumper) const {
+  Dumper.dump(*this, OS, Indent);
 }
index 32602dc022b0c981b7271ab9eb990bbac1a89158..e04fb666cd87fd1ac5524a99cda5d2d04d2f96b1 100644 (file)
@@ -10,6 +10,7 @@
 #include "llvm/DebugInfo/PDB/PDBSymbolTypeManaged.h"
 
 #include "llvm/DebugInfo/PDB/PDBSymbol.h"
+#include "llvm/DebugInfo/PDB/PDBSymDumper.h"
 
 #include <utility>
 
@@ -20,4 +21,6 @@ PDBSymbolTypeManaged::PDBSymbolTypeManaged(
     : PDBSymbol(PDBSession, std::move(Symbol)) {}
 
 void PDBSymbolTypeManaged::dump(raw_ostream &OS, int Indent,
-                                PDB_DumpLevel Level, PDB_DumpFlags Flags) const {}
+                                PDBSymDumper &Dumper) const {
+  Dumper.dump(*this, OS, Indent);
+}
index 3461928993adce9667fa4dbc00c936f1c25644cd..cac23f737e528062fab94238232b190840a2ed51 100644 (file)
@@ -9,9 +9,7 @@
 
 #include "llvm/DebugInfo/PDB/PDBSymbolTypePointer.h"
 
-#include "llvm/DebugInfo/PDB/IPDBSession.h"
-#include "llvm/DebugInfo/PDB/PDBSymbol.h"
-#include "llvm/DebugInfo/PDB/PDBSymbolTypeFunctionSig.h"
+#include "llvm/DebugInfo/PDB/PDBSymDumper.h"
 
 #include <utility>
 
@@ -22,25 +20,6 @@ PDBSymbolTypePointer::PDBSymbolTypePointer(
     : PDBSymbol(PDBSession, std::move(Symbol)) {}
 
 void PDBSymbolTypePointer::dump(raw_ostream &OS, int Indent,
-                                PDB_DumpLevel Level, PDB_DumpFlags Flags) const {
-  OS << stream_indent(Indent);
-  if (isConstType())
-    OS << "const ";
-  if (isVolatileType())
-    OS << "volatile ";
-  uint32_t PointeeId = getTypeId();
-  if (auto PointeeType = Session.getSymbolById(PointeeId)) {
-    // Function pointers get special treatment, since we need to print the * in
-    // the middle of the signature.
-    if (auto FuncSig = dyn_cast<PDBSymbolTypeFunctionSig>(PointeeType.get())) {
-      if (auto ReturnType = FuncSig->getReturnType())
-        ReturnType->dump(OS, 0, PDB_DumpLevel::Compact, PDB_DF_Children);
-      OS << " (" << FuncSig->getCallingConvention() << " ";
-      OS << ((isReference()) ? "&" : "*") << ")";
-      FuncSig->dumpArgList(OS);
-    } else {
-      PointeeType->dump(OS, 0, PDB_DumpLevel::Compact, PDB_DF_Children);
-      OS << ((isReference()) ? "&" : "*");
-    }
-  }
+                                PDBSymDumper &Dumper) const {
+  Dumper.dump(*this, OS, Indent);
 }
index 9554d7082227e17068f190e283e706ca1ef11c00..12e3ead92f189aa22ec83733f0c978e8ae06761d 100644 (file)
@@ -9,9 +9,7 @@
 
 #include "llvm/DebugInfo/PDB/PDBSymbolTypeTypedef.h"
 
-#include "llvm/DebugInfo/PDB/IPDBSession.h"
-#include "llvm/DebugInfo/PDB/PDBSymbol.h"
-#include "llvm/DebugInfo/PDB/PDBSymbolTypeUDT.h"
+#include "llvm/DebugInfo/PDB/PDBSymDumper.h"
 
 #include <utility>
 
@@ -22,18 +20,6 @@ PDBSymbolTypeTypedef::PDBSymbolTypeTypedef(
     : PDBSymbol(PDBSession, std::move(Symbol)) {}
 
 void PDBSymbolTypeTypedef::dump(raw_ostream &OS, int Indent,
-                                PDB_DumpLevel Level, PDB_DumpFlags Flags) const {
-  OS.indent(Indent);
-  if (Level >= PDB_DumpLevel::Normal) {
-    std::string Name = getName();
-    OS << "typedef:" << Name << " -> ";
-    std::string TargetTypeName;
-    uint32_t TargetId = getTypeId();
-    if (auto TypeSymbol = Session.getSymbolById(TargetId)) {
-      TypeSymbol->dump(OS, 0, PDB_DumpLevel::Compact, PDB_DF_Children);
-    }
-    OS << TargetTypeName;
-  } else {
-    OS << getName();
-  }
+                                PDBSymDumper &Dumper) const {
+  Dumper.dump(*this, OS, Indent);
 }
index ea884bdac516f1d567efee211ef7bfba87688f17..8a7236874694b83234a0590986086b4bb2774d38 100644 (file)
@@ -9,8 +9,7 @@
 
 #include "llvm/DebugInfo/PDB/PDBSymbolTypeUDT.h"
 
-#include "llvm/DebugInfo/PDB/IPDBSession.h"
-#include "llvm/DebugInfo/PDB/PDBSymbol.h"
+#include "llvm/DebugInfo/PDB/PDBSymDumper.h"
 
 #include <utility>
 
@@ -21,22 +20,6 @@ PDBSymbolTypeUDT::PDBSymbolTypeUDT(const IPDBSession &PDBSession,
     : PDBSymbol(PDBSession, std::move(Symbol)) {}
 
 void PDBSymbolTypeUDT::dump(raw_ostream &OS, int Indent,
-                            PDB_DumpLevel Level, PDB_DumpFlags Flags) const {
-  OS << stream_indent(Indent);
-  if (Level >= PDB_DumpLevel::Normal)
-    OS << "class ";
-
-  if (isNested()) {
-    uint32_t ClassId = getClassParentId();
-    if (ClassId != 0) {
-      if (auto ClassParent = Session.getSymbolById(ClassId)) {
-        ClassParent->dump(OS, 0, Level, PDB_DF_Children);
-        OS << "::";
-      }
-    }
-  }
-  OS << getName();
-
-  if (Level >= PDB_DumpLevel::Normal)
-    OS << " (" << getLength() << " bytes)";
+                            PDBSymDumper &Dumper) const {
+  Dumper.dump(*this, OS, Indent);
 }
index 4c1f05ea0d3489b57cfcc5c35a79f4316dd71c80..a100526839ace0c90863cabcce6625443849bbd0 100644 (file)
@@ -9,10 +9,7 @@
 
 #include "llvm/DebugInfo/PDB/PDBSymbolTypeVTable.h"
 
-#include "llvm/DebugInfo/PDB/IPDBSession.h"
-#include "llvm/DebugInfo/PDB/PDBSymbol.h"
-#include "llvm/DebugInfo/PDB/PDBSymbolTypePointer.h"
-#include "llvm/DebugInfo/PDB/PDBSymbolTypeVTableShape.h"
+#include "llvm/DebugInfo/PDB/PDBSymDumper.h"
 
 #include <utility>
 
@@ -23,19 +20,6 @@ PDBSymbolTypeVTable::PDBSymbolTypeVTable(const IPDBSession &PDBSession,
     : PDBSymbol(PDBSession, std::move(Symbol)) {}
 
 void PDBSymbolTypeVTable::dump(raw_ostream &OS, int Indent,
-                               PDB_DumpLevel Level, PDB_DumpFlags Flags) const {
-  OS << stream_indent(Indent);
-  uint32_t ClassId = getClassParentId();
-  if (auto ClassParent = Session.getSymbolById(ClassId)) {
-    ClassParent->dump(OS, 0, PDB_DumpLevel::Compact, PDB_DF_Children);
-    OS << "::";
-  }
-  OS << "<vtbl> ";
-  if (auto VtblPointer =
-          Session.getConcreteSymbolById<PDBSymbolTypePointer>(getTypeId())) {
-    if (auto VtblShape =
-            Session.getConcreteSymbolById<PDBSymbolTypeVTableShape>(
-                VtblPointer->getTypeId()))
-      OS << "(" << VtblShape->getCount() << " entries)";
-  }
+                               PDBSymDumper &Dumper) const {
+  Dumper.dump(*this, OS, Indent);
 }
index cff0d03c4cf4cfa0532c109087758c1547da2cc7..6aaa668e384f439f01d05eb72d5a2780d94298b1 100644 (file)
@@ -10,6 +10,7 @@
 #include "llvm/DebugInfo/PDB/PDBSymbolTypeVTableShape.h"
 
 #include "llvm/DebugInfo/PDB/PDBSymbol.h"
+#include "llvm/DebugInfo/PDB/PDBSymDumper.h"
 
 #include <utility>
 
@@ -20,4 +21,6 @@ PDBSymbolTypeVTableShape::PDBSymbolTypeVTableShape(
     : PDBSymbol(PDBSession, std::move(Symbol)) {}
 
 void PDBSymbolTypeVTableShape::dump(raw_ostream &OS, int Indent,
-                                    PDB_DumpLevel Level, PDB_DumpFlags Flags) const {}
+                                    PDBSymDumper &Dumper) const {
+  Dumper.dump(*this, OS, Indent);
+}
index b7b4c38f24d664904d43da905649709ca6a0ae79..9cfb88a738ea47ee61a2b4179e77917e21863007 100644 (file)
@@ -10,6 +10,7 @@
 #include "llvm/DebugInfo/PDB/PDBSymbolUnknown.h"
 
 #include "llvm/DebugInfo/PDB/PDBSymbol.h"
+#include "llvm/DebugInfo/PDB/PDBSymDumper.h"
 
 #include <utility>
 
@@ -20,4 +21,6 @@ PDBSymbolUnknown::PDBSymbolUnknown(const IPDBSession &PDBSession,
     : PDBSymbol(PDBSession, std::move(Symbol)) {}
 
 void PDBSymbolUnknown::dump(raw_ostream &OS, int Indent,
-                            PDB_DumpLevel Level, PDB_DumpFlags Flags) const {}
+                            PDBSymDumper &Dumper) const {
+  Dumper.dump(*this, OS, Indent);
+}
index 077d2b3a3ae0637cf7658324a2c18c406d84b073..9176dfb1449d35afedbd8afd50d11698ced10053 100644 (file)
@@ -10,6 +10,7 @@
 #include "llvm/DebugInfo/PDB/PDBSymbolUsingNamespace.h"
 
 #include "llvm/DebugInfo/PDB/PDBSymbol.h"
+#include "llvm/DebugInfo/PDB/PDBSymDumper.h"
 
 #include <utility>
 
@@ -20,4 +21,6 @@ PDBSymbolUsingNamespace::PDBSymbolUsingNamespace(
     : PDBSymbol(PDBSession, std::move(Symbol)) {}
 
 void PDBSymbolUsingNamespace::dump(raw_ostream &OS, int Indent,
-                                   PDB_DumpLevel Level, PDB_DumpFlags Flags) const {}
+                                   PDBSymDumper &Dumper) const {
+  Dumper.dump(*this, OS, Indent);
+}
index 243fcc43d5dc27272f02fa2e2527c66132c0a62d..9d50ae226db91abf43da28527da51f4476137920 100644 (file)
@@ -3,7 +3,7 @@
 
 ; The format is func [0x<rva_start>+<prologue_length> - 0x<rva_end>-<epilogue_length>]
 ; SYM_FORMAT: symbolformat-fpo.obj
-; SYM_FORMAT-DAG: func [0x001130+0 - 0x001137-1] (VFrame) uint32_t __cdecl fpo_func(uint32_t)
+; SYM_FORMAT-DAG: func [0x001130+0 - 0x001137-1] (FPO) uint32_t __cdecl fpo_func(uint32_t)
 ; SYM_FORMAT: symbolformat.obj
 ; SYM_FORMAT-DAG: func [0x001060+3 - 0x001067-2] (EBP) int32_t __cdecl _purecall()
 ; SYM_FORMAT-DAG: func [0x001070+6 - 0x001099-4] (EBP) int32_t __cdecl main(int32_t, char**)
 ; TYPES_FORMAT: Function Signatures
 ; TYPES_FORMAT-DAG: int32_t __cdecl ()
 ; TYPES_FORMAT-DAG: int32_t __cdecl (int32_t, char**)
-; TYPES_FORMAT-DAG: void __thiscall (A::*)()
-; TYPES_FORMAT-DAG: void __thiscall (B::*)()
-; TYPES_FORMAT-DAG: void __thiscall (B::*)(B&)
-; TYPES_FORMAT-DAG: void __thiscall (B::*)()
-; TYPES_FORMAT-DAG: B& __thiscall (B::*)(B&)
-; TYPES_FORMAT-DAG: void __thiscall (A::*)(A&)
-; TYPES_FORMAT-DAG: void __thiscall (A::*)()
-; TYPES_FORMAT-DAG: A& __thiscall (A::*)(A&)
+; TYPES_FORMAT-DAG: void __thiscall (A::)()
+; TYPES_FORMAT-DAG: void __thiscall (B::)()
+; TYPES_FORMAT-DAG: void __thiscall (B::)(B&)
+; TYPES_FORMAT-DAG: void __thiscall (B::)()
+; TYPES_FORMAT-DAG: B& __thiscall (B::)(B&)
+; TYPES_FORMAT-DAG: void __thiscall (A::)(A&)
+; TYPES_FORMAT-DAG: void __thiscall (A::)()
+; TYPES_FORMAT-DAG: A& __thiscall (A::)(A&)
index a3bb408097cc5f9d0780f9bb5e763be7fa9aa5c8..64b3d620837268c6fba32bee69db990b831bb938 100644 (file)
@@ -5,4 +5,8 @@ set(LLVM_LINK_COMPONENTS
 
 add_llvm_tool(llvm-pdbdump
   llvm-pdbdump.cpp
+  CompilandDumper.cpp
+  FunctionDumper.cpp
+  TypeDumper.cpp
+  TypedefDumper.cpp
   )
diff --git a/tools/llvm-pdbdump/CompilandDumper.cpp b/tools/llvm-pdbdump/CompilandDumper.cpp
new file mode 100644 (file)
index 0000000..ee55228
--- /dev/null
@@ -0,0 +1,132 @@
+//===- CompilandDumper.cpp - llvm-pdbdump compiland symbol dumper *- C++ *-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "CompilandDumper.h"
+#include "llvm-pdbdump.h"
+
+#include "llvm/DebugInfo/PDB/IPDBEnumChildren.h"
+#include "llvm/DebugInfo/PDB/IPDBSession.h"
+#include "llvm/DebugInfo/PDB/PDBExtras.h"
+#include "llvm/DebugInfo/PDB/PDBSymbol.h"
+#include "llvm/DebugInfo/PDB/PDBSymbolCompiland.h"
+#include "llvm/DebugInfo/PDB/PDBSymbolData.h"
+#include "llvm/DebugInfo/PDB/PDBSymbolFunc.h"
+#include "llvm/DebugInfo/PDB/PDBSymbolFuncDebugEnd.h"
+#include "llvm/DebugInfo/PDB/PDBSymbolFuncDebugStart.h"
+#include "llvm/DebugInfo/PDB/PDBSymbolLabel.h"
+#include "llvm/DebugInfo/PDB/PDBSymbolThunk.h"
+#include "llvm/DebugInfo/PDB/PDBSymbolTypeFunctionSig.h"
+#include "llvm/DebugInfo/PDB/PDBSymbolUnknown.h"
+#include "llvm/Support/Format.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/raw_ostream.h"
+
+#include "FunctionDumper.h"
+
+#include <utility>
+#include <vector>
+
+using namespace llvm;
+
+CompilandDumper::CompilandDumper() : PDBSymDumper(true) {}
+
+void CompilandDumper::dump(const PDBSymbolCompilandDetails &Symbol,
+                           raw_ostream &OS, int Indent) {}
+
+void CompilandDumper::dump(const PDBSymbolCompilandEnv &Symbol, raw_ostream &OS,
+                           int Indent) {}
+
+void CompilandDumper::start(const PDBSymbolCompiland &Symbol, raw_ostream &OS,
+                            int Indent, bool Children) {
+  std::string FullName = Symbol.getName();
+  OS << newline(Indent) << FullName;
+  if (!Children)
+    return;
+
+  auto ChildrenEnum = Symbol.findAllChildren();
+  while (auto Child = ChildrenEnum->getNext())
+    Child->dump(OS, Indent + 2, *this);
+}
+
+void CompilandDumper::dump(const PDBSymbolData &Symbol, raw_ostream &OS,
+                           int Indent) {
+  OS << newline(Indent);
+  switch (auto LocType = Symbol.getLocationType()) {
+  case PDB_LocType::Static:
+    OS << "data: [";
+    OS << format_hex(Symbol.getRelativeVirtualAddress(), 10);
+    OS << "]";
+    break;
+  case PDB_LocType::Constant:
+    OS << "constant: [" << Symbol.getValue() << "]";
+    break;
+  default:
+    OS << "data(unexpected type=" << LocType << ")";
+  }
+
+  OS << " " << Symbol.getName();
+}
+
+void CompilandDumper::dump(const PDBSymbolFunc &Symbol, raw_ostream &OS,
+                           int Indent) {
+  uint32_t FuncStart = Symbol.getRelativeVirtualAddress();
+  uint32_t FuncEnd = FuncStart + Symbol.getLength();
+  OS << newline(Indent) << "func [" << format_hex(FuncStart, 8);
+  if (auto DebugStart = Symbol.findOneChild<PDBSymbolFuncDebugStart>())
+    OS << "+" << DebugStart->getRelativeVirtualAddress() - FuncStart;
+  OS << " - " << format_hex(FuncEnd, 8);
+  if (auto DebugEnd = Symbol.findOneChild<PDBSymbolFuncDebugEnd>())
+    OS << "-" << FuncEnd - DebugEnd->getRelativeVirtualAddress();
+  OS << "] ";
+
+  if (Symbol.hasFramePointer())
+    OS << "(" << Symbol.getLocalBasePointerRegisterId() << ")";
+  else
+    OS << "(FPO)";
+
+  OS << " ";
+
+  FunctionDumper Dumper;
+  Dumper.start(Symbol, OS);
+  OS.flush();
+}
+
+void CompilandDumper::dump(const PDBSymbolLabel &Symbol, raw_ostream &OS,
+                           int Indent) {
+  OS << newline(Indent);
+  OS << "label [" << format_hex(Symbol.getRelativeVirtualAddress(), 10) << "] "
+     << Symbol.getName();
+}
+
+void CompilandDumper::dump(const PDBSymbolThunk &Symbol, raw_ostream &OS,
+                           int Indent) {
+  OS << newline(Indent) << "thunk ";
+  PDB_ThunkOrdinal Ordinal = Symbol.getThunkOrdinal();
+  uint32_t RVA = Symbol.getRelativeVirtualAddress();
+  if (Ordinal == PDB_ThunkOrdinal::TrampIncremental) {
+    OS << format_hex(RVA, 10);
+    OS << " -> " << format_hex(Symbol.getTargetRelativeVirtualAddress(), 10);
+  } else {
+    OS << "[" << format_hex(RVA, 10);
+    OS << " - " << format_hex(RVA + Symbol.getLength(), 10) << "]";
+  }
+  OS << " (" << Ordinal << ") ";
+  std::string Name = Symbol.getName();
+  if (!Name.empty())
+    OS << Name;
+}
+
+void CompilandDumper::dump(const PDBSymbolTypeTypedef &Symbol, raw_ostream &OS,
+                           int Indent) {}
+
+void CompilandDumper::dump(const PDBSymbolUnknown &Symbol, raw_ostream &OS,
+                           int Indent) {
+  OS << newline(Indent);
+  OS << "unknown (" << Symbol.getSymTag() << ")";
+}
diff --git a/tools/llvm-pdbdump/CompilandDumper.h b/tools/llvm-pdbdump/CompilandDumper.h
new file mode 100644 (file)
index 0000000..abcebc2
--- /dev/null
@@ -0,0 +1,39 @@
+//===- CompilandDumper.h - llvm-pdbdump compiland symbol dumper *- C++ --*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_TOOLS_LLVMPDBDUMP_COMPILANDDUMPER_H
+#define LLVM_TOOLS_LLVMPDBDUMP_COMPILANDDUMPER_H
+
+#include "llvm/DebugInfo/PDB/PDBSymDumper.h"
+
+namespace llvm {
+
+class CompilandDumper : public PDBSymDumper {
+public:
+  CompilandDumper();
+
+  void start(const PDBSymbolCompiland &Symbol, raw_ostream &OS, int Indent,
+             bool Children);
+
+  void dump(const PDBSymbolCompilandDetails &Symbol, raw_ostream &OS,
+            int Indent) override;
+  void dump(const PDBSymbolCompilandEnv &Symbol, raw_ostream &OS,
+            int Indent) override;
+  void dump(const PDBSymbolData &Symbol, raw_ostream &OS, int Indent) override;
+  void dump(const PDBSymbolFunc &Symbol, raw_ostream &OS, int Indent) override;
+  void dump(const PDBSymbolLabel &Symbol, raw_ostream &OS, int Indent) override;
+  void dump(const PDBSymbolThunk &Symbol, raw_ostream &OS, int Indent) override;
+  void dump(const PDBSymbolTypeTypedef &Symbol, raw_ostream &OS,
+            int Indent) override;
+  void dump(const PDBSymbolUnknown &Symbol, raw_ostream &OS,
+            int Indent) override;
+};
+}
+
+#endif
diff --git a/tools/llvm-pdbdump/FunctionDumper.cpp b/tools/llvm-pdbdump/FunctionDumper.cpp
new file mode 100644 (file)
index 0000000..851fa1f
--- /dev/null
@@ -0,0 +1,187 @@
+//===- FunctionDumper.cpp ------------------------------------ *- C++ *-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "FunctionDumper.h"
+
+#include "llvm/DebugInfo/PDB/IPDBSession.h"
+#include "llvm/DebugInfo/PDB/PDBSymbolFunc.h"
+#include "llvm/DebugInfo/PDB/PDBSymbolTypeArray.h"
+#include "llvm/DebugInfo/PDB/PDBSymbolTypeBuiltin.h"
+#include "llvm/DebugInfo/PDB/PDBSymbolTypeEnum.h"
+#include "llvm/DebugInfo/PDB/PDBSymbolTypeFunctionArg.h"
+#include "llvm/DebugInfo/PDB/PDBSymbolTypeFunctionSig.h"
+#include "llvm/DebugInfo/PDB/PDBSymbolTypePointer.h"
+#include "llvm/DebugInfo/PDB/PDBSymbolTypeTypedef.h"
+#include "llvm/DebugInfo/PDB/PDBSymbolTypeUDT.h"
+
+namespace {
+template <class T>
+void dumpClassParentWithScopeOperator(const T &Symbol, llvm::raw_ostream &OS,
+                                      llvm::FunctionDumper &Dumper) {
+  uint32_t ClassParentId = Symbol.getClassParentId();
+  auto ClassParent =
+      Symbol.getSession().getConcreteSymbolById<PDBSymbolTypeUDT>(
+          ClassParentId);
+  if (!ClassParent)
+    return;
+
+  OS << ClassParent->getName() << "::";
+}
+}
+
+using namespace llvm;
+
+FunctionDumper::FunctionDumper() : PDBSymDumper(true) {}
+
+void FunctionDumper::start(const PDBSymbolTypeFunctionSig &Symbol,
+                           PointerType Pointer, raw_ostream &OS) {
+  auto ReturnType = Symbol.getReturnType();
+  ReturnType->dump(OS, 0, *this);
+  OS << " ";
+  uint32_t ClassParentId = Symbol.getClassParentId();
+  auto ClassParent =
+      Symbol.getSession().getConcreteSymbolById<PDBSymbolTypeUDT>(
+          ClassParentId);
+
+  if (Pointer == PointerType::None) {
+    OS << Symbol.getCallingConvention() << " ";
+    if (ClassParent)
+      OS << "(" << ClassParent->getName() << "::)";
+  } else {
+    OS << "(" << Symbol.getCallingConvention() << " ";
+    if (ClassParent)
+      OS << ClassParent->getName() << "::";
+    if (Pointer == PointerType::Reference)
+      OS << "&";
+    else
+      OS << "*";
+    OS << ")";
+  }
+
+  OS << "(";
+  if (auto ChildEnum = Symbol.getArguments()) {
+    uint32_t Index = 0;
+    while (auto Arg = ChildEnum->getNext()) {
+      Arg->dump(OS, 0, *this);
+      if (++Index < ChildEnum->getChildCount())
+        OS << ", ";
+    }
+  }
+  OS << ")";
+
+  if (Symbol.isConstType())
+    OS << " const";
+  if (Symbol.isVolatileType())
+    OS << " volatile";
+}
+
+void FunctionDumper::start(const PDBSymbolFunc &Symbol, raw_ostream &OS) {
+  if (Symbol.isVirtual() || Symbol.isPureVirtual())
+    OS << "virtual ";
+
+  auto Signature = Symbol.getSignature();
+  if (!Signature) {
+    OS << Symbol.getName();
+    return;
+  }
+
+  auto ReturnType = Signature->getReturnType();
+  ReturnType->dump(OS, 0, *this);
+
+  OS << " " << Signature->getCallingConvention() << " ";
+  OS << Symbol.getName();
+
+  OS << "(";
+  if (auto ChildEnum = Signature->getArguments()) {
+    uint32_t Index = 0;
+    while (auto Arg = ChildEnum->getNext()) {
+      Arg->dump(OS, 0, *this);
+      if (++Index < ChildEnum->getChildCount())
+        OS << ", ";
+    }
+  }
+  OS << ")";
+
+  if (Symbol.isConstType())
+    OS << " const";
+  if (Symbol.isVolatileType())
+    OS << " volatile";
+  if (Symbol.isPureVirtual())
+    OS << " = 0";
+}
+
+void FunctionDumper::dump(const PDBSymbolTypeArray &Symbol, raw_ostream &OS,
+                          int Indent) {
+  uint32_t ElementTypeId = Symbol.getTypeId();
+  auto ElementType = Symbol.getSession().getSymbolById(ElementTypeId);
+  if (!ElementType)
+    return;
+
+  ElementType->dump(OS, 0, *this);
+  OS << "[" << Symbol.getLength() << "]";
+}
+
+void FunctionDumper::dump(const PDBSymbolTypeBuiltin &Symbol, raw_ostream &OS,
+                          int Indent) {
+  PDB_BuiltinType Type = Symbol.getBuiltinType();
+  OS << Type;
+  if (Type == PDB_BuiltinType::UInt || Type == PDB_BuiltinType::Int)
+    OS << (8 * Symbol.getLength()) << "_t";
+}
+
+void FunctionDumper::dump(const PDBSymbolTypeEnum &Symbol, raw_ostream &OS,
+                          int Indent) {
+  dumpClassParentWithScopeOperator(Symbol, OS, *this);
+  OS << Symbol.getName();
+}
+
+void FunctionDumper::dump(const PDBSymbolTypeFunctionArg &Symbol,
+                          raw_ostream &OS, int Indent) {
+  // PDBSymbolTypeFunctionArg is just a shim over the real argument.  Just drill
+  // through to the
+  // real thing and dump it.
+  uint32_t TypeId = Symbol.getTypeId();
+  auto Type = Symbol.getSession().getSymbolById(TypeId);
+  if (!Type)
+    return;
+  Type->dump(OS, 0, *this);
+}
+
+void FunctionDumper::dump(const PDBSymbolTypeTypedef &Symbol, raw_ostream &OS,
+                          int Indent) {
+  dumpClassParentWithScopeOperator(Symbol, OS, *this);
+  OS << Symbol.getName();
+}
+
+void FunctionDumper::dump(const PDBSymbolTypePointer &Symbol, raw_ostream &OS,
+                          int Indent) {
+  uint32_t PointeeId = Symbol.getTypeId();
+  auto PointeeType = Symbol.getSession().getSymbolById(PointeeId);
+  if (!PointeeType)
+    return;
+
+  if (auto FuncSig = dyn_cast<PDBSymbolTypeFunctionSig>(PointeeType.get())) {
+    FunctionDumper NestedDumper;
+    PointerType Pointer =
+        Symbol.isReference() ? PointerType::Reference : PointerType::Pointer;
+    NestedDumper.start(*FuncSig, Pointer, OS);
+  } else {
+    if (Symbol.isConstType())
+      OS << "const ";
+    if (Symbol.isVolatileType())
+      OS << "volatile ";
+    PointeeType->dump(OS, Indent, *this);
+    OS << (Symbol.isReference() ? "&" : "*");
+  }
+}
+
+void FunctionDumper::dump(const PDBSymbolTypeUDT &Symbol, raw_ostream &OS,
+                          int Indent) {
+  OS << Symbol.getName();
+}
diff --git a/tools/llvm-pdbdump/FunctionDumper.h b/tools/llvm-pdbdump/FunctionDumper.h
new file mode 100644 (file)
index 0000000..287a79c
--- /dev/null
@@ -0,0 +1,44 @@
+//===- FunctionDumper.h --------------------------------------- *- C++ --*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_TOOLS_LLVMPDBDUMP_FUNCTIONDUMPER_H
+#define LLVM_TOOLS_LLVMPDBDUMP_FUNCTIONDUMPER_H
+
+#include "llvm/DebugInfo/PDB/PDBSymDumper.h"
+
+namespace llvm {
+
+class FunctionDumper : public PDBSymDumper {
+public:
+  FunctionDumper();
+
+  enum class PointerType { None, Pointer, Reference };
+
+  void start(const PDBSymbolTypeFunctionSig &Symbol, PointerType Pointer,
+             raw_ostream &OS);
+  void start(const PDBSymbolFunc &Symbol, raw_ostream &OS);
+
+  void dump(const PDBSymbolTypeArray &Symbol, raw_ostream &OS,
+            int Indent) override;
+  void dump(const PDBSymbolTypeBuiltin &Symbol, raw_ostream &OS,
+            int Indent) override;
+  void dump(const PDBSymbolTypeEnum &Symbol, raw_ostream &OS,
+            int Indent) override;
+  void dump(const PDBSymbolTypeFunctionArg &Symbol, raw_ostream &OS,
+            int Indent) override;
+  void dump(const PDBSymbolTypePointer &Symbol, raw_ostream &OS,
+            int Indent) override;
+  void dump(const PDBSymbolTypeTypedef &Symbol, raw_ostream &OS,
+            int Indent) override;
+  void dump(const PDBSymbolTypeUDT &Symbol, raw_ostream &OS,
+            int Indent) override;
+};
+}
+
+#endif
diff --git a/tools/llvm-pdbdump/TypeDumper.cpp b/tools/llvm-pdbdump/TypeDumper.cpp
new file mode 100644 (file)
index 0000000..72171b0
--- /dev/null
@@ -0,0 +1,63 @@
+//===- TypeDumper.cpp - PDBSymDumper implementation for types *----- C++ *-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "TypeDumper.h"
+
+#include "FunctionDumper.h"
+#include "llvm-pdbdump.h"
+#include "TypedefDumper.h"
+
+#include "llvm/DebugInfo/PDB/IPDBSession.h"
+#include "llvm/DebugInfo/PDB/PDBSymbolExe.h"
+#include "llvm/DebugInfo/PDB/PDBSymbolTypeEnum.h"
+#include "llvm/DebugInfo/PDB/PDBSymbolTypeFunctionSig.h"
+#include "llvm/DebugInfo/PDB/PDBSymbolTypeTypedef.h"
+
+using namespace llvm;
+
+TypeDumper::TypeDumper() : PDBSymDumper(true) {}
+
+void TypeDumper::start(const PDBSymbolExe &Exe, raw_ostream &OS, int Indent) {
+  auto Enums = Exe.findAllChildren<PDBSymbolTypeEnum>();
+  OS << newline(Indent) << "Enums: (" << Enums->getChildCount() << " items)";
+  while (auto Enum = Enums->getNext())
+    Enum->dump(OS, Indent + 2, *this);
+
+  auto FuncSigs = Exe.findAllChildren<PDBSymbolTypeFunctionSig>();
+  OS << newline(Indent);
+  OS << "Function Signatures: (" << FuncSigs->getChildCount() << " items)";
+  while (auto Sig = FuncSigs->getNext())
+    Sig->dump(OS, Indent + 2, *this);
+
+  auto Typedefs = Exe.findAllChildren<PDBSymbolTypeTypedef>();
+  OS << newline(Indent) << "Typedefs: (" << Typedefs->getChildCount()
+     << " items)";
+  while (auto Typedef = Typedefs->getNext())
+    Typedef->dump(OS, Indent + 2, *this);
+}
+
+void TypeDumper::dump(const PDBSymbolTypeEnum &Symbol, raw_ostream &OS,
+                      int Indent) {
+  OS << newline(Indent) << "enum " << Symbol.getName();
+}
+
+void TypeDumper::dump(const PDBSymbolTypeFunctionSig &Symbol, raw_ostream &OS,
+                      int Indent) {
+  OS << newline(Indent);
+  FunctionDumper Dumper;
+  Dumper.start(Symbol, FunctionDumper::PointerType::None, OS);
+}
+
+void TypeDumper::dump(const PDBSymbolTypeTypedef &Symbol, raw_ostream &OS,
+                      int Indent) {
+  OS << newline(Indent);
+  TypedefDumper Dumper;
+  Dumper.start(Symbol, OS, Indent);
+  OS.flush();
+}
diff --git a/tools/llvm-pdbdump/TypeDumper.h b/tools/llvm-pdbdump/TypeDumper.h
new file mode 100644 (file)
index 0000000..6c51d15
--- /dev/null
@@ -0,0 +1,32 @@
+//===- TypeDumper.h - PDBSymDumper implementation for types *- C++ ------*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_TOOLS_LLVMPDBDUMP_TYPEDUMPER_H
+#define LLVM_TOOLS_LLVMPDBDUMP_TYPEDUMPER_H
+
+#include "llvm/DebugInfo/PDB/PDBSymDumper.h"
+
+namespace llvm {
+
+class TypeDumper : public PDBSymDumper {
+public:
+  TypeDumper();
+
+  void start(const PDBSymbolExe &Exe, raw_ostream &OS, int Indent);
+
+  void dump(const PDBSymbolTypeEnum &Symbol, raw_ostream &OS,
+            int Indent) override;
+  void dump(const PDBSymbolTypeFunctionSig &Symbol, raw_ostream &OS,
+            int Indent) override;
+  void dump(const PDBSymbolTypeTypedef &Symbol, raw_ostream &OS,
+            int Indent) override;
+};
+}
+
+#endif
diff --git a/tools/llvm-pdbdump/TypedefDumper.cpp b/tools/llvm-pdbdump/TypedefDumper.cpp
new file mode 100644 (file)
index 0000000..55fcb1a
--- /dev/null
@@ -0,0 +1,84 @@
+//===- TypedefDumper.cpp - PDBSymDumper impl for typedefs -------- * C++ *-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "TypedefDumper.h"
+
+#include "FunctionDumper.h"
+#include "llvm-pdbdump.h"
+
+#include "llvm/DebugInfo/PDB/IPDBSession.h"
+#include "llvm/DebugInfo/PDB/PDBExtras.h"
+#include "llvm/DebugInfo/PDB/PDBSymbolTypeBuiltin.h"
+#include "llvm/DebugInfo/PDB/PDBSymbolTypeEnum.h"
+#include "llvm/DebugInfo/PDB/PDBSymbolTypeFunctionSig.h"
+#include "llvm/DebugInfo/PDB/PDBSymbolTypePointer.h"
+#include "llvm/DebugInfo/PDB/PDBSymbolTypeTypedef.h"
+#include "llvm/DebugInfo/PDB/PDBSymbolTypeUDT.h"
+
+using namespace llvm;
+
+TypedefDumper::TypedefDumper() : PDBSymDumper(true) {}
+
+void TypedefDumper::start(const PDBSymbolTypeTypedef &Symbol, raw_ostream &OS,
+                          int Indent) {
+  OS << "typedef:" << Symbol.getName() << " -> ";
+  uint32_t TargetId = Symbol.getTypeId();
+  if (auto TypeSymbol = Symbol.getSession().getSymbolById(TargetId))
+    TypeSymbol->dump(OS, 0, *this);
+}
+
+void TypedefDumper::dump(const PDBSymbolTypeArray &Symbol, raw_ostream &OS,
+                         int Indent) {}
+
+void TypedefDumper::dump(const PDBSymbolTypeBuiltin &Symbol, raw_ostream &OS,
+                         int Indent) {
+  PDB_BuiltinType Type = Symbol.getBuiltinType();
+  OS << Type;
+  if (Type == PDB_BuiltinType::UInt || Type == PDB_BuiltinType::Int)
+    OS << (8 * Symbol.getLength()) << "_t";
+}
+
+void TypedefDumper::dump(const PDBSymbolTypeEnum &Symbol, raw_ostream &OS,
+                         int Indent) {
+  OS << "enum " << Symbol.getName();
+}
+
+void TypedefDumper::dump(const PDBSymbolTypePointer &Symbol, raw_ostream &OS,
+                         int Indent) {
+  if (Symbol.isConstType())
+    OS << "const ";
+  if (Symbol.isVolatileType())
+    OS << "volatile ";
+  uint32_t PointeeId = Symbol.getTypeId();
+  auto PointeeType = Symbol.getSession().getSymbolById(PointeeId);
+  if (!PointeeType)
+    return;
+  if (auto FuncSig = dyn_cast<PDBSymbolTypeFunctionSig>(PointeeType.get())) {
+    FunctionDumper::PointerType Pointer = FunctionDumper::PointerType::Pointer;
+    if (Symbol.isReference())
+      Pointer = FunctionDumper::PointerType::Reference;
+    FunctionDumper NestedDumper;
+    NestedDumper.start(*FuncSig, Pointer, OS);
+    OS.flush();
+  } else {
+    PointeeType->dump(OS, Indent, *this);
+    OS << ((Symbol.isReference()) ? "&" : "*");
+  }
+}
+
+void TypedefDumper::dump(const PDBSymbolTypeFunctionSig &Symbol,
+                         raw_ostream &OS, int Indent) {
+  FunctionDumper Dumper;
+  Dumper.start(Symbol, FunctionDumper::PointerType::None, OS);
+}
+
+void TypedefDumper::dump(const PDBSymbolTypeUDT &Symbol, raw_ostream &OS,
+                         int Indent) {
+  OS << "class " << Symbol.getName();
+}
diff --git a/tools/llvm-pdbdump/TypedefDumper.h b/tools/llvm-pdbdump/TypedefDumper.h
new file mode 100644 (file)
index 0000000..e6211a8
--- /dev/null
@@ -0,0 +1,38 @@
+//===- TypedefDumper.h - llvm-pdbdump typedef dumper ---------*- C++ ----*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_TOOLS_LLVMPDBDUMP_TYPEDEFDUMPER_H
+#define LLVM_TOOLS_LLVMPDBDUMP_TYPEDEFDUMPER_H
+
+#include "llvm/DebugInfo/PDB/PDBSymDumper.h"
+
+namespace llvm {
+
+class TypedefDumper : public PDBSymDumper {
+public:
+  TypedefDumper();
+
+  void start(const PDBSymbolTypeTypedef &Symbol, raw_ostream &OS, int Indent);
+
+  void dump(const PDBSymbolTypeArray &Symbol, raw_ostream &OS,
+            int Indent) override;
+  void dump(const PDBSymbolTypeBuiltin &Symbol, raw_ostream &OS,
+            int Indent) override;
+  void dump(const PDBSymbolTypeEnum &Symbol, raw_ostream &OS,
+            int Indent) override;
+  void dump(const PDBSymbolTypeFunctionSig &Symbol, raw_ostream &OS,
+            int Indent) override;
+  void dump(const PDBSymbolTypePointer &Symbol, raw_ostream &OS,
+            int Indent) override;
+  void dump(const PDBSymbolTypeUDT &Symbol, raw_ostream &OS,
+            int Indent) override;
+};
+}
+
+#endif
index cc51dc0d222f1f017c632a512ed98a249b9a6d06..5c34db30f35e2dbb90b5a894dc693b8de3d15fbc 100644 (file)
 //
 //===----------------------------------------------------------------------===//
 
+#include "llvm-pdbdump.h"
+#include "CompilandDumper.h"
+#include "TypeDumper.h"
+
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/Config/config.h"
 #include "llvm/DebugInfo/PDB/PDBSymbolExe.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/ConvertUTF.h"
+#include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Format.h"
 #include "llvm/Support/ManagedStatic.h"
 #include "llvm/Support/PrettyStackTrace.h"
 #include "llvm/Support/Process.h"
-#include "llvm/Support/Signals.h"
 #include "llvm/Support/raw_ostream.h"
+#include "llvm/Support/Signals.h"
 
 #if defined(HAVE_DIA_SDK)
 #include <Windows.h>
@@ -61,24 +66,36 @@ static void dumpInput(StringRef Path) {
   }
 
   auto GlobalScope(Session->getGlobalScope());
+  std::string FileName(GlobalScope->getSymbolsFileName());
+
+  outs() << "Summary for " << FileName;
+  uint64_t FileSize = 0;
+  if (!llvm::sys::fs::file_size(FileName, FileSize))
+    outs() << newline(2) << "Size: " << FileSize << " bytes";
+  else
+    outs() << newline(2) << "Size: (Unable to obtain file size)";
+
+  outs() << newline(2) << "Guid: " << GlobalScope->getGuid();
+  outs() << newline(2) << "Age: " << GlobalScope->getAge();
+  outs() << newline(2) << "Attributes: ";
+  if (GlobalScope->hasCTypes())
+    outs() << "HasCTypes ";
+  if (GlobalScope->hasPrivateSymbols())
+    outs() << "HasPrivateSymbols ";
+
   PDB_DumpFlags Flags = PDB_DF_None;
-  if (opts::DumpTypes)
-    Flags |= PDB_DF_Children | PDB_DF_Enums | PDB_DF_Funcsigs |
-             PDB_DF_Typedefs | PDB_DF_VTables;
-  GlobalScope->dump(outs(), 0, PDB_DumpLevel::Normal, Flags);
-  outs() << "\n";
+  if (opts::DumpTypes) {
+    outs() << "\nDumping types";
+    TypeDumper Dumper;
+    Dumper.start(*GlobalScope, outs(), 2);
+  }
 
   if (opts::DumpSymbols || opts::DumpCompilands) {
-    outs() << "Dumping compilands\n";
+    outs() << "\nDumping compilands";
     auto Compilands = GlobalScope->findAllChildren<PDBSymbolCompiland>();
-    Flags = PDB_DF_None;
-    if (opts::DumpSymbols)
-      Flags |= PDB_DF_Children | PDB_DF_Data | PDB_DF_Functions |
-               PDB_DF_Thunks | PDB_DF_Labels;
-    while (auto Compiland = Compilands->getNext()) {
-      Compiland->dump(outs(), 2, PDB_DumpLevel::Detailed, Flags);
-      outs() << "\n";
-    }
+    CompilandDumper Dumper;
+    while (auto Compiland = Compilands->getNext())
+      Dumper.start(*Compiland, outs(), 2, opts::DumpSymbols);
   }
   outs().flush();
 }
diff --git a/tools/llvm-pdbdump/llvm-pdbdump.h b/tools/llvm-pdbdump/llvm-pdbdump.h
new file mode 100644 (file)
index 0000000..74a1718
--- /dev/null
@@ -0,0 +1,28 @@
+//===- llvm-pdbdump.h ----------------------------------------- *- C++ --*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_TOOLS_LLVMPDBDUMP_LLVMPDBDUMP_H
+#define LLVM_TOOLS_LLVMPDBDUMP_LLVMPDBDUMP_H
+
+#include "llvm/Support/raw_ostream.h"
+
+namespace llvm {
+struct newline {
+  newline(int IndentWidth) : Width(IndentWidth) {}
+  int Width;
+};
+
+inline raw_ostream &operator<<(raw_ostream &OS, const newline &Indent) {
+  OS << "\n";
+  OS.indent(Indent.Width);
+  return OS;
+}
+}
+
+#endif
\ No newline at end of file