diff options
Diffstat (limited to 'llvm/lib')
35 files changed, 293 insertions, 498 deletions
diff --git a/llvm/lib/DebugInfo/PDB/CMakeLists.txt b/llvm/lib/DebugInfo/PDB/CMakeLists.txt index d86c8bdcad8..ed8c67411d9 100644 --- a/llvm/lib/DebugInfo/PDB/CMakeLists.txt +++ b/llvm/lib/DebugInfo/PDB/CMakeLists.txt @@ -66,6 +66,7 @@ add_llvm_library(LLVMDebugInfoPDB PDBSymbolTypeVTableShape.cpp PDBSymbolUnknown.cpp PDBSymbolUsingNamespace.cpp + PDBSymDumper.cpp ${PDB_IMPL_SOURCES} ADDITIONAL_HEADER_DIRS diff --git a/llvm/lib/DebugInfo/PDB/PDBExtras.cpp b/llvm/lib/DebugInfo/PDB/PDBExtras.cpp index c9cc9c3aebf..1002b2e2dad 100644 --- a/llvm/lib/DebugInfo/PDB/PDBExtras.cpp +++ b/llvm/lib/DebugInfo/PDB/PDBExtras.cpp @@ -21,11 +21,6 @@ using namespace llvm; #define CASE_OUTPUT_ENUM_CLASS_NAME(Class, Value, Stream) \ CASE_OUTPUT_ENUM_CLASS_STR(Class, Value, #Value, Stream) -raw_ostream &llvm::operator<<(raw_ostream &OS, const stream_indent &Indent) { - OS.indent(Indent.Width); - return OS; -} - raw_ostream &llvm::operator<<(raw_ostream &OS, const PDB_VariantType &Type) { switch (Type) { CASE_OUTPUT_ENUM_CLASS_NAME(PDB_VariantType, Bool, OS) diff --git a/llvm/lib/DebugInfo/PDB/PDBSymDumper.cpp b/llvm/lib/DebugInfo/PDB/PDBSymDumper.cpp new file mode 100644 index 00000000000..0f29c740563 --- /dev/null +++ b/llvm/lib/DebugInfo/PDB/PDBSymDumper.cpp @@ -0,0 +1,177 @@ +//===- PDBSymDumper.cpp - ---------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "llvm/DebugInfo/PDB/PDBSymDumper.h" +#include "llvm/Support/ErrorHandling.h" + +using namespace llvm; + +#define PDB_SYMDUMP_UNREACHABLE(Type) \ + if (RequireImpl) \ + llvm_unreachable("Attempt to dump " #Type " with no dump implementation"); + +PDBSymDumper::PDBSymDumper(bool ShouldRequireImpl) + : RequireImpl(ShouldRequireImpl) {} + +PDBSymDumper::~PDBSymDumper() {} + +void PDBSymDumper::dump(const PDBSymbolAnnotation &Symbol, raw_ostream &OS, + int Indent) { + PDB_SYMDUMP_UNREACHABLE(PDBSymbolAnnotation) +} + +void PDBSymDumper::dump(const PDBSymbolBlock &Symbol, raw_ostream &OS, + int Indent) { + PDB_SYMDUMP_UNREACHABLE(PDBSymbolBlock) +} + +void PDBSymDumper::dump(const PDBSymbolCompiland &Symbol, raw_ostream &OS, + int Indent) { + PDB_SYMDUMP_UNREACHABLE(PDBSymbolCompiland) +} + +void PDBSymDumper::dump(const PDBSymbolCompilandDetails &Symbol, + raw_ostream &OS, int Indent) { + PDB_SYMDUMP_UNREACHABLE(PDBSymbolCompilandDetails) +} + +void PDBSymDumper::dump(const PDBSymbolCompilandEnv &Symbol, raw_ostream &OS, + int Indent) { + PDB_SYMDUMP_UNREACHABLE(PDBSymbolCompilandEnv) +} + +void PDBSymDumper::dump(const PDBSymbolCustom &Symbol, raw_ostream &OS, + int Indent) { + PDB_SYMDUMP_UNREACHABLE(PDBSymbolCustom) +} + +void PDBSymDumper::dump(const PDBSymbolData &Symbol, raw_ostream &OS, + int Indent) { + PDB_SYMDUMP_UNREACHABLE(PDBSymbolData) +} + +void PDBSymDumper::dump(const PDBSymbolExe &Symbol, raw_ostream &OS, + int Indent) { + PDB_SYMDUMP_UNREACHABLE(PDBSymbolExe) +} + +void PDBSymDumper::dump(const PDBSymbolFunc &Symbol, raw_ostream &OS, + int Indent) { + PDB_SYMDUMP_UNREACHABLE(PDBSymbolFunc) +} + +void PDBSymDumper::dump(const PDBSymbolFuncDebugEnd &Symbol, raw_ostream &OS, + int Indent) { + PDB_SYMDUMP_UNREACHABLE(PDBSymbolFuncDebugEnd) +} + +void PDBSymDumper::dump(const PDBSymbolFuncDebugStart &Symbol, raw_ostream &OS, + int Indent) { + PDB_SYMDUMP_UNREACHABLE(PDBSymbolFuncDebugStart) +} + +void PDBSymDumper::dump(const PDBSymbolLabel &Symbol, raw_ostream &OS, + int Indent) { + PDB_SYMDUMP_UNREACHABLE(PDBSymbolLabel) +} + +void PDBSymDumper::dump(const PDBSymbolPublicSymbol &Symbol, raw_ostream &OS, + int Indent) { + PDB_SYMDUMP_UNREACHABLE(PDBSymbolPublicSymbol) +} + +void PDBSymDumper::dump(const PDBSymbolThunk &Symbol, raw_ostream &OS, + int Indent) { + PDB_SYMDUMP_UNREACHABLE(PDBSymbolThunk) +} + +void PDBSymDumper::dump(const PDBSymbolTypeArray &Symbol, raw_ostream &OS, + int Indent) { + PDB_SYMDUMP_UNREACHABLE(PDBSymbolTypeArray) +} + +void PDBSymDumper::dump(const PDBSymbolTypeBaseClass &Symbol, raw_ostream &OS, + int Indent) { + PDB_SYMDUMP_UNREACHABLE(PDBSymbolTypeBaseClass) +} + +void PDBSymDumper::dump(const PDBSymbolTypeBuiltin &Symbol, raw_ostream &OS, + int Indent) { + PDB_SYMDUMP_UNREACHABLE(PDBSymbolTypeBuiltin) +} + +void PDBSymDumper::dump(const PDBSymbolTypeCustom &Symbol, raw_ostream &OS, + int Indent) { + PDB_SYMDUMP_UNREACHABLE(PDBSymbolTypeCustom) +} + +void PDBSymDumper::dump(const PDBSymbolTypeDimension &Symbol, raw_ostream &OS, + int Indent) { + PDB_SYMDUMP_UNREACHABLE(PDBSymbolTypeDimension) +} + +void PDBSymDumper::dump(const PDBSymbolTypeEnum &Symbol, raw_ostream &OS, + int Indent) { + PDB_SYMDUMP_UNREACHABLE(PDBSymbolTypeEnum) +} + +void PDBSymDumper::dump(const PDBSymbolTypeFriend &Symbol, raw_ostream &OS, + int Indent) { + PDB_SYMDUMP_UNREACHABLE(PDBSymbolTypeFriend) +} + +void PDBSymDumper::dump(const PDBSymbolTypeFunctionArg &Symbol, raw_ostream &OS, + int Indent) { + PDB_SYMDUMP_UNREACHABLE(PDBSymbolTypeFunctionArg) +} + +void PDBSymDumper::dump(const PDBSymbolTypeFunctionSig &Symbol, raw_ostream &OS, + int Indent) { + PDB_SYMDUMP_UNREACHABLE(PDBSymbolTypeFunctionSig) +} + +void PDBSymDumper::dump(const PDBSymbolTypeManaged &Symbol, raw_ostream &OS, + int Indent) { + PDB_SYMDUMP_UNREACHABLE(PDBSymbolTypeManaged) +} + +void PDBSymDumper::dump(const PDBSymbolTypePointer &Symbol, raw_ostream &OS, + int Indent) { + PDB_SYMDUMP_UNREACHABLE(PDBSymbolTypePointer) +} + +void PDBSymDumper::dump(const PDBSymbolTypeTypedef &Symbol, raw_ostream &OS, + int Indent) { + PDB_SYMDUMP_UNREACHABLE(PDBSymbolTypeTypedef) +} + +void PDBSymDumper::dump(const PDBSymbolTypeUDT &Symbol, raw_ostream &OS, + int Indent) { + PDB_SYMDUMP_UNREACHABLE(PDBSymbolTypeUDT) +} + +void PDBSymDumper::dump(const PDBSymbolTypeVTable &Symbol, raw_ostream &OS, + int Indent) { + PDB_SYMDUMP_UNREACHABLE(PDBSymbolTypeVTable) +} + +void PDBSymDumper::dump(const PDBSymbolTypeVTableShape &Symbol, raw_ostream &OS, + int Indent) { + PDB_SYMDUMP_UNREACHABLE(PDBSymbolTypeVTableShape) +} + +void PDBSymDumper::dump(const PDBSymbolUnknown &Symbol, raw_ostream &OS, + int Indent) { + PDB_SYMDUMP_UNREACHABLE(PDBSymbolUnknown) +} + +void PDBSymDumper::dump(const PDBSymbolUsingNamespace &Symbol, raw_ostream &OS, + int Indent) { + PDB_SYMDUMP_UNREACHABLE(PDBSymbolUsingNamespace) +} diff --git a/llvm/lib/DebugInfo/PDB/PDBSymbol.cpp b/llvm/lib/DebugInfo/PDB/PDBSymbol.cpp index 9ab8b936a5d..f24e318a941 100644 --- a/llvm/lib/DebugInfo/PDB/PDBSymbol.cpp +++ b/llvm/lib/DebugInfo/PDB/PDBSymbol.cpp @@ -42,6 +42,7 @@ #include "llvm/DebugInfo/PDB/PDBSymbolTypeVTableShape.h" #include "llvm/DebugInfo/PDB/PDBSymbolUnknown.h" #include "llvm/DebugInfo/PDB/PDBSymbolUsingNamespace.h" +#include "llvm/DebugInfo/PDB/PDBSymDumper.h" #include <memory> #include <utility> @@ -100,6 +101,12 @@ PDBSymbol::create(const IPDBSession &PDBSession, } } +#define TRY_DUMP_TYPE(Type) \ + if (const Type *DerivedThis = dyn_cast<Type>(this)) \ + Dumper.dump(OS, Indent, *DerivedThis); + +#define ELSE_TRY_DUMP_TYPE(Type, Dumper) else TRY_DUMP_TYPE(Type, Dumper) + void PDBSymbol::defaultDump(raw_ostream &OS, int Indent, PDB_DumpLevel Level) const { RawSymbol->dump(OS, Indent, Level); diff --git a/llvm/lib/DebugInfo/PDB/PDBSymbolAnnotation.cpp b/llvm/lib/DebugInfo/PDB/PDBSymbolAnnotation.cpp index c965d1d9d6b..4c76e3bc24f 100644 --- a/llvm/lib/DebugInfo/PDB/PDBSymbolAnnotation.cpp +++ b/llvm/lib/DebugInfo/PDB/PDBSymbolAnnotation.cpp @@ -9,7 +9,7 @@ #include "llvm/DebugInfo/PDB/PDBSymbolAnnotation.h" -#include "llvm/DebugInfo/PDB/PDBSymbol.h" +#include "llvm/DebugInfo/PDB/PDBSymDumper.h" #include <utility> @@ -20,4 +20,6 @@ PDBSymbolAnnotation::PDBSymbolAnnotation(const IPDBSession &PDBSession, : PDBSymbol(PDBSession, std::move(Symbol)) {} void PDBSymbolAnnotation::dump(raw_ostream &OS, int Indent, - PDB_DumpLevel Level, PDB_DumpFlags Flags) const {} + PDBSymDumper &Dumper) const { + Dumper.dump(*this, OS, Indent); +} diff --git a/llvm/lib/DebugInfo/PDB/PDBSymbolBlock.cpp b/llvm/lib/DebugInfo/PDB/PDBSymbolBlock.cpp index 2e350ad2fe9..bb159d5036d 100644 --- a/llvm/lib/DebugInfo/PDB/PDBSymbolBlock.cpp +++ b/llvm/lib/DebugInfo/PDB/PDBSymbolBlock.cpp @@ -10,6 +10,7 @@ #include "llvm/DebugInfo/PDB/PDBSymbolBlock.h" #include "llvm/DebugInfo/PDB/PDBSymbol.h" +#include "llvm/DebugInfo/PDB/PDBSymDumper.h" #include <utility> @@ -20,4 +21,6 @@ PDBSymbolBlock::PDBSymbolBlock(const IPDBSession &PDBSession, : PDBSymbol(PDBSession, std::move(Symbol)) {} void PDBSymbolBlock::dump(raw_ostream &OS, int Indent, - PDB_DumpLevel Level, PDB_DumpFlags Flags) const {} + PDBSymDumper &Dumper) const { + Dumper.dump(*this, OS, Indent); +} diff --git a/llvm/lib/DebugInfo/PDB/PDBSymbolCompiland.cpp b/llvm/lib/DebugInfo/PDB/PDBSymbolCompiland.cpp index f014b3959b0..0c9b1909e8d 100644 --- a/llvm/lib/DebugInfo/PDB/PDBSymbolCompiland.cpp +++ b/llvm/lib/DebugInfo/PDB/PDBSymbolCompiland.cpp @@ -9,18 +9,9 @@ #include "llvm/DebugInfo/PDB/PDBSymbolCompiland.h" -#include "llvm/DebugInfo/PDB/IPDBEnumChildren.h" -#include "llvm/DebugInfo/PDB/IPDBSession.h" -#include "llvm/DebugInfo/PDB/IPDBSourceFile.h" -#include "llvm/DebugInfo/PDB/PDBExtras.h" -#include "llvm/DebugInfo/PDB/PDBSymbol.h" -#include "llvm/DebugInfo/PDB/PDBSymbolCompilandDetails.h" -#include "llvm/DebugInfo/PDB/PDBSymbolCompilandEnv.h" -#include "llvm/Support/Path.h" -#include "llvm/Support/raw_ostream.h" +#include "llvm/DebugInfo/PDB/PDBSymDumper.h" #include <utility> -#include <vector> using namespace llvm; @@ -28,45 +19,7 @@ PDBSymbolCompiland::PDBSymbolCompiland(const IPDBSession &PDBSession, std::unique_ptr<IPDBRawSymbol> Symbol) : PDBSymbol(PDBSession, std::move(Symbol)) {} -#define SKIP_SYMBOL_IF_FLAG_UNSET(Tag, Flag) \ - case PDB_SymType::Tag: \ - if ((Flags & Flag) == 0) \ - continue; \ - break; - void PDBSymbolCompiland::dump(raw_ostream &OS, int Indent, - PDB_DumpLevel Level, PDB_DumpFlags Flags) const { - if (Level == PDB_DumpLevel::Detailed) { - std::string FullName = getName(); - OS << stream_indent(Indent) << FullName; - if (Flags & PDB_DF_Children) { - if (Level >= PDB_DumpLevel::Detailed) { - auto ChildrenEnum = findAllChildren(); - while (auto Child = ChildrenEnum->getNext()) { - switch (Child->getSymTag()) { - SKIP_SYMBOL_IF_FLAG_UNSET(Function, PDB_DF_Functions) - SKIP_SYMBOL_IF_FLAG_UNSET(Data, PDB_DF_Data) - SKIP_SYMBOL_IF_FLAG_UNSET(Label, PDB_DF_Labels) - SKIP_SYMBOL_IF_FLAG_UNSET(PublicSymbol, PDB_DF_PublicSyms) - SKIP_SYMBOL_IF_FLAG_UNSET(UDT, PDB_DF_Classes) - SKIP_SYMBOL_IF_FLAG_UNSET(Enum, PDB_DF_Enums) - SKIP_SYMBOL_IF_FLAG_UNSET(FunctionSig, PDB_DF_Funcsigs) - SKIP_SYMBOL_IF_FLAG_UNSET(VTable, PDB_DF_VTables) - SKIP_SYMBOL_IF_FLAG_UNSET(Thunk, PDB_DF_Thunks) - SKIP_SYMBOL_IF_FLAG_UNSET(Compiland, PDB_DF_ObjFiles) - default: - continue; - } - PDB_DumpLevel ChildLevel = (Level == PDB_DumpLevel::Detailed) - ? PDB_DumpLevel::Normal - : PDB_DumpLevel::Compact; - OS << "\n"; - Child->dump(OS, Indent + 2, ChildLevel, PDB_DF_Children); - } - } - } - } else { - std::string FullName = getName(); - OS << stream_indent(Indent) << "Compiland: " << FullName; - } + PDBSymDumper &Dumper) const { + Dumper.dump(*this, OS, Indent); } diff --git a/llvm/lib/DebugInfo/PDB/PDBSymbolCompilandDetails.cpp b/llvm/lib/DebugInfo/PDB/PDBSymbolCompilandDetails.cpp index 9194376eee0..208d68faa6e 100644 --- a/llvm/lib/DebugInfo/PDB/PDBSymbolCompilandDetails.cpp +++ b/llvm/lib/DebugInfo/PDB/PDBSymbolCompilandDetails.cpp @@ -10,6 +10,7 @@ #include "llvm/DebugInfo/PDB/PDBSymbolCompilandDetails.h" #include "llvm/DebugInfo/PDB/PDBSymbol.h" +#include "llvm/DebugInfo/PDB/PDBSymDumper.h" #include <utility> @@ -20,4 +21,6 @@ PDBSymbolCompilandDetails::PDBSymbolCompilandDetails( : PDBSymbol(PDBSession, std::move(Symbol)) {} void PDBSymbolCompilandDetails::dump(raw_ostream &OS, int Indent, - PDB_DumpLevel Level, PDB_DumpFlags Flags) const {} + PDBSymDumper &Dumper) const { + Dumper.dump(*this, OS, Indent); +} diff --git a/llvm/lib/DebugInfo/PDB/PDBSymbolCompilandEnv.cpp b/llvm/lib/DebugInfo/PDB/PDBSymbolCompilandEnv.cpp index b44dc578ea4..c54b8fb3492 100644 --- a/llvm/lib/DebugInfo/PDB/PDBSymbolCompilandEnv.cpp +++ b/llvm/lib/DebugInfo/PDB/PDBSymbolCompilandEnv.cpp @@ -11,6 +11,7 @@ #include "llvm/DebugInfo/PDB/IPDBRawSymbol.h" #include "llvm/DebugInfo/PDB/PDBSymbol.h" +#include "llvm/DebugInfo/PDB/PDBSymDumper.h" #include <utility> @@ -26,4 +27,6 @@ std::string PDBSymbolCompilandEnv::getValue() const { } void PDBSymbolCompilandEnv::dump(raw_ostream &OS, int Indent, - PDB_DumpLevel Level, PDB_DumpFlags Flags) const {} + PDBSymDumper &Dumper) const { + Dumper.dump(*this, OS, Indent); +} diff --git a/llvm/lib/DebugInfo/PDB/PDBSymbolCustom.cpp b/llvm/lib/DebugInfo/PDB/PDBSymbolCustom.cpp index 68f2b45194c..1b6b50b6dd0 100644 --- a/llvm/lib/DebugInfo/PDB/PDBSymbolCustom.cpp +++ b/llvm/lib/DebugInfo/PDB/PDBSymbolCustom.cpp @@ -11,6 +11,7 @@ #include "llvm/DebugInfo/PDB/IPDBRawSymbol.h" #include "llvm/DebugInfo/PDB/PDBSymbol.h" +#include "llvm/DebugInfo/PDB/PDBSymDumper.h" #include <utility> @@ -25,4 +26,6 @@ void PDBSymbolCustom::getDataBytes(llvm::SmallVector<uint8_t, 32> &bytes) { } void PDBSymbolCustom::dump(raw_ostream &OS, int Indent, - PDB_DumpLevel Level, PDB_DumpFlags Flags) const {}
\ No newline at end of file + PDBSymDumper &Dumper) const { + Dumper.dump(*this, OS, Indent); +}
\ No newline at end of file diff --git a/llvm/lib/DebugInfo/PDB/PDBSymbolData.cpp b/llvm/lib/DebugInfo/PDB/PDBSymbolData.cpp index 9a04ecd1f43..09b96bc6c9b 100644 --- a/llvm/lib/DebugInfo/PDB/PDBSymbolData.cpp +++ b/llvm/lib/DebugInfo/PDB/PDBSymbolData.cpp @@ -9,11 +9,7 @@ #include "llvm/DebugInfo/PDB/PDBSymbolData.h" -#include "llvm/DebugInfo/PDB/IPDBSession.h" -#include "llvm/DebugInfo/PDB/PDBExtras.h" -#include "llvm/DebugInfo/PDB/PDBSymbolTypeUDT.h" -#include "llvm/Support/Format.h" -#include <utility> +#include "llvm/DebugInfo/PDB/PDBSymDumper.h" #include <utility> @@ -24,68 +20,6 @@ PDBSymbolData::PDBSymbolData(const IPDBSession &PDBSession, : PDBSymbol(PDBSession, std::move(DataSymbol)) {} void PDBSymbolData::dump(raw_ostream &OS, int Indent, - PDB_DumpLevel Level, PDB_DumpFlags Flags) const { - OS << stream_indent(Indent); - PDB_LocType Loc = getLocationType(); - PDB_DataKind Kind = getDataKind(); - switch (Loc) { - case PDB_LocType::Static: { - uint32_t RVA = getRelativeVirtualAddress(); - OS << Kind << " data["; - if (RVA != 0) - OS << format_hex(RVA, 10); - else - OS << "???"; - break; - } - case PDB_LocType::TLS: - OS << "threadlocal " << Kind << " data["; - OS << getAddressSection() << ":" << format_hex(getAddressOffset(), 10); - break; - case PDB_LocType::RegRel: - OS << "regrel " << Kind << " data["; - OS << getRegisterId() << " + " << getOffset(); - break; - case PDB_LocType::ThisRel: { - uint32_t Offset = getOffset(); - OS << Kind << " data[this + " << format_hex(Offset, 4); - break; - } - case PDB_LocType::Enregistered: - OS << "register " << Kind << " data[" << getRegisterId(); - break; - case PDB_LocType::BitField: { - OS << "bitfield data[this + "; - uint32_t Offset = getOffset(); - uint32_t BitPos = getBitPosition(); - uint32_t Length = getLength(); - OS << format_hex(Offset, 4) << ":" << BitPos << "," << Length; - break; - } - case PDB_LocType::Slot: - OS << getSlot(); - break; - case PDB_LocType::Constant: { - OS << "constant data["; - OS << getValue(); - break; - } - case PDB_LocType::IlRel: - case PDB_LocType::MetaData: - default: - OS << "???"; - } - - OS << "] "; - if (Kind == PDB_DataKind::Member || Kind == PDB_DataKind::StaticMember) { - uint32_t ClassId = getClassParentId(); - if (auto Class = Session.getSymbolById(ClassId)) { - if (auto UDT = dyn_cast<PDBSymbolTypeUDT>(Class.get())) - OS << UDT->getName(); - else - OS << "{class " << Class->getSymTag() << "}"; - OS << "::"; - } - } - OS << getName(); + PDBSymDumper &Dumper) const { + Dumper.dump(*this, OS, Indent); }
\ No newline at end of file diff --git a/llvm/lib/DebugInfo/PDB/PDBSymbolExe.cpp b/llvm/lib/DebugInfo/PDB/PDBSymbolExe.cpp index efd28bca469..ef091934859 100644 --- a/llvm/lib/DebugInfo/PDB/PDBSymbolExe.cpp +++ b/llvm/lib/DebugInfo/PDB/PDBSymbolExe.cpp @@ -9,129 +9,17 @@ #include "llvm/DebugInfo/PDB/PDBSymbolExe.h" -#include "llvm/DebugInfo/PDB/IPDBEnumChildren.h" -#include "llvm/DebugInfo/PDB/PDBExtras.h" -#include "llvm/DebugInfo/PDB/PDBSymbol.h" -#include "llvm/Support/ConvertUTF.h" -#include "llvm/Support/FileSystem.h" -#include "llvm/Support/raw_ostream.h" -#include <utility> +#include "llvm/DebugInfo/PDB/PDBSymDumper.h" #include <utility> using namespace llvm; -#define SKIP_SYMBOL_IF_FLAG_UNSET(Tag, Flag) \ - case PDB_SymType::Tag: \ - if ((Flags & Flag) == 0) \ - continue; \ - break; - PDBSymbolExe::PDBSymbolExe(const IPDBSession &PDBSession, std::unique_ptr<IPDBRawSymbol> Symbol) : PDBSymbol(PDBSession, std::move(Symbol)) {} void PDBSymbolExe::dump(raw_ostream &OS, int Indent, - PDB_DumpLevel Level, PDB_DumpFlags Flags) const { - std::string FileName(getSymbolsFileName()); - - OS << stream_indent(Indent) << "Summary for " << FileName << "\n"; - - uint64_t FileSize = 0; - if (!llvm::sys::fs::file_size(FileName, FileSize)) - OS << stream_indent(Indent + 2) << "Size: " << FileSize << " bytes\n"; - else - OS << stream_indent(Indent + 2) << "Size: (Unable to obtain file size)\n"; - PDB_UniqueId Guid = getGuid(); - OS << stream_indent(Indent + 2) << "Guid: " << Guid << "\n"; - OS << stream_indent(Indent + 2) << "Age: " << getAge() << "\n"; - OS << stream_indent(Indent + 2) << "Attributes: "; - if (hasCTypes()) - OS << "HasCTypes "; - if (hasPrivateSymbols()) - OS << "HasPrivateSymbols "; - OS << "\n"; - - if (Flags & PDB_DF_Children) { - OS << stream_indent(Indent + 2) << "Dumping types\n"; - if (Flags & PDB_DF_Hidden) { - // For some reason, for each SymTag T, this dumps more items of type T - // than are dumped by calling dumpChildren(T). In other words, there are - // "hidden" symbols. For example, it causes functions to be dumped which - // have no address information, whereas specifically dumping only - // functions will not find those symbols. - // - // My suspicion is that in the underlying DIA call, when you call - // findChildren, passing a value of SymTagNone means all children - // recursively, whereas passing a concrete tag value means only immediate - // children of the global scope. So perhaps we need to find these - // mysterious missing values by recursing through the hierarchy. - // - // On the other hand, there may just be some symbols that DIA tries to - // hide from you because it thinks you don't care about them. However - // experimentation shows that even vtables, for example, can't be found - // without an exhaustive search. - auto ChildrenEnum = findAllChildren(); - OS << stream_indent(Indent + 2) << ChildrenEnum->getChildCount() - << " symbols"; - - while (auto Child = ChildrenEnum->getNext()) { - switch (Child->getSymTag()) { - SKIP_SYMBOL_IF_FLAG_UNSET(Function, PDB_DF_Functions) - SKIP_SYMBOL_IF_FLAG_UNSET(Data, PDB_DF_Data) - SKIP_SYMBOL_IF_FLAG_UNSET(Label, PDB_DF_Labels) - SKIP_SYMBOL_IF_FLAG_UNSET(PublicSymbol, PDB_DF_PublicSyms) - SKIP_SYMBOL_IF_FLAG_UNSET(UDT, PDB_DF_Classes) - SKIP_SYMBOL_IF_FLAG_UNSET(Enum, PDB_DF_Enums) - SKIP_SYMBOL_IF_FLAG_UNSET(FunctionSig, PDB_DF_Funcsigs) - SKIP_SYMBOL_IF_FLAG_UNSET(VTable, PDB_DF_VTables) - SKIP_SYMBOL_IF_FLAG_UNSET(Thunk, PDB_DF_Thunks) - SKIP_SYMBOL_IF_FLAG_UNSET(Compiland, PDB_DF_ObjFiles) - default: - continue; - } - PDB_DumpLevel ChildLevel = (Level == PDB_DumpLevel::Detailed) - ? PDB_DumpLevel::Normal - : PDB_DumpLevel::Compact; - OS << "\n"; - Child->dump(OS, Indent + 4, ChildLevel, PDB_DF_Children); - } - } else { - if (Flags & PDB_DF_ObjFiles) - dumpChildren(OS, "Compilands", PDB_SymType::Compiland, Indent + 4); - if (Flags & PDB_DF_Functions) - dumpChildren(OS, "Functions", PDB_SymType::Function, Indent + 4); - if (Flags & PDB_DF_Data) - dumpChildren(OS, "Data", PDB_SymType::Data, Indent + 4); - if (Flags & PDB_DF_Labels) - dumpChildren(OS, "Labels", PDB_SymType::Label, Indent + 4); - if (Flags & PDB_DF_PublicSyms) - dumpChildren(OS, "Public Symbols", PDB_SymType::PublicSymbol, - Indent + 4); - if (Flags & PDB_DF_Classes) - dumpChildren(OS, "UDTs", PDB_SymType::UDT, Indent + 4); - if (Flags & PDB_DF_Enums) - dumpChildren(OS, "Enums", PDB_SymType::Enum, Indent + 4); - if (Flags & PDB_DF_Funcsigs) - dumpChildren(OS, "Function Signatures", PDB_SymType::FunctionSig, - Indent + 4); - if (Flags & PDB_DF_Typedefs) - dumpChildren(OS, "Typedefs", PDB_SymType::Typedef, Indent + 4); - if (Flags & PDB_DF_VTables) - dumpChildren(OS, "VTables", PDB_SymType::VTable, Indent + 4); - if (Flags & PDB_DF_Thunks) - dumpChildren(OS, "Thunks", PDB_SymType::Thunk, Indent + 4); - } - } -} - -void PDBSymbolExe::dumpChildren(raw_ostream &OS, StringRef Label, - PDB_SymType ChildType, int Indent) const { - auto ChildrenEnum = findAllChildren(ChildType); - OS << stream_indent(Indent) << Label << ": (" << ChildrenEnum->getChildCount() - << " items)\n"; - while (auto Child = ChildrenEnum->getNext()) { - Child->dump(OS, Indent + 2, PDB_DumpLevel::Normal, PDB_DF_None); - OS << "\n"; - } + PDBSymDumper &Dumper) const { + Dumper.dump(*this, OS, Indent); } diff --git a/llvm/lib/DebugInfo/PDB/PDBSymbolFunc.cpp b/llvm/lib/DebugInfo/PDB/PDBSymbolFunc.cpp index cd01423c9b7..4702d6dac21 100644 --- a/llvm/lib/DebugInfo/PDB/PDBSymbolFunc.cpp +++ b/llvm/lib/DebugInfo/PDB/PDBSymbolFunc.cpp @@ -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); } diff --git a/llvm/lib/DebugInfo/PDB/PDBSymbolFuncDebugEnd.cpp b/llvm/lib/DebugInfo/PDB/PDBSymbolFuncDebugEnd.cpp index 8658be951fa..c20748808c5 100644 --- a/llvm/lib/DebugInfo/PDB/PDBSymbolFuncDebugEnd.cpp +++ b/llvm/lib/DebugInfo/PDB/PDBSymbolFuncDebugEnd.cpp @@ -10,6 +10,7 @@ #include "llvm/DebugInfo/PDB/PDBSymbolFuncDebugEnd.h" #include "llvm/DebugInfo/PDB/PDBSymbol.h" +#include "llvm/DebugInfo/PDB/PDBSymDumper.h" #include <utility> @@ -20,4 +21,6 @@ PDBSymbolFuncDebugEnd::PDBSymbolFuncDebugEnd( : PDBSymbol(PDBSession, std::move(Symbol)) {} void PDBSymbolFuncDebugEnd::dump(raw_ostream &OS, int Indent, - PDB_DumpLevel Level, PDB_DumpFlags Flags) const {} + PDBSymDumper &Dumper) const { + Dumper.dump(*this, OS, Indent); +} diff --git a/llvm/lib/DebugInfo/PDB/PDBSymbolFuncDebugStart.cpp b/llvm/lib/DebugInfo/PDB/PDBSymbolFuncDebugStart.cpp index 64cd3e36705..83df22e2cf1 100644 --- a/llvm/lib/DebugInfo/PDB/PDBSymbolFuncDebugStart.cpp +++ b/llvm/lib/DebugInfo/PDB/PDBSymbolFuncDebugStart.cpp @@ -10,6 +10,7 @@ #include "llvm/DebugInfo/PDB/PDBSymbolFuncDebugStart.h" #include "llvm/DebugInfo/PDB/PDBSymbol.h" +#include "llvm/DebugInfo/PDB/PDBSymDumper.h" #include <utility> @@ -20,4 +21,6 @@ PDBSymbolFuncDebugStart::PDBSymbolFuncDebugStart( : PDBSymbol(PDBSession, std::move(Symbol)) {} void PDBSymbolFuncDebugStart::dump(raw_ostream &OS, int Indent, - PDB_DumpLevel Level, PDB_DumpFlags Flags) const {} + PDBSymDumper &Dumper) const { + Dumper.dump(*this, OS, Indent); +} diff --git a/llvm/lib/DebugInfo/PDB/PDBSymbolLabel.cpp b/llvm/lib/DebugInfo/PDB/PDBSymbolLabel.cpp index abb516330de..ce569e2f50b 100644 --- a/llvm/lib/DebugInfo/PDB/PDBSymbolLabel.cpp +++ b/llvm/lib/DebugInfo/PDB/PDBSymbolLabel.cpp @@ -9,8 +9,7 @@ #include "llvm/DebugInfo/PDB/PDBSymbolLabel.h" -#include "llvm/DebugInfo/PDB/PDBSymbol.h" -#include "llvm/Support/Format.h" +#include "llvm/DebugInfo/PDB/PDBSymDumper.h" #include <utility> @@ -21,8 +20,6 @@ PDBSymbolLabel::PDBSymbolLabel(const IPDBSession &PDBSession, : PDBSymbol(PDBSession, std::move(Symbol)) {} void PDBSymbolLabel::dump(raw_ostream &OS, int Indent, - PDB_DumpLevel Level, PDB_DumpFlags Flags) const { - OS << stream_indent(Indent); - OS << "label [" << format_hex(getRelativeVirtualAddress(), 10) << "] " - << getName(); + PDBSymDumper &Dumper) const { + Dumper.dump(*this, OS, Indent); } diff --git a/llvm/lib/DebugInfo/PDB/PDBSymbolPublicSymbol.cpp b/llvm/lib/DebugInfo/PDB/PDBSymbolPublicSymbol.cpp index a2cea8be82c..a7f156cc49c 100644 --- a/llvm/lib/DebugInfo/PDB/PDBSymbolPublicSymbol.cpp +++ b/llvm/lib/DebugInfo/PDB/PDBSymbolPublicSymbol.cpp @@ -10,6 +10,7 @@ #include "llvm/DebugInfo/PDB/PDBSymbolPublicSymbol.h" #include "llvm/DebugInfo/PDB/PDBSymbol.h" +#include "llvm/DebugInfo/PDB/PDBSymDumper.h" #include <utility> @@ -20,7 +21,6 @@ PDBSymbolPublicSymbol::PDBSymbolPublicSymbol( : PDBSymbol(PDBSession, std::move(Symbol)) {} void PDBSymbolPublicSymbol::dump(raw_ostream &OS, int Indent, - PDB_DumpLevel Level, PDB_DumpFlags Flags) const { - OS << stream_indent(Indent); - OS << "public symbol: " << getName(); + PDBSymDumper &Dumper) const { + Dumper.dump(*this, OS, Indent); } diff --git a/llvm/lib/DebugInfo/PDB/PDBSymbolThunk.cpp b/llvm/lib/DebugInfo/PDB/PDBSymbolThunk.cpp index c62c96b6ae4..edade834b71 100644 --- a/llvm/lib/DebugInfo/PDB/PDBSymbolThunk.cpp +++ b/llvm/lib/DebugInfo/PDB/PDBSymbolThunk.cpp @@ -9,8 +9,7 @@ #include "llvm/DebugInfo/PDB/PDBSymbolThunk.h" -#include "llvm/DebugInfo/PDB/PDBSymbol.h" -#include "llvm/Support/Format.h" +#include "llvm/DebugInfo/PDB/PDBSymDumper.h" #include <utility> @@ -21,22 +20,6 @@ PDBSymbolThunk::PDBSymbolThunk(const IPDBSession &PDBSession, : PDBSymbol(PDBSession, std::move(Symbol)) {} void PDBSymbolThunk::dump(raw_ostream &OS, int Indent, - PDB_DumpLevel Level, PDB_DumpFlags Flags) const { - OS.indent(Indent); - OS << "thunk "; - PDB_ThunkOrdinal Ordinal = getThunkOrdinal(); - uint32_t RVA = getRelativeVirtualAddress(); - if (Ordinal == PDB_ThunkOrdinal::TrampIncremental) { - OS << format_hex(RVA, 10); - } else { - OS << "[" << format_hex(RVA, 10); - OS << " - " << format_hex(RVA + getLength(), 10) << "]"; - } - OS << " (" << Ordinal << ")"; - if (Ordinal == PDB_ThunkOrdinal::TrampIncremental) - OS << " -> " << format_hex(getTargetRelativeVirtualAddress(), 10); - OS << " "; - std::string Name = getName(); - if (!Name.empty()) - OS << Name; + PDBSymDumper &Dumper) const { + Dumper.dump(*this, OS, Indent); } diff --git a/llvm/lib/DebugInfo/PDB/PDBSymbolTypeArray.cpp b/llvm/lib/DebugInfo/PDB/PDBSymbolTypeArray.cpp index b418e3343f6..1759bd8ead5 100644 --- a/llvm/lib/DebugInfo/PDB/PDBSymbolTypeArray.cpp +++ b/llvm/lib/DebugInfo/PDB/PDBSymbolTypeArray.cpp @@ -9,8 +9,7 @@ #include "llvm/DebugInfo/PDB/PDBSymbolTypeArray.h" -#include "llvm/DebugInfo/PDB/IPDBSession.h" -#include "llvm/DebugInfo/PDB/PDBSymbol.h" +#include "llvm/DebugInfo/PDB/PDBSymDumper.h" #include <utility> @@ -21,11 +20,6 @@ PDBSymbolTypeArray::PDBSymbolTypeArray(const IPDBSession &PDBSession, : PDBSymbol(PDBSession, std::move(Symbol)) {} void PDBSymbolTypeArray::dump(raw_ostream &OS, int Indent, - PDB_DumpLevel Level, PDB_DumpFlags Flags) const { - OS << stream_indent(Indent); - if (auto ElementType = Session.getSymbolById(getTypeId())) - ElementType->dump(OS, 0, PDB_DumpLevel::Compact, PDB_DF_Children); - else - OS << "<unknown-element-type>"; - OS << "[" << getLength() << "]"; + PDBSymDumper &Dumper) const { + Dumper.dump(*this, OS, Indent); } diff --git a/llvm/lib/DebugInfo/PDB/PDBSymbolTypeBaseClass.cpp b/llvm/lib/DebugInfo/PDB/PDBSymbolTypeBaseClass.cpp index 532e8b8178f..c44cc527fec 100644 --- a/llvm/lib/DebugInfo/PDB/PDBSymbolTypeBaseClass.cpp +++ b/llvm/lib/DebugInfo/PDB/PDBSymbolTypeBaseClass.cpp @@ -10,6 +10,7 @@ #include "llvm/DebugInfo/PDB/PDBSymbolTypeBaseClass.h" #include "llvm/DebugInfo/PDB/PDBSymbol.h" +#include "llvm/DebugInfo/PDB/PDBSymDumper.h" #include <utility> @@ -20,7 +21,6 @@ PDBSymbolTypeBaseClass::PDBSymbolTypeBaseClass( : PDBSymbol(PDBSession, std::move(Symbol)) {} void PDBSymbolTypeBaseClass::dump(raw_ostream &OS, int Indent, - PDB_DumpLevel Level, PDB_DumpFlags Flags) const { - OS << stream_indent(Indent); - OS << "<base class> " << getName(); + PDBSymDumper &Dumper) const { + Dumper.dump(*this, OS, Indent); } diff --git a/llvm/lib/DebugInfo/PDB/PDBSymbolTypeBuiltin.cpp b/llvm/lib/DebugInfo/PDB/PDBSymbolTypeBuiltin.cpp index b7afdcddeb0..f0c94c707de 100644 --- a/llvm/lib/DebugInfo/PDB/PDBSymbolTypeBuiltin.cpp +++ b/llvm/lib/DebugInfo/PDB/PDBSymbolTypeBuiltin.cpp @@ -9,7 +9,7 @@ #include "llvm/DebugInfo/PDB/PDBSymbolTypeBuiltin.h" -#include "llvm/DebugInfo/PDB/PDBSymbol.h" +#include "llvm/DebugInfo/PDB/PDBSymDumper.h" #include <utility> @@ -20,10 +20,6 @@ PDBSymbolTypeBuiltin::PDBSymbolTypeBuiltin( : PDBSymbol(PDBSession, std::move(Symbol)) {} void PDBSymbolTypeBuiltin::dump(raw_ostream &OS, int Indent, - PDB_DumpLevel Level, PDB_DumpFlags Flags) const { - OS << stream_indent(Indent); - PDB_BuiltinType Type = getBuiltinType(); - OS << Type; - if (Type == PDB_BuiltinType::UInt || Type == PDB_BuiltinType::Int) - OS << (8 * getLength()) << "_t"; + PDBSymDumper &Dumper) const { + Dumper.dump(*this, OS, Indent); } diff --git a/llvm/lib/DebugInfo/PDB/PDBSymbolTypeCustom.cpp b/llvm/lib/DebugInfo/PDB/PDBSymbolTypeCustom.cpp index 0bfa8eb4e74..0fa8f45bfc9 100644 --- a/llvm/lib/DebugInfo/PDB/PDBSymbolTypeCustom.cpp +++ b/llvm/lib/DebugInfo/PDB/PDBSymbolTypeCustom.cpp @@ -10,6 +10,7 @@ #include "llvm/DebugInfo/PDB/PDBSymbolTypeCustom.h" #include "llvm/DebugInfo/PDB/PDBSymbol.h" +#include "llvm/DebugInfo/PDB/PDBSymDumper.h" #include <utility> @@ -20,4 +21,6 @@ PDBSymbolTypeCustom::PDBSymbolTypeCustom(const IPDBSession &PDBSession, : PDBSymbol(PDBSession, std::move(Symbol)) {} void PDBSymbolTypeCustom::dump(raw_ostream &OS, int Indent, - PDB_DumpLevel Level, PDB_DumpFlags Flags) const {} + PDBSymDumper &Dumper) const { + Dumper.dump(*this, OS, Indent); +} diff --git a/llvm/lib/DebugInfo/PDB/PDBSymbolTypeDimension.cpp b/llvm/lib/DebugInfo/PDB/PDBSymbolTypeDimension.cpp index 84f48ea4310..47fb08d6e99 100644 --- a/llvm/lib/DebugInfo/PDB/PDBSymbolTypeDimension.cpp +++ b/llvm/lib/DebugInfo/PDB/PDBSymbolTypeDimension.cpp @@ -11,6 +11,7 @@ #include "llvm/DebugInfo/PDB/PDBSymbolTypeDimension.h" #include "llvm/DebugInfo/PDB/PDBSymbol.h" +#include "llvm/DebugInfo/PDB/PDBSymDumper.h" #include <utility> @@ -21,4 +22,6 @@ PDBSymbolTypeDimension::PDBSymbolTypeDimension( : PDBSymbol(PDBSession, std::move(Symbol)) {} void PDBSymbolTypeDimension::dump(raw_ostream &OS, int Indent, - PDB_DumpLevel Level, PDB_DumpFlags Flags) const {} + PDBSymDumper &Dumper) const { + Dumper.dump(*this, OS, Indent); +} diff --git a/llvm/lib/DebugInfo/PDB/PDBSymbolTypeEnum.cpp b/llvm/lib/DebugInfo/PDB/PDBSymbolTypeEnum.cpp index 512b602244f..121d41e522d 100644 --- a/llvm/lib/DebugInfo/PDB/PDBSymbolTypeEnum.cpp +++ b/llvm/lib/DebugInfo/PDB/PDBSymbolTypeEnum.cpp @@ -9,8 +9,7 @@ #include "llvm/DebugInfo/PDB/PDBSymbolTypeEnum.h" -#include "llvm/DebugInfo/PDB/IPDBSession.h" -#include "llvm/DebugInfo/PDB/PDBSymbol.h" +#include "llvm/DebugInfo/PDB/PDBSymDumper.h" #include <utility> @@ -21,17 +20,6 @@ PDBSymbolTypeEnum::PDBSymbolTypeEnum(const IPDBSession &PDBSession, : PDBSymbol(PDBSession, std::move(Symbol)) {} void PDBSymbolTypeEnum::dump(raw_ostream &OS, int Indent, - PDB_DumpLevel Level, PDB_DumpFlags Flags) const { - OS << stream_indent(Indent); - if (Level >= PDB_DumpLevel::Normal) - OS << "enum "; - - uint32_t ClassId = getClassParentId(); - if (ClassId != 0) { - if (auto ClassParent = Session.getSymbolById(ClassId)) { - ClassParent->dump(OS, 0, Level, PDB_DF_Children); - OS << "::"; - } - } - OS << getName(); + PDBSymDumper &Dumper) const { + Dumper.dump(*this, OS, Indent); } diff --git a/llvm/lib/DebugInfo/PDB/PDBSymbolTypeFriend.cpp b/llvm/lib/DebugInfo/PDB/PDBSymbolTypeFriend.cpp index 236304eb478..b2bf72e0f3d 100644 --- a/llvm/lib/DebugInfo/PDB/PDBSymbolTypeFriend.cpp +++ b/llvm/lib/DebugInfo/PDB/PDBSymbolTypeFriend.cpp @@ -10,6 +10,7 @@ #include "llvm/DebugInfo/PDB/PDBSymbolTypeFriend.h" #include "llvm/DebugInfo/PDB/PDBSymbol.h" +#include "llvm/DebugInfo/PDB/PDBSymDumper.h" #include <utility> @@ -20,4 +21,6 @@ PDBSymbolTypeFriend::PDBSymbolTypeFriend(const IPDBSession &PDBSession, : PDBSymbol(PDBSession, std::move(Symbol)) {} void PDBSymbolTypeFriend::dump(raw_ostream &OS, int Indent, - PDB_DumpLevel Level, PDB_DumpFlags Flags) const {} + PDBSymDumper &Dumper) const { + Dumper.dump(*this, OS, Indent); +} diff --git a/llvm/lib/DebugInfo/PDB/PDBSymbolTypeFunctionArg.cpp b/llvm/lib/DebugInfo/PDB/PDBSymbolTypeFunctionArg.cpp index 4b8cc26d9f7..f394c04ad69 100644 --- a/llvm/lib/DebugInfo/PDB/PDBSymbolTypeFunctionArg.cpp +++ b/llvm/lib/DebugInfo/PDB/PDBSymbolTypeFunctionArg.cpp @@ -9,8 +9,7 @@ #include "llvm/DebugInfo/PDB/PDBSymbolTypeFunctionArg.h" -#include "llvm/DebugInfo/PDB/IPDBSession.h" -#include "llvm/DebugInfo/PDB/PDBSymbol.h" +#include "llvm/DebugInfo/PDB/PDBSymDumper.h" #include <utility> @@ -21,10 +20,6 @@ PDBSymbolTypeFunctionArg::PDBSymbolTypeFunctionArg( : PDBSymbol(PDBSession, std::move(Symbol)) {} void PDBSymbolTypeFunctionArg::dump(raw_ostream &OS, int Indent, - PDB_DumpLevel Level, PDB_DumpFlags Flags) const { - OS << stream_indent(Indent); - uint32_t TypeId = getTypeId(); - if (auto Type = Session.getSymbolById(TypeId)) { - Type->dump(OS, 0, Level, PDB_DF_Children); - } + PDBSymDumper &Dumper) const { + Dumper.dump(*this, OS, Indent); } diff --git a/llvm/lib/DebugInfo/PDB/PDBSymbolTypeFunctionSig.cpp b/llvm/lib/DebugInfo/PDB/PDBSymbolTypeFunctionSig.cpp index 13b89b235dd..1ba397b50c5 100644 --- a/llvm/lib/DebugInfo/PDB/PDBSymbolTypeFunctionSig.cpp +++ b/llvm/lib/DebugInfo/PDB/PDBSymbolTypeFunctionSig.cpp @@ -14,6 +14,7 @@ #include "llvm/DebugInfo/PDB/IPDBSession.h" #include "llvm/DebugInfo/PDB/PDBSymbol.h" #include "llvm/DebugInfo/PDB/PDBSymbolTypeFunctionArg.h" +#include "llvm/DebugInfo/PDB/PDBSymDumper.h" #include <utility> @@ -82,38 +83,7 @@ std::unique_ptr<PDBSymbol> PDBSymbolTypeFunctionSig::getClassParent() const { return Session.getSymbolById(ClassId); } -void PDBSymbolTypeFunctionSig::dumpArgList(raw_ostream &OS) const { - OS << "("; - if (auto ChildEnum = getArguments()) { - uint32_t Index = 0; - while (auto Arg = ChildEnum->getNext()) { - Arg->dump(OS, 0, PDB_DumpLevel::Compact, PDB_DF_Children); - if (++Index < ChildEnum->getChildCount()) - OS << ", "; - } - } - OS << ")"; - if (isConstType()) - OS << " const"; - if (isVolatileType()) - OS << " volatile"; -} - void PDBSymbolTypeFunctionSig::dump(raw_ostream &OS, int Indent, - PDB_DumpLevel Level, PDB_DumpFlags Flags) const { - OS << stream_indent(Indent); - - if (auto ReturnType = getReturnType()) { - ReturnType->dump(OS, 0, PDB_DumpLevel::Compact, PDB_DF_Children); - OS << " "; - } - - OS << getCallingConvention() << " "; - if (auto ClassParent = getClassParent()) { - OS << "("; - ClassParent->dump(OS, 0, PDB_DumpLevel::Compact, PDB_DF_Children); - OS << "::*)"; - } - - dumpArgList(OS); + PDBSymDumper &Dumper) const { + Dumper.dump(*this, OS, Indent); } diff --git a/llvm/lib/DebugInfo/PDB/PDBSymbolTypeManaged.cpp b/llvm/lib/DebugInfo/PDB/PDBSymbolTypeManaged.cpp index 32602dc022b..e04fb666cd8 100644 --- a/llvm/lib/DebugInfo/PDB/PDBSymbolTypeManaged.cpp +++ b/llvm/lib/DebugInfo/PDB/PDBSymbolTypeManaged.cpp @@ -10,6 +10,7 @@ #include "llvm/DebugInfo/PDB/PDBSymbolTypeManaged.h" #include "llvm/DebugInfo/PDB/PDBSymbol.h" +#include "llvm/DebugInfo/PDB/PDBSymDumper.h" #include <utility> @@ -20,4 +21,6 @@ PDBSymbolTypeManaged::PDBSymbolTypeManaged( : PDBSymbol(PDBSession, std::move(Symbol)) {} void PDBSymbolTypeManaged::dump(raw_ostream &OS, int Indent, - PDB_DumpLevel Level, PDB_DumpFlags Flags) const {} + PDBSymDumper &Dumper) const { + Dumper.dump(*this, OS, Indent); +} diff --git a/llvm/lib/DebugInfo/PDB/PDBSymbolTypePointer.cpp b/llvm/lib/DebugInfo/PDB/PDBSymbolTypePointer.cpp index 3461928993a..cac23f737e5 100644 --- a/llvm/lib/DebugInfo/PDB/PDBSymbolTypePointer.cpp +++ b/llvm/lib/DebugInfo/PDB/PDBSymbolTypePointer.cpp @@ -9,9 +9,7 @@ #include "llvm/DebugInfo/PDB/PDBSymbolTypePointer.h" -#include "llvm/DebugInfo/PDB/IPDBSession.h" -#include "llvm/DebugInfo/PDB/PDBSymbol.h" -#include "llvm/DebugInfo/PDB/PDBSymbolTypeFunctionSig.h" +#include "llvm/DebugInfo/PDB/PDBSymDumper.h" #include <utility> @@ -22,25 +20,6 @@ PDBSymbolTypePointer::PDBSymbolTypePointer( : PDBSymbol(PDBSession, std::move(Symbol)) {} void PDBSymbolTypePointer::dump(raw_ostream &OS, int Indent, - PDB_DumpLevel Level, PDB_DumpFlags Flags) const { - OS << stream_indent(Indent); - if (isConstType()) - OS << "const "; - if (isVolatileType()) - OS << "volatile "; - uint32_t PointeeId = getTypeId(); - if (auto PointeeType = Session.getSymbolById(PointeeId)) { - // Function pointers get special treatment, since we need to print the * in - // the middle of the signature. - if (auto FuncSig = dyn_cast<PDBSymbolTypeFunctionSig>(PointeeType.get())) { - if (auto ReturnType = FuncSig->getReturnType()) - ReturnType->dump(OS, 0, PDB_DumpLevel::Compact, PDB_DF_Children); - OS << " (" << FuncSig->getCallingConvention() << " "; - OS << ((isReference()) ? "&" : "*") << ")"; - FuncSig->dumpArgList(OS); - } else { - PointeeType->dump(OS, 0, PDB_DumpLevel::Compact, PDB_DF_Children); - OS << ((isReference()) ? "&" : "*"); - } - } + PDBSymDumper &Dumper) const { + Dumper.dump(*this, OS, Indent); } diff --git a/llvm/lib/DebugInfo/PDB/PDBSymbolTypeTypedef.cpp b/llvm/lib/DebugInfo/PDB/PDBSymbolTypeTypedef.cpp index 9554d708222..12e3ead92f1 100644 --- a/llvm/lib/DebugInfo/PDB/PDBSymbolTypeTypedef.cpp +++ b/llvm/lib/DebugInfo/PDB/PDBSymbolTypeTypedef.cpp @@ -9,9 +9,7 @@ #include "llvm/DebugInfo/PDB/PDBSymbolTypeTypedef.h" -#include "llvm/DebugInfo/PDB/IPDBSession.h" -#include "llvm/DebugInfo/PDB/PDBSymbol.h" -#include "llvm/DebugInfo/PDB/PDBSymbolTypeUDT.h" +#include "llvm/DebugInfo/PDB/PDBSymDumper.h" #include <utility> @@ -22,18 +20,6 @@ PDBSymbolTypeTypedef::PDBSymbolTypeTypedef( : PDBSymbol(PDBSession, std::move(Symbol)) {} void PDBSymbolTypeTypedef::dump(raw_ostream &OS, int Indent, - PDB_DumpLevel Level, PDB_DumpFlags Flags) const { - OS.indent(Indent); - if (Level >= PDB_DumpLevel::Normal) { - std::string Name = getName(); - OS << "typedef:" << Name << " -> "; - std::string TargetTypeName; - uint32_t TargetId = getTypeId(); - if (auto TypeSymbol = Session.getSymbolById(TargetId)) { - TypeSymbol->dump(OS, 0, PDB_DumpLevel::Compact, PDB_DF_Children); - } - OS << TargetTypeName; - } else { - OS << getName(); - } + PDBSymDumper &Dumper) const { + Dumper.dump(*this, OS, Indent); } diff --git a/llvm/lib/DebugInfo/PDB/PDBSymbolTypeUDT.cpp b/llvm/lib/DebugInfo/PDB/PDBSymbolTypeUDT.cpp index ea884bdac51..8a723687469 100644 --- a/llvm/lib/DebugInfo/PDB/PDBSymbolTypeUDT.cpp +++ b/llvm/lib/DebugInfo/PDB/PDBSymbolTypeUDT.cpp @@ -9,8 +9,7 @@ #include "llvm/DebugInfo/PDB/PDBSymbolTypeUDT.h" -#include "llvm/DebugInfo/PDB/IPDBSession.h" -#include "llvm/DebugInfo/PDB/PDBSymbol.h" +#include "llvm/DebugInfo/PDB/PDBSymDumper.h" #include <utility> @@ -21,22 +20,6 @@ PDBSymbolTypeUDT::PDBSymbolTypeUDT(const IPDBSession &PDBSession, : PDBSymbol(PDBSession, std::move(Symbol)) {} void PDBSymbolTypeUDT::dump(raw_ostream &OS, int Indent, - PDB_DumpLevel Level, PDB_DumpFlags Flags) const { - OS << stream_indent(Indent); - if (Level >= PDB_DumpLevel::Normal) - OS << "class "; - - if (isNested()) { - uint32_t ClassId = getClassParentId(); - if (ClassId != 0) { - if (auto ClassParent = Session.getSymbolById(ClassId)) { - ClassParent->dump(OS, 0, Level, PDB_DF_Children); - OS << "::"; - } - } - } - OS << getName(); - - if (Level >= PDB_DumpLevel::Normal) - OS << " (" << getLength() << " bytes)"; + PDBSymDumper &Dumper) const { + Dumper.dump(*this, OS, Indent); } diff --git a/llvm/lib/DebugInfo/PDB/PDBSymbolTypeVTable.cpp b/llvm/lib/DebugInfo/PDB/PDBSymbolTypeVTable.cpp index 4c1f05ea0d3..a100526839a 100644 --- a/llvm/lib/DebugInfo/PDB/PDBSymbolTypeVTable.cpp +++ b/llvm/lib/DebugInfo/PDB/PDBSymbolTypeVTable.cpp @@ -9,10 +9,7 @@ #include "llvm/DebugInfo/PDB/PDBSymbolTypeVTable.h" -#include "llvm/DebugInfo/PDB/IPDBSession.h" -#include "llvm/DebugInfo/PDB/PDBSymbol.h" -#include "llvm/DebugInfo/PDB/PDBSymbolTypePointer.h" -#include "llvm/DebugInfo/PDB/PDBSymbolTypeVTableShape.h" +#include "llvm/DebugInfo/PDB/PDBSymDumper.h" #include <utility> @@ -23,19 +20,6 @@ PDBSymbolTypeVTable::PDBSymbolTypeVTable(const IPDBSession &PDBSession, : PDBSymbol(PDBSession, std::move(Symbol)) {} void PDBSymbolTypeVTable::dump(raw_ostream &OS, int Indent, - PDB_DumpLevel Level, PDB_DumpFlags Flags) const { - OS << stream_indent(Indent); - uint32_t ClassId = getClassParentId(); - if (auto ClassParent = Session.getSymbolById(ClassId)) { - ClassParent->dump(OS, 0, PDB_DumpLevel::Compact, PDB_DF_Children); - OS << "::"; - } - OS << "<vtbl> "; - if (auto VtblPointer = - Session.getConcreteSymbolById<PDBSymbolTypePointer>(getTypeId())) { - if (auto VtblShape = - Session.getConcreteSymbolById<PDBSymbolTypeVTableShape>( - VtblPointer->getTypeId())) - OS << "(" << VtblShape->getCount() << " entries)"; - } + PDBSymDumper &Dumper) const { + Dumper.dump(*this, OS, Indent); } diff --git a/llvm/lib/DebugInfo/PDB/PDBSymbolTypeVTableShape.cpp b/llvm/lib/DebugInfo/PDB/PDBSymbolTypeVTableShape.cpp index cff0d03c4cf..6aaa668e384 100644 --- a/llvm/lib/DebugInfo/PDB/PDBSymbolTypeVTableShape.cpp +++ b/llvm/lib/DebugInfo/PDB/PDBSymbolTypeVTableShape.cpp @@ -10,6 +10,7 @@ #include "llvm/DebugInfo/PDB/PDBSymbolTypeVTableShape.h" #include "llvm/DebugInfo/PDB/PDBSymbol.h" +#include "llvm/DebugInfo/PDB/PDBSymDumper.h" #include <utility> @@ -20,4 +21,6 @@ PDBSymbolTypeVTableShape::PDBSymbolTypeVTableShape( : PDBSymbol(PDBSession, std::move(Symbol)) {} void PDBSymbolTypeVTableShape::dump(raw_ostream &OS, int Indent, - PDB_DumpLevel Level, PDB_DumpFlags Flags) const {} + PDBSymDumper &Dumper) const { + Dumper.dump(*this, OS, Indent); +} diff --git a/llvm/lib/DebugInfo/PDB/PDBSymbolUnknown.cpp b/llvm/lib/DebugInfo/PDB/PDBSymbolUnknown.cpp index b7b4c38f24d..9cfb88a738e 100644 --- a/llvm/lib/DebugInfo/PDB/PDBSymbolUnknown.cpp +++ b/llvm/lib/DebugInfo/PDB/PDBSymbolUnknown.cpp @@ -10,6 +10,7 @@ #include "llvm/DebugInfo/PDB/PDBSymbolUnknown.h" #include "llvm/DebugInfo/PDB/PDBSymbol.h" +#include "llvm/DebugInfo/PDB/PDBSymDumper.h" #include <utility> @@ -20,4 +21,6 @@ PDBSymbolUnknown::PDBSymbolUnknown(const IPDBSession &PDBSession, : PDBSymbol(PDBSession, std::move(Symbol)) {} void PDBSymbolUnknown::dump(raw_ostream &OS, int Indent, - PDB_DumpLevel Level, PDB_DumpFlags Flags) const {} + PDBSymDumper &Dumper) const { + Dumper.dump(*this, OS, Indent); +} diff --git a/llvm/lib/DebugInfo/PDB/PDBSymbolUsingNamespace.cpp b/llvm/lib/DebugInfo/PDB/PDBSymbolUsingNamespace.cpp index 077d2b3a3ae..9176dfb1449 100644 --- a/llvm/lib/DebugInfo/PDB/PDBSymbolUsingNamespace.cpp +++ b/llvm/lib/DebugInfo/PDB/PDBSymbolUsingNamespace.cpp @@ -10,6 +10,7 @@ #include "llvm/DebugInfo/PDB/PDBSymbolUsingNamespace.h" #include "llvm/DebugInfo/PDB/PDBSymbol.h" +#include "llvm/DebugInfo/PDB/PDBSymDumper.h" #include <utility> @@ -20,4 +21,6 @@ PDBSymbolUsingNamespace::PDBSymbolUsingNamespace( : PDBSymbol(PDBSession, std::move(Symbol)) {} void PDBSymbolUsingNamespace::dump(raw_ostream &OS, int Indent, - PDB_DumpLevel Level, PDB_DumpFlags Flags) const {} + PDBSymDumper &Dumper) const { + Dumper.dump(*this, OS, Indent); +} |