summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-pdbutil
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/tools/llvm-pdbutil')
-rw-r--r--llvm/tools/llvm-pdbutil/PrettyTypeDumper.cpp153
-rw-r--r--llvm/tools/llvm-pdbutil/PrettyTypeDumper.h2
-rw-r--r--llvm/tools/llvm-pdbutil/llvm-pdbutil.cpp7
-rw-r--r--llvm/tools/llvm-pdbutil/llvm-pdbutil.h1
4 files changed, 110 insertions, 53 deletions
diff --git a/llvm/tools/llvm-pdbutil/PrettyTypeDumper.cpp b/llvm/tools/llvm-pdbutil/PrettyTypeDumper.cpp
index 9ffdcfdf956..093164b5068 100644
--- a/llvm/tools/llvm-pdbutil/PrettyTypeDumper.cpp
+++ b/llvm/tools/llvm-pdbutil/PrettyTypeDumper.cpp
@@ -22,6 +22,7 @@
#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"
#include "llvm/DebugInfo/PDB/UDTLayout.h"
@@ -136,43 +137,72 @@ filterAndSortClassDefs(LinePrinter &Printer, Enumerator &E,
TypeDumper::TypeDumper(LinePrinter &P) : PDBSymDumper(true), Printer(P) {}
-void TypeDumper::start(const PDBSymbolExe &Exe) {
- if (opts::pretty::Enums) {
- if (auto Enums = Exe.findAllChildren<PDBSymbolTypeEnum>()) {
- Printer.NewLine();
- WithColor(Printer, PDB_ColorItem::Identifier).get() << "Enums";
- Printer << ": (" << Enums->getChildCount() << " items)";
- Printer.Indent();
- while (auto Enum = Enums->getNext())
- Enum->dump(*this);
- Printer.Unindent();
- }
- }
+template <typename T>
+static bool isTypeExcluded(LinePrinter &Printer, const T &Symbol) {
+ return false;
+}
+
+static bool isTypeExcluded(LinePrinter &Printer,
+ const PDBSymbolTypeEnum &Enum) {
+ if (Printer.IsTypeExcluded(Enum.getName(), Enum.getLength()))
+ return true;
+ // Dump member enums when dumping their class definition.
+ if (nullptr != Enum.getClassParent())
+ return true;
+ return false;
+}
+
+static bool isTypeExcluded(LinePrinter &Printer,
+ const PDBSymbolTypeTypedef &Typedef) {
+ return Printer.IsTypeExcluded(Typedef.getName(), Typedef.getLength());
+}
+
+template <typename SymbolT>
+static void dumpSymbolCategory(LinePrinter &Printer, const PDBSymbolExe &Exe,
+ TypeDumper &TD, StringRef Label) {
+ if (auto Children = Exe.findAllChildren<SymbolT>()) {
+ Printer.NewLine();
+ WithColor(Printer, PDB_ColorItem::Identifier).get() << Label;
+ Printer << ": (" << Children->getChildCount() << " items)";
+ Printer.Indent();
+ while (auto Child = Children->getNext()) {
+ if (isTypeExcluded(Printer, *Child))
+ continue;
- if (opts::pretty::Funcsigs) {
- if (auto Funcsigs = Exe.findAllChildren<PDBSymbolTypeFunctionSig>()) {
Printer.NewLine();
- WithColor(Printer, PDB_ColorItem::Identifier).get()
- << "Function Signatures";
- Printer << ": (" << Funcsigs->getChildCount() << " items)";
- Printer.Indent();
- while (auto FS = Funcsigs->getNext())
- FS->dump(*this);
- Printer.Unindent();
+ Child->dump(TD);
}
+ Printer.Unindent();
}
+}
- if (opts::pretty::Typedefs) {
- if (auto Typedefs = Exe.findAllChildren<PDBSymbolTypeTypedef>()) {
- Printer.NewLine();
- WithColor(Printer, PDB_ColorItem::Identifier).get() << "Typedefs";
- Printer << ": (" << Typedefs->getChildCount() << " items)";
- Printer.Indent();
- while (auto Typedef = Typedefs->getNext())
- Typedef->dump(*this);
- Printer.Unindent();
- }
+static void printClassDecl(LinePrinter &Printer,
+ const PDBSymbolTypeUDT &Class) {
+ if (Class.getUnmodifiedTypeId() != 0) {
+ if (Class.isConstType())
+ WithColor(Printer, PDB_ColorItem::Keyword).get() << "const ";
+ if (Class.isVolatileType())
+ WithColor(Printer, PDB_ColorItem::Keyword).get() << "volatile ";
+ if (Class.isUnalignedType())
+ WithColor(Printer, PDB_ColorItem::Keyword).get() << "unaligned ";
}
+ WithColor(Printer, PDB_ColorItem::Keyword).get() << Class.getUdtKind() << " ";
+ WithColor(Printer, PDB_ColorItem::Type).get() << Class.getName();
+}
+
+void TypeDumper::start(const PDBSymbolExe &Exe) {
+ if (opts::pretty::Enums)
+ dumpSymbolCategory<PDBSymbolTypeEnum>(Printer, Exe, *this, "Enums");
+
+ if (opts::pretty::Funcsigs)
+ dumpSymbolCategory<PDBSymbolTypeFunctionSig>(Printer, Exe, *this,
+ "Function Signatures");
+
+ if (opts::pretty::Typedefs)
+ dumpSymbolCategory<PDBSymbolTypeTypedef>(Printer, Exe, *this, "Typedefs");
+
+ if (opts::pretty::Pointers)
+ dumpSymbolCategory<PDBSymbolTypePointer>(Printer, Exe, *this, "Pointers");
if (opts::pretty::Classes) {
if (auto Classes = Exe.findAllChildren<PDBSymbolTypeUDT>()) {
@@ -214,17 +244,11 @@ void TypeDumper::start(const PDBSymbolExe &Exe) {
if (Printer.IsTypeExcluded(Class->getName(), Class->getLength()))
continue;
+ // No point duplicating a full class layout. Just print the modified
+ // declaration and continue.
if (Class->getUnmodifiedTypeId() != 0) {
Printer.NewLine();
- if (Class->isConstType())
- WithColor(Printer, PDB_ColorItem::Keyword).get() << "const ";
- if (Class->isVolatileType())
- WithColor(Printer, PDB_ColorItem::Keyword).get() << "volatile ";
- if (Class->isUnalignedType())
- WithColor(Printer, PDB_ColorItem::Keyword).get() << "unaligned ";
- WithColor(Printer, PDB_ColorItem::Keyword).get()
- << Class->getUdtKind() << " ";
- WithColor(Printer, PDB_ColorItem::Type).get() << Class->getName();
+ printClassDecl(Printer, *Class);
continue;
}
@@ -244,34 +268,59 @@ void TypeDumper::start(const PDBSymbolExe &Exe) {
void TypeDumper::dump(const PDBSymbolTypeEnum &Symbol) {
assert(opts::pretty::Enums);
- if (Printer.IsTypeExcluded(Symbol.getName(), Symbol.getLength()))
- return;
- // Dump member enums when dumping their class definition.
- if (nullptr != Symbol.getClassParent())
- return;
-
- Printer.NewLine();
EnumDumper Dumper(Printer);
Dumper.start(Symbol);
}
+void TypeDumper::dump(const PDBSymbolTypeBuiltin &Symbol) {
+ BuiltinDumper BD(Printer);
+ BD.start(Symbol);
+}
+
void TypeDumper::dump(const PDBSymbolTypeTypedef &Symbol) {
assert(opts::pretty::Typedefs);
- if (Printer.IsTypeExcluded(Symbol.getName(), Symbol.getLength()))
- return;
-
- Printer.NewLine();
TypedefDumper Dumper(Printer);
Dumper.start(Symbol);
}
void TypeDumper::dump(const PDBSymbolTypeFunctionSig &Symbol) {
- Printer.NewLine();
FunctionDumper Dumper(Printer);
Dumper.start(Symbol, nullptr, FunctionDumper::PointerType::None);
}
+void TypeDumper::dump(const PDBSymbolTypePointer &Symbol) {
+ std::unique_ptr<PDBSymbol> P = Symbol.getPointeeType();
+
+ if (auto *FS = dyn_cast<PDBSymbolTypeFunctionSig>(P.get())) {
+ FunctionDumper Dumper(Printer);
+ FunctionDumper::PointerType PT =
+ Symbol.isReference() ? FunctionDumper::PointerType::Reference
+ : FunctionDumper::PointerType::Pointer;
+ Dumper.start(*FS, nullptr, PT);
+ return;
+ }
+
+ if (auto *UDT = dyn_cast<PDBSymbolTypeUDT>(P.get())) {
+ printClassDecl(Printer, *UDT);
+ } else {
+ P->dump(*this);
+ }
+
+ if (auto Parent = Symbol.getClassParent()) {
+ auto UDT = llvm::unique_dyn_cast<PDBSymbolTypeUDT>(std::move(Parent));
+ if (UDT)
+ Printer << " " << UDT->getName() << "::";
+ }
+
+ if (Symbol.isReference())
+ Printer << "&";
+ else if (Symbol.isRValueReference())
+ Printer << "&&";
+ else
+ Printer << "*";
+}
+
void TypeDumper::dumpClassLayout(const ClassLayout &Class) {
assert(opts::pretty::Classes);
diff --git a/llvm/tools/llvm-pdbutil/PrettyTypeDumper.h b/llvm/tools/llvm-pdbutil/PrettyTypeDumper.h
index b94c4feef5f..cb6fcb1add7 100644
--- a/llvm/tools/llvm-pdbutil/PrettyTypeDumper.h
+++ b/llvm/tools/llvm-pdbutil/PrettyTypeDumper.h
@@ -26,6 +26,8 @@ public:
void dump(const PDBSymbolTypeEnum &Symbol) override;
void dump(const PDBSymbolTypeTypedef &Symbol) override;
void dump(const PDBSymbolTypeFunctionSig &Symbol) override;
+ void dump(const PDBSymbolTypeBuiltin &Symbol) override;
+ void dump(const PDBSymbolTypePointer &Symbol) override;
void dumpClassLayout(const ClassLayout &Class);
diff --git a/llvm/tools/llvm-pdbutil/llvm-pdbutil.cpp b/llvm/tools/llvm-pdbutil/llvm-pdbutil.cpp
index 5783661a0b6..c9162dd1577 100644
--- a/llvm/tools/llvm-pdbutil/llvm-pdbutil.cpp
+++ b/llvm/tools/llvm-pdbutil/llvm-pdbutil.cpp
@@ -243,6 +243,9 @@ cl::opt<bool> Typedefs("typedefs", cl::desc("Display typedef types"),
cl::cat(TypeCategory), cl::sub(PrettySubcommand));
cl::opt<bool> Funcsigs("funcsigs", cl::desc("Display function signatures"),
cl::cat(TypeCategory), cl::sub(PrettySubcommand));
+cl::opt<bool> Pointers("pointers", cl::desc("Display pointer types"),
+ cl::cat(TypeCategory), cl::sub(PrettySubcommand));
+
cl::opt<SymbolSortMode> SymbolOrder(
"symbol-order", cl::desc("symbol sort order"),
cl::init(SymbolSortMode::None),
@@ -1179,7 +1182,7 @@ static void dumpPretty(StringRef Path) {
}
if (opts::pretty::Classes || opts::pretty::Enums || opts::pretty::Typedefs ||
- opts::pretty::Funcsigs) {
+ opts::pretty::Funcsigs || opts::pretty::Pointers) {
Printer.NewLine();
WithColor(Printer, PDB_ColorItem::SectionHeader).get() << "---TYPES---";
Printer.Indent();
@@ -1516,6 +1519,8 @@ int main(int Argc, const char **Argv) {
opts::pretty::Classes = true;
opts::pretty::Typedefs = true;
opts::pretty::Enums = true;
+ opts::pretty::Pointers = true;
+ opts::pretty::Funcsigs = true;
}
// When adding filters for excluded compilands and types, we need to
diff --git a/llvm/tools/llvm-pdbutil/llvm-pdbutil.h b/llvm/tools/llvm-pdbutil/llvm-pdbutil.h
index 234beb36e03..eaedb1a56f9 100644
--- a/llvm/tools/llvm-pdbutil/llvm-pdbutil.h
+++ b/llvm/tools/llvm-pdbutil/llvm-pdbutil.h
@@ -84,6 +84,7 @@ extern llvm::cl::opt<bool> Classes;
extern llvm::cl::opt<bool> Enums;
extern llvm::cl::opt<bool> Funcsigs;
extern llvm::cl::opt<bool> Typedefs;
+extern llvm::cl::opt<bool> Pointers;
extern llvm::cl::opt<bool> All;
extern llvm::cl::opt<bool> ExcludeCompilerGenerated;
OpenPOWER on IntegriCloud