[llvm] r229232 - llvm-pdbdump: Only dump whitelisted global symbols.

Zachary Turner zturner at google.com
Fri Feb 13 19:54:29 PST 2015


Author: zturner
Date: Fri Feb 13 21:54:28 2015
New Revision: 229232

URL: http://llvm.org/viewvc/llvm-project?rev=229232&view=rev
Log:
llvm-pdbdump: Only dump whitelisted global symbols.

Dumping the global scope contains a lot of very uninteresting
things and is generally polluted with a lot of random junk.
Furthermore, it dumps values unsorted, making it hard to read.
This patch dumps known interesting types only, and as a side
effect sorts the list by symbol type.

Modified:
    llvm/trunk/include/llvm/DebugInfo/PDB/PDBSymbol.h
    llvm/trunk/include/llvm/DebugInfo/PDB/PDBSymbolExe.h
    llvm/trunk/lib/DebugInfo/PDB/PDBSymbol.cpp
    llvm/trunk/lib/DebugInfo/PDB/PDBSymbolExe.cpp
    llvm/trunk/lib/DebugInfo/PDB/PDBSymbolFunc.cpp

Modified: llvm/trunk/include/llvm/DebugInfo/PDB/PDBSymbol.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/PDBSymbol.h?rev=229232&r1=229231&r2=229232&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/PDB/PDBSymbol.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/PDB/PDBSymbol.h Fri Feb 13 21:54:28 2015
@@ -68,8 +68,9 @@ public:
     auto BaseIter = RawSymbol->findChildren(T::Tag);
     return llvm::make_unique<ConcreteSymbolEnumerator<T>>(std::move(BaseIter));
   }
-
+  std::unique_ptr<IPDBEnumSymbols> findAllChildren(PDB_SymType Type) const;
   std::unique_ptr<IPDBEnumSymbols> findAllChildren() const;
+
   std::unique_ptr<IPDBEnumSymbols>
   findChildren(PDB_SymType Type, StringRef Name,
                PDB_NameSearchFlags Flags) const;

Modified: llvm/trunk/include/llvm/DebugInfo/PDB/PDBSymbolExe.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/PDBSymbolExe.h?rev=229232&r1=229231&r2=229232&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/PDB/PDBSymbolExe.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/PDB/PDBSymbolExe.h Fri Feb 13 21:54:28 2015
@@ -36,6 +36,10 @@ public:
   FORWARD_SYMBOL_METHOD(getSignature)
   FORWARD_SYMBOL_METHOD(getSymbolsFileName)
   FORWARD_SYMBOL_METHOD(getSymIndexId)
+
+private:
+  void dumpChildren(raw_ostream &OS, StringRef Label, PDB_SymType ChildType,
+                    int Indent) const;
 };
 } // namespace llvm
 

Modified: llvm/trunk/lib/DebugInfo/PDB/PDBSymbol.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/PDBSymbol.cpp?rev=229232&r1=229231&r2=229232&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/PDB/PDBSymbol.cpp (original)
+++ llvm/trunk/lib/DebugInfo/PDB/PDBSymbol.cpp Fri Feb 13 21:54:28 2015
@@ -108,7 +108,12 @@ void PDBSymbol::defaultDump(raw_ostream
 PDB_SymType PDBSymbol::getSymTag() const { return RawSymbol->getSymTag(); }
 
 std::unique_ptr<IPDBEnumSymbols> PDBSymbol::findAllChildren() const {
-  return RawSymbol->findChildren(PDB_SymType::None);
+  return findAllChildren(PDB_SymType::None);
+}
+
+std::unique_ptr<IPDBEnumSymbols>
+PDBSymbol::findAllChildren(PDB_SymType Type) const {
+  return RawSymbol->findChildren(Type);
 }
 
 std::unique_ptr<IPDBEnumSymbols>

Modified: llvm/trunk/lib/DebugInfo/PDB/PDBSymbolExe.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/PDBSymbolExe.cpp?rev=229232&r1=229231&r2=229232&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/PDB/PDBSymbolExe.cpp (original)
+++ llvm/trunk/lib/DebugInfo/PDB/PDBSymbolExe.cpp Fri Feb 13 21:54:28 2015
@@ -46,31 +46,34 @@ void PDBSymbolExe::dump(raw_ostream &OS,
     OS << "HasPrivateSymbols ";
   OS << "\n";
 
-  TagStats Stats;
-  auto ChildrenEnum = getChildStats(Stats);
-  OS << stream_indent(Indent + 2) << "Children: " << Stats << "\n";
+  auto ChildrenEnum = findAllChildren();
+  OS << stream_indent(Indent + 2) << ChildrenEnum->getChildCount()
+     << " children\n";
+#if 0
+  dumpChildren(OS, PDB_SymType::None, Indent+4);
+#else
+  dumpChildren(OS, "Compilands", PDB_SymType::Compiland, Indent + 4);
+  dumpChildren(OS, "Functions", PDB_SymType::Function, Indent + 4);
+  dumpChildren(OS, "Blocks", PDB_SymType::Block, Indent + 4);
+  dumpChildren(OS, "Data", PDB_SymType::Data, Indent + 4);
+  dumpChildren(OS, "Labels", PDB_SymType::Label, Indent + 4);
+  dumpChildren(OS, "Public Symbols", PDB_SymType::PublicSymbol, Indent + 4);
+  dumpChildren(OS, "UDTs", PDB_SymType::UDT, Indent + 4);
+  dumpChildren(OS, "Enums", PDB_SymType::Enum, Indent + 4);
+  dumpChildren(OS, "Function Signatures", PDB_SymType::FunctionSig, Indent + 4);
+  dumpChildren(OS, "Typedefs", PDB_SymType::Typedef, Indent + 4);
+  dumpChildren(OS, "VTables", PDB_SymType::VTable, Indent + 4);
+  dumpChildren(OS, "Thunks", PDB_SymType::Thunk, Indent + 4);
+#endif
+}
+
+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()) {
-    // Skip uninteresting types.  These are useful to print as part of type
-    // hierarchies, but as general children of the global scope, they are
-    // not very interesting.
-    switch (Child->getSymTag()) {
-    case PDB_SymType::ArrayType:
-    case PDB_SymType::BaseClass:
-    case PDB_SymType::BuiltinType:
-    case PDB_SymType::CompilandEnv:
-    case PDB_SymType::CustomType:
-    case PDB_SymType::Dimension:
-    case PDB_SymType::Friend:
-    case PDB_SymType::ManagedType:
-    case PDB_SymType::VTableShape:
-    case PDB_SymType::PointerType:
-    case PDB_SymType::FunctionSig:
-    case PDB_SymType::FunctionArg:
-      continue;
-    default:
-      break;
-    }
-    Child->dump(OS, Indent + 4, PDB_DumpLevel::Normal);
+    Child->dump(OS, Indent + 2, PDB_DumpLevel::Normal);
     OS << "\n";
   }
 }

Modified: llvm/trunk/lib/DebugInfo/PDB/PDBSymbolFunc.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/PDBSymbolFunc.cpp?rev=229232&r1=229231&r2=229232&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/PDB/PDBSymbolFunc.cpp (original)
+++ llvm/trunk/lib/DebugInfo/PDB/PDBSymbolFunc.cpp Fri Feb 13 21:54:28 2015
@@ -31,6 +31,10 @@ std::unique_ptr<PDBSymbolTypeFunctionSig
 void PDBSymbolFunc::dump(raw_ostream &OS, int Indent,
                          PDB_DumpLevel Level) const {
   OS << stream_indent(Indent);
+  // if (getName() == "__crtCreateThreadpoolWait") {
+  //  RawSymbol->dump(OS, Indent+2, Level);
+  //  OS.flush();
+  //}
   if (Level >= PDB_DumpLevel::Normal) {
     uint32_t FuncStart = getRelativeVirtualAddress();
     uint32_t FuncEnd = FuncStart + getLength();





More information about the llvm-commits mailing list