[llvm-pdbdump] Rewrite dumper using visitor pattern.

This increases the flexibility of how to dump different
symbol types -- necessary for context-sensitive formatting of
symbol types -- and also improves the modularity by allowing
the dumping to be implemented in the actual dumper, as opposed
to in the PDB library.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@230184 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Zachary Turner
2015-02-22 22:03:38 +00:00
parent e759e99a67
commit 395adf9f89
82 changed files with 1106 additions and 563 deletions

View File

@@ -9,14 +9,10 @@
#include "llvm/DebugInfo/PDB/PDBSymbolFunc.h"
#include "llvm/DebugInfo/PDB/IPDBEnumChildren.h"
#include "llvm/DebugInfo/PDB/IPDBSession.h"
#include "llvm/DebugInfo/PDB/PDBSymbol.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"
#include "llvm/DebugInfo/PDB/PDBSymDumper.h"
#include <utility>
using namespace llvm;
@@ -29,58 +25,6 @@ std::unique_ptr<PDBSymbolTypeFunctionSig> PDBSymbolFunc::getSignature() const {
}
void PDBSymbolFunc::dump(raw_ostream &OS, int Indent,
PDB_DumpLevel Level, PDB_DumpFlags Flags) const {
uint32_t FuncStart = getRelativeVirtualAddress();
uint32_t FuncEnd = FuncStart + getLength();
OS << stream_indent(Indent);
if (FuncStart == 0 && FuncEnd == 0) {
OS << "func [???] ";
} else {
OS << "func ";
OS << "[" << format_hex(FuncStart, 8);
if (auto DebugStart = findOneChild<PDBSymbolFuncDebugStart>())
OS << "+" << DebugStart->getRelativeVirtualAddress() - FuncStart;
OS << " - " << format_hex(FuncEnd, 8);
if (auto DebugEnd = findOneChild<PDBSymbolFuncDebugEnd>())
OS << "-" << FuncEnd - DebugEnd->getRelativeVirtualAddress();
OS << "] ";
}
PDB_RegisterId Reg = getLocalBasePointerRegisterId();
if (Reg == PDB_RegisterId::VFrame)
OS << "(VFrame)";
else if (hasFramePointer())
OS << "(" << Reg << ")";
else
OS << "(FPO)";
OS << " ";
if (isVirtual() || isPureVirtual())
OS << "virtual ";
if (auto FuncSig = getSignature()) {
// If we have a signature, dump the name with the signature.
if (auto ReturnType = FuncSig->getReturnType()) {
ReturnType->dump(OS, 0, PDB_DumpLevel::Compact, PDB_DF_Children);
OS << " ";
}
OS << FuncSig->getCallingConvention() << " ";
OS << getName();
FuncSig->dumpArgList(OS);
if (isPureVirtual())
OS << " = 0";
} else {
uint32_t ClassId = getClassParentId();
if (ClassId != 0) {
if (auto Class = Session.getSymbolById(ClassId)) {
if (auto UDT = dyn_cast<PDBSymbolTypeUDT>(Class.get()))
OS << UDT->getName() << "::";
else
OS << "{class " << Class->getSymTag() << "}::";
}
}
OS << getName();
}
PDBSymDumper &Dumper) const {
Dumper.dump(*this, OS, Indent);
}