mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 18:54:02 +01:00
[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. llvm-svn: 230184
This commit is contained in:
parent
a0f04e851c
commit
1a7a66bda7
@ -17,12 +17,6 @@
|
||||
namespace llvm {
|
||||
typedef std::unordered_map<PDB_SymType, int> TagStats;
|
||||
|
||||
struct stream_indent {
|
||||
stream_indent(int IndentWidth) : Width(IndentWidth) {}
|
||||
int Width;
|
||||
};
|
||||
raw_ostream &operator<<(raw_ostream &OS, const stream_indent &Indent);
|
||||
|
||||
raw_ostream &operator<<(raw_ostream &OS, const PDB_VariantType &Value);
|
||||
raw_ostream &operator<<(raw_ostream &OS, const PDB_CallingConv &Conv);
|
||||
raw_ostream &operator<<(raw_ostream &OS, const PDB_DataKind &Data);
|
||||
|
85
include/llvm/DebugInfo/PDB/PDBSymDumper.h
Normal file
85
include/llvm/DebugInfo/PDB/PDBSymDumper.h
Normal file
@ -0,0 +1,85 @@
|
||||
//===- PDBSymDumper.h - base interface for PDB symbol dumper *- C++ -----*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LLVM_DEBUGINFO_PDB_PDBSYMDUMPER_H
|
||||
#define LLVM_DEBUGINFO_PDB_PDBSYMDUMPER_H
|
||||
|
||||
#include "PDBTypes.h"
|
||||
|
||||
namespace llvm {
|
||||
|
||||
class raw_ostream;
|
||||
|
||||
class PDBSymDumper {
|
||||
public:
|
||||
PDBSymDumper(bool ShouldRequireImpl);
|
||||
virtual ~PDBSymDumper();
|
||||
|
||||
virtual void dump(const PDBSymbolAnnotation &Symbol, raw_ostream &OS,
|
||||
int Indent);
|
||||
virtual void dump(const PDBSymbolBlock &Symbol, raw_ostream &OS, int Indent);
|
||||
virtual void dump(const PDBSymbolCompiland &Symbol, raw_ostream &OS,
|
||||
int Indent);
|
||||
virtual void dump(const PDBSymbolCompilandDetails &Symbol, raw_ostream &OS,
|
||||
int Indent);
|
||||
virtual void dump(const PDBSymbolCompilandEnv &Symbol, raw_ostream &OS,
|
||||
int Indent);
|
||||
virtual void dump(const PDBSymbolCustom &Symbol, raw_ostream &OS, int Indent);
|
||||
virtual void dump(const PDBSymbolData &Symbol, raw_ostream &OS, int Indent);
|
||||
virtual void dump(const PDBSymbolExe &Symbol, raw_ostream &OS, int Indent);
|
||||
virtual void dump(const PDBSymbolFunc &Symbol, raw_ostream &OS, int Indent);
|
||||
virtual void dump(const PDBSymbolFuncDebugEnd &Symbol, raw_ostream &OS,
|
||||
int Indent);
|
||||
virtual void dump(const PDBSymbolFuncDebugStart &Symbol, raw_ostream &OS,
|
||||
int Indent);
|
||||
virtual void dump(const PDBSymbolLabel &Symbol, raw_ostream &OS, int Indent);
|
||||
virtual void dump(const PDBSymbolPublicSymbol &Symbol, raw_ostream &OS,
|
||||
int Indent);
|
||||
virtual void dump(const PDBSymbolThunk &Symbol, raw_ostream &OS, int Indent);
|
||||
virtual void dump(const PDBSymbolTypeArray &Symbol, raw_ostream &OS,
|
||||
int Indent);
|
||||
virtual void dump(const PDBSymbolTypeBaseClass &Symbol, raw_ostream &OS,
|
||||
int Indent);
|
||||
virtual void dump(const PDBSymbolTypeBuiltin &Symbol, raw_ostream &OS,
|
||||
int Indent);
|
||||
virtual void dump(const PDBSymbolTypeCustom &Symbol, raw_ostream &OS,
|
||||
int Indent);
|
||||
virtual void dump(const PDBSymbolTypeDimension &Symbol, raw_ostream &OS,
|
||||
int Indent);
|
||||
virtual void dump(const PDBSymbolTypeEnum &Symbol, raw_ostream &OS,
|
||||
int Indent);
|
||||
virtual void dump(const PDBSymbolTypeFriend &Symbol, raw_ostream &OS,
|
||||
int Indent);
|
||||
virtual void dump(const PDBSymbolTypeFunctionArg &Symbol, raw_ostream &OS,
|
||||
int Indent);
|
||||
virtual void dump(const PDBSymbolTypeFunctionSig &Symbol, raw_ostream &OS,
|
||||
int Indent);
|
||||
virtual void dump(const PDBSymbolTypeManaged &Symbol, raw_ostream &OS,
|
||||
int Indent);
|
||||
virtual void dump(const PDBSymbolTypePointer &Symbol, raw_ostream &OS,
|
||||
int Indent);
|
||||
virtual void dump(const PDBSymbolTypeTypedef &Symbol, raw_ostream &OS,
|
||||
int Indent);
|
||||
virtual void dump(const PDBSymbolTypeUDT &Symbol, raw_ostream &OS,
|
||||
int Indent);
|
||||
virtual void dump(const PDBSymbolTypeVTable &Symbol, raw_ostream &OS,
|
||||
int Indent);
|
||||
virtual void dump(const PDBSymbolTypeVTableShape &Symbol, raw_ostream &OS,
|
||||
int Indent);
|
||||
virtual void dump(const PDBSymbolUnknown &Symbol, raw_ostream &OS,
|
||||
int Indent);
|
||||
virtual void dump(const PDBSymbolUsingNamespace &Symbol, raw_ostream &OS,
|
||||
int Indent);
|
||||
|
||||
private:
|
||||
bool RequireImpl;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
@ -53,7 +53,8 @@ public:
|
||||
/// call dump() on the underlying RawSymbol, which allows us to discover
|
||||
/// unknown properties, but individual implementations of PDBSymbol may
|
||||
/// override the behavior to only dump known fields.
|
||||
virtual void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level, PDB_DumpFlags Flags) const = 0;
|
||||
virtual void dump(raw_ostream &OS, int Indent,
|
||||
PDBSymDumper &Dumper) const = 0;
|
||||
void defaultDump(raw_ostream &OS, int Indent, PDB_DumpLevel Level) const;
|
||||
|
||||
PDB_SymType getSymTag() const;
|
||||
@ -83,6 +84,8 @@ public:
|
||||
const IPDBRawSymbol &getRawSymbol() const { return *RawSymbol; }
|
||||
IPDBRawSymbol &getRawSymbol() { return *RawSymbol; }
|
||||
|
||||
const IPDBSession &getSession() const { return Session; }
|
||||
|
||||
protected:
|
||||
std::unique_ptr<IPDBEnumSymbols> getChildStats(TagStats &Stats) const;
|
||||
|
||||
|
@ -24,7 +24,7 @@ public:
|
||||
|
||||
DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::Annotation)
|
||||
|
||||
void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level, PDB_DumpFlags Flags) const override;
|
||||
void dump(raw_ostream &OS, int Indent, PDBSymDumper &Dumper) const override;
|
||||
|
||||
FORWARD_SYMBOL_METHOD(getAddressOffset)
|
||||
FORWARD_SYMBOL_METHOD(getAddressSection)
|
||||
|
@ -24,7 +24,7 @@ public:
|
||||
|
||||
DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::Block)
|
||||
|
||||
void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level, PDB_DumpFlags Flags) const override;
|
||||
void dump(raw_ostream &OS, int Indent, PDBSymDumper &Dumper) const override;
|
||||
|
||||
FORWARD_SYMBOL_METHOD(getAddressOffset)
|
||||
FORWARD_SYMBOL_METHOD(getAddressSection)
|
||||
|
@ -24,7 +24,7 @@ public:
|
||||
|
||||
DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::Compiland)
|
||||
|
||||
void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level, PDB_DumpFlags Flags) const override;
|
||||
void dump(raw_ostream &OS, int Indent, PDBSymDumper &Dumper) const override;
|
||||
|
||||
FORWARD_SYMBOL_METHOD(isEditAndContinueEnabled)
|
||||
FORWARD_SYMBOL_METHOD(getLexicalParentId)
|
||||
|
@ -24,7 +24,7 @@ public:
|
||||
|
||||
DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::CompilandDetails)
|
||||
|
||||
void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level, PDB_DumpFlags Flags) const override;
|
||||
void dump(raw_ostream &OS, int Indent, PDBSymDumper &Dumper) const override;
|
||||
|
||||
void getFrontEndVersion(VersionInfo &Version) const {
|
||||
RawSymbol->getFrontEndVersion(Version);
|
||||
|
@ -24,7 +24,7 @@ public:
|
||||
|
||||
DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::CompilandEnv)
|
||||
|
||||
void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level, PDB_DumpFlags Flags) const override;
|
||||
void dump(raw_ostream &OS, int Indent, PDBSymDumper &Dumper) const override;
|
||||
|
||||
FORWARD_SYMBOL_METHOD(getLexicalParentId)
|
||||
FORWARD_SYMBOL_METHOD(getName)
|
||||
|
@ -28,7 +28,7 @@ public:
|
||||
|
||||
DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::Custom)
|
||||
|
||||
void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level, PDB_DumpFlags Flags) const override;
|
||||
void dump(raw_ostream &OS, int Indent, PDBSymDumper &Dumper) const override;
|
||||
|
||||
void getDataBytes(llvm::SmallVector<uint8_t, 32> &bytes);
|
||||
FORWARD_SYMBOL_METHOD(getSymIndexId)
|
||||
|
@ -24,7 +24,7 @@ public:
|
||||
|
||||
DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::Data)
|
||||
|
||||
void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level, PDB_DumpFlags Flags) const override;
|
||||
void dump(raw_ostream &OS, int Indent, PDBSymDumper &Dumper) const override;
|
||||
|
||||
FORWARD_SYMBOL_METHOD(getAccess)
|
||||
FORWARD_SYMBOL_METHOD(getAddressOffset)
|
||||
|
@ -25,7 +25,7 @@ public:
|
||||
|
||||
DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::Exe)
|
||||
|
||||
void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level, PDB_DumpFlags Flags) const override;
|
||||
void dump(raw_ostream &OS, int Indent, PDBSymDumper &Dumper) const override;
|
||||
|
||||
FORWARD_SYMBOL_METHOD(getAge)
|
||||
FORWARD_SYMBOL_METHOD(getGuid)
|
||||
|
@ -22,7 +22,7 @@ public:
|
||||
PDBSymbolFunc(const IPDBSession &PDBSession,
|
||||
std::unique_ptr<IPDBRawSymbol> FuncSymbol);
|
||||
|
||||
void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level, PDB_DumpFlags Flags) const override;
|
||||
void dump(raw_ostream &OS, int Indent, PDBSymDumper &Dumper) const override;
|
||||
|
||||
std::unique_ptr<PDBSymbolTypeFunctionSig> getSignature() const;
|
||||
|
||||
|
@ -24,7 +24,7 @@ public:
|
||||
|
||||
DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::FuncDebugEnd)
|
||||
|
||||
void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level, PDB_DumpFlags Flags) const override;
|
||||
void dump(raw_ostream &OS, int Indent, PDBSymDumper &Dumper) const override;
|
||||
|
||||
FORWARD_SYMBOL_METHOD(getAddressOffset)
|
||||
FORWARD_SYMBOL_METHOD(getAddressSection)
|
||||
|
@ -24,7 +24,7 @@ public:
|
||||
|
||||
DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::FuncDebugStart)
|
||||
|
||||
void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level, PDB_DumpFlags Flags) const override;
|
||||
void dump(raw_ostream &OS, int Indent, PDBSymDumper &Dumper) const override;
|
||||
|
||||
FORWARD_SYMBOL_METHOD(getAddressOffset)
|
||||
FORWARD_SYMBOL_METHOD(getAddressSection)
|
||||
|
@ -24,7 +24,7 @@ public:
|
||||
|
||||
DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::Label)
|
||||
|
||||
void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level, PDB_DumpFlags Flags) const override;
|
||||
void dump(raw_ostream &OS, int Indent, PDBSymDumper &Dumper) const override;
|
||||
|
||||
FORWARD_SYMBOL_METHOD(getAddressOffset)
|
||||
FORWARD_SYMBOL_METHOD(getAddressSection)
|
||||
|
@ -24,7 +24,7 @@ public:
|
||||
|
||||
DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::PublicSymbol)
|
||||
|
||||
void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level, PDB_DumpFlags Flags) const override;
|
||||
void dump(raw_ostream &OS, int Indent, PDBSymDumper &Dumper) const override;
|
||||
|
||||
FORWARD_SYMBOL_METHOD(getAddressOffset)
|
||||
FORWARD_SYMBOL_METHOD(getAddressSection)
|
||||
|
@ -25,7 +25,7 @@ public:
|
||||
|
||||
DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::Thunk)
|
||||
|
||||
void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level, PDB_DumpFlags Flags) const override;
|
||||
void dump(raw_ostream &OS, int Indent, PDBSymDumper &Dumper) const override;
|
||||
|
||||
FORWARD_SYMBOL_METHOD(getAccess)
|
||||
FORWARD_SYMBOL_METHOD(getAddressOffset)
|
||||
|
@ -24,7 +24,7 @@ public:
|
||||
|
||||
DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::ArrayType)
|
||||
|
||||
void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level, PDB_DumpFlags Flags) const override;
|
||||
void dump(raw_ostream &OS, int Indent, PDBSymDumper &Dumper) const override;
|
||||
|
||||
FORWARD_SYMBOL_METHOD(getArrayIndexTypeId)
|
||||
FORWARD_SYMBOL_METHOD(isConstType)
|
||||
|
@ -24,7 +24,7 @@ public:
|
||||
|
||||
DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::BaseClass)
|
||||
|
||||
void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level, PDB_DumpFlags Flags) const override;
|
||||
void dump(raw_ostream &OS, int Indent, PDBSymDumper &Dumper) const override;
|
||||
|
||||
FORWARD_SYMBOL_METHOD(getAccess)
|
||||
FORWARD_SYMBOL_METHOD(getClassParentId)
|
||||
|
@ -24,7 +24,7 @@ public:
|
||||
|
||||
DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::BuiltinType)
|
||||
|
||||
void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level, PDB_DumpFlags Flags) const override;
|
||||
void dump(raw_ostream &OS, int Indent, PDBSymDumper &Dumper) const override;
|
||||
|
||||
FORWARD_SYMBOL_METHOD(getBuiltinType)
|
||||
FORWARD_SYMBOL_METHOD(isConstType)
|
||||
|
@ -24,7 +24,7 @@ public:
|
||||
|
||||
DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::CustomType)
|
||||
|
||||
void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level, PDB_DumpFlags Flags) const override;
|
||||
void dump(raw_ostream &OS, int Indent, PDBSymDumper &Dumper) const override;
|
||||
|
||||
FORWARD_SYMBOL_METHOD(getOemId)
|
||||
FORWARD_SYMBOL_METHOD(getOemSymbolId)
|
||||
|
@ -24,7 +24,7 @@ public:
|
||||
|
||||
DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::Dimension)
|
||||
|
||||
void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level, PDB_DumpFlags Flags) const override;
|
||||
void dump(raw_ostream &OS, int Indent, PDBSymDumper &Dumper) const override;
|
||||
|
||||
FORWARD_SYMBOL_METHOD(getLowerBoundId)
|
||||
FORWARD_SYMBOL_METHOD(getUpperBoundId)
|
||||
|
@ -24,7 +24,7 @@ public:
|
||||
|
||||
DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::Enum)
|
||||
|
||||
void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level, PDB_DumpFlags Flags) const override;
|
||||
void dump(raw_ostream &OS, int Indent, PDBSymDumper &Dumper) const override;
|
||||
|
||||
FORWARD_SYMBOL_METHOD(getBuiltinType)
|
||||
FORWARD_SYMBOL_METHOD(getClassParentId)
|
||||
|
@ -24,7 +24,7 @@ public:
|
||||
|
||||
DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::Friend)
|
||||
|
||||
void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level, PDB_DumpFlags Flags) const override;
|
||||
void dump(raw_ostream &OS, int Indent, PDBSymDumper &Dumper) const override;
|
||||
|
||||
FORWARD_SYMBOL_METHOD(getClassParentId)
|
||||
FORWARD_SYMBOL_METHOD(getName)
|
||||
|
@ -24,7 +24,7 @@ public:
|
||||
|
||||
DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::FunctionArg)
|
||||
|
||||
void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level, PDB_DumpFlags Flags) const override;
|
||||
void dump(raw_ostream &OS, int Indent, PDBSymDumper &Dumper) const override;
|
||||
|
||||
FORWARD_SYMBOL_METHOD(getClassParentId)
|
||||
FORWARD_SYMBOL_METHOD(getLexicalParentId)
|
||||
|
@ -28,7 +28,7 @@ public:
|
||||
std::unique_ptr<IPDBEnumSymbols> getArguments() const;
|
||||
std::unique_ptr<PDBSymbol> getClassParent() const;
|
||||
|
||||
void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level, PDB_DumpFlags Flags) const override;
|
||||
void dump(raw_ostream &OS, int Indent, PDBSymDumper &Dumper) const override;
|
||||
void dumpArgList(raw_ostream &OS) const;
|
||||
|
||||
FORWARD_SYMBOL_METHOD(getCallingConvention)
|
||||
|
@ -24,7 +24,7 @@ public:
|
||||
|
||||
DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::ManagedType)
|
||||
|
||||
void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level, PDB_DumpFlags Flags) const override;
|
||||
void dump(raw_ostream &OS, int Indent, PDBSymDumper &Dumper) const override;
|
||||
|
||||
FORWARD_SYMBOL_METHOD(getName)
|
||||
FORWARD_SYMBOL_METHOD(getSymIndexId)
|
||||
|
@ -24,7 +24,7 @@ public:
|
||||
|
||||
DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::PointerType)
|
||||
|
||||
void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level, PDB_DumpFlags Flags) const override;
|
||||
void dump(raw_ostream &OS, int Indent, PDBSymDumper &Dumper) const override;
|
||||
|
||||
FORWARD_SYMBOL_METHOD(isConstType)
|
||||
FORWARD_SYMBOL_METHOD(getLength)
|
||||
|
@ -24,7 +24,7 @@ public:
|
||||
|
||||
DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::Typedef)
|
||||
|
||||
void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level, PDB_DumpFlags Flags) const override;
|
||||
void dump(raw_ostream &OS, int Indent, PDBSymDumper &Dumper) const override;
|
||||
|
||||
FORWARD_SYMBOL_METHOD(getBuiltinType)
|
||||
FORWARD_SYMBOL_METHOD(getClassParentId)
|
||||
|
@ -24,7 +24,7 @@ public:
|
||||
|
||||
DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::UDT)
|
||||
|
||||
void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level, PDB_DumpFlags Flags) const override;
|
||||
void dump(raw_ostream &OS, int Indent, PDBSymDumper &Dumper) const override;
|
||||
|
||||
FORWARD_SYMBOL_METHOD(getClassParentId)
|
||||
FORWARD_SYMBOL_METHOD(hasConstructor)
|
||||
|
@ -24,7 +24,7 @@ public:
|
||||
|
||||
DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::VTable)
|
||||
|
||||
void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level, PDB_DumpFlags Flags) const override;
|
||||
void dump(raw_ostream &OS, int Indent, PDBSymDumper &Dumper) const override;
|
||||
|
||||
FORWARD_SYMBOL_METHOD(getClassParentId)
|
||||
FORWARD_SYMBOL_METHOD(isConstType)
|
||||
|
@ -24,7 +24,7 @@ public:
|
||||
|
||||
DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::VTableShape)
|
||||
|
||||
void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level, PDB_DumpFlags Flags) const override;
|
||||
void dump(raw_ostream &OS, int Indent, PDBSymDumper &Dumper) const override;
|
||||
|
||||
FORWARD_SYMBOL_METHOD(isConstType)
|
||||
FORWARD_SYMBOL_METHOD(getCount)
|
||||
|
@ -21,7 +21,7 @@ public:
|
||||
PDBSymbolUnknown(const IPDBSession &PDBSession,
|
||||
std::unique_ptr<IPDBRawSymbol> UnknownSymbol);
|
||||
|
||||
void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level, PDB_DumpFlags Flags) const override;
|
||||
void dump(raw_ostream &OS, int Indent, PDBSymDumper &Dumper) const override;
|
||||
|
||||
static bool classof(const PDBSymbol *S) {
|
||||
return (S->getSymTag() == PDB_SymType::None ||
|
||||
|
@ -24,7 +24,7 @@ public:
|
||||
|
||||
DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::UsingNamespace)
|
||||
|
||||
void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level, PDB_DumpFlags Flags) const override;
|
||||
void dump(raw_ostream &OS, int Indent, PDBSymDumper &Dumper) const override;
|
||||
|
||||
FORWARD_SYMBOL_METHOD(getLexicalParentId)
|
||||
FORWARD_SYMBOL_METHOD(getName)
|
||||
|
@ -16,10 +16,8 @@
|
||||
|
||||
namespace llvm {
|
||||
|
||||
class PDBSymDumper;
|
||||
class PDBSymbol;
|
||||
class PDBSymbolCompiland;
|
||||
class PDBSymbolFunc;
|
||||
class PDBSymbolExe;
|
||||
|
||||
class IPDBDataStream;
|
||||
template <class T> class IPDBEnumChildren;
|
||||
|
@ -66,6 +66,7 @@ add_llvm_library(LLVMDebugInfoPDB
|
||||
PDBSymbolTypeVTableShape.cpp
|
||||
PDBSymbolUnknown.cpp
|
||||
PDBSymbolUsingNamespace.cpp
|
||||
PDBSymDumper.cpp
|
||||
${PDB_IMPL_SOURCES}
|
||||
|
||||
ADDITIONAL_HEADER_DIRS
|
||||
|
@ -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)
|
||||
|
177
lib/DebugInfo/PDB/PDBSymDumper.cpp
Normal file
177
lib/DebugInfo/PDB/PDBSymDumper.cpp
Normal file
@ -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)
|
||||
}
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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 {}
|
||||
PDBSymDumper &Dumper) const {
|
||||
Dumper.dump(*this, OS, Indent);
|
||||
}
|
@ -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);
|
||||
}
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
; The format is func [0x<rva_start>+<prologue_length> - 0x<rva_end>-<epilogue_length>]
|
||||
; SYM_FORMAT: symbolformat-fpo.obj
|
||||
; SYM_FORMAT-DAG: func [0x001130+0 - 0x001137-1] (VFrame) uint32_t __cdecl fpo_func(uint32_t)
|
||||
; SYM_FORMAT-DAG: func [0x001130+0 - 0x001137-1] (FPO) uint32_t __cdecl fpo_func(uint32_t)
|
||||
; SYM_FORMAT: symbolformat.obj
|
||||
; SYM_FORMAT-DAG: func [0x001060+3 - 0x001067-2] (EBP) int32_t __cdecl _purecall()
|
||||
; SYM_FORMAT-DAG: func [0x001070+6 - 0x001099-4] (EBP) int32_t __cdecl main(int32_t, char**)
|
||||
@ -17,11 +17,11 @@
|
||||
; TYPES_FORMAT: Function Signatures
|
||||
; TYPES_FORMAT-DAG: int32_t __cdecl ()
|
||||
; TYPES_FORMAT-DAG: int32_t __cdecl (int32_t, char**)
|
||||
; TYPES_FORMAT-DAG: void __thiscall (A::*)()
|
||||
; TYPES_FORMAT-DAG: void __thiscall (B::*)()
|
||||
; TYPES_FORMAT-DAG: void __thiscall (B::*)(B&)
|
||||
; TYPES_FORMAT-DAG: void __thiscall (B::*)()
|
||||
; TYPES_FORMAT-DAG: B& __thiscall (B::*)(B&)
|
||||
; TYPES_FORMAT-DAG: void __thiscall (A::*)(A&)
|
||||
; TYPES_FORMAT-DAG: void __thiscall (A::*)()
|
||||
; TYPES_FORMAT-DAG: A& __thiscall (A::*)(A&)
|
||||
; TYPES_FORMAT-DAG: void __thiscall (A::)()
|
||||
; TYPES_FORMAT-DAG: void __thiscall (B::)()
|
||||
; TYPES_FORMAT-DAG: void __thiscall (B::)(B&)
|
||||
; TYPES_FORMAT-DAG: void __thiscall (B::)()
|
||||
; TYPES_FORMAT-DAG: B& __thiscall (B::)(B&)
|
||||
; TYPES_FORMAT-DAG: void __thiscall (A::)(A&)
|
||||
; TYPES_FORMAT-DAG: void __thiscall (A::)()
|
||||
; TYPES_FORMAT-DAG: A& __thiscall (A::)(A&)
|
||||
|
@ -5,4 +5,8 @@ set(LLVM_LINK_COMPONENTS
|
||||
|
||||
add_llvm_tool(llvm-pdbdump
|
||||
llvm-pdbdump.cpp
|
||||
CompilandDumper.cpp
|
||||
FunctionDumper.cpp
|
||||
TypeDumper.cpp
|
||||
TypedefDumper.cpp
|
||||
)
|
||||
|
132
tools/llvm-pdbdump/CompilandDumper.cpp
Normal file
132
tools/llvm-pdbdump/CompilandDumper.cpp
Normal file
@ -0,0 +1,132 @@
|
||||
//===- CompilandDumper.cpp - llvm-pdbdump compiland symbol dumper *- C++ *-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "CompilandDumper.h"
|
||||
#include "llvm-pdbdump.h"
|
||||
|
||||
#include "llvm/DebugInfo/PDB/IPDBEnumChildren.h"
|
||||
#include "llvm/DebugInfo/PDB/IPDBSession.h"
|
||||
#include "llvm/DebugInfo/PDB/PDBExtras.h"
|
||||
#include "llvm/DebugInfo/PDB/PDBSymbol.h"
|
||||
#include "llvm/DebugInfo/PDB/PDBSymbolCompiland.h"
|
||||
#include "llvm/DebugInfo/PDB/PDBSymbolData.h"
|
||||
#include "llvm/DebugInfo/PDB/PDBSymbolFunc.h"
|
||||
#include "llvm/DebugInfo/PDB/PDBSymbolFuncDebugEnd.h"
|
||||
#include "llvm/DebugInfo/PDB/PDBSymbolFuncDebugStart.h"
|
||||
#include "llvm/DebugInfo/PDB/PDBSymbolLabel.h"
|
||||
#include "llvm/DebugInfo/PDB/PDBSymbolThunk.h"
|
||||
#include "llvm/DebugInfo/PDB/PDBSymbolTypeFunctionSig.h"
|
||||
#include "llvm/DebugInfo/PDB/PDBSymbolUnknown.h"
|
||||
#include "llvm/Support/Format.h"
|
||||
#include "llvm/Support/Path.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
|
||||
#include "FunctionDumper.h"
|
||||
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
using namespace llvm;
|
||||
|
||||
CompilandDumper::CompilandDumper() : PDBSymDumper(true) {}
|
||||
|
||||
void CompilandDumper::dump(const PDBSymbolCompilandDetails &Symbol,
|
||||
raw_ostream &OS, int Indent) {}
|
||||
|
||||
void CompilandDumper::dump(const PDBSymbolCompilandEnv &Symbol, raw_ostream &OS,
|
||||
int Indent) {}
|
||||
|
||||
void CompilandDumper::start(const PDBSymbolCompiland &Symbol, raw_ostream &OS,
|
||||
int Indent, bool Children) {
|
||||
std::string FullName = Symbol.getName();
|
||||
OS << newline(Indent) << FullName;
|
||||
if (!Children)
|
||||
return;
|
||||
|
||||
auto ChildrenEnum = Symbol.findAllChildren();
|
||||
while (auto Child = ChildrenEnum->getNext())
|
||||
Child->dump(OS, Indent + 2, *this);
|
||||
}
|
||||
|
||||
void CompilandDumper::dump(const PDBSymbolData &Symbol, raw_ostream &OS,
|
||||
int Indent) {
|
||||
OS << newline(Indent);
|
||||
switch (auto LocType = Symbol.getLocationType()) {
|
||||
case PDB_LocType::Static:
|
||||
OS << "data: [";
|
||||
OS << format_hex(Symbol.getRelativeVirtualAddress(), 10);
|
||||
OS << "]";
|
||||
break;
|
||||
case PDB_LocType::Constant:
|
||||
OS << "constant: [" << Symbol.getValue() << "]";
|
||||
break;
|
||||
default:
|
||||
OS << "data(unexpected type=" << LocType << ")";
|
||||
}
|
||||
|
||||
OS << " " << Symbol.getName();
|
||||
}
|
||||
|
||||
void CompilandDumper::dump(const PDBSymbolFunc &Symbol, raw_ostream &OS,
|
||||
int Indent) {
|
||||
uint32_t FuncStart = Symbol.getRelativeVirtualAddress();
|
||||
uint32_t FuncEnd = FuncStart + Symbol.getLength();
|
||||
OS << newline(Indent) << "func [" << format_hex(FuncStart, 8);
|
||||
if (auto DebugStart = Symbol.findOneChild<PDBSymbolFuncDebugStart>())
|
||||
OS << "+" << DebugStart->getRelativeVirtualAddress() - FuncStart;
|
||||
OS << " - " << format_hex(FuncEnd, 8);
|
||||
if (auto DebugEnd = Symbol.findOneChild<PDBSymbolFuncDebugEnd>())
|
||||
OS << "-" << FuncEnd - DebugEnd->getRelativeVirtualAddress();
|
||||
OS << "] ";
|
||||
|
||||
if (Symbol.hasFramePointer())
|
||||
OS << "(" << Symbol.getLocalBasePointerRegisterId() << ")";
|
||||
else
|
||||
OS << "(FPO)";
|
||||
|
||||
OS << " ";
|
||||
|
||||
FunctionDumper Dumper;
|
||||
Dumper.start(Symbol, OS);
|
||||
OS.flush();
|
||||
}
|
||||
|
||||
void CompilandDumper::dump(const PDBSymbolLabel &Symbol, raw_ostream &OS,
|
||||
int Indent) {
|
||||
OS << newline(Indent);
|
||||
OS << "label [" << format_hex(Symbol.getRelativeVirtualAddress(), 10) << "] "
|
||||
<< Symbol.getName();
|
||||
}
|
||||
|
||||
void CompilandDumper::dump(const PDBSymbolThunk &Symbol, raw_ostream &OS,
|
||||
int Indent) {
|
||||
OS << newline(Indent) << "thunk ";
|
||||
PDB_ThunkOrdinal Ordinal = Symbol.getThunkOrdinal();
|
||||
uint32_t RVA = Symbol.getRelativeVirtualAddress();
|
||||
if (Ordinal == PDB_ThunkOrdinal::TrampIncremental) {
|
||||
OS << format_hex(RVA, 10);
|
||||
OS << " -> " << format_hex(Symbol.getTargetRelativeVirtualAddress(), 10);
|
||||
} else {
|
||||
OS << "[" << format_hex(RVA, 10);
|
||||
OS << " - " << format_hex(RVA + Symbol.getLength(), 10) << "]";
|
||||
}
|
||||
OS << " (" << Ordinal << ") ";
|
||||
std::string Name = Symbol.getName();
|
||||
if (!Name.empty())
|
||||
OS << Name;
|
||||
}
|
||||
|
||||
void CompilandDumper::dump(const PDBSymbolTypeTypedef &Symbol, raw_ostream &OS,
|
||||
int Indent) {}
|
||||
|
||||
void CompilandDumper::dump(const PDBSymbolUnknown &Symbol, raw_ostream &OS,
|
||||
int Indent) {
|
||||
OS << newline(Indent);
|
||||
OS << "unknown (" << Symbol.getSymTag() << ")";
|
||||
}
|
39
tools/llvm-pdbdump/CompilandDumper.h
Normal file
39
tools/llvm-pdbdump/CompilandDumper.h
Normal file
@ -0,0 +1,39 @@
|
||||
//===- CompilandDumper.h - llvm-pdbdump compiland symbol dumper *- C++ --*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LLVM_TOOLS_LLVMPDBDUMP_COMPILANDDUMPER_H
|
||||
#define LLVM_TOOLS_LLVMPDBDUMP_COMPILANDDUMPER_H
|
||||
|
||||
#include "llvm/DebugInfo/PDB/PDBSymDumper.h"
|
||||
|
||||
namespace llvm {
|
||||
|
||||
class CompilandDumper : public PDBSymDumper {
|
||||
public:
|
||||
CompilandDumper();
|
||||
|
||||
void start(const PDBSymbolCompiland &Symbol, raw_ostream &OS, int Indent,
|
||||
bool Children);
|
||||
|
||||
void dump(const PDBSymbolCompilandDetails &Symbol, raw_ostream &OS,
|
||||
int Indent) override;
|
||||
void dump(const PDBSymbolCompilandEnv &Symbol, raw_ostream &OS,
|
||||
int Indent) override;
|
||||
void dump(const PDBSymbolData &Symbol, raw_ostream &OS, int Indent) override;
|
||||
void dump(const PDBSymbolFunc &Symbol, raw_ostream &OS, int Indent) override;
|
||||
void dump(const PDBSymbolLabel &Symbol, raw_ostream &OS, int Indent) override;
|
||||
void dump(const PDBSymbolThunk &Symbol, raw_ostream &OS, int Indent) override;
|
||||
void dump(const PDBSymbolTypeTypedef &Symbol, raw_ostream &OS,
|
||||
int Indent) override;
|
||||
void dump(const PDBSymbolUnknown &Symbol, raw_ostream &OS,
|
||||
int Indent) override;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
187
tools/llvm-pdbdump/FunctionDumper.cpp
Normal file
187
tools/llvm-pdbdump/FunctionDumper.cpp
Normal file
@ -0,0 +1,187 @@
|
||||
//===- FunctionDumper.cpp ------------------------------------ *- C++ *-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "FunctionDumper.h"
|
||||
|
||||
#include "llvm/DebugInfo/PDB/IPDBSession.h"
|
||||
#include "llvm/DebugInfo/PDB/PDBSymbolFunc.h"
|
||||
#include "llvm/DebugInfo/PDB/PDBSymbolTypeArray.h"
|
||||
#include "llvm/DebugInfo/PDB/PDBSymbolTypeBuiltin.h"
|
||||
#include "llvm/DebugInfo/PDB/PDBSymbolTypeEnum.h"
|
||||
#include "llvm/DebugInfo/PDB/PDBSymbolTypeFunctionArg.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"
|
||||
|
||||
namespace {
|
||||
template <class T>
|
||||
void dumpClassParentWithScopeOperator(const T &Symbol, llvm::raw_ostream &OS,
|
||||
llvm::FunctionDumper &Dumper) {
|
||||
uint32_t ClassParentId = Symbol.getClassParentId();
|
||||
auto ClassParent =
|
||||
Symbol.getSession().getConcreteSymbolById<PDBSymbolTypeUDT>(
|
||||
ClassParentId);
|
||||
if (!ClassParent)
|
||||
return;
|
||||
|
||||
OS << ClassParent->getName() << "::";
|
||||
}
|
||||
}
|
||||
|
||||
using namespace llvm;
|
||||
|
||||
FunctionDumper::FunctionDumper() : PDBSymDumper(true) {}
|
||||
|
||||
void FunctionDumper::start(const PDBSymbolTypeFunctionSig &Symbol,
|
||||
PointerType Pointer, raw_ostream &OS) {
|
||||
auto ReturnType = Symbol.getReturnType();
|
||||
ReturnType->dump(OS, 0, *this);
|
||||
OS << " ";
|
||||
uint32_t ClassParentId = Symbol.getClassParentId();
|
||||
auto ClassParent =
|
||||
Symbol.getSession().getConcreteSymbolById<PDBSymbolTypeUDT>(
|
||||
ClassParentId);
|
||||
|
||||
if (Pointer == PointerType::None) {
|
||||
OS << Symbol.getCallingConvention() << " ";
|
||||
if (ClassParent)
|
||||
OS << "(" << ClassParent->getName() << "::)";
|
||||
} else {
|
||||
OS << "(" << Symbol.getCallingConvention() << " ";
|
||||
if (ClassParent)
|
||||
OS << ClassParent->getName() << "::";
|
||||
if (Pointer == PointerType::Reference)
|
||||
OS << "&";
|
||||
else
|
||||
OS << "*";
|
||||
OS << ")";
|
||||
}
|
||||
|
||||
OS << "(";
|
||||
if (auto ChildEnum = Symbol.getArguments()) {
|
||||
uint32_t Index = 0;
|
||||
while (auto Arg = ChildEnum->getNext()) {
|
||||
Arg->dump(OS, 0, *this);
|
||||
if (++Index < ChildEnum->getChildCount())
|
||||
OS << ", ";
|
||||
}
|
||||
}
|
||||
OS << ")";
|
||||
|
||||
if (Symbol.isConstType())
|
||||
OS << " const";
|
||||
if (Symbol.isVolatileType())
|
||||
OS << " volatile";
|
||||
}
|
||||
|
||||
void FunctionDumper::start(const PDBSymbolFunc &Symbol, raw_ostream &OS) {
|
||||
if (Symbol.isVirtual() || Symbol.isPureVirtual())
|
||||
OS << "virtual ";
|
||||
|
||||
auto Signature = Symbol.getSignature();
|
||||
if (!Signature) {
|
||||
OS << Symbol.getName();
|
||||
return;
|
||||
}
|
||||
|
||||
auto ReturnType = Signature->getReturnType();
|
||||
ReturnType->dump(OS, 0, *this);
|
||||
|
||||
OS << " " << Signature->getCallingConvention() << " ";
|
||||
OS << Symbol.getName();
|
||||
|
||||
OS << "(";
|
||||
if (auto ChildEnum = Signature->getArguments()) {
|
||||
uint32_t Index = 0;
|
||||
while (auto Arg = ChildEnum->getNext()) {
|
||||
Arg->dump(OS, 0, *this);
|
||||
if (++Index < ChildEnum->getChildCount())
|
||||
OS << ", ";
|
||||
}
|
||||
}
|
||||
OS << ")";
|
||||
|
||||
if (Symbol.isConstType())
|
||||
OS << " const";
|
||||
if (Symbol.isVolatileType())
|
||||
OS << " volatile";
|
||||
if (Symbol.isPureVirtual())
|
||||
OS << " = 0";
|
||||
}
|
||||
|
||||
void FunctionDumper::dump(const PDBSymbolTypeArray &Symbol, raw_ostream &OS,
|
||||
int Indent) {
|
||||
uint32_t ElementTypeId = Symbol.getTypeId();
|
||||
auto ElementType = Symbol.getSession().getSymbolById(ElementTypeId);
|
||||
if (!ElementType)
|
||||
return;
|
||||
|
||||
ElementType->dump(OS, 0, *this);
|
||||
OS << "[" << Symbol.getLength() << "]";
|
||||
}
|
||||
|
||||
void FunctionDumper::dump(const PDBSymbolTypeBuiltin &Symbol, raw_ostream &OS,
|
||||
int Indent) {
|
||||
PDB_BuiltinType Type = Symbol.getBuiltinType();
|
||||
OS << Type;
|
||||
if (Type == PDB_BuiltinType::UInt || Type == PDB_BuiltinType::Int)
|
||||
OS << (8 * Symbol.getLength()) << "_t";
|
||||
}
|
||||
|
||||
void FunctionDumper::dump(const PDBSymbolTypeEnum &Symbol, raw_ostream &OS,
|
||||
int Indent) {
|
||||
dumpClassParentWithScopeOperator(Symbol, OS, *this);
|
||||
OS << Symbol.getName();
|
||||
}
|
||||
|
||||
void FunctionDumper::dump(const PDBSymbolTypeFunctionArg &Symbol,
|
||||
raw_ostream &OS, int Indent) {
|
||||
// PDBSymbolTypeFunctionArg is just a shim over the real argument. Just drill
|
||||
// through to the
|
||||
// real thing and dump it.
|
||||
uint32_t TypeId = Symbol.getTypeId();
|
||||
auto Type = Symbol.getSession().getSymbolById(TypeId);
|
||||
if (!Type)
|
||||
return;
|
||||
Type->dump(OS, 0, *this);
|
||||
}
|
||||
|
||||
void FunctionDumper::dump(const PDBSymbolTypeTypedef &Symbol, raw_ostream &OS,
|
||||
int Indent) {
|
||||
dumpClassParentWithScopeOperator(Symbol, OS, *this);
|
||||
OS << Symbol.getName();
|
||||
}
|
||||
|
||||
void FunctionDumper::dump(const PDBSymbolTypePointer &Symbol, raw_ostream &OS,
|
||||
int Indent) {
|
||||
uint32_t PointeeId = Symbol.getTypeId();
|
||||
auto PointeeType = Symbol.getSession().getSymbolById(PointeeId);
|
||||
if (!PointeeType)
|
||||
return;
|
||||
|
||||
if (auto FuncSig = dyn_cast<PDBSymbolTypeFunctionSig>(PointeeType.get())) {
|
||||
FunctionDumper NestedDumper;
|
||||
PointerType Pointer =
|
||||
Symbol.isReference() ? PointerType::Reference : PointerType::Pointer;
|
||||
NestedDumper.start(*FuncSig, Pointer, OS);
|
||||
} else {
|
||||
if (Symbol.isConstType())
|
||||
OS << "const ";
|
||||
if (Symbol.isVolatileType())
|
||||
OS << "volatile ";
|
||||
PointeeType->dump(OS, Indent, *this);
|
||||
OS << (Symbol.isReference() ? "&" : "*");
|
||||
}
|
||||
}
|
||||
|
||||
void FunctionDumper::dump(const PDBSymbolTypeUDT &Symbol, raw_ostream &OS,
|
||||
int Indent) {
|
||||
OS << Symbol.getName();
|
||||
}
|
44
tools/llvm-pdbdump/FunctionDumper.h
Normal file
44
tools/llvm-pdbdump/FunctionDumper.h
Normal file
@ -0,0 +1,44 @@
|
||||
//===- FunctionDumper.h --------------------------------------- *- C++ --*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LLVM_TOOLS_LLVMPDBDUMP_FUNCTIONDUMPER_H
|
||||
#define LLVM_TOOLS_LLVMPDBDUMP_FUNCTIONDUMPER_H
|
||||
|
||||
#include "llvm/DebugInfo/PDB/PDBSymDumper.h"
|
||||
|
||||
namespace llvm {
|
||||
|
||||
class FunctionDumper : public PDBSymDumper {
|
||||
public:
|
||||
FunctionDumper();
|
||||
|
||||
enum class PointerType { None, Pointer, Reference };
|
||||
|
||||
void start(const PDBSymbolTypeFunctionSig &Symbol, PointerType Pointer,
|
||||
raw_ostream &OS);
|
||||
void start(const PDBSymbolFunc &Symbol, raw_ostream &OS);
|
||||
|
||||
void dump(const PDBSymbolTypeArray &Symbol, raw_ostream &OS,
|
||||
int Indent) override;
|
||||
void dump(const PDBSymbolTypeBuiltin &Symbol, raw_ostream &OS,
|
||||
int Indent) override;
|
||||
void dump(const PDBSymbolTypeEnum &Symbol, raw_ostream &OS,
|
||||
int Indent) override;
|
||||
void dump(const PDBSymbolTypeFunctionArg &Symbol, raw_ostream &OS,
|
||||
int Indent) override;
|
||||
void dump(const PDBSymbolTypePointer &Symbol, raw_ostream &OS,
|
||||
int Indent) override;
|
||||
void dump(const PDBSymbolTypeTypedef &Symbol, raw_ostream &OS,
|
||||
int Indent) override;
|
||||
void dump(const PDBSymbolTypeUDT &Symbol, raw_ostream &OS,
|
||||
int Indent) override;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
63
tools/llvm-pdbdump/TypeDumper.cpp
Normal file
63
tools/llvm-pdbdump/TypeDumper.cpp
Normal file
@ -0,0 +1,63 @@
|
||||
//===- TypeDumper.cpp - PDBSymDumper implementation for types *----- C++ *-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "TypeDumper.h"
|
||||
|
||||
#include "FunctionDumper.h"
|
||||
#include "llvm-pdbdump.h"
|
||||
#include "TypedefDumper.h"
|
||||
|
||||
#include "llvm/DebugInfo/PDB/IPDBSession.h"
|
||||
#include "llvm/DebugInfo/PDB/PDBSymbolExe.h"
|
||||
#include "llvm/DebugInfo/PDB/PDBSymbolTypeEnum.h"
|
||||
#include "llvm/DebugInfo/PDB/PDBSymbolTypeFunctionSig.h"
|
||||
#include "llvm/DebugInfo/PDB/PDBSymbolTypeTypedef.h"
|
||||
|
||||
using namespace llvm;
|
||||
|
||||
TypeDumper::TypeDumper() : PDBSymDumper(true) {}
|
||||
|
||||
void TypeDumper::start(const PDBSymbolExe &Exe, raw_ostream &OS, int Indent) {
|
||||
auto Enums = Exe.findAllChildren<PDBSymbolTypeEnum>();
|
||||
OS << newline(Indent) << "Enums: (" << Enums->getChildCount() << " items)";
|
||||
while (auto Enum = Enums->getNext())
|
||||
Enum->dump(OS, Indent + 2, *this);
|
||||
|
||||
auto FuncSigs = Exe.findAllChildren<PDBSymbolTypeFunctionSig>();
|
||||
OS << newline(Indent);
|
||||
OS << "Function Signatures: (" << FuncSigs->getChildCount() << " items)";
|
||||
while (auto Sig = FuncSigs->getNext())
|
||||
Sig->dump(OS, Indent + 2, *this);
|
||||
|
||||
auto Typedefs = Exe.findAllChildren<PDBSymbolTypeTypedef>();
|
||||
OS << newline(Indent) << "Typedefs: (" << Typedefs->getChildCount()
|
||||
<< " items)";
|
||||
while (auto Typedef = Typedefs->getNext())
|
||||
Typedef->dump(OS, Indent + 2, *this);
|
||||
}
|
||||
|
||||
void TypeDumper::dump(const PDBSymbolTypeEnum &Symbol, raw_ostream &OS,
|
||||
int Indent) {
|
||||
OS << newline(Indent) << "enum " << Symbol.getName();
|
||||
}
|
||||
|
||||
void TypeDumper::dump(const PDBSymbolTypeFunctionSig &Symbol, raw_ostream &OS,
|
||||
int Indent) {
|
||||
OS << newline(Indent);
|
||||
FunctionDumper Dumper;
|
||||
Dumper.start(Symbol, FunctionDumper::PointerType::None, OS);
|
||||
}
|
||||
|
||||
void TypeDumper::dump(const PDBSymbolTypeTypedef &Symbol, raw_ostream &OS,
|
||||
int Indent) {
|
||||
OS << newline(Indent);
|
||||
TypedefDumper Dumper;
|
||||
Dumper.start(Symbol, OS, Indent);
|
||||
OS.flush();
|
||||
}
|
32
tools/llvm-pdbdump/TypeDumper.h
Normal file
32
tools/llvm-pdbdump/TypeDumper.h
Normal file
@ -0,0 +1,32 @@
|
||||
//===- TypeDumper.h - PDBSymDumper implementation for types *- C++ ------*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LLVM_TOOLS_LLVMPDBDUMP_TYPEDUMPER_H
|
||||
#define LLVM_TOOLS_LLVMPDBDUMP_TYPEDUMPER_H
|
||||
|
||||
#include "llvm/DebugInfo/PDB/PDBSymDumper.h"
|
||||
|
||||
namespace llvm {
|
||||
|
||||
class TypeDumper : public PDBSymDumper {
|
||||
public:
|
||||
TypeDumper();
|
||||
|
||||
void start(const PDBSymbolExe &Exe, raw_ostream &OS, int Indent);
|
||||
|
||||
void dump(const PDBSymbolTypeEnum &Symbol, raw_ostream &OS,
|
||||
int Indent) override;
|
||||
void dump(const PDBSymbolTypeFunctionSig &Symbol, raw_ostream &OS,
|
||||
int Indent) override;
|
||||
void dump(const PDBSymbolTypeTypedef &Symbol, raw_ostream &OS,
|
||||
int Indent) override;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
84
tools/llvm-pdbdump/TypedefDumper.cpp
Normal file
84
tools/llvm-pdbdump/TypedefDumper.cpp
Normal file
@ -0,0 +1,84 @@
|
||||
//===- TypedefDumper.cpp - PDBSymDumper impl for typedefs -------- * C++ *-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "TypedefDumper.h"
|
||||
|
||||
#include "FunctionDumper.h"
|
||||
#include "llvm-pdbdump.h"
|
||||
|
||||
#include "llvm/DebugInfo/PDB/IPDBSession.h"
|
||||
#include "llvm/DebugInfo/PDB/PDBExtras.h"
|
||||
#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"
|
||||
|
||||
using namespace llvm;
|
||||
|
||||
TypedefDumper::TypedefDumper() : PDBSymDumper(true) {}
|
||||
|
||||
void TypedefDumper::start(const PDBSymbolTypeTypedef &Symbol, raw_ostream &OS,
|
||||
int Indent) {
|
||||
OS << "typedef:" << Symbol.getName() << " -> ";
|
||||
uint32_t TargetId = Symbol.getTypeId();
|
||||
if (auto TypeSymbol = Symbol.getSession().getSymbolById(TargetId))
|
||||
TypeSymbol->dump(OS, 0, *this);
|
||||
}
|
||||
|
||||
void TypedefDumper::dump(const PDBSymbolTypeArray &Symbol, raw_ostream &OS,
|
||||
int Indent) {}
|
||||
|
||||
void TypedefDumper::dump(const PDBSymbolTypeBuiltin &Symbol, raw_ostream &OS,
|
||||
int Indent) {
|
||||
PDB_BuiltinType Type = Symbol.getBuiltinType();
|
||||
OS << Type;
|
||||
if (Type == PDB_BuiltinType::UInt || Type == PDB_BuiltinType::Int)
|
||||
OS << (8 * Symbol.getLength()) << "_t";
|
||||
}
|
||||
|
||||
void TypedefDumper::dump(const PDBSymbolTypeEnum &Symbol, raw_ostream &OS,
|
||||
int Indent) {
|
||||
OS << "enum " << Symbol.getName();
|
||||
}
|
||||
|
||||
void TypedefDumper::dump(const PDBSymbolTypePointer &Symbol, raw_ostream &OS,
|
||||
int Indent) {
|
||||
if (Symbol.isConstType())
|
||||
OS << "const ";
|
||||
if (Symbol.isVolatileType())
|
||||
OS << "volatile ";
|
||||
uint32_t PointeeId = Symbol.getTypeId();
|
||||
auto PointeeType = Symbol.getSession().getSymbolById(PointeeId);
|
||||
if (!PointeeType)
|
||||
return;
|
||||
if (auto FuncSig = dyn_cast<PDBSymbolTypeFunctionSig>(PointeeType.get())) {
|
||||
FunctionDumper::PointerType Pointer = FunctionDumper::PointerType::Pointer;
|
||||
if (Symbol.isReference())
|
||||
Pointer = FunctionDumper::PointerType::Reference;
|
||||
FunctionDumper NestedDumper;
|
||||
NestedDumper.start(*FuncSig, Pointer, OS);
|
||||
OS.flush();
|
||||
} else {
|
||||
PointeeType->dump(OS, Indent, *this);
|
||||
OS << ((Symbol.isReference()) ? "&" : "*");
|
||||
}
|
||||
}
|
||||
|
||||
void TypedefDumper::dump(const PDBSymbolTypeFunctionSig &Symbol,
|
||||
raw_ostream &OS, int Indent) {
|
||||
FunctionDumper Dumper;
|
||||
Dumper.start(Symbol, FunctionDumper::PointerType::None, OS);
|
||||
}
|
||||
|
||||
void TypedefDumper::dump(const PDBSymbolTypeUDT &Symbol, raw_ostream &OS,
|
||||
int Indent) {
|
||||
OS << "class " << Symbol.getName();
|
||||
}
|
38
tools/llvm-pdbdump/TypedefDumper.h
Normal file
38
tools/llvm-pdbdump/TypedefDumper.h
Normal file
@ -0,0 +1,38 @@
|
||||
//===- TypedefDumper.h - llvm-pdbdump typedef dumper ---------*- C++ ----*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LLVM_TOOLS_LLVMPDBDUMP_TYPEDEFDUMPER_H
|
||||
#define LLVM_TOOLS_LLVMPDBDUMP_TYPEDEFDUMPER_H
|
||||
|
||||
#include "llvm/DebugInfo/PDB/PDBSymDumper.h"
|
||||
|
||||
namespace llvm {
|
||||
|
||||
class TypedefDumper : public PDBSymDumper {
|
||||
public:
|
||||
TypedefDumper();
|
||||
|
||||
void start(const PDBSymbolTypeTypedef &Symbol, raw_ostream &OS, int Indent);
|
||||
|
||||
void dump(const PDBSymbolTypeArray &Symbol, raw_ostream &OS,
|
||||
int Indent) override;
|
||||
void dump(const PDBSymbolTypeBuiltin &Symbol, raw_ostream &OS,
|
||||
int Indent) override;
|
||||
void dump(const PDBSymbolTypeEnum &Symbol, raw_ostream &OS,
|
||||
int Indent) override;
|
||||
void dump(const PDBSymbolTypeFunctionSig &Symbol, raw_ostream &OS,
|
||||
int Indent) override;
|
||||
void dump(const PDBSymbolTypePointer &Symbol, raw_ostream &OS,
|
||||
int Indent) override;
|
||||
void dump(const PDBSymbolTypeUDT &Symbol, raw_ostream &OS,
|
||||
int Indent) override;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
@ -13,6 +13,10 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "llvm-pdbdump.h"
|
||||
#include "CompilandDumper.h"
|
||||
#include "TypeDumper.h"
|
||||
|
||||
#include "llvm/ADT/ArrayRef.h"
|
||||
#include "llvm/ADT/StringExtras.h"
|
||||
#include "llvm/Config/config.h"
|
||||
@ -24,12 +28,13 @@
|
||||
#include "llvm/DebugInfo/PDB/PDBSymbolExe.h"
|
||||
#include "llvm/Support/CommandLine.h"
|
||||
#include "llvm/Support/ConvertUTF.h"
|
||||
#include "llvm/Support/FileSystem.h"
|
||||
#include "llvm/Support/Format.h"
|
||||
#include "llvm/Support/ManagedStatic.h"
|
||||
#include "llvm/Support/PrettyStackTrace.h"
|
||||
#include "llvm/Support/Process.h"
|
||||
#include "llvm/Support/Signals.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
#include "llvm/Support/Signals.h"
|
||||
|
||||
#if defined(HAVE_DIA_SDK)
|
||||
#include <Windows.h>
|
||||
@ -61,24 +66,36 @@ static void dumpInput(StringRef Path) {
|
||||
}
|
||||
|
||||
auto GlobalScope(Session->getGlobalScope());
|
||||
std::string FileName(GlobalScope->getSymbolsFileName());
|
||||
|
||||
outs() << "Summary for " << FileName;
|
||||
uint64_t FileSize = 0;
|
||||
if (!llvm::sys::fs::file_size(FileName, FileSize))
|
||||
outs() << newline(2) << "Size: " << FileSize << " bytes";
|
||||
else
|
||||
outs() << newline(2) << "Size: (Unable to obtain file size)";
|
||||
|
||||
outs() << newline(2) << "Guid: " << GlobalScope->getGuid();
|
||||
outs() << newline(2) << "Age: " << GlobalScope->getAge();
|
||||
outs() << newline(2) << "Attributes: ";
|
||||
if (GlobalScope->hasCTypes())
|
||||
outs() << "HasCTypes ";
|
||||
if (GlobalScope->hasPrivateSymbols())
|
||||
outs() << "HasPrivateSymbols ";
|
||||
|
||||
PDB_DumpFlags Flags = PDB_DF_None;
|
||||
if (opts::DumpTypes)
|
||||
Flags |= PDB_DF_Children | PDB_DF_Enums | PDB_DF_Funcsigs |
|
||||
PDB_DF_Typedefs | PDB_DF_VTables;
|
||||
GlobalScope->dump(outs(), 0, PDB_DumpLevel::Normal, Flags);
|
||||
outs() << "\n";
|
||||
if (opts::DumpTypes) {
|
||||
outs() << "\nDumping types";
|
||||
TypeDumper Dumper;
|
||||
Dumper.start(*GlobalScope, outs(), 2);
|
||||
}
|
||||
|
||||
if (opts::DumpSymbols || opts::DumpCompilands) {
|
||||
outs() << "Dumping compilands\n";
|
||||
outs() << "\nDumping compilands";
|
||||
auto Compilands = GlobalScope->findAllChildren<PDBSymbolCompiland>();
|
||||
Flags = PDB_DF_None;
|
||||
if (opts::DumpSymbols)
|
||||
Flags |= PDB_DF_Children | PDB_DF_Data | PDB_DF_Functions |
|
||||
PDB_DF_Thunks | PDB_DF_Labels;
|
||||
while (auto Compiland = Compilands->getNext()) {
|
||||
Compiland->dump(outs(), 2, PDB_DumpLevel::Detailed, Flags);
|
||||
outs() << "\n";
|
||||
}
|
||||
CompilandDumper Dumper;
|
||||
while (auto Compiland = Compilands->getNext())
|
||||
Dumper.start(*Compiland, outs(), 2, opts::DumpSymbols);
|
||||
}
|
||||
outs().flush();
|
||||
}
|
||||
|
28
tools/llvm-pdbdump/llvm-pdbdump.h
Normal file
28
tools/llvm-pdbdump/llvm-pdbdump.h
Normal file
@ -0,0 +1,28 @@
|
||||
//===- llvm-pdbdump.h ----------------------------------------- *- C++ --*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LLVM_TOOLS_LLVMPDBDUMP_LLVMPDBDUMP_H
|
||||
#define LLVM_TOOLS_LLVMPDBDUMP_LLVMPDBDUMP_H
|
||||
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
|
||||
namespace llvm {
|
||||
struct newline {
|
||||
newline(int IndentWidth) : Width(IndentWidth) {}
|
||||
int Width;
|
||||
};
|
||||
|
||||
inline raw_ostream &operator<<(raw_ostream &OS, const newline &Indent) {
|
||||
OS << "\n";
|
||||
OS.indent(Indent.Width);
|
||||
return OS;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user