From 08eb343cce893e2594de62f1ab976ed03536cb56 Mon Sep 17 00:00:00 2001 From: Adrian McCarthy Date: Mon, 10 Apr 2017 16:43:09 +0000 Subject: [PATCH] Improves pretty printing of variable types in llvm-pdbdump * Adds support for pointers to arrays, which was missing * Adds some tests * Improves consistency of const and volatile qualifiers * Eliminates non-composable special case code for arrays and function by using a more general recursive approach * Has a hack for getting the calling convention into the right spot for pointer-to-functions Given the rapid changes happenning in llvm-pdbdump, this may be difficult to merge. Differential Revision: https://reviews.llvm.org/D31832 llvm-svn: 299848 --- .../include/llvm/DebugInfo/PDB/PDBSymDumper.h | 16 ++ llvm/include/llvm/DebugInfo/PDB/PDBSymbol.h | 5 + .../llvm/DebugInfo/PDB/PDBSymbolTypeArray.h | 1 + .../DebugInfo/PDB/PDBSymbolTypeFunctionSig.h | 1 + .../llvm/DebugInfo/PDB/PDBSymbolTypePointer.h | 1 + llvm/lib/DebugInfo/PDB/PDBSymbolTypeArray.cpp | 4 + .../PDB/PDBSymbolTypeFunctionSig.cpp | 4 + .../DebugInfo/PDB/PDBSymbolTypePointer.cpp | 4 + .../PDB/DIA/pdbdump-linenumbers.test | 14 +- .../PDB/DIA/pdbdump-symbol-format.test | 15 +- .../DebugInfo/PDB/Inputs/symbolformat.cpp | 8 + .../DebugInfo/PDB/Inputs/symbolformat.pdb | Bin 35840 -> 44032 bytes .../llvm-pdbdump/PrettyBuiltinDumper.cpp | 4 + .../llvm-pdbdump/PrettyVariableDumper.cpp | 137 +++++++++++------- .../tools/llvm-pdbdump/PrettyVariableDumper.h | 6 +- 15 files changed, 155 insertions(+), 65 deletions(-) diff --git a/llvm/include/llvm/DebugInfo/PDB/PDBSymDumper.h b/llvm/include/llvm/DebugInfo/PDB/PDBSymDumper.h index 095c33cfe8b5..c976935c48e0 100644 --- a/llvm/include/llvm/DebugInfo/PDB/PDBSymDumper.h +++ b/llvm/include/llvm/DebugInfo/PDB/PDBSymDumper.h @@ -54,6 +54,22 @@ public: virtual void dump(const PDBSymbolUnknown &Symbol); virtual void dump(const PDBSymbolUsingNamespace &Symbol); + virtual void dumpRight(const PDBSymbolTypeArray &Symbol) {} + virtual void dumpRight(const PDBSymbolTypeBaseClass &Symbol) {} + virtual void dumpRight(const PDBSymbolTypeBuiltin &Symbol) {} + virtual void dumpRight(const PDBSymbolTypeCustom &Symbol) {} + virtual void dumpRight(const PDBSymbolTypeDimension &Symbol) {} + virtual void dumpRight(const PDBSymbolTypeEnum &Symbol) {} + virtual void dumpRight(const PDBSymbolTypeFriend &Symbol) {} + virtual void dumpRight(const PDBSymbolTypeFunctionArg &Symbol) {} + virtual void dumpRight(const PDBSymbolTypeFunctionSig &Symbol) {} + virtual void dumpRight(const PDBSymbolTypeManaged &Symbol) {} + virtual void dumpRight(const PDBSymbolTypePointer &Symbol) {} + virtual void dumpRight(const PDBSymbolTypeTypedef &Symbol) {} + virtual void dumpRight(const PDBSymbolTypeUDT &Symbol) {} + virtual void dumpRight(const PDBSymbolTypeVTable &Symbol) {} + virtual void dumpRight(const PDBSymbolTypeVTableShape &Symbol) {} + private: bool RequireImpl; }; diff --git a/llvm/include/llvm/DebugInfo/PDB/PDBSymbol.h b/llvm/include/llvm/DebugInfo/PDB/PDBSymbol.h index e85d22875cb6..652f21361056 100644 --- a/llvm/include/llvm/DebugInfo/PDB/PDBSymbol.h +++ b/llvm/include/llvm/DebugInfo/PDB/PDBSymbol.h @@ -74,6 +74,11 @@ public: /// unknown properties, but individual implementations of PDBSymbol may /// override the behavior to only dump known fields. virtual void dump(PDBSymDumper &Dumper) const = 0; + + /// For certain PDBSymbolTypes, dumps additional information for the type that + /// normally goes on the right side of the symbol. + virtual void dumpRight(PDBSymDumper &Dumper) const {} + void defaultDump(raw_ostream &OS, int Indent) const; void dumpProperties() const; void dumpChildStats() const; diff --git a/llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypeArray.h b/llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypeArray.h index b70d0e852d9e..39b7d3b300ea 100644 --- a/llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypeArray.h +++ b/llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypeArray.h @@ -26,6 +26,7 @@ public: DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::ArrayType) void dump(PDBSymDumper &Dumper) const override; + void dumpRight(PDBSymDumper &Dumper) const override; FORWARD_SYMBOL_ID_METHOD(getArrayIndexType) FORWARD_SYMBOL_METHOD(isConstType) diff --git a/llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypeFunctionSig.h b/llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypeFunctionSig.h index a716cd324b7e..8de54e70701d 100644 --- a/llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypeFunctionSig.h +++ b/llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypeFunctionSig.h @@ -28,6 +28,7 @@ public: std::unique_ptr getArguments() const; void dump(PDBSymDumper &Dumper) const override; + void dumpRight(PDBSymDumper &Dumper) const override; void dumpArgList(raw_ostream &OS) const; FORWARD_SYMBOL_METHOD(getCallingConvention) diff --git a/llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypePointer.h b/llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypePointer.h index 47cfc8a34dbb..c502d4e77afe 100644 --- a/llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypePointer.h +++ b/llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypePointer.h @@ -26,6 +26,7 @@ public: DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::PointerType) void dump(PDBSymDumper &Dumper) const override; + void dumpRight(PDBSymDumper &Dumper) const override; FORWARD_SYMBOL_METHOD(isConstType) FORWARD_SYMBOL_METHOD(getLength) diff --git a/llvm/lib/DebugInfo/PDB/PDBSymbolTypeArray.cpp b/llvm/lib/DebugInfo/PDB/PDBSymbolTypeArray.cpp index cf9b6fee98da..a8054a42d866 100644 --- a/llvm/lib/DebugInfo/PDB/PDBSymbolTypeArray.cpp +++ b/llvm/lib/DebugInfo/PDB/PDBSymbolTypeArray.cpp @@ -26,3 +26,7 @@ PDBSymbolTypeArray::PDBSymbolTypeArray(const IPDBSession &PDBSession, void PDBSymbolTypeArray::dump(PDBSymDumper &Dumper) const { Dumper.dump(*this); } + +void PDBSymbolTypeArray::dumpRight(PDBSymDumper &Dumper) const { + Dumper.dumpRight(*this); +} diff --git a/llvm/lib/DebugInfo/PDB/PDBSymbolTypeFunctionSig.cpp b/llvm/lib/DebugInfo/PDB/PDBSymbolTypeFunctionSig.cpp index 1d53c7daabf0..473529d1b043 100644 --- a/llvm/lib/DebugInfo/PDB/PDBSymbolTypeFunctionSig.cpp +++ b/llvm/lib/DebugInfo/PDB/PDBSymbolTypeFunctionSig.cpp @@ -80,3 +80,7 @@ PDBSymbolTypeFunctionSig::getArguments() const { void PDBSymbolTypeFunctionSig::dump(PDBSymDumper &Dumper) const { Dumper.dump(*this); } + +void PDBSymbolTypeFunctionSig::dumpRight(PDBSymDumper &Dumper) const { + Dumper.dumpRight(*this); +} diff --git a/llvm/lib/DebugInfo/PDB/PDBSymbolTypePointer.cpp b/llvm/lib/DebugInfo/PDB/PDBSymbolTypePointer.cpp index f93b12d11adc..69819811d61f 100644 --- a/llvm/lib/DebugInfo/PDB/PDBSymbolTypePointer.cpp +++ b/llvm/lib/DebugInfo/PDB/PDBSymbolTypePointer.cpp @@ -26,3 +26,7 @@ PDBSymbolTypePointer::PDBSymbolTypePointer( void PDBSymbolTypePointer::dump(PDBSymDumper &Dumper) const { Dumper.dump(*this); } + +void PDBSymbolTypePointer::dumpRight(PDBSymDumper &Dumper) const { + Dumper.dumpRight(*this); +} diff --git a/llvm/test/DebugInfo/PDB/DIA/pdbdump-linenumbers.test b/llvm/test/DebugInfo/PDB/DIA/pdbdump-linenumbers.test index 780e0db84665..2a596e4af149 100644 --- a/llvm/test/DebugInfo/PDB/DIA/pdbdump-linenumbers.test +++ b/llvm/test/DebugInfo/PDB/DIA/pdbdump-linenumbers.test @@ -1,12 +1,14 @@ +; RUN: llvm-pdbdump pretty -lines %p/../Inputs/symbolformat.pdb | FileCheck --check-prefix=LINE_NUMS_FPO %s ; RUN: llvm-pdbdump pretty -lines %p/../Inputs/symbolformat.pdb | FileCheck --check-prefix=LINE_NUMS %s -; LINE_NUMS: llvm\test\debuginfo\pdb\inputs\symbolformat-fpo.cpp -; LINE_NUMS: Line 5, Address: [0x000011a0 - 0x000011a5] (6 bytes) -; LINE_NUMS: Line 6, Address: [0x000011a6 - 0x000011a6] (1 bytes) +; LINE_NUMS_FPO: llvm\test\debuginfo\pdb\inputs\symbolformat-fpo.cpp +; LINE_NUMS_FPO: Line 5, Address: [0x000011a0 - 0x000011a5] (6 bytes) +; LINE_NUMS_FPO: Line 6, Address: [0x000011a6 - 0x000011a6] (1 bytes) + ; LINE_NUMS: llvm\test\debuginfo\pdb\inputs\symbolformat.cpp ; LINE_NUMS: Line 6, Address: [0x00001060 - 0x00001066] (7 bytes) -; LINE_NUMS: Line 72, Address: [0x000010d0 - 0x000010d1] (2 bytes) -; LINE_NUMS: Line 73, Address: [0x000010d2 - 0x000010d5] (4 bytes) +; LINE_NUMS: Line 80, Address: [0x000010d0 - 0x000010d1] (2 bytes) +; LINE_NUMS: Line 81, Address: [0x000010d2 - 0x000010d5] (4 bytes) ; LINE_NUMS: Line 28, Address: [0x00001170 - 0x0000117a] (11 bytes) ; LINE_NUMS: Line 21, Address: [0x00001180 - 0x0000118a] (11 bytes) -; LINE_NUMS: Line 20, Address: [0x00001190 - 0x0000119a] (11 bytes) \ No newline at end of file +; LINE_NUMS: Line 20, Address: [0x00001190 - 0x0000119a] (11 bytes) diff --git a/llvm/test/DebugInfo/PDB/DIA/pdbdump-symbol-format.test b/llvm/test/DebugInfo/PDB/DIA/pdbdump-symbol-format.test index 4116deb99227..697a723c483a 100644 --- a/llvm/test/DebugInfo/PDB/DIA/pdbdump-symbol-format.test +++ b/llvm/test/DebugInfo/PDB/DIA/pdbdump-symbol-format.test @@ -1,3 +1,4 @@ +; RUN: llvm-pdbdump pretty -symbols %p/../Inputs/symbolformat.pdb | FileCheck --check-prefix=SYM_FORMAT_FPO %s ; RUN: llvm-pdbdump pretty -symbols %p/../Inputs/symbolformat.pdb | FileCheck --check-prefix=SYM_FORMAT %s ; RUN: llvm-pdbdump pretty -types %p/../Inputs/symbolformat.pdb > %t.types ; RUN: FileCheck --check-prefix=TYPES_FORMAT %s < %t.types @@ -7,9 +8,11 @@ ; RUN: llvm-pdbdump pretty -globals %p/../Inputs/symbolformat.pdb | FileCheck --check-prefix=GLOBALS %s ; The format is func [0x+ - 0x-] +; SYM_FORMAT_FPO: ---SYMBOLS--- +; SYM_FORMAT_FPO: symbolformat-fpo.obj +; SYM_FORMAT-FPO: func [{{.*}}] (FPO) unsigned int __cdecl fpo_func(unsigned int n) + ; SYM_FORMAT: ---SYMBOLS--- -; SYM_FORMAT: symbolformat-fpo.obj -; SYM_FORMAT-DAG: func [{{.*}}] (FPO) unsigned int __cdecl fpo_func(unsigned int n) ; SYM_FORMAT: symbolformat.obj ; SYM_FORMAT-DAG: func [{{.*}}] (EBP) int __cdecl _purecall() ; SYM_FORMAT-DAG: func [{{.*}}] (EBP) int __cdecl main(int argc, char** argv) @@ -50,10 +53,16 @@ ; TYPES_2: data +0x28 unsigned __int64 m_unsigned_int64 ; TYPES_2: data +0x30 float m_float ; TYPES_2: data +0x38 double m_double -; TYPES_2: data +0x40 void (__cdecl *m_pfn_2_args)(int, double) +; TYPES_2: data +0x40 void (__cdecl * m_pfn_2_args)(int, double) +; TYPES_2: data +0x44 int m_multidimensional_array[2][3] ; TYPES_2: } ; GLOBALS: ---GLOBALS--- ; GLOBALS-DAG: func [{{.*}}] (FPO) unsigned int __cdecl fpo_func(unsigned int n) ; GLOBALS-DAG: data [{{.*}}] static void* g_global_pointer ; GLOBALS-DAG: data [{{.*}}] static int g_global_int +; GLOBALS-DAG: data [{{.*}}] static int g_array[3] +; GLOBALS-DAG: data [{{.*}}] static int (* g_pointer_to_array)[3] +; GLOBALS-DAG: data [{{.*}}] static const int* g_pointer_to_const_int +; GLOBALS-DAG: data int* const g_const_pointer_to_int = 0 +; GLOBALS-DAG: data const int* const g_const_pointer_to_const_int = 0 diff --git a/llvm/test/DebugInfo/PDB/Inputs/symbolformat.cpp b/llvm/test/DebugInfo/PDB/Inputs/symbolformat.cpp index 5479b717cd9d..14b44ae3c316 100644 --- a/llvm/test/DebugInfo/PDB/Inputs/symbolformat.cpp +++ b/llvm/test/DebugInfo/PDB/Inputs/symbolformat.cpp @@ -50,6 +50,7 @@ struct MemberTest { float m_float; double m_double; void (*m_pfn_2_args)(int, double); + int m_multidimensional_array[2][3]; }; typedef int IntType; @@ -58,6 +59,13 @@ typedef A ClassAType; int g_global_int; void *g_global_pointer = nullptr; +typedef int int_array[3]; +int_array g_array = { 1, 2, 3 }; +int_array *g_pointer_to_array = &g_array; +const int *g_pointer_to_const_int = nullptr; +int * const g_const_pointer_to_int = nullptr; +const int * const g_const_pointer_to_const_int = nullptr; + int main(int argc, char **argv) { // Force symbol references so the linker generates debug info B b; diff --git a/llvm/test/DebugInfo/PDB/Inputs/symbolformat.pdb b/llvm/test/DebugInfo/PDB/Inputs/symbolformat.pdb index 53d8a1b31a39c68c3f29c570f8dc87c179a26b6a..0e509f3a93c33fa65471692bb69155effebdb7d4 100644 GIT binary patch delta 5746 zcmb_geQZ4p$OYCARwAqffCCVU4PKFVktNF3VT{~^8Or)8#Nn2aksKm6cqG~r)8r9g;t(w#h!rH3s7}@VUKL?LN z*&n;gFX!IhJ@>qO&b{}%>o;;-HS&&XyviUE(cQo~fJ@Dk!~7d{rdF+ekFHM{G?&%F ztjX0}xt66(wdQ0WvpJ-sag#R_-&GL=XF;Q0WkV>NwM=Qdrm_~fQ=%x5-qLEBkSPO~4 zv>tL9fn4j=}M0>^(+RQ4_QvIWbTL324^!eK2ij3;;WY|nh* zvKC0?V!~QbyZ~A~0CxOre+}AZNqoz?yHJlPIq_$U`aCfYQ86tu92D8M1@Z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S?Eb*xuH~CQt@Re3WcIu(T+u{(4LJ}IXQT4*m<0zxxWt$=XU9Or$TqK ze!pg0b8F7~+_}R0dG9HBFFq;5p$lNYwN0sm&huK9

xA&nC{!1GX4O0l#o5WV#S4sgojI#B zEb1=OSa2nub7Hfg&h`)`LKcd*d+3W$sS>~vZ}#vM`Nv@9(=jJSvR@2NM}Ah%w;8Uq zPgW(P$5RuQjAihVmYOtS@y(V48g8x3h~+Jfnup41d}vpuKk=%XsW|0QvcAKQig)mJ zMKUX3c+;i?Vk=<$`} n1gZfmPzsa)e0=k)JV`mg@3#mj25NxXbYz#tn( + ClassParentId); + + if (ClassParent) { + WithColor(Printer, PDB_ColorItem::Identifier).get() + << ClassParent->getName(); + Printer << "::"; + } +} + +void VariableDumper::dumpRight(const PDBSymbolTypeFunctionSig &Symbol) { + Printer << "("; + if (auto Arguments = Symbol.getArguments()) { + uint32_t Index = 0; + while (auto Arg = Arguments->getNext()) { + Arg->dump(*this); + if (++Index < Arguments->getChildCount()) + Printer << ", "; + } + } + Printer << ")"; + + if (Symbol.isConstType()) + WithColor(Printer, PDB_ColorItem::Keyword).get() << " const"; + if (Symbol.isVolatileType()) + WithColor(Printer, PDB_ColorItem::Keyword).get() << " volatile"; +} void VariableDumper::dump(const PDBSymbolTypePointer &Symbol) { auto PointeeType = Symbol.getPointeeType(); if (!PointeeType) return; - - if (auto Func = PointeeType->cast()) { - FunctionDumper NestedDumper(Printer); - FunctionDumper::PointerType Pointer = - Symbol.isReference() ? FunctionDumper::PointerType::Reference - : FunctionDumper::PointerType::Pointer; - NestedDumper.start(*Func, Pointer); - } else { - if (Symbol.isConstType()) - WithColor(Printer, PDB_ColorItem::Keyword).get() << "const "; - if (Symbol.isVolatileType()) - WithColor(Printer, PDB_ColorItem::Keyword).get() << "volatile "; - PointeeType->dump(*this); - Printer << (Symbol.isReference() ? "&" : "*"); + PointeeType->dump(*this); + if (auto Func = PointeeType->cast()) { + // A hack to get the calling convention in the right spot. + Printer << " ("; + PDB_CallingConv CC = Func->getCallingConvention(); + WithColor(Printer, PDB_ColorItem::Keyword).get() << CC << " "; + } else if (isa(PointeeType.get())) { + Printer << " ("; } + Printer << (Symbol.isReference() ? "&" : "*"); + if (Symbol.isConstType()) + WithColor(Printer, PDB_ColorItem::Keyword).get() << " const "; + if (Symbol.isVolatileType()) + WithColor(Printer, PDB_ColorItem::Keyword).get() << " volatile "; +} + +void VariableDumper::dumpRight(const PDBSymbolTypePointer &Symbol) { + auto PointeeType = Symbol.getPointeeType(); + assert(PointeeType); + if (!PointeeType) + return; + if (isa(PointeeType.get()) || + isa(PointeeType.get())) { + Printer << ")"; + } + PointeeType->dumpRight(*this); } void VariableDumper::dump(const PDBSymbolTypeTypedef &Symbol) { @@ -128,43 +191,7 @@ void VariableDumper::dump(const PDBSymbolTypeUDT &Symbol) { void VariableDumper::dumpSymbolTypeAndName(const PDBSymbol &Type, StringRef Name) { - if (auto *ArrayType = Type.cast()) { - std::string IndexSpec; - raw_string_ostream IndexStream(IndexSpec); - std::unique_ptr ElementType = ArrayType->getElementType(); - while (auto NestedArray = ElementType->cast()) { - IndexStream << "["; - IndexStream << NestedArray->getCount(); - IndexStream << "]"; - ElementType = NestedArray->getElementType(); - } - IndexStream << "[" << ArrayType->getCount() << "]"; - ElementType->dump(*this); - WithColor(Printer, PDB_ColorItem::Identifier).get() << " " << Name; - Printer << IndexStream.str(); - } else { - if (!tryDumpFunctionPointer(Type, Name)) { - Type.dump(*this); - WithColor(Printer, PDB_ColorItem::Identifier).get() << " " << Name; - } - } -} - -bool VariableDumper::tryDumpFunctionPointer(const PDBSymbol &Type, - StringRef Name) { - // Function pointers come across as pointers to function signatures. But the - // signature carries no name, so we have to handle this case separately. - if (auto *PointerType = Type.cast()) { - auto PointeeType = PointerType->getPointeeType(); - if (auto *FunctionSig = PointeeType->cast()) { - FunctionDumper Dumper(Printer); - FunctionDumper::PointerType PT = FunctionDumper::PointerType::Pointer; - if (PointerType->isReference()) - PT = FunctionDumper::PointerType::Reference; - std::string NameStr(Name.begin(), Name.end()); - Dumper.start(*FunctionSig, NameStr.c_str(), PT); - return true; - } - } - return false; + Type.dump(*this); + WithColor(Printer, PDB_ColorItem::Identifier).get() << " " << Name; + Type.dumpRight(*this); } diff --git a/llvm/tools/llvm-pdbdump/PrettyVariableDumper.h b/llvm/tools/llvm-pdbdump/PrettyVariableDumper.h index a122bb86058c..eec389b17077 100644 --- a/llvm/tools/llvm-pdbdump/PrettyVariableDumper.h +++ b/llvm/tools/llvm-pdbdump/PrettyVariableDumper.h @@ -26,6 +26,7 @@ public: void start(const PDBSymbolData &Var); + void dump(const PDBSymbolTypeArray &Symbol) override; void dump(const PDBSymbolTypeBuiltin &Symbol) override; void dump(const PDBSymbolTypeEnum &Symbol) override; void dump(const PDBSymbolTypeFunctionSig &Symbol) override; @@ -33,9 +34,12 @@ public: void dump(const PDBSymbolTypeTypedef &Symbol) override; void dump(const PDBSymbolTypeUDT &Symbol) override; + void dumpRight(const PDBSymbolTypeArray &Symbol) override; + void dumpRight(const PDBSymbolTypeFunctionSig &Symbol) override; + void dumpRight(const PDBSymbolTypePointer &Symbol) override; + private: void dumpSymbolTypeAndName(const PDBSymbol &Type, StringRef Name); - bool tryDumpFunctionPointer(const PDBSymbol &Type, StringRef Name); LinePrinter &Printer; };