void CompilandDumper::dump(const PDBSymbolFunc &Symbol) { if (Symbol.getLength() == 0) return; if (Printer.IsSymbolExcluded(Symbol.getName())) return; Printer.NewLine(); FunctionDumper Dumper(Printer); Dumper.start(Symbol, FunctionDumper::PointerType::None); }
void PrettyClassLayoutGraphicalDumper::dump(const PDBSymbolFunc &Symbol) { if (Printer.IsSymbolExcluded(Symbol.getName())) return; if (Symbol.isCompilerGenerated() && opts::pretty::ExcludeCompilerGenerated) return; if (Symbol.getLength() == 0 && !Symbol.isPureVirtual() && !Symbol.isIntroVirtualFunction()) return; DumpedAnything = true; Printer.NewLine(); FunctionDumper Dumper(Printer); Dumper.start(Symbol, FunctionDumper::PointerType::None); }
void FunctionDumper::start(const PDBSymbolFunc &Symbol, PointerType Pointer) { uint64_t FuncStart = Symbol.getVirtualAddress(); uint64_t FuncEnd = FuncStart + Symbol.getLength(); Printer << "func ["; WithColor(Printer, PDB_ColorItem::Address).get() << format_hex(FuncStart, 10); if (auto DebugStart = Symbol.findOneChild<PDBSymbolFuncDebugStart>()) { uint64_t Prologue = DebugStart->getVirtualAddress() - FuncStart; WithColor(Printer, PDB_ColorItem::Offset).get() << formatv("+{0,2}", Prologue); } Printer << " - "; WithColor(Printer, PDB_ColorItem::Address).get() << format_hex(FuncEnd, 10); if (auto DebugEnd = Symbol.findOneChild<PDBSymbolFuncDebugEnd>()) { uint64_t Epilogue = FuncEnd - DebugEnd->getVirtualAddress(); WithColor(Printer, PDB_ColorItem::Offset).get() << formatv("-{0,2}", Epilogue); } WithColor(Printer, PDB_ColorItem::Comment).get() << formatv(" | sizeof={0,3}", Symbol.getLength()); Printer << "] ("; if (Symbol.hasFramePointer()) { WithColor(Printer, PDB_ColorItem::Register).get() << Symbol.getLocalBasePointerRegisterId(); } else { WithColor(Printer, PDB_ColorItem::Register).get() << "FPO"; } Printer << ") "; if (Symbol.isVirtual() || Symbol.isPureVirtual()) WithColor(Printer, PDB_ColorItem::Keyword).get() << "virtual "; auto Signature = Symbol.getSignature(); if (!Signature) { WithColor(Printer, PDB_ColorItem::Identifier).get() << Symbol.getName(); if (Pointer == PointerType::Pointer) Printer << "*"; else if (Pointer == FunctionDumper::PointerType::Reference) Printer << "&"; return; } auto ReturnType = Signature->getReturnType(); ReturnType->dump(*this); Printer << " "; auto ClassParent = Symbol.getClassParent(); CallingConvention CC = Signature->getCallingConvention(); if (Pointer != FunctionDumper::PointerType::None) Printer << "("; if ((ClassParent && CC != CallingConvention::ThisCall) || (!ClassParent && CC != CallingConvention::NearStdCall)) { WithColor(Printer, PDB_ColorItem::Keyword).get() << Signature->getCallingConvention() << " "; } WithColor(Printer, PDB_ColorItem::Identifier).get() << Symbol.getName(); if (Pointer != FunctionDumper::PointerType::None) { if (Pointer == PointerType::Pointer) Printer << "*"; else if (Pointer == FunctionDumper::PointerType::Reference) Printer << "&"; Printer << ")"; } Printer << "("; if (auto Arguments = Symbol.getArguments()) { uint32_t Index = 0; while (auto Arg = Arguments->getNext()) { auto ArgType = Arg->getType(); ArgType->dump(*this); WithColor(Printer, PDB_ColorItem::Identifier).get() << " " << Arg->getName(); if (++Index < Arguments->getChildCount()) Printer << ", "; } if (Signature->isCVarArgs()) Printer << ", ..."; } Printer << ")"; if (Symbol.isConstType()) WithColor(Printer, PDB_ColorItem::Keyword).get() << " const"; if (Symbol.isVolatileType()) WithColor(Printer, PDB_ColorItem::Keyword).get() << " volatile"; if (Symbol.isPureVirtual()) Printer << " = 0"; }