llvm-pdbdump: Add more comprehensive dumping of symbol types.
authorZachary Turner <zturner@google.com>
Fri, 13 Feb 2015 07:40:03 +0000 (07:40 +0000)
committerZachary Turner <zturner@google.com>
Fri, 13 Feb 2015 07:40:03 +0000 (07:40 +0000)
In particular this patch adds the ability to dump complete
function signature information including argument types as
correctly formatted strings.  A side effect of this is that
almost all symbol and meta types are now formatted.

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

23 files changed:
include/llvm/DebugInfo/PDB/IPDBSession.h
include/llvm/DebugInfo/PDB/PDBExtras.h
include/llvm/DebugInfo/PDB/PDBSymbolUnknown.h
lib/DebugInfo/PDB/DIA/DIARawSymbol.cpp
lib/DebugInfo/PDB/PDBExtras.cpp
lib/DebugInfo/PDB/PDBSymbolCompiland.cpp
lib/DebugInfo/PDB/PDBSymbolData.cpp
lib/DebugInfo/PDB/PDBSymbolExe.cpp
lib/DebugInfo/PDB/PDBSymbolFunc.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/PDBSymbolTypeEnum.cpp
lib/DebugInfo/PDB/PDBSymbolTypeFunctionArg.cpp
lib/DebugInfo/PDB/PDBSymbolTypeFunctionSig.cpp
lib/DebugInfo/PDB/PDBSymbolTypePointer.cpp
lib/DebugInfo/PDB/PDBSymbolTypeTypedef.cpp
lib/DebugInfo/PDB/PDBSymbolTypeUDT.cpp
lib/DebugInfo/PDB/PDBSymbolTypeVTable.cpp
tools/llvm-pdbdump/llvm-pdbdump.cpp

index 0e0b2c5..a36d65f 100644 (file)
@@ -30,6 +30,19 @@ public:
   virtual std::unique_ptr<PDBSymbolExe> getGlobalScope() const = 0;
   virtual std::unique_ptr<PDBSymbol> getSymbolById(uint32_t SymbolId) const = 0;
 
+  template <typename T>
+  std::unique_ptr<T> getConcreteSymbolById(uint32_t SymbolId) const {
+    auto Symbol(getSymbolById(SymbolId));
+    if (!Symbol)
+      return nullptr;
+
+    T *ConcreteSymbol = dyn_cast<T>(Symbol.get());
+    if (!ConcreteSymbol)
+      return nullptr;
+    Symbol.release();
+    return std::unique_ptr<T>(ConcreteSymbol);
+  }
+
   virtual std::unique_ptr<IPDBEnumSourceFiles> getAllSourceFiles() const = 0;
   virtual std::unique_ptr<IPDBEnumSourceFiles>
   getSourceFilesForCompiland(const PDBSymbolCompiland &Compiland) const = 0;
index 1dee665..44c79a5 100644 (file)
@@ -26,6 +26,7 @@ struct stream_indent {
 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);
 raw_ostream &operator<<(raw_ostream &OS, const PDB_RegisterId &Reg);
 raw_ostream &operator<<(raw_ostream &OS, const PDB_LocType &Loc);
@@ -33,6 +34,7 @@ raw_ostream &operator<<(raw_ostream &OS, const PDB_ThunkOrdinal &Thunk);
 raw_ostream &operator<<(raw_ostream &OS, const PDB_Checksum &Checksum);
 raw_ostream &operator<<(raw_ostream &OS, const PDB_Lang &Lang);
 raw_ostream &operator<<(raw_ostream &OS, const PDB_SymType &Tag);
+raw_ostream &operator<<(raw_ostream &OS, const PDB_BuiltinType &Type);
 raw_ostream &operator<<(raw_ostream &OS, const PDB_UniqueId &Id);
 
 raw_ostream &operator<<(raw_ostream &OS, const Variant &Value);
index cc8ab37..1fa358c 100644 (file)
@@ -11,7 +11,6 @@
 #define LLVM_DEBUGINFO_PDB_PDBSYMBOLUNKNOWN_H
 
 #include "PDBSymbol.h"
-#include "PDBTypes.h"
 
 namespace llvm {
 
index e9e5ce2..32239c1 100644 (file)
@@ -190,7 +190,7 @@ void DIARawSymbol::dump(raw_ostream &OS, int Indent,
   RAW_METHOD_DUMP(OS, get_baseDataOffset)
   RAW_METHOD_DUMP(OS, get_baseDataSlot)
   RAW_METHOD_DUMP(OS, get_baseSymbolId)
-  RAW_METHOD_DUMP(OS, get_builtInKind)
+  RAW_METHOD_DUMP(OS, get_baseType)
   RAW_METHOD_DUMP(OS, get_bitPosition)
   RAW_METHOD_DUMP(OS, get_callingConvention)
   RAW_METHOD_DUMP(OS, get_classParentId)
@@ -457,8 +457,8 @@ uint32_t DIARawSymbol::getBaseSymbolId() const {
 }
 
 PDB_BuiltinType DIARawSymbol::getBuiltinType() const {
-  return PrivateGetDIAValue<DWORD, PDB_BuiltinType>(
-      Symbol, &IDiaSymbol::get_builtInKind);
+  return PrivateGetDIAValue<DWORD, PDB_BuiltinType>(Symbol,
+                                                    &IDiaSymbol::get_baseType);
 }
 
 uint32_t DIARawSymbol::getBitPosition() const {
index 9ead764..8a813c8 100644 (file)
@@ -44,6 +44,41 @@ raw_ostream &llvm::operator<<(raw_ostream &OS, const PDB_VariantType &Type) {
   return OS;
 }
 
+raw_ostream &llvm::operator<<(raw_ostream &OS, const PDB_CallingConv &Conv) {
+  OS << "__";
+  switch (Conv) {
+    CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, NearCdecl, "cdecl", OS)
+    CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, FarCdecl, "cdecl", OS)
+    CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, NearPascal, "pascal", OS)
+    CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, FarPascal, "pascal", OS)
+    CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, NearFastcall, "fastcall", OS)
+    CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, FarFastcall, "fastcall", OS)
+    CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, Skipped, "skippedcall", OS)
+    CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, NearStdcall, "stdcall", OS)
+    CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, FarStdcall, "stdcall", OS)
+    CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, NearSyscall, "syscall", OS)
+    CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, FarSyscall, "syscall", OS)
+    CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, Thiscall, "thiscall", OS)
+    CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, MipsCall, "mipscall", OS)
+    CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, Generic, "genericcall", OS)
+    CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, Alphacall, "alphacall", OS)
+    CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, Ppccall, "ppccall", OS)
+    CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, SuperHCall, "superhcall", OS)
+    CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, Armcall, "armcall", OS)
+    CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, AM33call, "am33call", OS)
+    CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, Tricall, "tricall", OS)
+    CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, Sh5call, "sh5call", OS)
+    CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, M32R, "m32rcall", OS)
+    CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, Clrcall, "clrcall", OS)
+    CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, Inline, "inlinecall", OS)
+    CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, NearVectorcall, "vectorcall",
+                               OS)
+  default:
+    OS << "unknowncall";
+  }
+  return OS;
+}
+
 raw_ostream &llvm::operator<<(raw_ostream &OS, const PDB_DataKind &Data) {
   switch (Data) {
     CASE_OUTPUT_ENUM_CLASS_STR(PDB_DataKind, Unknown, "unknown", OS)
@@ -216,6 +251,31 @@ raw_ostream &llvm::operator<<(raw_ostream &OS, const PDB_SymType &Tag) {
   return OS;
 }
 
+raw_ostream &llvm::operator<<(raw_ostream &OS, const PDB_BuiltinType &Type) {
+  switch (Type) {
+    CASE_OUTPUT_ENUM_CLASS_STR(PDB_BuiltinType, Void, "void", OS)
+    CASE_OUTPUT_ENUM_CLASS_STR(PDB_BuiltinType, Char, "char", OS)
+    CASE_OUTPUT_ENUM_CLASS_STR(PDB_BuiltinType, WCharT, "wchar_t", OS)
+    CASE_OUTPUT_ENUM_CLASS_STR(PDB_BuiltinType, Int, "int", OS)
+    CASE_OUTPUT_ENUM_CLASS_STR(PDB_BuiltinType, UInt, "uint", OS)
+    CASE_OUTPUT_ENUM_CLASS_STR(PDB_BuiltinType, Float, "float", OS)
+    CASE_OUTPUT_ENUM_CLASS_STR(PDB_BuiltinType, BCD, "BCD", OS)
+    CASE_OUTPUT_ENUM_CLASS_STR(PDB_BuiltinType, Bool, "bool", OS)
+    CASE_OUTPUT_ENUM_CLASS_STR(PDB_BuiltinType, Long, "long", OS)
+    CASE_OUTPUT_ENUM_CLASS_STR(PDB_BuiltinType, ULong, "ulong", OS)
+    CASE_OUTPUT_ENUM_CLASS_STR(PDB_BuiltinType, Currency, "CURRENCY", OS)
+    CASE_OUTPUT_ENUM_CLASS_STR(PDB_BuiltinType, Date, "DATE", OS)
+    CASE_OUTPUT_ENUM_CLASS_STR(PDB_BuiltinType, Variant, "VARIANT", OS)
+    CASE_OUTPUT_ENUM_CLASS_STR(PDB_BuiltinType, Complex, "complex", OS)
+    CASE_OUTPUT_ENUM_CLASS_STR(PDB_BuiltinType, Bitfield, "bitfield", OS)
+    CASE_OUTPUT_ENUM_CLASS_STR(PDB_BuiltinType, BSTR, "BSTR", OS)
+    CASE_OUTPUT_ENUM_CLASS_STR(PDB_BuiltinType, HResult, "HRESULT", OS)
+  default:
+    break;
+  }
+  return OS;
+}
+
 raw_ostream &llvm::operator<<(raw_ostream &OS, const PDB_UniqueId &Id) {
   static const char *Lookup = "0123456789ABCDEF";
 
index 39bb9bc..03ebe2b 100644 (file)
@@ -29,70 +29,75 @@ PDBSymbolCompiland::PDBSymbolCompiland(const IPDBSession &PDBSession,
 
 void PDBSymbolCompiland::dump(raw_ostream &OS, int Indent,
                               PDB_DumpLevel Level) const {
-  std::string FullName = getName();
-  StringRef Name = llvm::sys::path::filename(StringRef(FullName.c_str()));
+  if (Level == PDB_DumpLevel::Detailed) {
+    std::string FullName = getName();
+    StringRef Name = llvm::sys::path::filename(StringRef(FullName.c_str()));
 
-  OS.indent(Indent);
-  OS << "Compiland: " << Name << "\n";
+    OS.indent(Indent);
+    OS << "Compiland: " << Name << "\n";
 
-  std::string Source = getSourceFileName();
-  std::string Library = getLibraryName();
-  if (!Source.empty())
-    OS << stream_indent(Indent + 2) << "Source: " << this->getSourceFileName()
-       << "\n";
-  if (!Library.empty())
-    OS << stream_indent(Indent + 2) << "Library: " << this->getLibraryName()
-       << "\n";
+    std::string Source = getSourceFileName();
+    std::string Library = getLibraryName();
+    if (!Source.empty())
+      OS << stream_indent(Indent + 2) << "Source: " << this->getSourceFileName()
+         << "\n";
+    if (!Library.empty())
+      OS << stream_indent(Indent + 2) << "Library: " << this->getLibraryName()
+         << "\n";
 
-  TagStats Stats;
-  auto ChildrenEnum = getChildStats(Stats);
-  OS << stream_indent(Indent + 2) << "Children: " << Stats << "\n";
-  if (Level >= PDB_DumpLevel::Normal) {
-    while (auto Child = ChildrenEnum->getNext()) {
-      if (llvm::isa<PDBSymbolCompilandDetails>(*Child))
-        continue;
-      if (llvm::isa<PDBSymbolCompilandEnv>(*Child))
-        continue;
-      Child->dump(OS, Indent + 4, PDB_DumpLevel::Compact);
+    TagStats Stats;
+    auto ChildrenEnum = getChildStats(Stats);
+    OS << stream_indent(Indent + 2) << "Children: " << Stats << "\n";
+    if (Level >= PDB_DumpLevel::Detailed) {
+      while (auto Child = ChildrenEnum->getNext()) {
+        if (llvm::isa<PDBSymbolCompilandDetails>(*Child))
+          continue;
+        if (llvm::isa<PDBSymbolCompilandEnv>(*Child))
+          continue;
+        PDB_DumpLevel ChildLevel = (Level == PDB_DumpLevel::Detailed)
+                                       ? PDB_DumpLevel::Normal
+                                       : PDB_DumpLevel::Compact;
+        Child->dump(OS, Indent + 4, ChildLevel);
+        OS << "\n";
+      }
     }
-  }
 
-  auto DetailsEnum(findAllChildren<PDBSymbolCompilandDetails>());
-  if (auto CD = DetailsEnum->getNext()) {
-    VersionInfo FE;
-    VersionInfo BE;
-    CD->getFrontEndVersion(FE);
-    CD->getBackEndVersion(BE);
-    OS << stream_indent(Indent + 2) << "Compiler: " << CD->getCompilerName()
-       << "\n";
-    OS << stream_indent(Indent + 2) << "Version: " << FE << ", " << BE << "\n";
+    auto DetailsEnum(findAllChildren<PDBSymbolCompilandDetails>());
+    if (auto CD = DetailsEnum->getNext()) {
+      VersionInfo FE;
+      VersionInfo BE;
+      CD->getFrontEndVersion(FE);
+      CD->getBackEndVersion(BE);
+      OS << stream_indent(Indent + 2) << "Compiler: " << CD->getCompilerName()
+         << "\n";
+      OS << stream_indent(Indent + 2) << "Version: " << FE << ", " << BE
+         << "\n";
 
-    OS << stream_indent(Indent + 2) << "Lang: " << CD->getLanguage() << "\n";
-    OS << stream_indent(Indent + 2) << "Attributes: ";
-    if (CD->hasDebugInfo())
-      OS << "DebugInfo ";
-    if (CD->isDataAligned())
-      OS << "DataAligned ";
-    if (CD->isLTCG())
-      OS << "LTCG ";
-    if (CD->hasSecurityChecks())
-      OS << "SecurityChecks ";
-    if (CD->isHotpatchable())
-      OS << "HotPatchable";
+      OS << stream_indent(Indent + 2) << "Lang: " << CD->getLanguage() << "\n";
+      OS << stream_indent(Indent + 2) << "Attributes: ";
+      if (CD->hasDebugInfo())
+        OS << "DebugInfo ";
+      if (CD->isDataAligned())
+        OS << "DataAligned ";
+      if (CD->isLTCG())
+        OS << "LTCG ";
+      if (CD->hasSecurityChecks())
+        OS << "SecurityChecks ";
+      if (CD->isHotpatchable())
+        OS << "HotPatchable";
 
-    OS << "\n";
-    auto Files(Session.getSourceFilesForCompiland(*this));
-    if (Level >= PDB_DumpLevel::Detailed) {
+      auto Files(Session.getSourceFilesForCompiland(*this));
+      OS << "\n";
       OS << stream_indent(Indent + 2) << Files->getChildCount()
-         << " source files:\n";
-      while (auto File = Files->getNext())
-        File->dump(OS, Indent + 4, PDB_DumpLevel::Compact);
-    } else {
-      OS << stream_indent(Indent + 2) << Files->getChildCount()
-         << " source files\n";
+         << " source files";
+    }
+    uint32_t Count = DetailsEnum->getChildCount();
+    if (Count > 1) {
+      OS << "\n";
+      OS << stream_indent(Indent + 2) << "(" << Count - 1 << " more omitted)";
     }
+  } else {
+    std::string FullName = getName();
+    OS << stream_indent(Indent) << "Compiland: " << FullName;
   }
-  uint32_t Count = DetailsEnum->getChildCount();
-  if (Count > 1)
-    OS << stream_indent(Indent + 2) << "(" << Count - 1 << " more omitted)\n";
 }
index 3c4be3a..9a1ca26 100644 (file)
@@ -26,7 +26,7 @@ void PDBSymbolData::dump(raw_ostream &OS, int Indent,
   OS << stream_indent(Indent);
   PDB_LocType Loc = getLocationType();
   PDB_DataKind Kind = getDataKind();
-  if (Level == PDB_DumpLevel::Compact) {
+  if (Level >= PDB_DumpLevel::Normal) {
     switch (Loc) {
     case PDB_LocType::Static: {
       uint32_t RVA = getRelativeVirtualAddress();
@@ -75,6 +75,7 @@ void PDBSymbolData::dump(raw_ostream &OS, int Indent,
       OS << "???";
     }
   }
+
   OS << "] ";
   if (Kind == PDB_DataKind::Member || Kind == PDB_DataKind::StaticMember) {
     uint32_t ClassId = getClassParentId();
@@ -86,6 +87,5 @@ void PDBSymbolData::dump(raw_ostream &OS, int Indent,
       OS << "::";
     }
   }
-  OS << getName() << "\n";
-  OS.flush();
+  OS << getName();
 }
\ No newline at end of file
index 4f999d9..ddf6efc 100644 (file)
@@ -27,17 +27,17 @@ void PDBSymbolExe::dump(raw_ostream &OS, int Indent,
                         PDB_DumpLevel Level) const {
   std::string FileName(getSymbolsFileName());
 
-  OS << "Summary for " << FileName << "\n";
+  OS << stream_indent(Indent) << "Summary for " << FileName << "\n";
 
   uint64_t FileSize = 0;
   if (!llvm::sys::fs::file_size(FileName, FileSize))
-    OS << "  Size: " << FileSize << " bytes\n";
+    OS << stream_indent(Indent + 2) << "Size: " << FileSize << " bytes\n";
   else
-    OS << "  Size: (Unable to obtain file size)\n";
+    OS << stream_indent(Indent + 2) << "Size: (Unable to obtain file size)\n";
   PDB_UniqueId Guid = getGuid();
-  OS << "  Guid: " << Guid << "\n";
-  OS << "  Age: " << getAge() << "\n";
-  OS << "  Attributes: ";
+  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())
@@ -48,6 +48,7 @@ void PDBSymbolExe::dump(raw_ostream &OS, int Indent,
   auto ChildrenEnum = getChildStats(Stats);
   OS << stream_indent(Indent + 2) << "Children: " << Stats << "\n";
   while (auto Child = ChildrenEnum->getNext()) {
-    Child->dump(OS, Indent+2, PDB_DumpLevel::Compact);
+    Child->dump(OS, Indent + 4, PDB_DumpLevel::Normal);
+    OS << "\n";
   }
 }
index 4bd9608..4ae48df 100644 (file)
@@ -15,6 +15,7 @@
 #include "llvm/DebugInfo/PDB/PDBSymbolFunc.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"
@@ -26,9 +27,8 @@ PDBSymbolFunc::PDBSymbolFunc(const IPDBSession &PDBSession,
 
 void PDBSymbolFunc::dump(raw_ostream &OS, int Indent,
                          PDB_DumpLevel Level) const {
-  if (Level == PDB_DumpLevel::Compact) {
-    OS << stream_indent(Indent);
-
+  OS << stream_indent(Indent);
+  if (Level >= PDB_DumpLevel::Normal) {
     uint32_t FuncStart = getRelativeVirtualAddress();
     uint32_t FuncEnd = FuncStart + getLength();
     if (FuncStart == 0 && FuncEnd == 0) {
@@ -53,6 +53,12 @@ void PDBSymbolFunc::dump(raw_ostream &OS, int Indent,
       OS << "(FPO)";
 
     OS << " ";
+    uint32_t FuncSigId = getTypeId();
+    if (auto FuncSig = Session.getConcreteSymbolById<PDBSymbolTypeFunctionSig>(
+            FuncSigId)) {
+      OS << "(" << FuncSig->getCallingConvention() << ") ";
+    }
+
     uint32_t ClassId = getClassParentId();
     if (ClassId != 0) {
       if (auto Class = Session.getSymbolById(ClassId)) {
@@ -63,6 +69,7 @@ void PDBSymbolFunc::dump(raw_ostream &OS, int Indent,
       }
     }
     OS << getName();
-    OS << "\n";
+  } else {
+    OS << getName();
   }
 }
index 50d1e2a..6b2c36e 100644 (file)
@@ -12,6 +12,8 @@
 #include "llvm/DebugInfo/PDB/PDBSymbol.h"
 #include "llvm/DebugInfo/PDB/PDBSymbolLabel.h"
 
+#include "llvm/Support/Format.h"
+
 using namespace llvm;
 
 PDBSymbolLabel::PDBSymbolLabel(const IPDBSession &PDBSession,
@@ -19,4 +21,8 @@ PDBSymbolLabel::PDBSymbolLabel(const IPDBSession &PDBSession,
     : PDBSymbol(PDBSession, std::move(Symbol)) {}
 
 void PDBSymbolLabel::dump(raw_ostream &OS, int Indent,
-                          PDB_DumpLevel Level) const {}
+                          PDB_DumpLevel Level) const {
+  OS << stream_indent(Indent);
+  OS << "label [" << format_hex(getRelativeVirtualAddress(), 10) << "] "
+     << getName();
+}
index bb4400a..271f525 100644 (file)
@@ -19,4 +19,7 @@ PDBSymbolPublicSymbol::PDBSymbolPublicSymbol(
     : PDBSymbol(PDBSession, std::move(Symbol)) {}
 
 void PDBSymbolPublicSymbol::dump(raw_ostream &OS, int Indent,
-                                 PDB_DumpLevel Level) const {}
+                                 PDB_DumpLevel Level) const {
+  OS << stream_indent(Indent);
+  OS << "public symbol: " << getName();
+}
index eac1a54..dc24507 100644 (file)
@@ -22,23 +22,21 @@ PDBSymbolThunk::PDBSymbolThunk(const IPDBSession &PDBSession,
 
 void PDBSymbolThunk::dump(raw_ostream &OS, int Indent,
                           PDB_DumpLevel Level) const {
-  if (Level == PDB_DumpLevel::Compact) {
-    OS.indent(Indent);
-    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 << " thunk(" << Ordinal << ")";
-    if (Ordinal == PDB_ThunkOrdinal::TrampIncremental)
-      OS << " -> " << format_hex(getTargetRelativeVirtualAddress(), 10);
-    OS << " ";
-    std::string Name = getName();
-    if (!Name.empty())
-      OS << Name;
-    OS << "\n";
+  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;
 }
index 856d3aa..3a3c6f1 100644 (file)
@@ -9,6 +9,7 @@
 
 #include <utility>
 
+#include "llvm/DebugInfo/PDB/IPDBSession.h"
 #include "llvm/DebugInfo/PDB/PDBSymbol.h"
 #include "llvm/DebugInfo/PDB/PDBSymbolTypeArray.h"
 
@@ -19,4 +20,11 @@ PDBSymbolTypeArray::PDBSymbolTypeArray(const IPDBSession &PDBSession,
     : PDBSymbol(PDBSession, std::move(Symbol)) {}
 
 void PDBSymbolTypeArray::dump(raw_ostream &OS, int Indent,
-                              PDB_DumpLevel Level) const {}
+                              PDB_DumpLevel Level) const {
+  OS << stream_indent(Indent);
+  if (auto ElementType = Session.getSymbolById(getTypeId()))
+    ElementType->dump(OS, 0, PDB_DumpLevel::Compact);
+  else
+    OS << "<unknown-element-type>";
+  OS << "[" << getLength() << "]";
+}
index 31a2e51..5aa73e8 100644 (file)
@@ -19,4 +19,7 @@ PDBSymbolTypeBaseClass::PDBSymbolTypeBaseClass(
     : PDBSymbol(PDBSession, std::move(Symbol)) {}
 
 void PDBSymbolTypeBaseClass::dump(raw_ostream &OS, int Indent,
-                                  PDB_DumpLevel Level) const {}
+                                  PDB_DumpLevel Level) const {
+  OS << stream_indent(Indent);
+  OS << "<base class> " << getName();
+}
index 1a68f8c..8297751 100644 (file)
@@ -19,4 +19,10 @@ PDBSymbolTypeBuiltin::PDBSymbolTypeBuiltin(
     : PDBSymbol(PDBSession, std::move(Symbol)) {}
 
 void PDBSymbolTypeBuiltin::dump(raw_ostream &OS, int Indent,
-                                PDB_DumpLevel Level) const {}
+                                PDB_DumpLevel Level) const {
+  OS << stream_indent(Indent);
+  PDB_BuiltinType Type = getBuiltinType();
+  OS << Type;
+  if (Type == PDB_BuiltinType::UInt || Type == PDB_BuiltinType::Int)
+    OS << (8 * getLength()) << "_t";
+}
index 4bc3b7b..cc84b1c 100644 (file)
@@ -9,6 +9,7 @@
 
 #include <utility>
 
+#include "llvm/DebugInfo/PDB/IPDBSession.h"
 #include "llvm/DebugInfo/PDB/PDBSymbol.h"
 #include "llvm/DebugInfo/PDB/PDBSymbolTypeEnum.h"
 
@@ -19,4 +20,17 @@ PDBSymbolTypeEnum::PDBSymbolTypeEnum(const IPDBSession &PDBSession,
     : PDBSymbol(PDBSession, std::move(Symbol)) {}
 
 void PDBSymbolTypeEnum::dump(raw_ostream &OS, int Indent,
-                             PDB_DumpLevel Level) const {}
+                             PDB_DumpLevel Level) 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);
+      OS << "::";
+    }
+  }
+  OS << getName();
+}
index 86c337d..2f5be7c 100644 (file)
@@ -9,6 +9,7 @@
 
 #include <utility>
 
+#include "llvm/DebugInfo/PDB/IPDBSession.h"
 #include "llvm/DebugInfo/PDB/PDBSymbol.h"
 #include "llvm/DebugInfo/PDB/PDBSymbolTypeFunctionArg.h"
 
@@ -19,4 +20,10 @@ PDBSymbolTypeFunctionArg::PDBSymbolTypeFunctionArg(
     : PDBSymbol(PDBSession, std::move(Symbol)) {}
 
 void PDBSymbolTypeFunctionArg::dump(raw_ostream &OS, int Indent,
-                                    PDB_DumpLevel Level) const {}
+                                    PDB_DumpLevel Level) const {
+  OS << stream_indent(Indent);
+  uint32_t TypeId = getTypeId();
+  if (auto Type = Session.getSymbolById(TypeId)) {
+    Type->dump(OS, 0, Level);
+  }
+}
index 99953ad..90d009a 100644 (file)
@@ -9,7 +9,11 @@
 
 #include <utility>
 
+#include "llvm/DebugInfo/PDB/ConcreteSymbolEnumerator.h"
+#include "llvm/DebugInfo/PDB/IPDBEnumChildren.h"
+#include "llvm/DebugInfo/PDB/IPDBSession.h"
 #include "llvm/DebugInfo/PDB/PDBSymbol.h"
+#include "llvm/DebugInfo/PDB/PDBSymbolTypeFunctionArg.h"
 #include "llvm/DebugInfo/PDB/PDBSymbolTypeFunctionSig.h"
 
 using namespace llvm;
@@ -19,4 +23,36 @@ PDBSymbolTypeFunctionSig::PDBSymbolTypeFunctionSig(
     : PDBSymbol(PDBSession, std::move(Symbol)) {}
 
 void PDBSymbolTypeFunctionSig::dump(raw_ostream &OS, int Indent,
-                                    PDB_DumpLevel Level) const {}
+                                    PDB_DumpLevel Level) const {
+  OS << stream_indent(Indent);
+
+  uint32_t ReturnTypeId = getTypeId();
+  if (auto ReturnType = Session.getSymbolById(ReturnTypeId)) {
+    ReturnType->dump(OS, 0, PDB_DumpLevel::Compact);
+    OS << " ";
+  }
+  // TODO: We need a way to detect if this is a pointer to function so that we
+  // can print the * between the return type and the argument list.  The only
+  // way to do this is to pass the parent into this function, but that will
+  // require a larger interface change.
+  OS << getCallingConvention() << " ";
+  uint32_t ClassId = getClassParentId();
+  if (ClassId != 0) {
+    if (auto ClassParent = Session.getSymbolById(ClassId)) {
+      OS << "(";
+      ClassParent->dump(OS, 0, PDB_DumpLevel::Compact);
+      OS << "::*)";
+    }
+  }
+  OS.flush();
+  OS << "(";
+  if (auto ChildEnum = findAllChildren<PDBSymbolTypeFunctionArg>()) {
+    uint32_t Index = 0;
+    while (auto Arg = ChildEnum->getNext()) {
+      Arg->dump(OS, 0, PDB_DumpLevel::Compact);
+      if (++Index < ChildEnum->getChildCount())
+        OS << ", ";
+    }
+  }
+  OS << ")";
+}
index a6625b3..2fd4314 100644 (file)
@@ -10,6 +10,7 @@
 
 #include <utility>
 
+#include "llvm/DebugInfo/PDB/IPDBSession.h"
 #include "llvm/DebugInfo/PDB/PDBSymbol.h"
 #include "llvm/DebugInfo/PDB/PDBSymbolTypePointer.h"
 
@@ -20,4 +21,14 @@ PDBSymbolTypePointer::PDBSymbolTypePointer(
     : PDBSymbol(PDBSession, std::move(Symbol)) {}
 
 void PDBSymbolTypePointer::dump(raw_ostream &OS, int Indent,
-                                PDB_DumpLevel Level) const {}
+                                PDB_DumpLevel Level) const {
+  OS << stream_indent(Indent);
+  if (isConstType())
+    OS << "const ";
+  if (isVolatileType())
+    OS << "volatile ";
+  uint32_t PointeeId = getTypeId();
+  if (auto PointeeType = Session.getSymbolById(PointeeId))
+    PointeeType->dump(OS, 0, PDB_DumpLevel::Compact);
+  OS << ((isReference()) ? "&" : "*");
+}
index 74cfeeb..c081a5c 100644 (file)
@@ -23,11 +23,16 @@ PDBSymbolTypeTypedef::PDBSymbolTypeTypedef(
 void PDBSymbolTypeTypedef::dump(raw_ostream &OS, int Indent,
                                 PDB_DumpLevel Level) const {
   OS.indent(Indent);
-  OS << "typedef:" << getName() << " -> ";
-  std::string TargetTypeName;
-  auto TypeSymbol = Session.getSymbolById(getTypeId());
-  if (PDBSymbolTypeUDT *UDT = dyn_cast<PDBSymbolTypeUDT>(TypeSymbol.get())) {
-    TargetTypeName = UDT->getName();
+  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);
+    }
+    OS << TargetTypeName;
+  } else {
+    OS << getName();
   }
-  OS << TargetTypeName << "\n";
 }
index 13f6223..147045a 100644 (file)
@@ -9,6 +9,7 @@
 
 #include <utility>
 
+#include "llvm/DebugInfo/PDB/IPDBSession.h"
 #include "llvm/DebugInfo/PDB/PDBSymbol.h"
 #include "llvm/DebugInfo/PDB/PDBSymbolTypeUDT.h"
 
@@ -19,4 +20,22 @@ PDBSymbolTypeUDT::PDBSymbolTypeUDT(const IPDBSession &PDBSession,
     : PDBSymbol(PDBSession, std::move(Symbol)) {}
 
 void PDBSymbolTypeUDT::dump(raw_ostream &OS, int Indent,
-                            PDB_DumpLevel Level) const {}
+                            PDB_DumpLevel Level) 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);
+        OS << "::";
+      }
+    }
+  }
+  OS << getName();
+
+  if (Level >= PDB_DumpLevel::Normal)
+    OS << " (" << getLength() << " bytes)";
+}
index 31c41d1..6eee2ff 100644 (file)
@@ -9,8 +9,11 @@
 
 #include <utility>
 
+#include "llvm/DebugInfo/PDB/IPDBSession.h"
 #include "llvm/DebugInfo/PDB/PDBSymbol.h"
+#include "llvm/DebugInfo/PDB/PDBSymbolTypePointer.h"
 #include "llvm/DebugInfo/PDB/PDBSymbolTypeVTable.h"
+#include "llvm/DebugInfo/PDB/PDBSymbolTypeVTableShape.h"
 
 using namespace llvm;
 
@@ -19,4 +22,20 @@ PDBSymbolTypeVTable::PDBSymbolTypeVTable(const IPDBSession &PDBSession,
     : PDBSymbol(PDBSession, std::move(Symbol)) {}
 
 void PDBSymbolTypeVTable::dump(raw_ostream &OS, int Indent,
-                               PDB_DumpLevel Level) const {}
+                               PDB_DumpLevel Level) const {
+  OS << stream_indent(Indent);
+  uint32_t ClassId = getClassParentId();
+  if (auto ClassParent = Session.getSymbolById(ClassId)) {
+    ClassParent->dump(OS, 0, PDB_DumpLevel::Compact);
+    OS << "::";
+  }
+  OS << "<vtbl> ";
+  if (auto VtblPointer =
+          Session.getConcreteSymbolById<PDBSymbolTypePointer>(getTypeId())) {
+    if (auto VtblShape =
+            Session.getConcreteSymbolById<PDBSymbolTypeVTableShape>(
+                VtblPointer->getTypeId()))
+      OS << "(" << VtblShape->getCount() << " entries)";
+  }
+  OS.flush();
+}
index 6f66a4c..ce79c79 100644 (file)
@@ -65,7 +65,8 @@ static void dumpInput(StringRef Path) {
   if (opts::Compilands) {
     auto Compilands = GlobalScope->findAllChildren<PDBSymbolCompiland>();
     while (auto Compiland = Compilands->getNext()) {
-      Compiland->dump(outs(), 0, PDB_DumpLevel::Normal);
+      Compiland->dump(outs(), 0, PDB_DumpLevel::Detailed);
+      outs() << "\n";
     }
   }
   outs().flush();