summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-pdbdump/PrettyVariableDumper.cpp
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2017-04-12 23:18:21 +0000
committerZachary Turner <zturner@google.com>2017-04-12 23:18:21 +0000
commitc883a8c6dce207a494c6c3a54de1492635acb664 (patch)
treefb2ff9010b62853109fd592e006e560fc2cb4ed7 /llvm/tools/llvm-pdbdump/PrettyVariableDumper.cpp
parent1b395144442f4bf872fb772c87d8b6e3bf78cfd7 (diff)
downloadbcm5719-llvm-c883a8c6dce207a494c6c3a54de1492635acb664.tar.gz
bcm5719-llvm-c883a8c6dce207a494c6c3a54de1492635acb664.zip
[llvm-pdbdump] More advanced class definition dumping.
Previously the dumping of class definitions was very primitive, and it made it hard to do more than the most trivial of output formats when dumping. As such, we would only dump one line for each field, and then dump non-layout items like nested types and enums. With this patch, we do a complete analysis of the object hierarchy including aggregate types, bases, virtual bases, vftable analysis, etc. The only immediately visible effects of this are that a) we can now dump a line for the vfptr where before we would treat that as padding, and b) we now don't treat virtual bases that come at the end of a class as padding since we have a more detailed analysis of the class's storage usage. In subsequent patches, we should be able to use this analysis to display a complete graphical view of a class's layout including recursing arbitrarily deep into an object's base class / aggregate member hierarchy. llvm-svn: 300133
Diffstat (limited to 'llvm/tools/llvm-pdbdump/PrettyVariableDumper.cpp')
-rw-r--r--llvm/tools/llvm-pdbdump/PrettyVariableDumper.cpp23
1 files changed, 18 insertions, 5 deletions
diff --git a/llvm/tools/llvm-pdbdump/PrettyVariableDumper.cpp b/llvm/tools/llvm-pdbdump/PrettyVariableDumper.cpp
index 65f0139dfbc..ef9a9b51bd0 100644
--- a/llvm/tools/llvm-pdbdump/PrettyVariableDumper.cpp
+++ b/llvm/tools/llvm-pdbdump/PrettyVariableDumper.cpp
@@ -91,6 +91,19 @@ void VariableDumper::start(const PDBSymbolData &Var) {
}
}
+void VariableDumper::start(const PDBSymbolTypeVTable &Var) {
+ Printer.NewLine();
+ Printer << "data ";
+ auto VTableType = cast<PDBSymbolTypePointer>(Var.getType());
+ uint32_t PointerSize = VTableType->getLength();
+
+ WithColor(Printer, PDB_ColorItem::Offset).get()
+ << "+" << format_hex(Var.getOffset(), 4) << " [sizeof=" << PointerSize
+ << "] ";
+
+ WithColor(Printer, PDB_ColorItem::Identifier).get() << " __vfptr";
+}
+
void VariableDumper::dump(const PDBSymbolTypeArray &Symbol) {
auto ElementType = Symbol.getElementType();
assert(ElementType);
@@ -157,12 +170,12 @@ void VariableDumper::dump(const PDBSymbolTypePointer &Symbol) {
if (!PointeeType)
return;
PointeeType->dump(*this);
- if (auto Func = PointeeType->cast<PDBSymbolTypeFunctionSig>()) {
+ if (auto FuncSig = unique_dyn_cast<PDBSymbolTypeFunctionSig>(PointeeType)) {
// A hack to get the calling convention in the right spot.
Printer << " (";
- PDB_CallingConv CC = Func->getCallingConvention();
+ PDB_CallingConv CC = FuncSig->getCallingConvention();
WithColor(Printer, PDB_ColorItem::Keyword).get() << CC << " ";
- } else if (isa<PDBSymbolTypeArray>(PointeeType.get())) {
+ } else if (isa<PDBSymbolTypeArray>(PointeeType)) {
Printer << " (";
}
Printer << (Symbol.isReference() ? "&" : "*");
@@ -177,8 +190,8 @@ void VariableDumper::dumpRight(const PDBSymbolTypePointer &Symbol) {
assert(PointeeType);
if (!PointeeType)
return;
- if (isa<PDBSymbolTypeFunctionSig>(PointeeType.get()) ||
- isa<PDBSymbolTypeArray>(PointeeType.get())) {
+ if (isa<PDBSymbolTypeFunctionSig>(PointeeType) ||
+ isa<PDBSymbolTypeArray>(PointeeType)) {
Printer << ")";
}
PointeeType->dumpRight(*this);
OpenPOWER on IntegriCloud