From 1e708541480f90958ee18273a540e70edda2e3d3 Mon Sep 17 00:00:00 2001 From: Zachary Turner Date: Tue, 10 Feb 2015 22:43:25 +0000 Subject: [PATCH] Rewrite llvm-pdbdump in terms of LLVMDebugInfoPDB. This makes llvm-pdbdump available on all platforms, although it will currently fail to create a dumper if there is no PDB reader implementation for the current platform. It implements dumping of compilands and children, which is less information than was previously available, but it has to be rewritten from scratch using the new set of interfaces, so the rest of the functionality will be added back in subsequent commits. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@228755 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/DebugInfo/PDB/DIA/DIARawSymbol.h | 11 +- include/llvm/DebugInfo/PDB/DIA/DIASession.h | 4 + include/llvm/DebugInfo/PDB/IPDBRawSymbol.h | 10 +- include/llvm/DebugInfo/PDB/IPDBSession.h | 5 + include/llvm/DebugInfo/PDB/IPDBSourceFile.h | 4 + include/llvm/DebugInfo/PDB/PDBExtras.h | 39 + include/llvm/DebugInfo/PDB/PDBSymbol.h | 11 +- .../llvm/DebugInfo/PDB/PDBSymbolAnnotation.h | 2 +- include/llvm/DebugInfo/PDB/PDBSymbolBlock.h | 2 +- .../llvm/DebugInfo/PDB/PDBSymbolCompiland.h | 2 +- .../DebugInfo/PDB/PDBSymbolCompilandDetails.h | 2 +- .../DebugInfo/PDB/PDBSymbolCompilandEnv.h | 2 +- include/llvm/DebugInfo/PDB/PDBSymbolCustom.h | 2 +- include/llvm/DebugInfo/PDB/PDBSymbolData.h | 2 +- include/llvm/DebugInfo/PDB/PDBSymbolExe.h | 2 +- include/llvm/DebugInfo/PDB/PDBSymbolFunc.h | 4 +- .../DebugInfo/PDB/PDBSymbolFuncDebugEnd.h | 2 +- .../DebugInfo/PDB/PDBSymbolFuncDebugStart.h | 2 +- include/llvm/DebugInfo/PDB/PDBSymbolLabel.h | 2 +- .../DebugInfo/PDB/PDBSymbolPublicSymbol.h | 2 +- include/llvm/DebugInfo/PDB/PDBSymbolThunk.h | 2 +- .../llvm/DebugInfo/PDB/PDBSymbolTypeArray.h | 2 +- .../DebugInfo/PDB/PDBSymbolTypeBaseClass.h | 2 +- .../llvm/DebugInfo/PDB/PDBSymbolTypeBuiltin.h | 2 +- .../llvm/DebugInfo/PDB/PDBSymbolTypeCustom.h | 2 +- .../DebugInfo/PDB/PDBSymbolTypeDimension.h | 2 +- .../llvm/DebugInfo/PDB/PDBSymbolTypeEnum.h | 2 +- .../llvm/DebugInfo/PDB/PDBSymbolTypeFriend.h | 2 +- .../DebugInfo/PDB/PDBSymbolTypeFunctionArg.h | 2 +- .../DebugInfo/PDB/PDBSymbolTypeFunctionSig.h | 2 +- .../llvm/DebugInfo/PDB/PDBSymbolTypeManaged.h | 2 +- .../llvm/DebugInfo/PDB/PDBSymbolTypePointer.h | 2 +- .../llvm/DebugInfo/PDB/PDBSymbolTypeTypedef.h | 2 +- include/llvm/DebugInfo/PDB/PDBSymbolTypeUDT.h | 2 +- .../llvm/DebugInfo/PDB/PDBSymbolTypeVTable.h | 2 +- .../DebugInfo/PDB/PDBSymbolTypeVTableShape.h | 2 +- include/llvm/DebugInfo/PDB/PDBSymbolUnknown.h | 2 +- .../DebugInfo/PDB/PDBSymbolUsingNamespace.h | 2 +- include/llvm/DebugInfo/PDB/PDBTypes.h | 70 ++ lib/DebugInfo/PDB/CMakeLists.txt | 2 + lib/DebugInfo/PDB/DIA/DIARawSymbol.cpp | 237 ++++- lib/DebugInfo/PDB/DIA/DIASession.cpp | 26 +- lib/DebugInfo/PDB/IPDBSourceFile.cpp | 34 + lib/DebugInfo/PDB/PDBExtras.cpp | 219 ++++ lib/DebugInfo/PDB/PDBInterfaceAnchors.cpp | 2 - lib/DebugInfo/PDB/PDBSymbol.cpp | 20 +- lib/DebugInfo/PDB/PDBSymbolAnnotation.cpp | 3 +- lib/DebugInfo/PDB/PDBSymbolBlock.cpp | 3 +- lib/DebugInfo/PDB/PDBSymbolCompiland.cpp | 75 +- .../PDB/PDBSymbolCompilandDetails.cpp | 3 +- lib/DebugInfo/PDB/PDBSymbolCompilandEnv.cpp | 3 +- lib/DebugInfo/PDB/PDBSymbolCustom.cpp | 3 +- lib/DebugInfo/PDB/PDBSymbolData.cpp | 49 +- lib/DebugInfo/PDB/PDBSymbolExe.cpp | 27 +- lib/DebugInfo/PDB/PDBSymbolFunc.cpp | 46 +- lib/DebugInfo/PDB/PDBSymbolFuncDebugEnd.cpp | 3 +- lib/DebugInfo/PDB/PDBSymbolFuncDebugStart.cpp | 3 +- lib/DebugInfo/PDB/PDBSymbolLabel.cpp | 3 +- lib/DebugInfo/PDB/PDBSymbolPublicSymbol.cpp | 3 +- lib/DebugInfo/PDB/PDBSymbolThunk.cpp | 19 +- lib/DebugInfo/PDB/PDBSymbolTypeArray.cpp | 3 +- lib/DebugInfo/PDB/PDBSymbolTypeBaseClass.cpp | 3 +- lib/DebugInfo/PDB/PDBSymbolTypeBuiltin.cpp | 3 +- lib/DebugInfo/PDB/PDBSymbolTypeCustom.cpp | 3 +- lib/DebugInfo/PDB/PDBSymbolTypeDimension.cpp | 3 +- lib/DebugInfo/PDB/PDBSymbolTypeEnum.cpp | 3 +- lib/DebugInfo/PDB/PDBSymbolTypeFriend.cpp | 3 +- .../PDB/PDBSymbolTypeFunctionArg.cpp | 3 +- .../PDB/PDBSymbolTypeFunctionSig.cpp | 3 +- lib/DebugInfo/PDB/PDBSymbolTypeManaged.cpp | 3 +- lib/DebugInfo/PDB/PDBSymbolTypePointer.cpp | 3 +- lib/DebugInfo/PDB/PDBSymbolTypeTypedef.cpp | 15 +- lib/DebugInfo/PDB/PDBSymbolTypeUDT.cpp | 3 +- lib/DebugInfo/PDB/PDBSymbolTypeVTable.cpp | 3 +- .../PDB/PDBSymbolTypeVTableShape.cpp | 3 +- lib/DebugInfo/PDB/PDBSymbolUnknown.cpp | 3 +- lib/DebugInfo/PDB/PDBSymbolUsingNamespace.cpp | 3 +- tools/CMakeLists.txt | 9 +- tools/Makefile | 2 +- tools/llvm-pdbdump/CMakeLists.txt | 34 +- tools/llvm-pdbdump/COMExtras.h | 295 ------ tools/llvm-pdbdump/DIAExtras.cpp | 189 ---- tools/llvm-pdbdump/DIAExtras.h | 131 --- tools/llvm-pdbdump/DIASymbol.cpp | 968 ------------------ tools/llvm-pdbdump/DIASymbol.h | 282 ----- tools/llvm-pdbdump/LLVMBuild.txt | 2 +- tools/llvm-pdbdump/Makefile | 17 + tools/llvm-pdbdump/llvm-pdbdump.cpp | 325 +----- tools/llvm-pdbdump/llvm-pdbdump.h | 32 - unittests/DebugInfo/PDB/PDBApiTest.cpp | 30 +- 90 files changed, 1044 insertions(+), 2336 deletions(-) create mode 100644 include/llvm/DebugInfo/PDB/PDBExtras.h create mode 100644 lib/DebugInfo/PDB/IPDBSourceFile.cpp create mode 100644 lib/DebugInfo/PDB/PDBExtras.cpp delete mode 100644 tools/llvm-pdbdump/COMExtras.h delete mode 100644 tools/llvm-pdbdump/DIAExtras.cpp delete mode 100644 tools/llvm-pdbdump/DIAExtras.h delete mode 100644 tools/llvm-pdbdump/DIASymbol.cpp delete mode 100644 tools/llvm-pdbdump/DIASymbol.h create mode 100644 tools/llvm-pdbdump/Makefile delete mode 100644 tools/llvm-pdbdump/llvm-pdbdump.h diff --git a/include/llvm/DebugInfo/PDB/DIA/DIARawSymbol.h b/include/llvm/DebugInfo/PDB/DIA/DIARawSymbol.h index 08904907f55..6336b319a4f 100644 --- a/include/llvm/DebugInfo/PDB/DIA/DIARawSymbol.h +++ b/include/llvm/DebugInfo/PDB/DIA/DIARawSymbol.h @@ -19,8 +19,12 @@ class DIARawSymbol : public IPDBRawSymbol { public: DIARawSymbol(const DIASession &PDBSession, CComPtr DiaSymbol); - void dump(llvm::raw_ostream &OS) const override; + void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level) const override; + CComPtr getDiaSymbol() const { return Symbol; } + + std::unique_ptr + DIARawSymbol::findChildren(PDB_SymType Type) const override; std::unique_ptr findChildren(PDB_SymType Type, StringRef Name, PDB_NameSearchFlags Flags) const override; @@ -54,7 +58,7 @@ public: uint32_t getLiveRangeStartAddressOffset() const override; uint32_t getLiveRangeStartAddressSection() const override; uint32_t getLiveRangeStartRelativeVirtualAddress() const override; - uint32_t getLocalBasePointerRegisterId() const override; + PDB_RegisterId getLocalBasePointerRegisterId() const override; uint32_t getLowerBoundId() const override; uint32_t getMemorySpaceKind() const override; std::string getName() const override; @@ -69,7 +73,7 @@ public: uint32_t getOffsetInUdt() const override; PDB_Cpu getPlatform() const override; uint32_t getRank() const override; - uint32_t getRegisterId() const override; + PDB_RegisterId getRegisterId() const override; uint32_t getRegisterType() const override; uint32_t getRelativeVirtualAddress() const override; uint32_t getSamplerSlot() const override; @@ -129,6 +133,7 @@ public: bool hasInlAsm() const override; bool hasInlineAttribute() const override; bool hasInterruptReturn() const override; + bool hasFramePointer() const override; bool hasLongJump() const override; bool hasManagedCode() const override; bool hasNestedTypes() const override; diff --git a/include/llvm/DebugInfo/PDB/DIA/DIASession.h b/include/llvm/DebugInfo/PDB/DIA/DIASession.h index 7ee0cb02fd2..141b9b0d989 100644 --- a/include/llvm/DebugInfo/PDB/DIA/DIASession.h +++ b/include/llvm/DebugInfo/PDB/DIA/DIASession.h @@ -25,6 +25,10 @@ public: void setLoadAddress(uint64_t Address) override; std::unique_ptr getGlobalScope() const override; std::unique_ptr getSymbolById(uint32_t SymbolId) const override; + + std::unique_ptr getAllSourceFiles() const override; + std::unique_ptr getSourceFilesForCompiland( + const PDBSymbolCompiland &Compiland) const override; std::unique_ptr getSourceFileById(uint32_t FileId) const override; diff --git a/include/llvm/DebugInfo/PDB/IPDBRawSymbol.h b/include/llvm/DebugInfo/PDB/IPDBRawSymbol.h index 960821d6ad6..5dd103ff100 100644 --- a/include/llvm/DebugInfo/PDB/IPDBRawSymbol.h +++ b/include/llvm/DebugInfo/PDB/IPDBRawSymbol.h @@ -29,7 +29,10 @@ class IPDBRawSymbol { public: virtual ~IPDBRawSymbol(); - virtual void dump(llvm::raw_ostream &OS) const = 0; + virtual void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level) const = 0; + + virtual std::unique_ptr + findChildren(PDB_SymType Type) const = 0; virtual std::unique_ptr findChildren(PDB_SymType Type, StringRef Name, @@ -64,7 +67,7 @@ public: virtual uint32_t getLiveRangeStartAddressOffset() const = 0; virtual uint32_t getLiveRangeStartAddressSection() const = 0; virtual uint32_t getLiveRangeStartRelativeVirtualAddress() const = 0; - virtual uint32_t getLocalBasePointerRegisterId() const = 0; + virtual PDB_RegisterId getLocalBasePointerRegisterId() const = 0; virtual uint32_t getLowerBoundId() const = 0; virtual uint32_t getMemorySpaceKind() const = 0; virtual std::string getName() const = 0; @@ -79,7 +82,7 @@ public: virtual uint32_t getOffsetInUdt() const = 0; virtual PDB_Cpu getPlatform() const = 0; virtual uint32_t getRank() const = 0; - virtual uint32_t getRegisterId() const = 0; + virtual PDB_RegisterId getRegisterId() const = 0; virtual uint32_t getRegisterType() const = 0; virtual uint32_t getRelativeVirtualAddress() const = 0; virtual uint32_t getSamplerSlot() const = 0; @@ -136,6 +139,7 @@ public: virtual bool hasDebugInfo() const = 0; virtual bool hasEH() const = 0; virtual bool hasEHa() const = 0; + virtual bool hasFramePointer() const = 0; virtual bool hasInlAsm() const = 0; virtual bool hasInlineAttribute() const = 0; virtual bool hasInterruptReturn() const = 0; diff --git a/include/llvm/DebugInfo/PDB/IPDBSession.h b/include/llvm/DebugInfo/PDB/IPDBSession.h index 5f16d94f932..0e0b2c5f68e 100644 --- a/include/llvm/DebugInfo/PDB/IPDBSession.h +++ b/include/llvm/DebugInfo/PDB/IPDBSession.h @@ -16,6 +16,7 @@ namespace llvm { +class PDBSymbolCompiland; class PDBSymbolExe; /// IPDBSession defines an interface used to provide a context for querying @@ -28,6 +29,10 @@ public: virtual void setLoadAddress(uint64_t Address) = 0; virtual std::unique_ptr getGlobalScope() const = 0; virtual std::unique_ptr getSymbolById(uint32_t SymbolId) const = 0; + + virtual std::unique_ptr getAllSourceFiles() const = 0; + virtual std::unique_ptr + getSourceFilesForCompiland(const PDBSymbolCompiland &Compiland) const = 0; virtual std::unique_ptr getSourceFileById(uint32_t FileId) const = 0; diff --git a/include/llvm/DebugInfo/PDB/IPDBSourceFile.h b/include/llvm/DebugInfo/PDB/IPDBSourceFile.h index 2b834e2d732..ae584d717e3 100644 --- a/include/llvm/DebugInfo/PDB/IPDBSourceFile.h +++ b/include/llvm/DebugInfo/PDB/IPDBSourceFile.h @@ -17,12 +17,16 @@ namespace llvm { +class raw_ostream; + /// IPDBSourceFile defines an interface used to represent source files whose /// information are stored in the PDB. class IPDBSourceFile { public: virtual ~IPDBSourceFile(); + void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level) const; + virtual std::string getFileName() const = 0; virtual uint32_t getUniqueId() const = 0; virtual std::string getChecksum() const = 0; diff --git a/include/llvm/DebugInfo/PDB/PDBExtras.h b/include/llvm/DebugInfo/PDB/PDBExtras.h new file mode 100644 index 00000000000..5a768e74e54 --- /dev/null +++ b/include/llvm/DebugInfo/PDB/PDBExtras.h @@ -0,0 +1,39 @@ +//===- PDBExtras.h - helper functions and classes for PDBs -------*- 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_PDBEXTRAS_H +#define LLVM_DEBUGINFO_PDB_PDBEXTRAS_H + +#include + +#include "PDBTypes.h" + +#include "llvm/Support/raw_ostream.h" + +namespace llvm { +typedef std::unordered_map 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_RegisterId &Reg); +raw_ostream &operator<<(raw_ostream &OS, const PDB_LocType &Loc); +raw_ostream &operator<<(raw_ostream &OS, const PDB_ThunkOrdinal &Thunk); +raw_ostream &operator<<(raw_ostream &OS, const PDB_Checksum &Checksum); +raw_ostream &operator<<(raw_ostream &OS, const PDB_Lang &Lang); +raw_ostream &operator<<(raw_ostream &OS, const PDB_SymType &Tag); +raw_ostream &operator<<(raw_ostream &OS, const PDB_UniqueId &Id); +raw_ostream &operator<<(raw_ostream &OS, const VersionInfo &Version); +raw_ostream &operator<<(raw_ostream &OS, const TagStats &Stats); +} + +#endif diff --git a/include/llvm/DebugInfo/PDB/PDBSymbol.h b/include/llvm/DebugInfo/PDB/PDBSymbol.h index ada3ab38994..95bc7fd44ec 100644 --- a/include/llvm/DebugInfo/PDB/PDBSymbol.h +++ b/include/llvm/DebugInfo/PDB/PDBSymbol.h @@ -11,11 +11,13 @@ #define LLVM_DEBUGINFO_PDB_IPDBSYMBOL_H #include +#include #include "llvm/ADT/StringRef.h" #include "llvm/Support/Casting.h" #include "IPDBRawSymbol.h" +#include "PDBExtras.h" #include "PDBTypes.h" #define FORWARD_SYMBOL_METHOD(MethodName) \ @@ -48,10 +50,12 @@ 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(llvm::raw_ostream &OS) const; + virtual void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level) const = 0; + void defaultDump(raw_ostream &OS, int Indent, PDB_DumpLevel Level) const; PDB_SymType getSymTag() const; + std::unique_ptr findChildren(PDB_SymType Type) const; std::unique_ptr findChildren(PDB_SymType Type, StringRef Name, PDB_NameSearchFlags Flags) const; @@ -61,7 +65,12 @@ public: uint32_t RVA) const; std::unique_ptr findInlineFramesByRVA(uint32_t RVA) const; + const IPDBRawSymbol &getRawSymbol() const { return *RawSymbol; } + IPDBRawSymbol &getRawSymbol() { return *RawSymbol; } + protected: + std::unique_ptr getChildStats(TagStats &Stats) const; + const IPDBSession &Session; const std::unique_ptr RawSymbol; }; diff --git a/include/llvm/DebugInfo/PDB/PDBSymbolAnnotation.h b/include/llvm/DebugInfo/PDB/PDBSymbolAnnotation.h index 773c9925e70..5751dcc9dd2 100644 --- a/include/llvm/DebugInfo/PDB/PDBSymbolAnnotation.h +++ b/include/llvm/DebugInfo/PDB/PDBSymbolAnnotation.h @@ -23,7 +23,7 @@ public: PDBSymbolAnnotation(const IPDBSession &PDBSession, std::unique_ptr Symbol); - void dump(llvm::raw_ostream &OS) const override; + void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level) const override; FORWARD_SYMBOL_METHOD(getAddressOffset) FORWARD_SYMBOL_METHOD(getAddressSection) diff --git a/include/llvm/DebugInfo/PDB/PDBSymbolBlock.h b/include/llvm/DebugInfo/PDB/PDBSymbolBlock.h index 5e6c7e193cb..760324b8c7d 100644 --- a/include/llvm/DebugInfo/PDB/PDBSymbolBlock.h +++ b/include/llvm/DebugInfo/PDB/PDBSymbolBlock.h @@ -23,7 +23,7 @@ public: PDBSymbolBlock(const IPDBSession &PDBSession, std::unique_ptr Symbol); - void dump(llvm::raw_ostream &OS) const override; + void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level) const override; FORWARD_SYMBOL_METHOD(getAddressOffset) FORWARD_SYMBOL_METHOD(getAddressSection) diff --git a/include/llvm/DebugInfo/PDB/PDBSymbolCompiland.h b/include/llvm/DebugInfo/PDB/PDBSymbolCompiland.h index b4831aa3ac3..b342444aaf6 100644 --- a/include/llvm/DebugInfo/PDB/PDBSymbolCompiland.h +++ b/include/llvm/DebugInfo/PDB/PDBSymbolCompiland.h @@ -23,7 +23,7 @@ public: PDBSymbolCompiland(const IPDBSession &PDBSession, std::unique_ptr CompilandSymbol); - void dump(llvm::raw_ostream &OS) const override; + void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level) const override; FORWARD_SYMBOL_METHOD(isEditAndContinueEnabled) FORWARD_SYMBOL_METHOD(getLexicalParentId) diff --git a/include/llvm/DebugInfo/PDB/PDBSymbolCompilandDetails.h b/include/llvm/DebugInfo/PDB/PDBSymbolCompilandDetails.h index e498bdd5265..dcffabf34fd 100644 --- a/include/llvm/DebugInfo/PDB/PDBSymbolCompilandDetails.h +++ b/include/llvm/DebugInfo/PDB/PDBSymbolCompilandDetails.h @@ -22,7 +22,7 @@ public: PDBSymbolCompilandDetails(const IPDBSession &PDBSession, std::unique_ptr Symbol); - void dump(llvm::raw_ostream &OS) const override; + void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level) const override; void getFrontEndVersion(VersionInfo &Version) const { RawSymbol->getFrontEndVersion(Version); diff --git a/include/llvm/DebugInfo/PDB/PDBSymbolCompilandEnv.h b/include/llvm/DebugInfo/PDB/PDBSymbolCompilandEnv.h index 4e732882c1d..dfff3f754b6 100644 --- a/include/llvm/DebugInfo/PDB/PDBSymbolCompilandEnv.h +++ b/include/llvm/DebugInfo/PDB/PDBSymbolCompilandEnv.h @@ -22,7 +22,7 @@ public: PDBSymbolCompilandEnv(const IPDBSession &PDBSession, std::unique_ptr Symbol); - void dump(llvm::raw_ostream &OS) const override; + void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level) const override; FORWARD_SYMBOL_METHOD(getLexicalParentId) FORWARD_SYMBOL_METHOD(getName) diff --git a/include/llvm/DebugInfo/PDB/PDBSymbolCustom.h b/include/llvm/DebugInfo/PDB/PDBSymbolCustom.h index 3d8c1fb4d94..0c972d8ba08 100644 --- a/include/llvm/DebugInfo/PDB/PDBSymbolCustom.h +++ b/include/llvm/DebugInfo/PDB/PDBSymbolCustom.h @@ -27,7 +27,7 @@ public: PDBSymbolCustom(const IPDBSession &PDBSession, std::unique_ptr CustomSymbol); - void dump(llvm::raw_ostream &OS) const override; + void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level) const override; void getDataBytes(llvm::SmallVector &bytes); FORWARD_SYMBOL_METHOD(getSymIndexId) diff --git a/include/llvm/DebugInfo/PDB/PDBSymbolData.h b/include/llvm/DebugInfo/PDB/PDBSymbolData.h index 22098e3bda0..e1c074e7298 100644 --- a/include/llvm/DebugInfo/PDB/PDBSymbolData.h +++ b/include/llvm/DebugInfo/PDB/PDBSymbolData.h @@ -22,7 +22,7 @@ public: PDBSymbolData(const IPDBSession &PDBSession, std::unique_ptr DataSymbol); - void dump(llvm::raw_ostream &OS) const override; + void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level) const override; FORWARD_SYMBOL_METHOD(getAccess) FORWARD_SYMBOL_METHOD(getAddressOffset) diff --git a/include/llvm/DebugInfo/PDB/PDBSymbolExe.h b/include/llvm/DebugInfo/PDB/PDBSymbolExe.h index 5f03c440d3b..caac1668ae3 100644 --- a/include/llvm/DebugInfo/PDB/PDBSymbolExe.h +++ b/include/llvm/DebugInfo/PDB/PDBSymbolExe.h @@ -24,7 +24,7 @@ public: PDBSymbolExe(const IPDBSession &PDBSession, std::unique_ptr ExeSymbol); - void dump(llvm::raw_ostream &OS) const override; + void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level) const override; FORWARD_SYMBOL_METHOD(getAge) FORWARD_SYMBOL_METHOD(getGuid) diff --git a/include/llvm/DebugInfo/PDB/PDBSymbolFunc.h b/include/llvm/DebugInfo/PDB/PDBSymbolFunc.h index f101d3072d8..4b78c2f5a6c 100644 --- a/include/llvm/DebugInfo/PDB/PDBSymbolFunc.h +++ b/include/llvm/DebugInfo/PDB/PDBSymbolFunc.h @@ -22,7 +22,7 @@ public: PDBSymbolFunc(const IPDBSession &PDBSession, std::unique_ptr FuncSymbol); - void dump(llvm::raw_ostream &OS) const override; + void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level) const override; FORWARD_SYMBOL_METHOD(getAccess) FORWARD_SYMBOL_METHOD(getAddressOffset) @@ -46,8 +46,10 @@ public: FORWARD_SYMBOL_METHOD(isStatic) FORWARD_SYMBOL_METHOD(getLength) FORWARD_SYMBOL_METHOD(getLexicalParentId) + FORWARD_SYMBOL_METHOD(getLocalBasePointerRegisterId) FORWARD_SYMBOL_METHOD(getLocationType) FORWARD_SYMBOL_METHOD(getName) + FORWARD_SYMBOL_METHOD(hasFramePointer) FORWARD_SYMBOL_METHOD(hasNoInlineAttribute) FORWARD_SYMBOL_METHOD(hasNoReturnAttribute) FORWARD_SYMBOL_METHOD(isUnreached) diff --git a/include/llvm/DebugInfo/PDB/PDBSymbolFuncDebugEnd.h b/include/llvm/DebugInfo/PDB/PDBSymbolFuncDebugEnd.h index 945596115c0..15ce8969d47 100644 --- a/include/llvm/DebugInfo/PDB/PDBSymbolFuncDebugEnd.h +++ b/include/llvm/DebugInfo/PDB/PDBSymbolFuncDebugEnd.h @@ -22,7 +22,7 @@ public: PDBSymbolFuncDebugEnd(const IPDBSession &PDBSession, std::unique_ptr FuncDebugEndSymbol); - void dump(llvm::raw_ostream &OS) const override; + void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level) const override; FORWARD_SYMBOL_METHOD(getAddressOffset) FORWARD_SYMBOL_METHOD(getAddressSection) diff --git a/include/llvm/DebugInfo/PDB/PDBSymbolFuncDebugStart.h b/include/llvm/DebugInfo/PDB/PDBSymbolFuncDebugStart.h index c3ccd2532b3..9ad6d3888f7 100644 --- a/include/llvm/DebugInfo/PDB/PDBSymbolFuncDebugStart.h +++ b/include/llvm/DebugInfo/PDB/PDBSymbolFuncDebugStart.h @@ -22,7 +22,7 @@ public: PDBSymbolFuncDebugStart(const IPDBSession &PDBSession, std::unique_ptr FuncDebugStartSymbol); - void dump(llvm::raw_ostream &OS) const override; + void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level) const override; FORWARD_SYMBOL_METHOD(getAddressOffset) FORWARD_SYMBOL_METHOD(getAddressSection) diff --git a/include/llvm/DebugInfo/PDB/PDBSymbolLabel.h b/include/llvm/DebugInfo/PDB/PDBSymbolLabel.h index 114bb378ca1..d7cb6f5a6df 100644 --- a/include/llvm/DebugInfo/PDB/PDBSymbolLabel.h +++ b/include/llvm/DebugInfo/PDB/PDBSymbolLabel.h @@ -22,7 +22,7 @@ public: PDBSymbolLabel(const IPDBSession &PDBSession, std::unique_ptr LabelSymbol); - void dump(llvm::raw_ostream &OS) const override; + void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level) const override; FORWARD_SYMBOL_METHOD(getAddressOffset) FORWARD_SYMBOL_METHOD(getAddressSection) diff --git a/include/llvm/DebugInfo/PDB/PDBSymbolPublicSymbol.h b/include/llvm/DebugInfo/PDB/PDBSymbolPublicSymbol.h index 98d4c3bd749..540cf19ac2f 100644 --- a/include/llvm/DebugInfo/PDB/PDBSymbolPublicSymbol.h +++ b/include/llvm/DebugInfo/PDB/PDBSymbolPublicSymbol.h @@ -22,7 +22,7 @@ public: PDBSymbolPublicSymbol(const IPDBSession &PDBSession, std::unique_ptr PublicSymbol); - void dump(llvm::raw_ostream &OS) const override; + void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level) const override; FORWARD_SYMBOL_METHOD(getAddressOffset) FORWARD_SYMBOL_METHOD(getAddressSection) diff --git a/include/llvm/DebugInfo/PDB/PDBSymbolThunk.h b/include/llvm/DebugInfo/PDB/PDBSymbolThunk.h index 136b6ca997a..7a2eab204f6 100644 --- a/include/llvm/DebugInfo/PDB/PDBSymbolThunk.h +++ b/include/llvm/DebugInfo/PDB/PDBSymbolThunk.h @@ -24,7 +24,7 @@ public: PDBSymbolThunk(const IPDBSession &PDBSession, std::unique_ptr ThunkSymbol); - void dump(llvm::raw_ostream &OS) const override; + void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level) const override; FORWARD_SYMBOL_METHOD(getAccess) FORWARD_SYMBOL_METHOD(getAddressOffset) diff --git a/include/llvm/DebugInfo/PDB/PDBSymbolTypeArray.h b/include/llvm/DebugInfo/PDB/PDBSymbolTypeArray.h index 8100ea7e292..ef81d792d3c 100644 --- a/include/llvm/DebugInfo/PDB/PDBSymbolTypeArray.h +++ b/include/llvm/DebugInfo/PDB/PDBSymbolTypeArray.h @@ -22,7 +22,7 @@ public: PDBSymbolTypeArray(const IPDBSession &PDBSession, std::unique_ptr ArrayTypeSymbol); - void dump(llvm::raw_ostream &OS) const override; + void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level) const override; FORWARD_SYMBOL_METHOD(getArrayIndexTypeId) FORWARD_SYMBOL_METHOD(isConstType) diff --git a/include/llvm/DebugInfo/PDB/PDBSymbolTypeBaseClass.h b/include/llvm/DebugInfo/PDB/PDBSymbolTypeBaseClass.h index 60c3dc28083..3cc7a022653 100644 --- a/include/llvm/DebugInfo/PDB/PDBSymbolTypeBaseClass.h +++ b/include/llvm/DebugInfo/PDB/PDBSymbolTypeBaseClass.h @@ -22,7 +22,7 @@ public: PDBSymbolTypeBaseClass(const IPDBSession &PDBSession, std::unique_ptr Symbol); - void dump(llvm::raw_ostream &OS) const override; + void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level) const override; FORWARD_SYMBOL_METHOD(getAccess) FORWARD_SYMBOL_METHOD(getClassParentId) diff --git a/include/llvm/DebugInfo/PDB/PDBSymbolTypeBuiltin.h b/include/llvm/DebugInfo/PDB/PDBSymbolTypeBuiltin.h index ba764ddb31b..769d4474031 100644 --- a/include/llvm/DebugInfo/PDB/PDBSymbolTypeBuiltin.h +++ b/include/llvm/DebugInfo/PDB/PDBSymbolTypeBuiltin.h @@ -22,7 +22,7 @@ public: PDBSymbolTypeBuiltin(const IPDBSession &PDBSession, std::unique_ptr Symbol); - void dump(llvm::raw_ostream &OS) const override; + void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level) const override; FORWARD_SYMBOL_METHOD(getBuiltinType) FORWARD_SYMBOL_METHOD(isConstType) diff --git a/include/llvm/DebugInfo/PDB/PDBSymbolTypeCustom.h b/include/llvm/DebugInfo/PDB/PDBSymbolTypeCustom.h index a28a6efc2cc..7bdbc9de72a 100644 --- a/include/llvm/DebugInfo/PDB/PDBSymbolTypeCustom.h +++ b/include/llvm/DebugInfo/PDB/PDBSymbolTypeCustom.h @@ -22,7 +22,7 @@ public: PDBSymbolTypeCustom(const IPDBSession &PDBSession, std::unique_ptr Symbol); - void dump(llvm::raw_ostream &OS) const override; + void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level) const override; FORWARD_SYMBOL_METHOD(getOemId) FORWARD_SYMBOL_METHOD(getOemSymbolId) diff --git a/include/llvm/DebugInfo/PDB/PDBSymbolTypeDimension.h b/include/llvm/DebugInfo/PDB/PDBSymbolTypeDimension.h index 3039b877918..737fdfa6acd 100644 --- a/include/llvm/DebugInfo/PDB/PDBSymbolTypeDimension.h +++ b/include/llvm/DebugInfo/PDB/PDBSymbolTypeDimension.h @@ -22,7 +22,7 @@ public: PDBSymbolTypeDimension(const IPDBSession &PDBSession, std::unique_ptr Symbol); - void dump(llvm::raw_ostream &OS) const override; + void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level) const override; FORWARD_SYMBOL_METHOD(getLowerBoundId) FORWARD_SYMBOL_METHOD(getUpperBoundId) diff --git a/include/llvm/DebugInfo/PDB/PDBSymbolTypeEnum.h b/include/llvm/DebugInfo/PDB/PDBSymbolTypeEnum.h index c44c4bede90..63c16b17c46 100644 --- a/include/llvm/DebugInfo/PDB/PDBSymbolTypeEnum.h +++ b/include/llvm/DebugInfo/PDB/PDBSymbolTypeEnum.h @@ -22,7 +22,7 @@ public: PDBSymbolTypeEnum(const IPDBSession &PDBSession, std::unique_ptr EnumTypeSymbol); - void dump(llvm::raw_ostream &OS) const override; + void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level) const override; FORWARD_SYMBOL_METHOD(getBuiltinType) FORWARD_SYMBOL_METHOD(getClassParentId) diff --git a/include/llvm/DebugInfo/PDB/PDBSymbolTypeFriend.h b/include/llvm/DebugInfo/PDB/PDBSymbolTypeFriend.h index 8e7e93e719a..0c63da7d318 100644 --- a/include/llvm/DebugInfo/PDB/PDBSymbolTypeFriend.h +++ b/include/llvm/DebugInfo/PDB/PDBSymbolTypeFriend.h @@ -22,7 +22,7 @@ public: PDBSymbolTypeFriend(const IPDBSession &PDBSession, std::unique_ptr Symbol); - void dump(llvm::raw_ostream &OS) const override; + void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level) const override; FORWARD_SYMBOL_METHOD(getClassParentId) FORWARD_SYMBOL_METHOD(getName) diff --git a/include/llvm/DebugInfo/PDB/PDBSymbolTypeFunctionArg.h b/include/llvm/DebugInfo/PDB/PDBSymbolTypeFunctionArg.h index c8f1e1dfa28..531ebda67b7 100644 --- a/include/llvm/DebugInfo/PDB/PDBSymbolTypeFunctionArg.h +++ b/include/llvm/DebugInfo/PDB/PDBSymbolTypeFunctionArg.h @@ -22,7 +22,7 @@ public: PDBSymbolTypeFunctionArg(const IPDBSession &PDBSession, std::unique_ptr Symbol); - void dump(llvm::raw_ostream &OS) const override; + void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level) const override; FORWARD_SYMBOL_METHOD(getClassParentId) FORWARD_SYMBOL_METHOD(getLexicalParentId) diff --git a/include/llvm/DebugInfo/PDB/PDBSymbolTypeFunctionSig.h b/include/llvm/DebugInfo/PDB/PDBSymbolTypeFunctionSig.h index d23d7876fef..91dab3ece95 100644 --- a/include/llvm/DebugInfo/PDB/PDBSymbolTypeFunctionSig.h +++ b/include/llvm/DebugInfo/PDB/PDBSymbolTypeFunctionSig.h @@ -22,7 +22,7 @@ public: PDBSymbolTypeFunctionSig(const IPDBSession &PDBSession, std::unique_ptr Symbol); - void dump(llvm::raw_ostream &OS) const override; + void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level) const override; FORWARD_SYMBOL_METHOD(getCallingConvention) FORWARD_SYMBOL_METHOD(getClassParentId) diff --git a/include/llvm/DebugInfo/PDB/PDBSymbolTypeManaged.h b/include/llvm/DebugInfo/PDB/PDBSymbolTypeManaged.h index 436f51e4500..f5d02f9a60f 100644 --- a/include/llvm/DebugInfo/PDB/PDBSymbolTypeManaged.h +++ b/include/llvm/DebugInfo/PDB/PDBSymbolTypeManaged.h @@ -22,7 +22,7 @@ public: PDBSymbolTypeManaged(const IPDBSession &PDBSession, std::unique_ptr Symbol); - void dump(llvm::raw_ostream &OS) const override; + void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level) const override; FORWARD_SYMBOL_METHOD(getName) FORWARD_SYMBOL_METHOD(getSymIndexId) diff --git a/include/llvm/DebugInfo/PDB/PDBSymbolTypePointer.h b/include/llvm/DebugInfo/PDB/PDBSymbolTypePointer.h index 2236f9a077b..3a75edde2ab 100644 --- a/include/llvm/DebugInfo/PDB/PDBSymbolTypePointer.h +++ b/include/llvm/DebugInfo/PDB/PDBSymbolTypePointer.h @@ -22,7 +22,7 @@ public: PDBSymbolTypePointer(const IPDBSession &PDBSession, std::unique_ptr Symbol); - void dump(llvm::raw_ostream &OS) const override; + void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level) const override; FORWARD_SYMBOL_METHOD(isConstType) FORWARD_SYMBOL_METHOD(getLength) diff --git a/include/llvm/DebugInfo/PDB/PDBSymbolTypeTypedef.h b/include/llvm/DebugInfo/PDB/PDBSymbolTypeTypedef.h index 4cb13cb2b03..957d184b858 100644 --- a/include/llvm/DebugInfo/PDB/PDBSymbolTypeTypedef.h +++ b/include/llvm/DebugInfo/PDB/PDBSymbolTypeTypedef.h @@ -22,7 +22,7 @@ public: PDBSymbolTypeTypedef(const IPDBSession &PDBSession, std::unique_ptr Symbol); - void dump(llvm::raw_ostream &OS) const override; + void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level) const override; FORWARD_SYMBOL_METHOD(getBuiltinType) FORWARD_SYMBOL_METHOD(getClassParentId) diff --git a/include/llvm/DebugInfo/PDB/PDBSymbolTypeUDT.h b/include/llvm/DebugInfo/PDB/PDBSymbolTypeUDT.h index 7025502e13d..2c86c84c331 100644 --- a/include/llvm/DebugInfo/PDB/PDBSymbolTypeUDT.h +++ b/include/llvm/DebugInfo/PDB/PDBSymbolTypeUDT.h @@ -22,7 +22,7 @@ public: PDBSymbolTypeUDT(const IPDBSession &PDBSession, std::unique_ptr UDTSymbol); - void dump(llvm::raw_ostream &OS) const override; + void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level) const override; FORWARD_SYMBOL_METHOD(getClassParentId) FORWARD_SYMBOL_METHOD(hasConstructor) diff --git a/include/llvm/DebugInfo/PDB/PDBSymbolTypeVTable.h b/include/llvm/DebugInfo/PDB/PDBSymbolTypeVTable.h index 0055969ae14..0c9a916e44b 100644 --- a/include/llvm/DebugInfo/PDB/PDBSymbolTypeVTable.h +++ b/include/llvm/DebugInfo/PDB/PDBSymbolTypeVTable.h @@ -22,7 +22,7 @@ public: PDBSymbolTypeVTable(const IPDBSession &PDBSession, std::unique_ptr VtblSymbol); - void dump(llvm::raw_ostream &OS) const override; + void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level) const override; FORWARD_SYMBOL_METHOD(getClassParentId) FORWARD_SYMBOL_METHOD(isConstType) diff --git a/include/llvm/DebugInfo/PDB/PDBSymbolTypeVTableShape.h b/include/llvm/DebugInfo/PDB/PDBSymbolTypeVTableShape.h index f5d6a4aeec9..5055c8da62f 100644 --- a/include/llvm/DebugInfo/PDB/PDBSymbolTypeVTableShape.h +++ b/include/llvm/DebugInfo/PDB/PDBSymbolTypeVTableShape.h @@ -22,7 +22,7 @@ public: PDBSymbolTypeVTableShape(const IPDBSession &PDBSession, std::unique_ptr VtblShapeSymbol); - void dump(llvm::raw_ostream &OS) const override; + void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level) const override; FORWARD_SYMBOL_METHOD(isConstType) FORWARD_SYMBOL_METHOD(getCount) diff --git a/include/llvm/DebugInfo/PDB/PDBSymbolUnknown.h b/include/llvm/DebugInfo/PDB/PDBSymbolUnknown.h index bcdb6835448..cc8ab370235 100644 --- a/include/llvm/DebugInfo/PDB/PDBSymbolUnknown.h +++ b/include/llvm/DebugInfo/PDB/PDBSymbolUnknown.h @@ -22,7 +22,7 @@ public: PDBSymbolUnknown(const IPDBSession &PDBSession, std::unique_ptr UnknownSymbol); - void dump(llvm::raw_ostream &OS) const override; + void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level) const override; static bool classof(const PDBSymbol *S) { return (S->getSymTag() == PDB_SymType::None || diff --git a/include/llvm/DebugInfo/PDB/PDBSymbolUsingNamespace.h b/include/llvm/DebugInfo/PDB/PDBSymbolUsingNamespace.h index 861f81ab886..535dc8d0c3f 100644 --- a/include/llvm/DebugInfo/PDB/PDBSymbolUsingNamespace.h +++ b/include/llvm/DebugInfo/PDB/PDBSymbolUsingNamespace.h @@ -22,7 +22,7 @@ public: PDBSymbolUsingNamespace(const IPDBSession &PDBSession, std::unique_ptr Symbol); - void dump(llvm::raw_ostream &OS) const override; + void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level) const override; FORWARD_SYMBOL_METHOD(getLexicalParentId) FORWARD_SYMBOL_METHOD(getName) diff --git a/include/llvm/DebugInfo/PDB/PDBTypes.h b/include/llvm/DebugInfo/PDB/PDBTypes.h index 836a423dbe7..0009b02505a 100644 --- a/include/llvm/DebugInfo/PDB/PDBTypes.h +++ b/include/llvm/DebugInfo/PDB/PDBTypes.h @@ -11,6 +11,7 @@ #define LLVM_DEBUGINFO_PDB_PDBTYPES_H #include +#include #include "llvm/Config/llvm-config.h" namespace llvm { @@ -68,6 +69,12 @@ enum class PDB_ReaderType { DIA = 0, }; +enum class PDB_DumpLevel { + Compact, + Normal, + Detailed, +}; + /// Defines a 128-bit unique identifier. This maps to a GUID on Windows, but /// is abstracted here for the purposes of non-Windows platforms that don't have /// the GUID structure defined. @@ -365,6 +372,58 @@ enum class PDB_BuiltinType { HResult = 31 }; +enum class PDB_RegisterId { + Unknown = 0, + VFrame = 30006, + AL = 1, + CL = 2, + DL = 3, + BL = 4, + AH = 5, + CH = 6, + DH = 7, + BH = 8, + AX = 9, + CX = 10, + DX = 11, + BX = 12, + SP = 13, + BP = 14, + SI = 15, + DI = 16, + EAX = 17, + ECX = 18, + EDX = 19, + EBX = 20, + ESP = 21, + EBP = 22, + ESI = 23, + EDI = 24, + ES = 25, + CS = 26, + SS = 27, + DS = 28, + FS = 29, + GS = 30, + IP = 31, + RAX = 328, + RBX = 329, + RCX = 330, + RDX = 331, + RSI = 332, + RDI = 333, + RBP = 334, + RSP = 335, + R8 = 336, + R9 = 337, + R10 = 338, + R11 = 339, + R12 = 340, + R13 = 341, + R14 = 342, + R15 = 343, +}; + enum class PDB_MemberAccess { Private = 1, Protected = 2, Public = 3 }; struct VersionInfo { @@ -376,4 +435,15 @@ struct VersionInfo { } // namespace llvm +namespace std { +template <> struct hash { + typedef llvm::PDB_SymType argument_type; + typedef std::size_t result_type; + + result_type operator()(const argument_type &Arg) const { + return std::hash()(static_cast(Arg)); + } +}; +} + #endif diff --git a/lib/DebugInfo/PDB/CMakeLists.txt b/lib/DebugInfo/PDB/CMakeLists.txt index 007406cedb8..00ad1caa46f 100644 --- a/lib/DebugInfo/PDB/CMakeLists.txt +++ b/lib/DebugInfo/PDB/CMakeLists.txt @@ -30,7 +30,9 @@ endif() list(APPEND LIBPDB_ADDITIONAL_HEADER_DIRS "../../../include/llvm/DebugInfo/PDB") add_llvm_library(LLVMDebugInfoPDB + IPDBSourceFile.cpp PDB.cpp + PDBExtras.cpp PDBInterfaceAnchors.cpp PDBSymbol.cpp PDBSymbolAnnotation.cpp diff --git a/lib/DebugInfo/PDB/DIA/DIARawSymbol.cpp b/lib/DebugInfo/PDB/DIA/DIARawSymbol.cpp index 66d5edca1eb..5c94f6e16ea 100644 --- a/lib/DebugInfo/PDB/DIA/DIARawSymbol.cpp +++ b/lib/DebugInfo/PDB/DIA/DIARawSymbol.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +#include "llvm/DebugInfo/PDB/PDBExtras.h" #include "llvm/DebugInfo/PDB/DIA/DIAEnumSymbols.h" #include "llvm/DebugInfo/PDB/DIA/DIARawSymbol.h" #include "llvm/DebugInfo/PDB/DIA/DIASession.h" @@ -54,13 +55,228 @@ PrivateGetDIAValue(IDiaSymbol *Symbol, ::memcpy(&IdResult, &Result, sizeof(GUID)); return IdResult; } + +template +void DumpDIAValue(llvm::raw_ostream &OS, int Indent, StringRef Name, + IDiaSymbol *Symbol, + HRESULT (__stdcall IDiaSymbol::*Method)(ArgType *)) { + ArgType Value; + if (S_OK == (Symbol->*Method)(&Value)) { + OS.indent(Indent); + OS << Name << ": " << Value << "\n"; + } +} + +void DumpDIAValue(llvm::raw_ostream &OS, int Indent, StringRef Name, + IDiaSymbol *Symbol, + HRESULT (__stdcall IDiaSymbol::*Method)(BSTR *)) { + BSTR Value = nullptr; + if (S_OK != (Symbol->*Method)(&Value)) + return; + const char *Bytes = reinterpret_cast(Value); + ArrayRef ByteArray(Bytes, ::SysStringByteLen(Value)); + std::string Result; + if (llvm::convertUTF16ToUTF8String(ByteArray, Result)) { + OS.indent(Indent); + OS << Name << ": " << Result << "\n"; + } + ::SysFreeString(Value); +} +} + +namespace llvm { +raw_ostream &operator<<(raw_ostream &OS, const GUID &Guid) { + const PDB_UniqueId *Id = reinterpret_cast(&Guid); + OS << *Id; + return OS; +} } DIARawSymbol::DIARawSymbol(const DIASession &PDBSession, CComPtr DiaSymbol) : Session(PDBSession), Symbol(DiaSymbol) {} -void DIARawSymbol::dump(llvm::raw_ostream &OS) const {} +#define RAW_METHOD_DUMP(Stream, Method) \ + DumpDIAValue(Stream, Indent, StringRef(#Method), Symbol, &IDiaSymbol::Method); + +void DIARawSymbol::dump(raw_ostream &OS, int Indent, + PDB_DumpLevel Level) const { + RAW_METHOD_DUMP(OS, get_access) + RAW_METHOD_DUMP(OS, get_addressOffset) + RAW_METHOD_DUMP(OS, get_addressSection) + RAW_METHOD_DUMP(OS, get_age) + RAW_METHOD_DUMP(OS, get_arrayIndexTypeId) + RAW_METHOD_DUMP(OS, get_backEndMajor) + RAW_METHOD_DUMP(OS, get_backEndMinor) + RAW_METHOD_DUMP(OS, get_backEndBuild) + RAW_METHOD_DUMP(OS, get_backEndQFE) + RAW_METHOD_DUMP(OS, get_baseDataOffset) + RAW_METHOD_DUMP(OS, get_baseDataSlot) + RAW_METHOD_DUMP(OS, get_baseSymbolId) + RAW_METHOD_DUMP(OS, get_builtInKind) + RAW_METHOD_DUMP(OS, get_bitPosition) + RAW_METHOD_DUMP(OS, get_callingConvention) + RAW_METHOD_DUMP(OS, get_classParentId) + RAW_METHOD_DUMP(OS, get_compilerName) + RAW_METHOD_DUMP(OS, get_count) + RAW_METHOD_DUMP(OS, get_countLiveRanges) + RAW_METHOD_DUMP(OS, get_frontEndMajor) + RAW_METHOD_DUMP(OS, get_frontEndMinor) + RAW_METHOD_DUMP(OS, get_frontEndBuild) + RAW_METHOD_DUMP(OS, get_frontEndQFE) + RAW_METHOD_DUMP(OS, get_count) + RAW_METHOD_DUMP(OS, get_lexicalParentId) + RAW_METHOD_DUMP(OS, get_libraryName) + RAW_METHOD_DUMP(OS, get_liveRangeStartAddressOffset) + RAW_METHOD_DUMP(OS, get_liveRangeStartAddressSection) + RAW_METHOD_DUMP(OS, get_liveRangeStartRelativeVirtualAddress) + RAW_METHOD_DUMP(OS, get_localBasePointerRegisterId) + RAW_METHOD_DUMP(OS, get_lowerBoundId) + RAW_METHOD_DUMP(OS, get_memorySpaceKind) + RAW_METHOD_DUMP(OS, get_name) + RAW_METHOD_DUMP(OS, get_numberOfAcceleratorPointerTags) + RAW_METHOD_DUMP(OS, get_numberOfColumns) + RAW_METHOD_DUMP(OS, get_numberOfModifiers) + RAW_METHOD_DUMP(OS, get_numberOfRegisterIndices) + RAW_METHOD_DUMP(OS, get_numberOfRows) + RAW_METHOD_DUMP(OS, get_objectFileName) + RAW_METHOD_DUMP(OS, get_oemId) + RAW_METHOD_DUMP(OS, get_oemSymbolId) + RAW_METHOD_DUMP(OS, get_offsetInUdt) + RAW_METHOD_DUMP(OS, get_platform) + RAW_METHOD_DUMP(OS, get_rank) + RAW_METHOD_DUMP(OS, get_registerId) + RAW_METHOD_DUMP(OS, get_registerType) + RAW_METHOD_DUMP(OS, get_relativeVirtualAddress) + RAW_METHOD_DUMP(OS, get_samplerSlot) + RAW_METHOD_DUMP(OS, get_signature) + RAW_METHOD_DUMP(OS, get_sizeInUdt) + RAW_METHOD_DUMP(OS, get_slot) + RAW_METHOD_DUMP(OS, get_sourceFileName) + RAW_METHOD_DUMP(OS, get_stride) + RAW_METHOD_DUMP(OS, get_subTypeId) + RAW_METHOD_DUMP(OS, get_symbolsFileName) + RAW_METHOD_DUMP(OS, get_symIndexId) + RAW_METHOD_DUMP(OS, get_targetOffset) + RAW_METHOD_DUMP(OS, get_targetRelativeVirtualAddress) + RAW_METHOD_DUMP(OS, get_targetVirtualAddress) + RAW_METHOD_DUMP(OS, get_targetSection) + RAW_METHOD_DUMP(OS, get_textureSlot) + RAW_METHOD_DUMP(OS, get_timeStamp) + RAW_METHOD_DUMP(OS, get_token) + RAW_METHOD_DUMP(OS, get_typeId) + RAW_METHOD_DUMP(OS, get_uavSlot) + RAW_METHOD_DUMP(OS, get_undecoratedName) + RAW_METHOD_DUMP(OS, get_unmodifiedTypeId) + RAW_METHOD_DUMP(OS, get_upperBoundId) + RAW_METHOD_DUMP(OS, get_virtualBaseDispIndex) + RAW_METHOD_DUMP(OS, get_virtualBaseOffset) + RAW_METHOD_DUMP(OS, get_virtualTableShapeId) + RAW_METHOD_DUMP(OS, get_dataKind) + RAW_METHOD_DUMP(OS, get_symTag) + RAW_METHOD_DUMP(OS, get_guid) + RAW_METHOD_DUMP(OS, get_offset) + RAW_METHOD_DUMP(OS, get_thisAdjust) + RAW_METHOD_DUMP(OS, get_virtualBasePointerOffset) + RAW_METHOD_DUMP(OS, get_locationType) + RAW_METHOD_DUMP(OS, get_machineType) + RAW_METHOD_DUMP(OS, get_thunkOrdinal) + RAW_METHOD_DUMP(OS, get_length) + RAW_METHOD_DUMP(OS, get_liveRangeLength) + RAW_METHOD_DUMP(OS, get_virtualAddress) + RAW_METHOD_DUMP(OS, get_udtKind) + RAW_METHOD_DUMP(OS, get_constructor) + RAW_METHOD_DUMP(OS, get_customCallingConvention) + RAW_METHOD_DUMP(OS, get_farReturn) + RAW_METHOD_DUMP(OS, get_code) + RAW_METHOD_DUMP(OS, get_compilerGenerated) + RAW_METHOD_DUMP(OS, get_constType) + RAW_METHOD_DUMP(OS, get_editAndContinueEnabled) + RAW_METHOD_DUMP(OS, get_function) + RAW_METHOD_DUMP(OS, get_stride) + RAW_METHOD_DUMP(OS, get_noStackOrdering) + RAW_METHOD_DUMP(OS, get_hasAlloca) + RAW_METHOD_DUMP(OS, get_hasAssignmentOperator) + RAW_METHOD_DUMP(OS, get_isCTypes) + RAW_METHOD_DUMP(OS, get_hasCastOperator) + RAW_METHOD_DUMP(OS, get_hasDebugInfo) + RAW_METHOD_DUMP(OS, get_hasEH) + RAW_METHOD_DUMP(OS, get_hasEHa) + RAW_METHOD_DUMP(OS, get_hasInlAsm) + RAW_METHOD_DUMP(OS, get_framePointerPresent) + RAW_METHOD_DUMP(OS, get_inlSpec) + RAW_METHOD_DUMP(OS, get_interruptReturn) + RAW_METHOD_DUMP(OS, get_hasLongJump) + RAW_METHOD_DUMP(OS, get_hasManagedCode) + RAW_METHOD_DUMP(OS, get_hasNestedTypes) + RAW_METHOD_DUMP(OS, get_noInline) + RAW_METHOD_DUMP(OS, get_noReturn) + RAW_METHOD_DUMP(OS, get_optimizedCodeDebugInfo) + RAW_METHOD_DUMP(OS, get_overloadedOperator) + RAW_METHOD_DUMP(OS, get_hasSEH) + RAW_METHOD_DUMP(OS, get_hasSecurityChecks) + RAW_METHOD_DUMP(OS, get_hasSetJump) + RAW_METHOD_DUMP(OS, get_strictGSCheck) + RAW_METHOD_DUMP(OS, get_isAcceleratorGroupSharedLocal) + RAW_METHOD_DUMP(OS, get_isAcceleratorPointerTagLiveRange) + RAW_METHOD_DUMP(OS, get_isAcceleratorStubFunction) + RAW_METHOD_DUMP(OS, get_isAggregated) + RAW_METHOD_DUMP(OS, get_intro) + RAW_METHOD_DUMP(OS, get_isCVTCIL) + RAW_METHOD_DUMP(OS, get_isConstructorVirtualBase) + RAW_METHOD_DUMP(OS, get_isCxxReturnUdt) + RAW_METHOD_DUMP(OS, get_isDataAligned) + RAW_METHOD_DUMP(OS, get_isHLSLData) + RAW_METHOD_DUMP(OS, get_isHotpatchable) + RAW_METHOD_DUMP(OS, get_indirectVirtualBaseClass) + RAW_METHOD_DUMP(OS, get_isInterfaceUdt) + RAW_METHOD_DUMP(OS, get_intrinsic) + RAW_METHOD_DUMP(OS, get_isLTCG) + RAW_METHOD_DUMP(OS, get_isLocationControlFlowDependent) + RAW_METHOD_DUMP(OS, get_isMSILNetmodule) + RAW_METHOD_DUMP(OS, get_isMatrixRowMajor) + RAW_METHOD_DUMP(OS, get_managed) + RAW_METHOD_DUMP(OS, get_msil) + RAW_METHOD_DUMP(OS, get_isMultipleInheritance) + RAW_METHOD_DUMP(OS, get_isNaked) + RAW_METHOD_DUMP(OS, get_nested) + RAW_METHOD_DUMP(OS, get_isOptimizedAway) + RAW_METHOD_DUMP(OS, get_packed) + RAW_METHOD_DUMP(OS, get_isPointerBasedOnSymbolValue) + RAW_METHOD_DUMP(OS, get_isPointerToDataMember) + RAW_METHOD_DUMP(OS, get_isPointerToMemberFunction) + RAW_METHOD_DUMP(OS, get_pure) + RAW_METHOD_DUMP(OS, get_RValueReference) + RAW_METHOD_DUMP(OS, get_isRefUdt) + RAW_METHOD_DUMP(OS, get_reference) + RAW_METHOD_DUMP(OS, get_restrictedType) + RAW_METHOD_DUMP(OS, get_isReturnValue) + RAW_METHOD_DUMP(OS, get_isSafeBuffers) + RAW_METHOD_DUMP(OS, get_scoped) + RAW_METHOD_DUMP(OS, get_isSdl) + RAW_METHOD_DUMP(OS, get_isSingleInheritance) + RAW_METHOD_DUMP(OS, get_isSplitted) + RAW_METHOD_DUMP(OS, get_isStatic) + RAW_METHOD_DUMP(OS, get_isStripped) + RAW_METHOD_DUMP(OS, get_unalignedType) + RAW_METHOD_DUMP(OS, get_notReached) + RAW_METHOD_DUMP(OS, get_isValueUdt) + RAW_METHOD_DUMP(OS, get_virtual) + RAW_METHOD_DUMP(OS, get_virtualBaseClass) + RAW_METHOD_DUMP(OS, get_isVirtualInheritance) + RAW_METHOD_DUMP(OS, get_volatileType) +} + +std::unique_ptr +DIARawSymbol::findChildren(PDB_SymType Type) const { + enum SymTagEnum EnumVal = static_cast(Type); + + CComPtr DiaEnumerator; + if (S_OK != Symbol->findChildren(EnumVal, nullptr, nsNone, &DiaEnumerator)) + return nullptr; + + return std::make_unique(Session, DiaEnumerator); +} std::unique_ptr DIARawSymbol::findChildren(PDB_SymType Type, StringRef Name, @@ -198,7 +414,7 @@ void DIARawSymbol::getFrontEndVersion(VersionInfo &Version) const { } PDB_Lang DIARawSymbol::getLanguage() const { - return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_count); + return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_language); } uint32_t DIARawSymbol::getLexicalParentId() const { @@ -224,9 +440,9 @@ uint32_t DIARawSymbol::getLiveRangeStartRelativeVirtualAddress() const { Symbol, &IDiaSymbol::get_liveRangeStartRelativeVirtualAddress); } -uint32_t DIARawSymbol::getLocalBasePointerRegisterId() const { - return PrivateGetDIAValue(Symbol, - &IDiaSymbol::get_localBasePointerRegisterId); +PDB_RegisterId DIARawSymbol::getLocalBasePointerRegisterId() const { + return PrivateGetDIAValue( + Symbol, &IDiaSymbol::get_localBasePointerRegisterId); } uint32_t DIARawSymbol::getLowerBoundId() const { @@ -286,8 +502,9 @@ uint32_t DIARawSymbol::getRank() const { return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_rank); } -uint32_t DIARawSymbol::getRegisterId() const { - return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_registerId); +PDB_RegisterId DIARawSymbol::getRegisterId() const { + return PrivateGetDIAValue(Symbol, + &IDiaSymbol::get_registerId); } uint32_t DIARawSymbol::getRegisterType() const { @@ -486,7 +703,7 @@ bool DIARawSymbol::isFunction() const { } bool DIARawSymbol::getAddressTaken() const { - return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_stride); + return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_addressTaken); } bool DIARawSymbol::getNoStackOrdering() const { @@ -533,6 +750,10 @@ bool DIARawSymbol::hasInterruptReturn() const { return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_interruptReturn); } +bool DIARawSymbol::hasFramePointer() const { + return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_framePointerPresent); +} + bool DIARawSymbol::hasLongJump() const { return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_hasLongJump); } diff --git a/lib/DebugInfo/PDB/DIA/DIASession.cpp b/lib/DebugInfo/PDB/DIA/DIASession.cpp index 3b5c951e2ba..0df2354e018 100644 --- a/lib/DebugInfo/PDB/DIA/DIASession.cpp +++ b/lib/DebugInfo/PDB/DIA/DIASession.cpp @@ -7,11 +7,14 @@ // //===----------------------------------------------------------------------===// +#include "llvm/DebugInfo/PDB/PDBSymbolCompiland.h" +#include "llvm/DebugInfo/PDB/PDBSymbolExe.h" + #include "llvm/DebugInfo/PDB/DIA/DIAEnumDebugStreams.h" +#include "llvm/DebugInfo/PDB/DIA/DIAEnumSourceFiles.h" #include "llvm/DebugInfo/PDB/DIA/DIARawSymbol.h" #include "llvm/DebugInfo/PDB/DIA/DIASession.h" #include "llvm/DebugInfo/PDB/DIA/DIASourceFile.h" -#include "llvm/DebugInfo/PDB/PDBSymbolExe.h" #include "llvm/Support/ConvertUTF.h" using namespace llvm; @@ -75,6 +78,27 @@ std::unique_ptr DIASession::getSymbolById(uint32_t SymbolId) const { return PDBSymbol::create(*this, std::move(RawSymbol)); } +std::unique_ptr DIASession::getAllSourceFiles() const { + CComPtr Files; + if (S_OK != Session->findFile(nullptr, nullptr, nsNone, &Files)) + return nullptr; + + return std::make_unique(*this, Files); +} + +std::unique_ptr DIASession::getSourceFilesForCompiland( + const PDBSymbolCompiland &Compiland) const { + CComPtr Files; + + const DIARawSymbol &RawSymbol = + static_cast(Compiland.getRawSymbol()); + if (S_OK != + Session->findFile(RawSymbol.getDiaSymbol(), nullptr, nsNone, &Files)) + return nullptr; + + return std::make_unique(*this, Files); +} + std::unique_ptr DIASession::getSourceFileById(uint32_t FileId) const { CComPtr LocatedFile; diff --git a/lib/DebugInfo/PDB/IPDBSourceFile.cpp b/lib/DebugInfo/PDB/IPDBSourceFile.cpp new file mode 100644 index 00000000000..f3e0284f47c --- /dev/null +++ b/lib/DebugInfo/PDB/IPDBSourceFile.cpp @@ -0,0 +1,34 @@ +//===- IPDBSourceFile.cpp - base interface for a PDB source file *- 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/IPDBSourceFile.h" +#include "llvm/DebugInfo/PDB/PDBExtras.h" +#include "llvm/Support/Format.h" +#include "llvm/Support/raw_ostream.h" + +using namespace llvm; + +IPDBSourceFile::~IPDBSourceFile() {} + +void IPDBSourceFile::dump(raw_ostream &OS, int Indent, + PDB_DumpLevel Level) const { + if (Level == PDB_DumpLevel::Compact) { + OS.indent(Indent); + PDB_Checksum ChecksumType = getChecksumType(); + OS << "["; + if (ChecksumType != PDB_Checksum::None) { + OS << ChecksumType << ": "; + std::string Checksum = getChecksum(); + for (uint8_t c : Checksum) + OS << format_hex_no_prefix(c, 2, true); + } else + OS << "No checksum"; + OS << "] " << getFileName() << "\n"; + } +} diff --git a/lib/DebugInfo/PDB/PDBExtras.cpp b/lib/DebugInfo/PDB/PDBExtras.cpp new file mode 100644 index 00000000000..60e5368ffdb --- /dev/null +++ b/lib/DebugInfo/PDB/PDBExtras.cpp @@ -0,0 +1,219 @@ +//===- PDBExtras.cpp - helper functions and classes for PDBs -----*- 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/PDBExtras.h" +#include "llvm/ADT/ArrayRef.h" + +using namespace llvm; + +#define CASE_OUTPUT_ENUM_CLASS_STR(Class, Value, Str, Stream) \ + case Class::Value: \ + Stream << Str; \ + break; + +#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_RegisterId &Reg) { + switch (Reg) { + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_RegisterId, AL, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_RegisterId, CL, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_RegisterId, DL, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_RegisterId, BL, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_RegisterId, AH, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_RegisterId, CH, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_RegisterId, DH, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_RegisterId, BH, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_RegisterId, AX, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_RegisterId, CX, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_RegisterId, DX, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_RegisterId, BX, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_RegisterId, SP, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_RegisterId, BP, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_RegisterId, SI, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_RegisterId, DI, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_RegisterId, EAX, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_RegisterId, ECX, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_RegisterId, EDX, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_RegisterId, EBX, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_RegisterId, ESP, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_RegisterId, EBP, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_RegisterId, ESI, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_RegisterId, EDI, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_RegisterId, ES, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_RegisterId, CS, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_RegisterId, SS, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_RegisterId, DS, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_RegisterId, FS, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_RegisterId, GS, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_RegisterId, IP, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_RegisterId, RAX, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_RegisterId, RBX, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_RegisterId, RCX, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_RegisterId, RDX, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_RegisterId, RSI, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_RegisterId, RDI, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_RegisterId, RBP, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_RegisterId, RSP, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_RegisterId, R8, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_RegisterId, R9, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_RegisterId, R10, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_RegisterId, R11, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_RegisterId, R12, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_RegisterId, R13, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_RegisterId, R14, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_RegisterId, R15, OS) + default: + OS << "Unknown"; + } + return OS; +} + +raw_ostream &llvm::operator<<(raw_ostream &OS, const PDB_LocType &Loc) { + switch (Loc) { + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_LocType, Static, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_LocType, TLS, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_LocType, RegRel, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_LocType, ThisRel, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_LocType, Enregistered, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_LocType, BitField, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_LocType, Slot, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_LocType, IlRel, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_LocType, MetaData, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_LocType, Constant, OS) + default: + OS << "Unknown"; + } + return OS; +} + +raw_ostream &llvm::operator<<(raw_ostream &OS, const PDB_ThunkOrdinal &Thunk) { + switch (Thunk) { + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_ThunkOrdinal, BranchIsland, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_ThunkOrdinal, Pcode, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_ThunkOrdinal, Standard, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_ThunkOrdinal, ThisAdjustor, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_ThunkOrdinal, TrampIncremental, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_ThunkOrdinal, UnknownLoad, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_ThunkOrdinal, Vcall, OS) + default: + OS << "Unknown"; + } + return OS; +} + +raw_ostream &llvm::operator<<(raw_ostream &OS, const PDB_Checksum &Checksum) { + switch (Checksum) { + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Checksum, None, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Checksum, MD5, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Checksum, SHA1, OS) + default: + OS << "Unknown"; + } + return OS; +} + +raw_ostream &llvm::operator<<(raw_ostream &OS, const PDB_Lang &Lang) { + switch (Lang) { + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Lang, C, OS) + CASE_OUTPUT_ENUM_CLASS_STR(PDB_Lang, Cpp, "C++", OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Lang, Fortran, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Lang, Masm, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Lang, Pascal, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Lang, Basic, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Lang, Cobol, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Lang, Link, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Lang, Cvtres, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Lang, Cvtpgd, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Lang, CSharp, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Lang, VB, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Lang, ILAsm, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Lang, Java, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Lang, JScript, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Lang, MSIL, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Lang, HLSL, OS) + default: + OS << "Unknown"; + } + return OS; +} + +raw_ostream &llvm::operator<<(raw_ostream &OS, const PDB_SymType &Tag) { + switch (Tag) { + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, Exe, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, Compiland, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, CompilandDetails, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, CompilandEnv, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, Function, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, Block, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, Data, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, Annotation, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, Label, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, PublicSymbol, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, UDT, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, Enum, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, FunctionSig, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, PointerType, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, ArrayType, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, BuiltinType, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, Typedef, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, BaseClass, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, Friend, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, FunctionArg, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, FuncDebugStart, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, FuncDebugEnd, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, UsingNamespace, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, VTableShape, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, VTable, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, Custom, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, Thunk, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, CustomType, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, ManagedType, OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, Dimension, OS) + default: + OS << "Unknown"; + } + return OS; +} + +raw_ostream &llvm::operator<<(raw_ostream &OS, const PDB_UniqueId &Id) { + static const char *Lookup = "0123456789ABCDEF"; + + static_assert(sizeof(PDB_UniqueId) == 16, "Expected 16-byte GUID"); + ArrayRef GuidBytes(reinterpret_cast(&Id), 16); + OS << "{"; + for (int i=0; i < 16;) { + uint8_t Byte = GuidBytes[i]; + uint8_t HighNibble = (Byte >> 4) & 0xF; + uint8_t LowNibble = Byte & 0xF; + OS << Lookup[HighNibble] << Lookup[LowNibble]; + ++i; + if (i>=4 && i<=10 && i%2==0) + OS << "-"; + } + OS << "}"; + return OS; +} + +raw_ostream &llvm::operator<<(raw_ostream &OS, const VersionInfo &Version) { + OS << Version.Major << "." << Version.Minor << "." << Version.Build; + return OS; +} + +raw_ostream &llvm::operator<<(raw_ostream &OS, const TagStats &Stats) { + for (auto Tag : Stats) { + OS << Tag.first << ":" << Tag.second << " "; + } + return OS; +} diff --git a/lib/DebugInfo/PDB/PDBInterfaceAnchors.cpp b/lib/DebugInfo/PDB/PDBInterfaceAnchors.cpp index 8b430cf7103..1183af10914 100644 --- a/lib/DebugInfo/PDB/PDBInterfaceAnchors.cpp +++ b/lib/DebugInfo/PDB/PDBInterfaceAnchors.cpp @@ -25,6 +25,4 @@ IPDBDataStream::~IPDBDataStream() {} IPDBRawSymbol::~IPDBRawSymbol() {} -IPDBSourceFile::~IPDBSourceFile() {} - IPDBLineNumber::~IPDBLineNumber() {} diff --git a/lib/DebugInfo/PDB/PDBSymbol.cpp b/lib/DebugInfo/PDB/PDBSymbol.cpp index bbc395284bc..d65a153623a 100644 --- a/lib/DebugInfo/PDB/PDBSymbol.cpp +++ b/lib/DebugInfo/PDB/PDBSymbol.cpp @@ -98,10 +98,17 @@ PDBSymbol::create(const IPDBSession &PDBSession, } } -void PDBSymbol::dump(llvm::raw_ostream &OS) const { RawSymbol->dump(OS); } +void PDBSymbol::defaultDump(raw_ostream &OS, int Indent, + PDB_DumpLevel Level) const { + RawSymbol->dump(OS, Indent, Level); +} PDB_SymType PDBSymbol::getSymTag() const { return RawSymbol->getSymTag(); } +std::unique_ptr PDBSymbol::findChildren(PDB_SymType Type) const { + return RawSymbol->findChildren(Type); +} + std::unique_ptr PDBSymbol::findChildren(PDB_SymType Type, StringRef Name, PDB_NameSearchFlags Flags) const { @@ -118,3 +125,14 @@ std::unique_ptr PDBSymbol::findInlineFramesByRVA(uint32_t RVA) const { return RawSymbol->findInlineFramesByRVA(RVA); } + +std::unique_ptr +PDBSymbol::getChildStats(TagStats &Stats) const { + std::unique_ptr Result(findChildren(PDB_SymType::None)); + Stats.clear(); + while (auto Child = Result->getNext()) { + ++Stats[Child->getSymTag()]; + } + Result->reset(); + return Result; +} diff --git a/lib/DebugInfo/PDB/PDBSymbolAnnotation.cpp b/lib/DebugInfo/PDB/PDBSymbolAnnotation.cpp index ed30c7dba6e..224a9a57dd7 100644 --- a/lib/DebugInfo/PDB/PDBSymbolAnnotation.cpp +++ b/lib/DebugInfo/PDB/PDBSymbolAnnotation.cpp @@ -18,4 +18,5 @@ PDBSymbolAnnotation::PDBSymbolAnnotation(const IPDBSession &PDBSession, std::unique_ptr Symbol) : PDBSymbol(PDBSession, std::move(Symbol)) {} -void PDBSymbolAnnotation::dump(llvm::raw_ostream &OS) const {} +void PDBSymbolAnnotation::dump(raw_ostream &OS, int Indent, + PDB_DumpLevel Level) const {} diff --git a/lib/DebugInfo/PDB/PDBSymbolBlock.cpp b/lib/DebugInfo/PDB/PDBSymbolBlock.cpp index b5c738fa30b..9f401067c18 100644 --- a/lib/DebugInfo/PDB/PDBSymbolBlock.cpp +++ b/lib/DebugInfo/PDB/PDBSymbolBlock.cpp @@ -18,4 +18,5 @@ PDBSymbolBlock::PDBSymbolBlock(const IPDBSession &PDBSession, std::unique_ptr Symbol) : PDBSymbol(PDBSession, std::move(Symbol)) {} -void PDBSymbolBlock::dump(llvm::raw_ostream &OS) const {} +void PDBSymbolBlock::dump(raw_ostream &OS, int Indent, + PDB_DumpLevel Level) const {} diff --git a/lib/DebugInfo/PDB/PDBSymbolCompiland.cpp b/lib/DebugInfo/PDB/PDBSymbolCompiland.cpp index 02a48fd51f0..13f6cccd0a2 100644 --- a/lib/DebugInfo/PDB/PDBSymbolCompiland.cpp +++ b/lib/DebugInfo/PDB/PDBSymbolCompiland.cpp @@ -8,11 +8,16 @@ //===----------------------------------------------------------------------===// #include +#include #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/PDBSymbolCompiland.h" #include "llvm/DebugInfo/PDB/PDBSymbolCompilandDetails.h" +#include "llvm/DebugInfo/PDB/PDBSymbolCompilandEnv.h" #include "llvm/Support/raw_ostream.h" using namespace llvm; @@ -21,5 +26,73 @@ PDBSymbolCompiland::PDBSymbolCompiland(const IPDBSession &PDBSession, std::unique_ptr Symbol) : PDBSymbol(PDBSession, std::move(Symbol)) {} -void PDBSymbolCompiland::dump(llvm::raw_ostream &OS) const { +void PDBSymbolCompiland::dump(raw_ostream &OS, int Indent, + PDB_DumpLevel Level) const { + std::string Name = getName(); + OS << "---- [IDX: " << getSymIndexId() << "] Compiland: " << Name + << " ----\n"; + + std::string Source = getSourceFileName(); + std::string Library = getLibraryName(); + if (!Source.empty()) + OS << stream_indent(Indent + 2) << "Source: " << this->getSourceFileName() + << "\n"; + if (!Library.empty()) + OS << stream_indent(Indent + 2) << "Library: " << this->getLibraryName() + << "\n"; + + TagStats Stats; + auto ChildrenEnum = getChildStats(Stats); + OS << stream_indent(Indent + 2) << "Children: " << Stats << "\n"; + if (Level >= PDB_DumpLevel::Normal) { + while (auto Child = ChildrenEnum->getNext()) { + if (llvm::isa(*Child)) + continue; + if (llvm::isa(*Child)) + continue; + Child->dump(OS, Indent + 4, PDB_DumpLevel::Compact); + } + } + + std::unique_ptr DetailsEnum( + findChildren(PDB_SymType::CompilandDetails)); + if (auto DetailsPtr = DetailsEnum->getNext()) { + const auto *CD = dyn_cast(DetailsPtr.get()); + assert(CD && "We only asked for compilands, but got something else!"); + VersionInfo FE; + VersionInfo BE; + CD->getFrontEndVersion(FE); + CD->getBackEndVersion(BE); + OS << stream_indent(Indent + 2) << "Compiler: " << CD->getCompilerName() + << "\n"; + OS << stream_indent(Indent + 2) << "Version: " << FE << ", " << BE << "\n"; + + OS << stream_indent(Indent + 2) << "Lang: " << CD->getLanguage() << "\n"; + OS << stream_indent(Indent + 2) << "Attributes: "; + if (CD->hasDebugInfo()) + OS << "DebugInfo "; + if (CD->isDataAligned()) + OS << "DataAligned "; + if (CD->isLTCG()) + OS << "LTCG "; + if (CD->hasSecurityChecks()) + OS << "SecurityChecks "; + if (CD->isHotpatchable()) + OS << "HotPatchable"; + + OS << "\n"; + auto Files(Session.getSourceFilesForCompiland(*this)); + if (Level >= PDB_DumpLevel::Detailed) { + OS << stream_indent(Indent + 2) << Files->getChildCount() + << " source files:\n"; + while (auto File = Files->getNext()) + File->dump(OS, Indent + 4, PDB_DumpLevel::Compact); + } else { + OS << stream_indent(Indent + 2) << Files->getChildCount() + << " source files\n"; + } + } + uint32_t Count = DetailsEnum->getChildCount(); + if (Count > 1) + OS << stream_indent(Indent + 2) << "(" << Count - 1 << " more omitted)\n"; } diff --git a/lib/DebugInfo/PDB/PDBSymbolCompilandDetails.cpp b/lib/DebugInfo/PDB/PDBSymbolCompilandDetails.cpp index c50848e455d..86844beab1c 100644 --- a/lib/DebugInfo/PDB/PDBSymbolCompilandDetails.cpp +++ b/lib/DebugInfo/PDB/PDBSymbolCompilandDetails.cpp @@ -18,4 +18,5 @@ PDBSymbolCompilandDetails::PDBSymbolCompilandDetails( const IPDBSession &PDBSession, std::unique_ptr Symbol) : PDBSymbol(PDBSession, std::move(Symbol)) {} -void PDBSymbolCompilandDetails::dump(llvm::raw_ostream &OS) const {} +void PDBSymbolCompilandDetails::dump(raw_ostream &OS, int Indent, + PDB_DumpLevel Level) const {} diff --git a/lib/DebugInfo/PDB/PDBSymbolCompilandEnv.cpp b/lib/DebugInfo/PDB/PDBSymbolCompilandEnv.cpp index 8ad90ee5295..ad1533968b5 100644 --- a/lib/DebugInfo/PDB/PDBSymbolCompilandEnv.cpp +++ b/lib/DebugInfo/PDB/PDBSymbolCompilandEnv.cpp @@ -24,4 +24,5 @@ std::string PDBSymbolCompilandEnv::getValue() const { return std::string(); } -void PDBSymbolCompilandEnv::dump(llvm::raw_ostream &OS) const {} +void PDBSymbolCompilandEnv::dump(raw_ostream &OS, int Indent, + PDB_DumpLevel Level) const {} diff --git a/lib/DebugInfo/PDB/PDBSymbolCustom.cpp b/lib/DebugInfo/PDB/PDBSymbolCustom.cpp index 0d44334f102..55334f32776 100644 --- a/lib/DebugInfo/PDB/PDBSymbolCustom.cpp +++ b/lib/DebugInfo/PDB/PDBSymbolCustom.cpp @@ -23,4 +23,5 @@ void PDBSymbolCustom::getDataBytes(llvm::SmallVector &bytes) { RawSymbol->getDataBytes(bytes); } -void PDBSymbolCustom::dump(llvm::raw_ostream &OS) const {} \ No newline at end of file +void PDBSymbolCustom::dump(raw_ostream &OS, int Indent, + PDB_DumpLevel Level) const {} \ No newline at end of file diff --git a/lib/DebugInfo/PDB/PDBSymbolData.cpp b/lib/DebugInfo/PDB/PDBSymbolData.cpp index e93307fba4d..f605af26771 100644 --- a/lib/DebugInfo/PDB/PDBSymbolData.cpp +++ b/lib/DebugInfo/PDB/PDBSymbolData.cpp @@ -8,12 +8,59 @@ //===----------------------------------------------------------------------===// #include +#include "llvm/DebugInfo/PDB/PDBExtras.h" #include "llvm/DebugInfo/PDB/PDBSymbolData.h" +#include "llvm/Support/Format.h" + using namespace llvm; PDBSymbolData::PDBSymbolData(const IPDBSession &PDBSession, std::unique_ptr DataSymbol) : PDBSymbol(PDBSession, std::move(DataSymbol)) {} -void PDBSymbolData::dump(llvm::raw_ostream &OS) const {} \ No newline at end of file +void PDBSymbolData::dump(raw_ostream &OS, int Indent, + PDB_DumpLevel Level) const { + OS.indent(Indent); + if (Level == PDB_DumpLevel::Compact) { + PDB_LocType Loc = getLocationType(); + OS << Loc << " data ["; + switch (Loc) { + case PDB_LocType::Static: + OS << format_hex(getRelativeVirtualAddress(), 10); + break; + case PDB_LocType::TLS: + OS << getAddressSection() << ":" << format_hex(getAddressOffset(), 10); + break; + case PDB_LocType::RegRel: + OS << getRegisterId() << " + " << getOffset() << "]"; + break; + case PDB_LocType::ThisRel: + OS << "this + " << getOffset() << "]"; + break; + case PDB_LocType::Enregistered: + OS << getRegisterId() << "]"; + break; + case PDB_LocType::BitField: { + uint32_t Offset = getOffset(); + uint32_t BitPos = getBitPosition(); + uint32_t Length = getLength(); + uint32_t StartBits = 8 - BitPos; + uint32_t MiddleBytes = (Length - StartBits) / 8; + uint32_t EndBits = Length - StartBits - MiddleBytes * 8; + OS << format_hex(Offset, 10) << ":" << BitPos; + OS << " - " << format_hex(Offset + MiddleBytes, 10) << ":" << EndBits; + break; + } + case PDB_LocType::Slot: + OS << getSlot(); + case PDB_LocType::IlRel: + case PDB_LocType::MetaData: + case PDB_LocType::Constant: + default: + OS << "???"; + } + OS << "] "; + } + OS << getName() << "\n"; +} \ No newline at end of file diff --git a/lib/DebugInfo/PDB/PDBSymbolExe.cpp b/lib/DebugInfo/PDB/PDBSymbolExe.cpp index 494c51c9b91..c058949991b 100644 --- a/lib/DebugInfo/PDB/PDBSymbolExe.cpp +++ b/lib/DebugInfo/PDB/PDBSymbolExe.cpp @@ -9,6 +9,8 @@ #include +#include "llvm/DebugInfo/PDB/IPDBEnumChildren.h" +#include "llvm/DebugInfo/PDB/PDBExtras.h" #include "llvm/DebugInfo/PDB/PDBSymbol.h" #include "llvm/DebugInfo/PDB/PDBSymbolExe.h" #include "llvm/Support/ConvertUTF.h" @@ -21,5 +23,28 @@ PDBSymbolExe::PDBSymbolExe(const IPDBSession &PDBSession, std::unique_ptr Symbol) : PDBSymbol(PDBSession, std::move(Symbol)) {} -void PDBSymbolExe::dump(llvm::raw_ostream &OS) const { +void PDBSymbolExe::dump(raw_ostream &OS, int Indent, + PDB_DumpLevel Level) const { + std::string FileName(getSymbolsFileName()); + + OS << "Summary for " << FileName << "\n"; + + TagStats Stats; + auto ChildrenEnum = getChildStats(Stats); + OS << stream_indent(Indent + 2) << "Children: " << Stats << "\n"; + + uint64_t FileSize = 0; + if (!llvm::sys::fs::file_size(FileName, FileSize)) + OS << " Size: " << FileSize << " bytes\n"; + else + OS << " Size: (Unable to obtain file size)\n"; + PDB_UniqueId Guid = getGuid(); + OS << " Guid: " << Guid << "\n"; + OS << " Age: " << getAge() << "\n"; + OS << " Attributes: "; + if (hasCTypes()) + OS << "HasCTypes "; + if (hasPrivateSymbols()) + OS << "HasPrivateSymbols "; + OS << "\n"; } diff --git a/lib/DebugInfo/PDB/PDBSymbolFunc.cpp b/lib/DebugInfo/PDB/PDBSymbolFunc.cpp index 38959f1445f..fcd533cb6c6 100644 --- a/lib/DebugInfo/PDB/PDBSymbolFunc.cpp +++ b/lib/DebugInfo/PDB/PDBSymbolFunc.cpp @@ -9,13 +9,55 @@ #include +#include "llvm/DebugInfo/PDB/IPDBEnumChildren.h" #include "llvm/DebugInfo/PDB/PDBSymbol.h" #include "llvm/DebugInfo/PDB/PDBSymbolFunc.h" +#include "llvm/DebugInfo/PDB/PDBSymbolFuncDebugEnd.h" +#include "llvm/DebugInfo/PDB/PDBSymbolFuncDebugStart.h" -using namespace llvm; +#include "llvm/Support/Format.h" +using namespace llvm; PDBSymbolFunc::PDBSymbolFunc(const IPDBSession &PDBSession, std::unique_ptr Symbol) : PDBSymbol(PDBSession, std::move(Symbol)) {} -void PDBSymbolFunc::dump(llvm::raw_ostream &OS) const {} +void PDBSymbolFunc::dump(raw_ostream &OS, int Indent, + PDB_DumpLevel Level) const { + bool doFullDump = false; + if (Level == PDB_DumpLevel::Compact) { + uint32_t FuncStart = getRelativeVirtualAddress(); + uint32_t FuncEnd = FuncStart + getLength(); + auto DebugEndSymbol = findChildren(PDB_SymType::FuncDebugEnd); + OS << stream_indent(Indent); + OS << "[" << format_hex(FuncStart, 8); + if (auto DebugStartEnum = findChildren(PDB_SymType::FuncDebugStart)) { + if (auto StartSym = DebugStartEnum->getNext()) { + auto DebugStart = dyn_cast(StartSym.get()); + OS << "+" << DebugStart->getRelativeVirtualAddress() - FuncStart; + } + } + OS << " - " << format_hex(FuncEnd, 8); + if (auto DebugEndEnum = findChildren(PDB_SymType::FuncDebugEnd)) { + if (auto DebugEndSym = DebugEndEnum->getNext()) { + auto DebugEnd = dyn_cast(DebugEndSym.get()); + OS << "-" << FuncEnd - DebugEnd->getRelativeVirtualAddress(); + } + } + OS << "] "; + PDB_RegisterId Reg = getLocalBasePointerRegisterId(); + if (Reg == PDB_RegisterId::VFrame) + OS << "(VFrame)"; + else if (hasFramePointer()) { + if (Reg == PDB_RegisterId::EBP) + OS << "(EBP)"; + else + OS << "(" << (int)Reg << ")"; + } else { + OS << "(FPO)"; + doFullDump = true; + } + OS << " " << getName() << "\n"; + } + OS.flush(); +} diff --git a/lib/DebugInfo/PDB/PDBSymbolFuncDebugEnd.cpp b/lib/DebugInfo/PDB/PDBSymbolFuncDebugEnd.cpp index 826d835a236..29766d0bae4 100644 --- a/lib/DebugInfo/PDB/PDBSymbolFuncDebugEnd.cpp +++ b/lib/DebugInfo/PDB/PDBSymbolFuncDebugEnd.cpp @@ -18,4 +18,5 @@ PDBSymbolFuncDebugEnd::PDBSymbolFuncDebugEnd( const IPDBSession &PDBSession, std::unique_ptr Symbol) : PDBSymbol(PDBSession, std::move(Symbol)) {} -void PDBSymbolFuncDebugEnd::dump(llvm::raw_ostream &OS) const {} +void PDBSymbolFuncDebugEnd::dump(raw_ostream &OS, int Indent, + PDB_DumpLevel Level) const {} diff --git a/lib/DebugInfo/PDB/PDBSymbolFuncDebugStart.cpp b/lib/DebugInfo/PDB/PDBSymbolFuncDebugStart.cpp index 3ad10d0cb43..d78d945f787 100644 --- a/lib/DebugInfo/PDB/PDBSymbolFuncDebugStart.cpp +++ b/lib/DebugInfo/PDB/PDBSymbolFuncDebugStart.cpp @@ -18,4 +18,5 @@ PDBSymbolFuncDebugStart::PDBSymbolFuncDebugStart( const IPDBSession &PDBSession, std::unique_ptr Symbol) : PDBSymbol(PDBSession, std::move(Symbol)) {} -void PDBSymbolFuncDebugStart::dump(llvm::raw_ostream &OS) const {} +void PDBSymbolFuncDebugStart::dump(raw_ostream &OS, int Indent, + PDB_DumpLevel Level) const {} diff --git a/lib/DebugInfo/PDB/PDBSymbolLabel.cpp b/lib/DebugInfo/PDB/PDBSymbolLabel.cpp index ab2d1a74b5b..50d1e2a9b6b 100644 --- a/lib/DebugInfo/PDB/PDBSymbolLabel.cpp +++ b/lib/DebugInfo/PDB/PDBSymbolLabel.cpp @@ -18,4 +18,5 @@ PDBSymbolLabel::PDBSymbolLabel(const IPDBSession &PDBSession, std::unique_ptr Symbol) : PDBSymbol(PDBSession, std::move(Symbol)) {} -void PDBSymbolLabel::dump(llvm::raw_ostream &OS) const {} +void PDBSymbolLabel::dump(raw_ostream &OS, int Indent, + PDB_DumpLevel Level) const {} diff --git a/lib/DebugInfo/PDB/PDBSymbolPublicSymbol.cpp b/lib/DebugInfo/PDB/PDBSymbolPublicSymbol.cpp index b94374a95e5..bb4400aeed1 100644 --- a/lib/DebugInfo/PDB/PDBSymbolPublicSymbol.cpp +++ b/lib/DebugInfo/PDB/PDBSymbolPublicSymbol.cpp @@ -18,4 +18,5 @@ PDBSymbolPublicSymbol::PDBSymbolPublicSymbol( const IPDBSession &PDBSession, std::unique_ptr Symbol) : PDBSymbol(PDBSession, std::move(Symbol)) {} -void PDBSymbolPublicSymbol::dump(llvm::raw_ostream &OS) const {} +void PDBSymbolPublicSymbol::dump(raw_ostream &OS, int Indent, + PDB_DumpLevel Level) const {} diff --git a/lib/DebugInfo/PDB/PDBSymbolThunk.cpp b/lib/DebugInfo/PDB/PDBSymbolThunk.cpp index f1a8936357b..a7bd96a3479 100644 --- a/lib/DebugInfo/PDB/PDBSymbolThunk.cpp +++ b/lib/DebugInfo/PDB/PDBSymbolThunk.cpp @@ -12,10 +12,27 @@ #include "llvm/DebugInfo/PDB/PDBSymbol.h" #include "llvm/DebugInfo/PDB/PDBSymbolThunk.h" +#include "llvm/Support/Format.h" + using namespace llvm; PDBSymbolThunk::PDBSymbolThunk(const IPDBSession &PDBSession, std::unique_ptr Symbol) : PDBSymbol(PDBSession, std::move(Symbol)) {} -void PDBSymbolThunk::dump(llvm::raw_ostream &OS) const {} +void PDBSymbolThunk::dump(raw_ostream &OS, int Indent, + PDB_DumpLevel Level) const { + if (Level == PDB_DumpLevel::Compact) { + OS.indent(Indent); + PDB_ThunkOrdinal Ordinal = getThunkOrdinal(); + OS << "THUNK[" << Ordinal << "] "; + OS << "[" << format_hex(getRelativeVirtualAddress(), 10); + if (Ordinal == PDB_ThunkOrdinal::TrampIncremental) + OS << " -> " << format_hex(getTargetRelativeVirtualAddress(), 10); + OS << "] "; + std::string Name = getName(); + if (!Name.empty()) + OS << Name; + OS << "\n"; + } +} diff --git a/lib/DebugInfo/PDB/PDBSymbolTypeArray.cpp b/lib/DebugInfo/PDB/PDBSymbolTypeArray.cpp index 12fe8650ccc..856d3aabef8 100644 --- a/lib/DebugInfo/PDB/PDBSymbolTypeArray.cpp +++ b/lib/DebugInfo/PDB/PDBSymbolTypeArray.cpp @@ -18,4 +18,5 @@ PDBSymbolTypeArray::PDBSymbolTypeArray(const IPDBSession &PDBSession, std::unique_ptr Symbol) : PDBSymbol(PDBSession, std::move(Symbol)) {} -void PDBSymbolTypeArray::dump(llvm::raw_ostream &OS) const {} +void PDBSymbolTypeArray::dump(raw_ostream &OS, int Indent, + PDB_DumpLevel Level) const {} diff --git a/lib/DebugInfo/PDB/PDBSymbolTypeBaseClass.cpp b/lib/DebugInfo/PDB/PDBSymbolTypeBaseClass.cpp index 7a94aa5cfe6..31a2e517f3f 100644 --- a/lib/DebugInfo/PDB/PDBSymbolTypeBaseClass.cpp +++ b/lib/DebugInfo/PDB/PDBSymbolTypeBaseClass.cpp @@ -18,4 +18,5 @@ PDBSymbolTypeBaseClass::PDBSymbolTypeBaseClass( const IPDBSession &PDBSession, std::unique_ptr Symbol) : PDBSymbol(PDBSession, std::move(Symbol)) {} -void PDBSymbolTypeBaseClass::dump(llvm::raw_ostream &OS) const {} +void PDBSymbolTypeBaseClass::dump(raw_ostream &OS, int Indent, + PDB_DumpLevel Level) const {} diff --git a/lib/DebugInfo/PDB/PDBSymbolTypeBuiltin.cpp b/lib/DebugInfo/PDB/PDBSymbolTypeBuiltin.cpp index e1d00aecb57..1a68f8c8ded 100644 --- a/lib/DebugInfo/PDB/PDBSymbolTypeBuiltin.cpp +++ b/lib/DebugInfo/PDB/PDBSymbolTypeBuiltin.cpp @@ -18,4 +18,5 @@ PDBSymbolTypeBuiltin::PDBSymbolTypeBuiltin( const IPDBSession &PDBSession, std::unique_ptr Symbol) : PDBSymbol(PDBSession, std::move(Symbol)) {} -void PDBSymbolTypeBuiltin::dump(llvm::raw_ostream &OS) const {} +void PDBSymbolTypeBuiltin::dump(raw_ostream &OS, int Indent, + PDB_DumpLevel Level) const {} diff --git a/lib/DebugInfo/PDB/PDBSymbolTypeCustom.cpp b/lib/DebugInfo/PDB/PDBSymbolTypeCustom.cpp index 2b78c9036ce..da9d41df801 100644 --- a/lib/DebugInfo/PDB/PDBSymbolTypeCustom.cpp +++ b/lib/DebugInfo/PDB/PDBSymbolTypeCustom.cpp @@ -18,4 +18,5 @@ PDBSymbolTypeCustom::PDBSymbolTypeCustom(const IPDBSession &PDBSession, std::unique_ptr Symbol) : PDBSymbol(PDBSession, std::move(Symbol)) {} -void PDBSymbolTypeCustom::dump(llvm::raw_ostream &OS) const {} +void PDBSymbolTypeCustom::dump(raw_ostream &OS, int Indent, + PDB_DumpLevel Level) const {} diff --git a/lib/DebugInfo/PDB/PDBSymbolTypeDimension.cpp b/lib/DebugInfo/PDB/PDBSymbolTypeDimension.cpp index 7912164f4f4..4bf20d051d9 100644 --- a/lib/DebugInfo/PDB/PDBSymbolTypeDimension.cpp +++ b/lib/DebugInfo/PDB/PDBSymbolTypeDimension.cpp @@ -19,4 +19,5 @@ PDBSymbolTypeDimension::PDBSymbolTypeDimension( const IPDBSession &PDBSession, std::unique_ptr Symbol) : PDBSymbol(PDBSession, std::move(Symbol)) {} -void PDBSymbolTypeDimension::dump(llvm::raw_ostream &OS) const {} +void PDBSymbolTypeDimension::dump(raw_ostream &OS, int Indent, + PDB_DumpLevel Level) const {} diff --git a/lib/DebugInfo/PDB/PDBSymbolTypeEnum.cpp b/lib/DebugInfo/PDB/PDBSymbolTypeEnum.cpp index 133ccea0f7c..4bc3b7b7860 100644 --- a/lib/DebugInfo/PDB/PDBSymbolTypeEnum.cpp +++ b/lib/DebugInfo/PDB/PDBSymbolTypeEnum.cpp @@ -18,4 +18,5 @@ PDBSymbolTypeEnum::PDBSymbolTypeEnum(const IPDBSession &PDBSession, std::unique_ptr Symbol) : PDBSymbol(PDBSession, std::move(Symbol)) {} -void PDBSymbolTypeEnum::dump(llvm::raw_ostream &OS) const {} +void PDBSymbolTypeEnum::dump(raw_ostream &OS, int Indent, + PDB_DumpLevel Level) const {} diff --git a/lib/DebugInfo/PDB/PDBSymbolTypeFriend.cpp b/lib/DebugInfo/PDB/PDBSymbolTypeFriend.cpp index 303d2b14b37..ce02d5174e0 100644 --- a/lib/DebugInfo/PDB/PDBSymbolTypeFriend.cpp +++ b/lib/DebugInfo/PDB/PDBSymbolTypeFriend.cpp @@ -18,4 +18,5 @@ PDBSymbolTypeFriend::PDBSymbolTypeFriend(const IPDBSession &PDBSession, std::unique_ptr Symbol) : PDBSymbol(PDBSession, std::move(Symbol)) {} -void PDBSymbolTypeFriend::dump(llvm::raw_ostream &OS) const {} +void PDBSymbolTypeFriend::dump(raw_ostream &OS, int Indent, + PDB_DumpLevel Level) const {} diff --git a/lib/DebugInfo/PDB/PDBSymbolTypeFunctionArg.cpp b/lib/DebugInfo/PDB/PDBSymbolTypeFunctionArg.cpp index 9a1af4f88fd..86c337d1b04 100644 --- a/lib/DebugInfo/PDB/PDBSymbolTypeFunctionArg.cpp +++ b/lib/DebugInfo/PDB/PDBSymbolTypeFunctionArg.cpp @@ -18,4 +18,5 @@ PDBSymbolTypeFunctionArg::PDBSymbolTypeFunctionArg( const IPDBSession &PDBSession, std::unique_ptr Symbol) : PDBSymbol(PDBSession, std::move(Symbol)) {} -void PDBSymbolTypeFunctionArg::dump(llvm::raw_ostream &OS) const {} +void PDBSymbolTypeFunctionArg::dump(raw_ostream &OS, int Indent, + PDB_DumpLevel Level) const {} diff --git a/lib/DebugInfo/PDB/PDBSymbolTypeFunctionSig.cpp b/lib/DebugInfo/PDB/PDBSymbolTypeFunctionSig.cpp index c31185ef7b6..99953ad21cb 100644 --- a/lib/DebugInfo/PDB/PDBSymbolTypeFunctionSig.cpp +++ b/lib/DebugInfo/PDB/PDBSymbolTypeFunctionSig.cpp @@ -18,4 +18,5 @@ PDBSymbolTypeFunctionSig::PDBSymbolTypeFunctionSig( const IPDBSession &PDBSession, std::unique_ptr Symbol) : PDBSymbol(PDBSession, std::move(Symbol)) {} -void PDBSymbolTypeFunctionSig::dump(llvm::raw_ostream &OS) const {} +void PDBSymbolTypeFunctionSig::dump(raw_ostream &OS, int Indent, + PDB_DumpLevel Level) const {} diff --git a/lib/DebugInfo/PDB/PDBSymbolTypeManaged.cpp b/lib/DebugInfo/PDB/PDBSymbolTypeManaged.cpp index 2a024f59906..d3728ea6ba0 100644 --- a/lib/DebugInfo/PDB/PDBSymbolTypeManaged.cpp +++ b/lib/DebugInfo/PDB/PDBSymbolTypeManaged.cpp @@ -18,4 +18,5 @@ PDBSymbolTypeManaged::PDBSymbolTypeManaged( const IPDBSession &PDBSession, std::unique_ptr Symbol) : PDBSymbol(PDBSession, std::move(Symbol)) {} -void PDBSymbolTypeManaged::dump(llvm::raw_ostream &OS) const {} +void PDBSymbolTypeManaged::dump(raw_ostream &OS, int Indent, + PDB_DumpLevel Level) const {} diff --git a/lib/DebugInfo/PDB/PDBSymbolTypePointer.cpp b/lib/DebugInfo/PDB/PDBSymbolTypePointer.cpp index 95ea850011d..a6625b36f79 100644 --- a/lib/DebugInfo/PDB/PDBSymbolTypePointer.cpp +++ b/lib/DebugInfo/PDB/PDBSymbolTypePointer.cpp @@ -19,4 +19,5 @@ PDBSymbolTypePointer::PDBSymbolTypePointer( const IPDBSession &PDBSession, std::unique_ptr Symbol) : PDBSymbol(PDBSession, std::move(Symbol)) {} -void PDBSymbolTypePointer::dump(llvm::raw_ostream &OS) const {} +void PDBSymbolTypePointer::dump(raw_ostream &OS, int Indent, + PDB_DumpLevel Level) const {} diff --git a/lib/DebugInfo/PDB/PDBSymbolTypeTypedef.cpp b/lib/DebugInfo/PDB/PDBSymbolTypeTypedef.cpp index 8b4fd5d4bb4..74cfeebbb05 100644 --- a/lib/DebugInfo/PDB/PDBSymbolTypeTypedef.cpp +++ b/lib/DebugInfo/PDB/PDBSymbolTypeTypedef.cpp @@ -10,13 +10,24 @@ #include +#include "llvm/DebugInfo/PDB/IPDBSession.h" #include "llvm/DebugInfo/PDB/PDBSymbol.h" #include "llvm/DebugInfo/PDB/PDBSymbolTypeTypedef.h" - +#include "llvm/DebugInfo/PDB/PDBSymbolTypeUDT.h" using namespace llvm; PDBSymbolTypeTypedef::PDBSymbolTypeTypedef( const IPDBSession &PDBSession, std::unique_ptr Symbol) : PDBSymbol(PDBSession, std::move(Symbol)) {} -void PDBSymbolTypeTypedef::dump(llvm::raw_ostream &OS) const {} +void PDBSymbolTypeTypedef::dump(raw_ostream &OS, int Indent, + PDB_DumpLevel Level) const { + OS.indent(Indent); + OS << "typedef:" << getName() << " -> "; + std::string TargetTypeName; + auto TypeSymbol = Session.getSymbolById(getTypeId()); + if (PDBSymbolTypeUDT *UDT = dyn_cast(TypeSymbol.get())) { + TargetTypeName = UDT->getName(); + } + OS << TargetTypeName << "\n"; +} diff --git a/lib/DebugInfo/PDB/PDBSymbolTypeUDT.cpp b/lib/DebugInfo/PDB/PDBSymbolTypeUDT.cpp index bd09fbad8a0..13f6223bcb6 100644 --- a/lib/DebugInfo/PDB/PDBSymbolTypeUDT.cpp +++ b/lib/DebugInfo/PDB/PDBSymbolTypeUDT.cpp @@ -18,4 +18,5 @@ PDBSymbolTypeUDT::PDBSymbolTypeUDT(const IPDBSession &PDBSession, std::unique_ptr Symbol) : PDBSymbol(PDBSession, std::move(Symbol)) {} -void PDBSymbolTypeUDT::dump(llvm::raw_ostream &OS) const {} +void PDBSymbolTypeUDT::dump(raw_ostream &OS, int Indent, + PDB_DumpLevel Level) const {} diff --git a/lib/DebugInfo/PDB/PDBSymbolTypeVTable.cpp b/lib/DebugInfo/PDB/PDBSymbolTypeVTable.cpp index 52169bb40aa..31c41d1d268 100644 --- a/lib/DebugInfo/PDB/PDBSymbolTypeVTable.cpp +++ b/lib/DebugInfo/PDB/PDBSymbolTypeVTable.cpp @@ -18,4 +18,5 @@ PDBSymbolTypeVTable::PDBSymbolTypeVTable(const IPDBSession &PDBSession, std::unique_ptr Symbol) : PDBSymbol(PDBSession, std::move(Symbol)) {} -void PDBSymbolTypeVTable::dump(llvm::raw_ostream &OS) const {} +void PDBSymbolTypeVTable::dump(raw_ostream &OS, int Indent, + PDB_DumpLevel Level) const {} diff --git a/lib/DebugInfo/PDB/PDBSymbolTypeVTableShape.cpp b/lib/DebugInfo/PDB/PDBSymbolTypeVTableShape.cpp index 186f86f537d..5a2fac0eba2 100644 --- a/lib/DebugInfo/PDB/PDBSymbolTypeVTableShape.cpp +++ b/lib/DebugInfo/PDB/PDBSymbolTypeVTableShape.cpp @@ -18,4 +18,5 @@ PDBSymbolTypeVTableShape::PDBSymbolTypeVTableShape( const IPDBSession &PDBSession, std::unique_ptr Symbol) : PDBSymbol(PDBSession, std::move(Symbol)) {} -void PDBSymbolTypeVTableShape::dump(llvm::raw_ostream &OS) const {} +void PDBSymbolTypeVTableShape::dump(raw_ostream &OS, int Indent, + PDB_DumpLevel Level) const {} diff --git a/lib/DebugInfo/PDB/PDBSymbolUnknown.cpp b/lib/DebugInfo/PDB/PDBSymbolUnknown.cpp index 56b70232c3d..5db34e5835d 100644 --- a/lib/DebugInfo/PDB/PDBSymbolUnknown.cpp +++ b/lib/DebugInfo/PDB/PDBSymbolUnknown.cpp @@ -18,4 +18,5 @@ PDBSymbolUnknown::PDBSymbolUnknown(const IPDBSession &PDBSession, std::unique_ptr Symbol) : PDBSymbol(PDBSession, std::move(Symbol)) {} -void PDBSymbolUnknown::dump(llvm::raw_ostream &OS) const {} +void PDBSymbolUnknown::dump(raw_ostream &OS, int Indent, + PDB_DumpLevel Level) const {} diff --git a/lib/DebugInfo/PDB/PDBSymbolUsingNamespace.cpp b/lib/DebugInfo/PDB/PDBSymbolUsingNamespace.cpp index 05590677cf1..0d4b2fe08bc 100644 --- a/lib/DebugInfo/PDB/PDBSymbolUsingNamespace.cpp +++ b/lib/DebugInfo/PDB/PDBSymbolUsingNamespace.cpp @@ -18,4 +18,5 @@ PDBSymbolUsingNamespace::PDBSymbolUsingNamespace( const IPDBSession &PDBSession, std::unique_ptr Symbol) : PDBSymbol(PDBSession, std::move(Symbol)) {} -void PDBSymbolUsingNamespace::dump(llvm::raw_ostream &OS) const {} +void PDBSymbolUsingNamespace::dump(raw_ostream &OS, int Indent, + PDB_DumpLevel Level) const {} diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 26d2dfde931..1f415b620df 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -61,14 +61,7 @@ add_llvm_tool_subdirectory(yaml2obj) add_llvm_tool_subdirectory(llvm-go) -if(MSVC AND NOT(MSVC_VERSION LESS 1800)) - # Certain aspects of llvm-pdbdump require language support only present in - # MSVC 2013 and higher. Since this is strictly a utility, and since we hope - # to drop support for MSVC 2012 soon, don't build this for MSVC < 2013. - add_llvm_tool_subdirectory(llvm-pdbdump) -else() - ignore_llvm_tool_subdirectory(llvm-pdbdump) -endif() +add_llvm_tool_subdirectory(llvm-pdbdump) if(NOT CYGWIN AND LLVM_ENABLE_PIC) add_llvm_tool_subdirectory(lto) diff --git a/tools/Makefile b/tools/Makefile index b559edacd52..fcb6c647e3a 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -33,7 +33,7 @@ PARALLEL_DIRS := opt llvm-as llvm-dis llc llvm-ar llvm-nm llvm-link \ macho-dump llvm-objdump llvm-readobj llvm-rtdyld \ llvm-dwarfdump llvm-cov llvm-size llvm-stress llvm-mcmarkup \ llvm-profdata llvm-symbolizer obj2yaml yaml2obj llvm-c-test \ - llvm-vtabledump verify-uselistorder dsymutil + llvm-vtabledump verify-uselistorder dsymutil llvm-pdbdump # If Intel JIT Events support is configured, build an extra tool to test it. ifeq ($(USE_INTEL_JITEVENTS), 1) diff --git a/tools/llvm-pdbdump/CMakeLists.txt b/tools/llvm-pdbdump/CMakeLists.txt index 6cad395b281..a3bb408097c 100644 --- a/tools/llvm-pdbdump/CMakeLists.txt +++ b/tools/llvm-pdbdump/CMakeLists.txt @@ -1,28 +1,8 @@ -set(MSVC_DIA_SDK_DIR "$ENV{VSINSTALLDIR}DIA SDK") +set(LLVM_LINK_COMPONENTS + Support + DebugInfoPDB + ) -# Due to a bug in MSVC 2013's installation software, it is possible -# for MSVC 2013 to write the DIA SDK into the Visual Studio 2012 -# install directory. If this happens, the installation is corrupt -# and there's nothing we can do. It happens with enough frequency -# though that we should handle it. We do so by simply checking that -# the DIA SDK folder exists. Should this happen you will need to -# uninstall VS 2012 and then re-install VS 2013. -if (IS_DIRECTORY ${MSVC_DIA_SDK_DIR}) - set(LLVM_LINK_COMPONENTS - Support - ) - - include_directories(${MSVC_DIA_SDK_DIR}/include) - if (CMAKE_SIZEOF_VOID_P EQUAL 8) - link_directories(${MSVC_DIA_SDK_DIR}/lib/amd64) - else() - link_directories(${MSVC_DIA_SDK_DIR}/lib) - endif() - - add_llvm_tool(llvm-pdbdump - llvm-pdbdump.cpp - DIAExtras.cpp - DIASymbol.cpp - ) - target_link_libraries(llvm-pdbdump diaguids) -endif() +add_llvm_tool(llvm-pdbdump + llvm-pdbdump.cpp + ) diff --git a/tools/llvm-pdbdump/COMExtras.h b/tools/llvm-pdbdump/COMExtras.h deleted file mode 100644 index 500f5714f81..00000000000 --- a/tools/llvm-pdbdump/COMExtras.h +++ /dev/null @@ -1,295 +0,0 @@ -//===- COMExtras.h - Helper files for COM operations -------------*- 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_LLVM_PDBDUMP_COMEXTRAS_H -#define LLVM_TOOLS_LLVM_PDBDUMP_COMEXTRAS_H - -#include "llvm/ADT/ArrayRef.h" -#include "llvm/ADT/SmallVector.h" -#include "llvm/Support/ConvertUTF.h" - -#include - -namespace llvm { - -template struct function_traits; - -#if LLVM_HAS_VARIADIC_TEMPLATES -template -struct function_traits : public function_traits {}; - -template -struct function_traits { - using args_tuple = std::tuple; -}; -#else - -// For the sake of COM, we only need a 3 argument version and a 5 argument -// version. We could provide 1, 2, 4, and other length of argument lists if -// this were intended to be more generic. Alternatively, this will "just work" -// if VS2012 support is dropped and we can use the variadic template case -// exclusively. -template -struct function_traits { - typedef std::tuple args_tuple; -}; - -template -struct function_traits { - typedef std::tuple args_tuple; -}; -#endif - -template struct function_arg { - // Writing function_arg as a separate class that accesses the tuple from - // function_traits is necessary due to what appears to be a bug in MSVC. - // If you write a nested class inside function_traits like this: - // template - // struct Argument - // { - // typedef typename - // std::tuple_element>::type type; - // }; - // MSVC encounters a parsing error. - typedef - typename std::tuple_element::type - type; -}; - -template struct remove_double_pointer {}; -template struct remove_double_pointer { typedef T type; }; - -namespace sys { -namespace windows { - -/// A helper class for allowing the use of COM enumerators in range-based -/// for loops. -/// -/// A common idiom in the COM world is to have an enumerator interface, say -/// IMyEnumerator. It's responsible for enumerating over some child data type, -/// say IChildType. You do the enumeration by calling IMyEnumerator::Next() -/// one of whose arguments will be an IChildType**. Eventually Next() fails, -/// indicating that there are no more items. -/// -/// com_iterator represents a single point-in-time of this iteration. It is -/// used by ComEnumerator to support iterating in this fashion via range-based -/// for loops and other common C++ paradigms. -template class com_iterator { - using FunctionTraits = function_traits; - typedef typename function_arg::type FuncArgType; - // FuncArgType is now something like ISomeCOMInterface **. Remove both - // pointers, so we can make a CComPtr out of it. - typedef typename remove_double_pointer::type EnumDataType; - - CComPtr EnumeratorObject; - CComPtr CurrentItem; - -public: - typedef CComPtr value_type; - typedef std::ptrdiff_t difference_type; - typedef value_type *pointer_type; - typedef value_type &reference_type; - typedef std::forward_iterator_tag iterator_category; - - explicit com_iterator(CComPtr Enumerator, - CComPtr Current) - : EnumeratorObject(Enumerator), CurrentItem(Current) {} - com_iterator() {} - - com_iterator &operator++() { - // EnumeratorObject->Next() expects CurrentItem to be NULL. - CurrentItem.Release(); - ULONG Count = 0; - HRESULT hr = EnumeratorObject->Next(1, &CurrentItem, &Count); - if (FAILED(hr) || Count == 0) - *this = com_iterator(); - - return *this; - } - - value_type operator*() { return CurrentItem; } - - bool operator==(const com_iterator &other) const { - return (EnumeratorObject == other.EnumeratorObject) && - (CurrentItem == other.CurrentItem); - } - - bool operator!=(const com_iterator &other) const { return !(*this == other); } - - com_iterator &operator=(const com_iterator &other) { - EnumeratorObject = other.EnumeratorObject; - CurrentItem = other.CurrentItem; - return *this; - } -}; - -/// ComEnumerator implements the interfaced required for C++ to allow its use -/// in range-based for loops. In particular, a begin() and end() method. -/// These methods simply construct and return an appropriate ComIterator -/// instance. -template class com_enumerator { - typedef function_traits FunctionTraits; - typedef typename function_arg::type FuncArgType; - typedef typename remove_double_pointer::type EnumDataType; - - CComPtr EnumeratorObject; - -public: - com_enumerator(CComPtr Enumerator) - : EnumeratorObject(Enumerator) {} - - com_iterator begin() { - if (!EnumeratorObject) - return end(); - - EnumeratorObject->Reset(); - ULONG Count = 0; - CComPtr FirstItem; - HRESULT hr = EnumeratorObject->Next(1, &FirstItem, &Count); - return (FAILED(hr) || Count == 0) ? end() - : com_iterator( - EnumeratorObject, FirstItem); - } - - com_iterator end() { - return com_iterator(); - } -}; - -/// A helper class for allowing the use of COM record enumerators in range- -/// based for loops. -/// -/// A record enumerator is almost the same as a regular enumerator, except -/// that it returns raw byte-data instead of interfaces to other COM objects. -/// As a result, the enumerator's Next() method has a slightly different -/// signature, and an iterator dereferences to an ArrayRef instead of a -/// CComPtr. -template class com_data_record_iterator { -public: - typedef llvm::ArrayRef value_type; - typedef std::ptrdiff_t difference_type; - typedef value_type *pointer_type; - typedef value_type &reference_type; - typedef std::forward_iterator_tag iterator_category; - - explicit com_data_record_iterator(CComPtr enumerator) - : Enumerator(enumerator), CurrentRecord(0) { - // Make sure we start at the beginning. If there are no records, - // immediately set ourselves equal to end(). - if (enumerator) - enumerator->Reset(); - - if (!ReadNextRecord()) - *this = com_data_record_iterator(); - } - com_data_record_iterator() {} - - com_data_record_iterator &operator++() { - ++CurrentRecord; - // If we can't read any more records, either because there are no more - // or because we encountered an error, we should compare equal to end. - if (!ReadNextRecord()) - *this = com_data_record_iterator(); - return *this; - } - - value_type operator*() { - return llvm::ArrayRef(RecordData.begin(), RecordData.end()); - } - - bool operator==(const com_data_record_iterator &other) const { - return (Enumerator == other.Enumerator) && - (CurrentRecord == other.CurrentRecord); - } - - bool operator!=(const com_data_record_iterator &other) const { - return !(*this == other); - } - -private: - bool ReadNextRecord() { - RecordData.clear(); - ULONG Count = 0; - DWORD RequiredBufferSize; - HRESULT hr = Enumerator->Next(1, 0, &RequiredBufferSize, nullptr, &Count); - if (hr == S_OK) { - RecordData.resize(RequiredBufferSize); - DWORD BytesRead = 0; - hr = Enumerator->Next(1, RequiredBufferSize, &BytesRead, - RecordData.data(), &Count); - } - if (hr != S_OK) - RecordData.clear(); - return (hr == S_OK); - } - - CComPtr Enumerator; - uint32_t CurrentRecord; - llvm::SmallVector RecordData; -}; - -/// Similar to ComEnumerator, com_data_record_enumerator implements the range -/// interface for ComDataRecordIterators. -template class com_data_record_enumerator { -public: - com_data_record_enumerator(CComPtr enumerator) - : Enumerator(enumerator) {} - - com_data_record_iterator begin() { - return com_data_record_iterator(Enumerator); - } - - com_data_record_iterator end() { - LONG NumElts = 0; - HRESULT hr = Enumerator->get_Count(&NumElts); - return (FAILED(hr)) ? com_data_record_iterator(Enumerator) - : com_data_record_iterator(); - } - -private: - CComPtr Enumerator; -}; - -/// com_enumerator is a simple helper function to allow the enumerator -/// class's type to be inferred automatically. -/// This allows you to write simply: -/// for (auto item : com_enumerator(MyEnumerator)) { -/// } -template -com_enumerator -make_com_enumerator(CComPtr Enumerator) { - return com_enumerator(Enumerator); -} - -/// com_data_record_enumerator is a simple helper function to allow the -/// enumerator class's type to be inferred automatically. -/// This allows you to write simply: -/// for (auto item : com_data_record_enumerator(MyEnumerator)) { -/// } -//============================================================================= -template -com_data_record_enumerator -make_com_data_record_enumerator(CComPtr Enumerator) { - return com_data_record_enumerator(Enumerator); -} - -inline bool BSTRToUTF8(BSTR String16, std::string &String8) { - UINT ByteLength = ::SysStringByteLen(String16); - char *Bytes = reinterpret_cast(String16); - String8.clear(); - return llvm::convertUTF16ToUTF8String(ArrayRef(Bytes, ByteLength), - String8); -} - -} // namespace windows -} // namespace sys -} // namespace llvm - -#endif diff --git a/tools/llvm-pdbdump/DIAExtras.cpp b/tools/llvm-pdbdump/DIAExtras.cpp deleted file mode 100644 index f08c42efc72..00000000000 --- a/tools/llvm-pdbdump/DIAExtras.cpp +++ /dev/null @@ -1,189 +0,0 @@ -//===- DIAExtras.cpp - Helper classes and functions for DIA C++ ---------*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -#include "llvm/Support/Format.h" -#include "llvm/Support/raw_ostream.h" - -#include "llvm-pdbdump.h" -#include "DIAExtras.h" - -using namespace llvm; -using namespace llvm::sys::windows; - -#define PRINT_ENUM_VALUE_CASE(Value, Name) \ - case Value: \ - outs() << Name; \ - break; - -raw_ostream &llvm::operator<<(raw_ostream &Stream, DiaSymTagEnum SymTag) { - switch (SymTag) { - PRINT_ENUM_VALUE_CASE(SymTagNull, "Null") - PRINT_ENUM_VALUE_CASE(SymTagExe, "Exe") - PRINT_ENUM_VALUE_CASE(SymTagCompiland, "Compiland") - PRINT_ENUM_VALUE_CASE(SymTagCompilandDetails, "CompilandDetails") - PRINT_ENUM_VALUE_CASE(SymTagCompilandEnv, "CompilandEnv") - PRINT_ENUM_VALUE_CASE(SymTagFunction, "Function") - PRINT_ENUM_VALUE_CASE(SymTagBlock, "Block") - PRINT_ENUM_VALUE_CASE(SymTagData, "Data") - PRINT_ENUM_VALUE_CASE(SymTagAnnotation, "Annotation") - PRINT_ENUM_VALUE_CASE(SymTagLabel, "Label") - PRINT_ENUM_VALUE_CASE(SymTagPublicSymbol, "PublicSymbol") - PRINT_ENUM_VALUE_CASE(SymTagUDT, "UDT") - PRINT_ENUM_VALUE_CASE(SymTagEnum, "Enum") - PRINT_ENUM_VALUE_CASE(SymTagFunctionType, "FunctionType") - PRINT_ENUM_VALUE_CASE(SymTagPointerType, "PointerType") - PRINT_ENUM_VALUE_CASE(SymTagArrayType, "ArrayType") - PRINT_ENUM_VALUE_CASE(SymTagBaseType, "BaseType") - PRINT_ENUM_VALUE_CASE(SymTagTypedef, "Typedef") - PRINT_ENUM_VALUE_CASE(SymTagBaseClass, "BaseClass") - PRINT_ENUM_VALUE_CASE(SymTagFriend, "Friend") - PRINT_ENUM_VALUE_CASE(SymTagFunctionArgType, "FunctionArgType") - PRINT_ENUM_VALUE_CASE(SymTagFuncDebugStart, "FuncDebugStart") - PRINT_ENUM_VALUE_CASE(SymTagFuncDebugEnd, "FuncDebugEnd") - PRINT_ENUM_VALUE_CASE(SymTagUsingNamespace, "UsingNamespace") - PRINT_ENUM_VALUE_CASE(SymTagVTableShape, "VTableShape") - PRINT_ENUM_VALUE_CASE(SymTagVTable, "VTable") - PRINT_ENUM_VALUE_CASE(SymTagCustom, "Custom") - PRINT_ENUM_VALUE_CASE(SymTagThunk, "Thunk") - PRINT_ENUM_VALUE_CASE(SymTagCustomType, "CustomType") - PRINT_ENUM_VALUE_CASE(SymTagManagedType, "ManagedType") - PRINT_ENUM_VALUE_CASE(SymTagDimension, "Dimension") - PRINT_ENUM_VALUE_CASE(SymTagCallSite, "CallSite") - PRINT_ENUM_VALUE_CASE(SymTagInlineSite, "InlineSite") - PRINT_ENUM_VALUE_CASE(SymTagBaseInterface, "BaseInterface") - PRINT_ENUM_VALUE_CASE(SymTagVectorType, "VectorType") - PRINT_ENUM_VALUE_CASE(SymTagMatrixType, "MatrixType") - PRINT_ENUM_VALUE_CASE(SymTagHLSLType, "HLSLType") -#if (_MSC_FULL_VER >= 180031101) - PRINT_ENUM_VALUE_CASE(SymTagCaller, "Caller") - PRINT_ENUM_VALUE_CASE(SymTagCallee, "Callee") -#endif - PRINT_ENUM_VALUE_CASE(SymTagMax, "Max") - } - outs() << " {" << (DWORD)SymTag << "}"; - return Stream; -} - -raw_ostream &llvm::operator<<(raw_ostream &Stream, CV_CPU_TYPE_e CpuType) { - switch (CpuType) { - PRINT_ENUM_VALUE_CASE(CV_CFL_8080, "8080") - PRINT_ENUM_VALUE_CASE(CV_CFL_8086, "8086") - PRINT_ENUM_VALUE_CASE(CV_CFL_80286, "80286") - PRINT_ENUM_VALUE_CASE(CV_CFL_80386, "80386") - PRINT_ENUM_VALUE_CASE(CV_CFL_80486, "80486") - PRINT_ENUM_VALUE_CASE(CV_CFL_PENTIUM, "Pentium") - PRINT_ENUM_VALUE_CASE(CV_CFL_PENTIUMPRO, "Pentium Pro") - PRINT_ENUM_VALUE_CASE(CV_CFL_PENTIUMIII, "Pentium III") - PRINT_ENUM_VALUE_CASE(CV_CFL_MIPS, "MIPS") - PRINT_ENUM_VALUE_CASE(CV_CFL_MIPS16, "MIPS 16") - PRINT_ENUM_VALUE_CASE(CV_CFL_MIPS32, "MIPS 32") - PRINT_ENUM_VALUE_CASE(CV_CFL_MIPS64, "MIPS 64") - PRINT_ENUM_VALUE_CASE(CV_CFL_MIPSI, "MIPS I") - PRINT_ENUM_VALUE_CASE(CV_CFL_MIPSII, "MIPS II") - PRINT_ENUM_VALUE_CASE(CV_CFL_MIPSIII, "MIPS III") - PRINT_ENUM_VALUE_CASE(CV_CFL_MIPSIV, "MIPS IV") - PRINT_ENUM_VALUE_CASE(CV_CFL_MIPSV, "MIPS V") - PRINT_ENUM_VALUE_CASE(CV_CFL_M68000, "M68000") - PRINT_ENUM_VALUE_CASE(CV_CFL_M68010, "M68010") - PRINT_ENUM_VALUE_CASE(CV_CFL_M68020, "M68020") - PRINT_ENUM_VALUE_CASE(CV_CFL_M68030, "M68030") - PRINT_ENUM_VALUE_CASE(CV_CFL_M68040, "M68040") - PRINT_ENUM_VALUE_CASE(CV_CFL_ALPHA, "Alpha") - PRINT_ENUM_VALUE_CASE(CV_CFL_ALPHA_21164, "Alpha 21164") - PRINT_ENUM_VALUE_CASE(CV_CFL_ALPHA_21164A, "Alpha 21164A") - PRINT_ENUM_VALUE_CASE(CV_CFL_ALPHA_21264, "Alpha 21264") - PRINT_ENUM_VALUE_CASE(CV_CFL_ALPHA_21364, "21364") - PRINT_ENUM_VALUE_CASE(CV_CFL_PPC601, "PowerPC 601") - PRINT_ENUM_VALUE_CASE(CV_CFL_PPC603, "PowerPC 603") - PRINT_ENUM_VALUE_CASE(CV_CFL_PPC604, "PowerPC 604") - PRINT_ENUM_VALUE_CASE(CV_CFL_PPC620, "PowerPC 620") - PRINT_ENUM_VALUE_CASE(CV_CFL_PPCFP, "PowerPC FP") - PRINT_ENUM_VALUE_CASE(CV_CFL_PPCBE, "PowerPC BE") - PRINT_ENUM_VALUE_CASE(CV_CFL_SH3, "SH3") - PRINT_ENUM_VALUE_CASE(CV_CFL_SH3E, "SH3-E") - PRINT_ENUM_VALUE_CASE(CV_CFL_SH3DSP, "SH3-DSP") - PRINT_ENUM_VALUE_CASE(CV_CFL_SH4, "SH4") - PRINT_ENUM_VALUE_CASE(CV_CFL_SHMEDIA, "SH Media") - PRINT_ENUM_VALUE_CASE(CV_CFL_ARM3, "ARM 3") - PRINT_ENUM_VALUE_CASE(CV_CFL_ARM4, "ARM 4") - PRINT_ENUM_VALUE_CASE(CV_CFL_ARM4T, "ARM 4T") - PRINT_ENUM_VALUE_CASE(CV_CFL_ARM5, "ARM 5") - PRINT_ENUM_VALUE_CASE(CV_CFL_ARM5T, "ARM 5T") - PRINT_ENUM_VALUE_CASE(CV_CFL_ARM6, "ARM 6") - PRINT_ENUM_VALUE_CASE(CV_CFL_ARM_XMAC, "ARM XMAC") - PRINT_ENUM_VALUE_CASE(CV_CFL_ARM_WMMX, "ARM WMMX") - PRINT_ENUM_VALUE_CASE(CV_CFL_ARM7, "ARM 7") - PRINT_ENUM_VALUE_CASE(CV_CFL_OMNI, "Omni") - PRINT_ENUM_VALUE_CASE(CV_CFL_IA64, "IA64") - PRINT_ENUM_VALUE_CASE(CV_CFL_IA64_2, "IA64-2") - PRINT_ENUM_VALUE_CASE(CV_CFL_CEE, "CEE") - PRINT_ENUM_VALUE_CASE(CV_CFL_AM33, "AM33") - PRINT_ENUM_VALUE_CASE(CV_CFL_M32R, "M32R") - PRINT_ENUM_VALUE_CASE(CV_CFL_TRICORE, "TriCore") - PRINT_ENUM_VALUE_CASE(CV_CFL_X64, "X64") - PRINT_ENUM_VALUE_CASE(CV_CFL_EBC, "EBC") - PRINT_ENUM_VALUE_CASE(CV_CFL_THUMB, "Thumb") - PRINT_ENUM_VALUE_CASE(CV_CFL_ARMNT, "ARM NT") -#if (_MSC_FULL_VER >= 180031101) - PRINT_ENUM_VALUE_CASE(CV_CFL_ARM64, "ARM 64") -#endif - PRINT_ENUM_VALUE_CASE(CV_CFL_D3D11_SHADER, "D3D11 Shader") - } - outs() << " {" << llvm::format_hex((DWORD)CpuType, 2, true) << "}"; - return Stream; -} - -raw_ostream &llvm::operator<<(raw_ostream &Stream, - MachineTypeEnum MachineType) { - switch (MachineType) { - PRINT_ENUM_VALUE_CASE(MachineTypeUnknown, "Unknown") - PRINT_ENUM_VALUE_CASE(MachineTypeX86, "x86") - PRINT_ENUM_VALUE_CASE(MachineTypeR3000, "R3000") - PRINT_ENUM_VALUE_CASE(MachineTypeR4000, "R4000") - PRINT_ENUM_VALUE_CASE(MachineTypeR10000, "R10000") - PRINT_ENUM_VALUE_CASE(MachineTypeWCEMIPSv2, "WCE MIPSv2") - PRINT_ENUM_VALUE_CASE(MachineTypeAlpha, "Alpha") - PRINT_ENUM_VALUE_CASE(MachineTypeSH3, "SH3") - PRINT_ENUM_VALUE_CASE(MachineTypeSH3DSP, "SH3-DSP") - PRINT_ENUM_VALUE_CASE(MachineTypeSH3E, "SH3-E") - PRINT_ENUM_VALUE_CASE(MachineTypeSH4, "SH4") - PRINT_ENUM_VALUE_CASE(MachineTypeSH5, "SH5") - PRINT_ENUM_VALUE_CASE(MachineTypeArm, "ARM") - PRINT_ENUM_VALUE_CASE(MachineTypeThumb, "Thumb") - PRINT_ENUM_VALUE_CASE(MachineTypeArmNT, "ARM NT") - PRINT_ENUM_VALUE_CASE(MachineTypeAM33, "AM33") - PRINT_ENUM_VALUE_CASE(MachineTypePowerPC, "PowerPC") - PRINT_ENUM_VALUE_CASE(MachineTypePowerPCFP, "PowerPC FP") - PRINT_ENUM_VALUE_CASE(MachineTypeIa64, "IA 64") - PRINT_ENUM_VALUE_CASE(MachineTypeMips16, "MIPS 16") - PRINT_ENUM_VALUE_CASE(MachineTypeAlpha64, "Alpha 64") - PRINT_ENUM_VALUE_CASE(MachineTypeMipsFpu, "FPU") - PRINT_ENUM_VALUE_CASE(MachineTypeMipsFpu16, "FPU 16") - PRINT_ENUM_VALUE_CASE(MachineTypeTriCore, "TriCore") - PRINT_ENUM_VALUE_CASE(MachineTypeCEF, "CEF") - PRINT_ENUM_VALUE_CASE(MachineTypeEBC, "EBC") - PRINT_ENUM_VALUE_CASE(MachineTypeAmd64, "x64") - PRINT_ENUM_VALUE_CASE(MachineTypeM32R, "M32R") - PRINT_ENUM_VALUE_CASE(MachineTypeCEE, "CEE") - } - outs() << " {" << llvm::format_hex((DWORD)MachineType, 2, true) << "}"; - return Stream; -} - -raw_ostream &llvm::operator<<(raw_ostream &Stream, HashAlgorithm Algorithm) { - switch (Algorithm) { - PRINT_ENUM_VALUE_CASE(HashNone, "None") - PRINT_ENUM_VALUE_CASE(HashMD5, "MD5") - PRINT_ENUM_VALUE_CASE(HashSHA1, "SHA-1") - default: - outs() << "(Unknown)"; - break; - } - outs() << " {" << (DWORD)Algorithm << "}"; - return Stream; -} diff --git a/tools/llvm-pdbdump/DIAExtras.h b/tools/llvm-pdbdump/DIAExtras.h deleted file mode 100644 index aeef1972dc2..00000000000 --- a/tools/llvm-pdbdump/DIAExtras.h +++ /dev/null @@ -1,131 +0,0 @@ -//===- DIAExtras.h - Helper classes and functions for accessing DIA C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// Defines helper types, classes, and functions for working with DIA. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_TOOLS_LLVMPDBDUMP_DIAEXTRAS_H -#define LLVM_TOOLS_LLVMPDBDUMP_DIAEXTRAS_H - -#include "llvm/ADT/SmallString.h" -#include "llvm/Support/raw_ostream.h" - -#include "COMExtras.h" - -namespace llvm { -namespace sys { -namespace windows { - -typedef llvm::SmallString<16> DIAString; - -template class DIAResult { -public: - DIAResult() : IsValid(false) {} - DIAResult(const T &ResultValue) : Result(ResultValue), IsValid(true) {} - - bool hasValue() const { return IsValid; } - T value() const { return Result; } - - void dump(StringRef Name, unsigned IndentLevel) const { - if (!hasValue()) - return; - outs().indent(IndentLevel); - outs() << Name << ": " << value() << "\n"; - } - -private: - T Result; - bool IsValid; -}; - -template <> -void DIAResult::dump(StringRef Name, unsigned IndentLevel) const { - if (!hasValue()) - return; - outs().indent(IndentLevel); - outs() << Name << ": " << (value() ? "true" : "false") << "\n"; -} - -template <> -void DIAResult::dump(StringRef Name, unsigned IndentLevel) const { - if (!hasValue()) - return; - std::string Guid8; - CComBSTR GuidBSTR(value()); - BSTRToUTF8(GuidBSTR.m_str, Guid8); - - outs().indent(IndentLevel); - outs() << Name << ": " << Guid8 << "\n"; -} - -// MSDN documents the IDiaSymbol::get_machineType method as returning a value -// from the CV_CPU_TYPE_e enumeration. This documentation is wrong, however, -// and this method actually returns a value from the IMAGE_FILE_xxx set of -// defines from winnt.h. These correspond to the platform magic number in -// the COFF file. This enumeration is built from the set of values in winnt.h -enum MachineTypeEnum { - MachineTypeUnknown = IMAGE_FILE_MACHINE_UNKNOWN, - MachineTypeX86 = IMAGE_FILE_MACHINE_I386, - MachineTypeR3000 = IMAGE_FILE_MACHINE_R3000, - MachineTypeR4000 = IMAGE_FILE_MACHINE_R4000, - MachineTypeR10000 = IMAGE_FILE_MACHINE_R10000, - MachineTypeWCEMIPSv2 = IMAGE_FILE_MACHINE_WCEMIPSV2, - MachineTypeAlpha = IMAGE_FILE_MACHINE_ALPHA, - MachineTypeSH3 = IMAGE_FILE_MACHINE_SH3, - MachineTypeSH3DSP = IMAGE_FILE_MACHINE_SH3DSP, - MachineTypeSH3E = IMAGE_FILE_MACHINE_SH3E, - MachineTypeSH4 = IMAGE_FILE_MACHINE_SH4, - MachineTypeSH5 = IMAGE_FILE_MACHINE_SH5, - MachineTypeArm = IMAGE_FILE_MACHINE_ARM, - MachineTypeThumb = IMAGE_FILE_MACHINE_THUMB, - MachineTypeArmNT = IMAGE_FILE_MACHINE_ARMNT, - MachineTypeAM33 = IMAGE_FILE_MACHINE_AM33, - MachineTypePowerPC = IMAGE_FILE_MACHINE_POWERPC, - MachineTypePowerPCFP = IMAGE_FILE_MACHINE_POWERPCFP, - MachineTypeIa64 = IMAGE_FILE_MACHINE_IA64, - MachineTypeMips16 = IMAGE_FILE_MACHINE_MIPS16, - MachineTypeAlpha64 = IMAGE_FILE_MACHINE_ALPHA64, - MachineTypeMipsFpu = IMAGE_FILE_MACHINE_MIPSFPU, - MachineTypeMipsFpu16 = IMAGE_FILE_MACHINE_MIPSFPU16, - MachineTypeTriCore = IMAGE_FILE_MACHINE_TRICORE, - MachineTypeCEF = IMAGE_FILE_MACHINE_CEF, - MachineTypeEBC = IMAGE_FILE_MACHINE_EBC, - MachineTypeAmd64 = IMAGE_FILE_MACHINE_AMD64, - MachineTypeM32R = IMAGE_FILE_MACHINE_M32R, - MachineTypeCEE = IMAGE_FILE_MACHINE_CEE, -}; - -enum HashAlgorithm { HashNone = 0, HashMD5 = 1, HashSHA1 = 2 }; - -// SymTagEnum has the unfortunate property that it is not only the name of -// the enum, but also the name of one of the values of the enum. So that we -// don't have to always type "enum SymTagEnum", we typedef this to a different -// name so that we can refer to it more easily. -typedef enum SymTagEnum DiaSymTagEnum; - -typedef CComPtr DiaSymbolPtr; - -} // namespace windows -} // namespace sys -} // namespace llvm - -namespace llvm { -class raw_ostream; - -raw_ostream &operator<<(raw_ostream &Stream, - llvm::sys::windows::DiaSymTagEnum SymTag); -raw_ostream &operator<<(raw_ostream &Stream, CV_CPU_TYPE_e CpuType); -raw_ostream &operator<<(raw_ostream &Stream, - llvm::sys::windows::MachineTypeEnum CpuType); -raw_ostream &operator<<(raw_ostream &Stream, - llvm::sys::windows::HashAlgorithm Algorithm); -} - -#endif diff --git a/tools/llvm-pdbdump/DIASymbol.cpp b/tools/llvm-pdbdump/DIASymbol.cpp deleted file mode 100644 index 753f6f9b4ea..00000000000 --- a/tools/llvm-pdbdump/DIASymbol.cpp +++ /dev/null @@ -1,968 +0,0 @@ -//===- DIASymbol.cpp - Dump debug info from a PDB file ----------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#include "llvm-pdbdump.h" -#include "DIASymbol.h" - -using namespace llvm::sys::windows; - -DIASymbol::DIASymbol(IDiaSymbol *DiaSymbol) : Symbol(DiaSymbol) { - Symbol->AddRef(); -} - -DIASymbol::~DIASymbol() { Symbol->Release(); } - -void DIASymbol::fullDump(int IndentLevel) { - getLexicalParent().dump("Lexical parent", IndentLevel); - getClassParent().dump("Class parent", IndentLevel); - getType().dump("Type", IndentLevel); - getArrayIndexType().dump("Array index type", IndentLevel); - getVirtualTableShape().dump("Vtable shape", IndentLevel); - getLowerBound().dump("Lower bound", IndentLevel); - getUpperBound().dump("Upper bound", IndentLevel); - getObjectPointerType().dump("Object pointer type", IndentLevel); - getContainer().dump("Container", IndentLevel); - getVirtualBaseTableType().dump("Virtual base table type", IndentLevel); - getUnmodifiedType().dump("Unmodified type", IndentLevel); - getSubType().dump("Sub type", IndentLevel); - getBaseSymbol().dump("Base symbol", IndentLevel); - -#if (_MSC_FULL_VER >= 180031101) - // These methods are only available on VS 2013 SP4 and higher. - isPGO().dump("Is PGO", IndentLevel); - hasValidPGOCounts().dump("Has valid PGO counts", IndentLevel); - isOptimizedForSpeed().dump("Is optimized for speed", IndentLevel); - getPGOEntryCount().dump("PGO entry count", IndentLevel); - getPGOEdgeCount().dump("PGO edge count", IndentLevel); - getPGODynamicInstructionCount().dump("PGO dynamic instruction count", - IndentLevel); - getStaticSize().dump("Static size", IndentLevel); - getFinalLiveStaticSize().dump("Final live static size", IndentLevel); - getPhaseName().dump("Phase name", IndentLevel); - hasControlFlowCheck().dump("Has control flow check", IndentLevel); -#endif - - getAccess().dump("Access", IndentLevel); - getAddressOffset().dump("Address Offset", IndentLevel); - getAddressSection().dump("Address Section", IndentLevel); - getAddressTaken().dump("Address Taken", IndentLevel); - getAge().dump("Age", IndentLevel); - getArrayIndexTypeId().dump("Array Index Type Id", IndentLevel); - getBackEndMajor().dump("Back End Major", IndentLevel); - getBackEndMinor().dump("Back End Minor", IndentLevel); - getBackEndBuild().dump("Back End Build", IndentLevel); - getBaseDataOffset().dump("Base Data Offset", IndentLevel); - getBaseDataSlot().dump("Base Data Slot", IndentLevel); - getBaseSymbolId().dump("Base Symbol Id", IndentLevel); - getBaseType().dump("Base Type", IndentLevel); - getBitPosition().dump("Bit Position", IndentLevel); - getBuiltInKind().dump("Built In Kind", IndentLevel); - getCallingConvention().dump("Calling Convention", IndentLevel); - getClassParentId().dump("Class Parent Id", IndentLevel); - isCode().dump("Code", IndentLevel); - isCompilerGenerated().dump("Compiler Generated", IndentLevel); - getCompilerName().dump("Compiler Name", IndentLevel); - hasConstructor().dump("Constructor", IndentLevel); - isConstType().dump("Const Type", IndentLevel); - getCount().dump("Count", IndentLevel); - getCountLiveRanges().dump("Count Live Ranges", IndentLevel); - hasCustomCallingConvention().dump("Custom Calling Convention", IndentLevel); - getDataKind().dump("Data Kind", IndentLevel); - isEditAndContinueEnabled().dump("Edit and Continue Enabled", IndentLevel); - hasFarReturn().dump("Far Return", IndentLevel); - getFrontEndMajor().dump("Front End Major", IndentLevel); - getFrontEndMinor().dump("Front End Minor", IndentLevel); - getFrontEndBuild().dump("Front End Build", IndentLevel); - isFunction().dump("Function", IndentLevel); - getGuid().dump("GUID", IndentLevel); - hasAlloca().dump("Has Alloca", IndentLevel); - hasAssignmentOperator().dump("Has Assignment Operator", IndentLevel); - hasCastOperator().dump("Has Cast Operator", IndentLevel); - hasDebugInfo().dump("Has Debug Info", IndentLevel); - hasEH().dump("Has EH", IndentLevel); - hasEHa().dump("Has EHa", IndentLevel); - hasInlAsm().dump("Has Inline Asm", IndentLevel); - hasLongJump().dump("Has longjmp", IndentLevel); - hasManagedCode().dump("Has Managed Code", IndentLevel); - hasNestedTypes().dump("Has Nested Types", IndentLevel); - hasSecurityChecks().dump("Has Security Checks", IndentLevel); - hasSEH().dump("Has SEH", IndentLevel); - hasSetJump().dump("Has setjmp", IndentLevel); - isIndirectVirtualBaseClass().dump("Is indirect virtual base", IndentLevel); - hasInlineAttribute().dump("Has inline declspec", IndentLevel); - hasInterruptReturn().dump("Has interrupt return", IndentLevel); - isBaseVirtualFunction().dump("Is base virtual function", IndentLevel); - isAcceleratorGroupSharedLocal().dump("Is Accelerator Group Shared Local", - IndentLevel); - isAcceleratorPointerTagLiveRange().dump( - "Is Accelerator Pointer Tag Live Range", IndentLevel); - isAcceleratorStubFunction().dump("Is Accelerator Stub Function", IndentLevel); - isAggregated().dump("Is aggregated", IndentLevel); - hasCTypes().dump("Has C types", IndentLevel); - isCVTCIL().dump("Was converted from MSIL", IndentLevel); - isDataAligned().dump("Is data aligned", IndentLevel); - isHLSLData().dump("Is HLSL data", IndentLevel); - isHotpatchable().dump("Is hot-patchable", IndentLevel); - isLTCG().dump("Is LTCG", IndentLevel); - isMatrixRowMajor().dump("Is matrix row major", IndentLevel); - isMSILNetmodule().dump("Is MSIL .netmodule", IndentLevel); - isMultipleInheritance().dump("Is multiple inheritance", IndentLevel); - isNaked().dump("Is naked", IndentLevel); - isOptimizedAway().dump("Is optimized away", IndentLevel); - isPointerBasedOnSymbolValue().dump("Is pointer based on symbol value", - IndentLevel); - isPointerToDataMember().dump("Is pointer to data member", IndentLevel); - isPointerToMemberFunction().dump("Is pointer to member function", - IndentLevel); - isReturnValue().dump("Is return value", IndentLevel); - isSdl().dump("Is SDL", IndentLevel); - isSingleInheritance().dump("Is single inheritance", IndentLevel); - isSplitted().dump("Is splitted", IndentLevel); - isStatic().dump("Is staic", IndentLevel); - isStripped().dump("Is stripped", IndentLevel); - isVirtualInheritance().dump("Is virtual inheritance", IndentLevel); - getLanguage().dump("Language", IndentLevel); - getLength().dump("Length", IndentLevel); - getLexicalParentId().dump("Lexical parent id", IndentLevel); - getLibraryName().dump("Library name", IndentLevel); - getLiveRangeLength().dump("Live range length", IndentLevel); - getLiveRangeStartAddressSection().dump("Live range start address section", - IndentLevel); - getLiveRangeStartAddressOffset().dump("Live range start address offset", - IndentLevel); - getLiveRangeStartRelativeVirtualAddress().dump("Live range start address RVA", - IndentLevel); - getLocationType().dump("Location type", IndentLevel); - getLowerBoundId().dump("Lower bound id", IndentLevel); - getMachineType().dump("Machine type", IndentLevel); - isManagedRef().dump("Managed", IndentLevel); - getMemorySpaceKind().dump("Memory space kind", IndentLevel); - isMsilRef().dump("MSIL", IndentLevel); - getName().dump("Name", IndentLevel); - isNested().dump("Nested", IndentLevel); - hasNoInlineAttribute().dump("Has noinline declspec", IndentLevel); - hasNoReturnAttribute().dump("Has noreturn declspec", IndentLevel); - getNoStackOrdering().dump("No stack ordering", IndentLevel); - isUnreached().dump("Not reached", IndentLevel); - getNumberOfAcceleratorPointerTags().dump("Number of accelerator pointer tags", - IndentLevel); - getNumberOfModifiers().dump("Number of modifiers", IndentLevel); - getNumberOfRegisterIndices().dump("Number of register indices", IndentLevel); - getNumberOfRows().dump("Number of rows", IndentLevel); - getNumberOfColumns().dump("Number of columns", IndentLevel); - getObjectFileName().dump("Object file name", IndentLevel); - getOemSymbolId().dump("OEM symbol id", IndentLevel); - getOffset().dump("Offset", IndentLevel); - hasOptimizedCodeDebugInfo().dump("Optimized code debug info", IndentLevel); - hasOverloadedOperator().dump("Overloaded operator", IndentLevel); - isPacked().dump("Packed", IndentLevel); - getPlatform().dump("Platform", IndentLevel); - isPureVirtual().dump("Pure", IndentLevel); - getRank().dump("Rank", IndentLevel); - isReference().dump("Reference", IndentLevel); - getRegisterId().dump("Register ID", IndentLevel); - getRegisterType().dump("Register type", IndentLevel); - getRelativeVirtualAddress().dump("RVA", IndentLevel); - isRestrictedType().dump("Restricted type", IndentLevel); - getSamplerSlot().dump("Sampler slot", IndentLevel); - isScoped().dump("Scoped", IndentLevel); - getSignature().dump("Signature", IndentLevel); - getSizeInUdt().dump("Size in UDT", IndentLevel); - getSlot().dump("Slot", IndentLevel); - getSourceFileName().dump("Source file name", IndentLevel); - getStride().dump("Stride", IndentLevel); - getSubTypeId().dump("Sub type ID", IndentLevel); - getSymbolsFileName().dump("File name", IndentLevel); - getSymIndexId().dump("Sym index ID", IndentLevel); - getSymTag().dump("Sym tag", IndentLevel); - getTargetOffset().dump("Target offset", IndentLevel); - getTargetRelativeVirtualAddress().dump("Target RVA", IndentLevel); - getTargetSection().dump("Target section", IndentLevel); - getTargetVirtualAddress().dump("Target virtual address", IndentLevel); - getTextureSlot().dump("Texture slot", IndentLevel); - getThisAdjust().dump("This adjust", IndentLevel); - getThunkOrdinal().dump("Thunk ordinal", IndentLevel); - getTimeStamp().dump("Time stamp", IndentLevel); - getToken().dump("Token", IndentLevel); - getUavSlot().dump("UAV slot", IndentLevel); - getUdtKind().dump("UDT kind", IndentLevel); - isUnalignedType().dump("Unaligned type", IndentLevel); - getUndecoratedName().dump("Undecorated name", IndentLevel); - getUnmodifiedTypeId().dump("Unmodified type id", IndentLevel); - getUpperBoundId().dump("Upper bound id", IndentLevel); - isVirtual().dump("Virtual", IndentLevel); - getVirtualAddress().dump("Virtual address", IndentLevel); - isVirtualBaseClass().dump("Virtual base class", IndentLevel); - getVirtualBaseDispIndex().dump("Virtual base disp index", IndentLevel); - getVirtualBaseOffset().dump("Virtual base offset", IndentLevel); - getVirtualBasePointerOffset().dump("Virtual base pointer offset", - IndentLevel); - getVirtualTableShapeId().dump("Vtable shape ID", IndentLevel); - isVolatileType().dump("Volatile type", IndentLevel); -} - -#if (_MSC_FULL_VER >= 180031101) -DIAResult DIASymbol::isPGO() { - return InternalGetDIAValue(&IDiaSymbol::get_isPGO); -} - -DIAResult DIASymbol::hasValidPGOCounts() { - return InternalGetDIAValue(&IDiaSymbol::get_hasValidPGOCounts); -} - -DIAResult DIASymbol::isOptimizedForSpeed() { - return InternalGetDIAValue(&IDiaSymbol::get_isOptimizedForSpeed); -} - -DIAResult DIASymbol::getPGOEntryCount() { - return InternalGetDIAValue(&IDiaSymbol::get_PGOEntryCount); -} - -DIAResult DIASymbol::getPGOEdgeCount() { - return InternalGetDIAValue(&IDiaSymbol::get_PGOEdgeCount); -} - -DIAResult DIASymbol::getPGODynamicInstructionCount() { - return InternalGetDIAValue(&IDiaSymbol::get_PGODynamicInstructionCount); -} - -DIAResult DIASymbol::getStaticSize() { - return InternalGetDIAValue(&IDiaSymbol::get_staticSize); -} - -DIAResult DIASymbol::getFinalLiveStaticSize() { - return InternalGetDIAValue(&IDiaSymbol::get_finalLiveStaticSize); -} - -DIAResult DIASymbol::getPhaseName() { - return InternalGetDIAStringValue(&IDiaSymbol::get_phaseName); -} - -DIAResult DIASymbol::hasControlFlowCheck() { - return InternalGetDIAValue(&IDiaSymbol::get_hasControlFlowCheck); -} -#endif - -DIAResult DIASymbol::getClassParent() { - return InternalGetDIAValue( - &IDiaSymbol::get_classParent); -} - -DIAResult DIASymbol::getType() { - return InternalGetDIAValue(&IDiaSymbol::get_type); -} - -DIAResult DIASymbol::getArrayIndexType() { - return InternalGetDIAValue( - &IDiaSymbol::get_arrayIndexType); -} - -DIAResult DIASymbol::getVirtualTableShape() { - return InternalGetDIAValue( - &IDiaSymbol::get_virtualTableShape); -} - -DIAResult DIASymbol::getLowerBound() { - return InternalGetDIAValue( - &IDiaSymbol::get_lowerBound); -} - -DIAResult DIASymbol::getUpperBound() { - return InternalGetDIAValue( - &IDiaSymbol::get_upperBound); -} - -DIAResult DIASymbol::getObjectPointerType() { - return InternalGetDIAValue( - &IDiaSymbol::get_objectPointerType); -} - -DIAResult DIASymbol::getContainer() { - return InternalGetDIAValue( - &IDiaSymbol::get_container); -} - -DIAResult DIASymbol::getVirtualBaseTableType() { - return InternalGetDIAValue( - &IDiaSymbol::get_virtualBaseTableType); -} - -DIAResult DIASymbol::getUnmodifiedType() { - return InternalGetDIAValue( - &IDiaSymbol::get_unmodifiedType); -} - -DIAResult DIASymbol::getSubType() { - return InternalGetDIAValue( - &IDiaSymbol::get_subType); -} - -DIAResult DIASymbol::getBaseSymbol() { - return InternalGetDIAValue( - &IDiaSymbol::get_baseSymbol); -} - -DIAResult DIASymbol::getAccess() { - return InternalGetDIAValue(&IDiaSymbol::get_access); -} - -DIAResult DIASymbol::getAddressOffset() { - return InternalGetDIAValue(&IDiaSymbol::get_addressOffset); -} - -DIAResult DIASymbol::getAddressSection() { - return InternalGetDIAValue(&IDiaSymbol::get_addressSection); -} - -DIAResult DIASymbol::getAddressTaken() { - return InternalGetDIAValue(&IDiaSymbol::get_addressTaken); -} - -DIAResult DIASymbol::getAge() { - return InternalGetDIAValue(&IDiaSymbol::get_age); -} - -DIAResult DIASymbol::getArrayIndexTypeId() { - return InternalGetDIAValue(&IDiaSymbol::get_arrayIndexTypeId); -} - -DIAResult DIASymbol::getBackEndMajor() { - return InternalGetDIAValue(&IDiaSymbol::get_backEndMajor); -} - -DIAResult DIASymbol::getBackEndMinor() { - - return InternalGetDIAValue(&IDiaSymbol::get_backEndMinor); -} - -DIAResult DIASymbol::getBackEndBuild() { - return InternalGetDIAValue(&IDiaSymbol::get_backEndBuild); -} - -DIAResult DIASymbol::getBackEndQFE() { - return InternalGetDIAValue(&IDiaSymbol::get_backEndQFE); -} - -DIAResult DIASymbol::getBaseDataOffset() { - return InternalGetDIAValue(&IDiaSymbol::get_baseDataOffset); -} - -DIAResult DIASymbol::getBaseDataSlot() { - return InternalGetDIAValue(&IDiaSymbol::get_baseDataSlot); -} - -DIAResult DIASymbol::getBaseSymbolId() { - return InternalGetDIAValue(&IDiaSymbol::get_baseSymbolId); -} - -DIAResult DIASymbol::getBaseType() { - return InternalGetDIAValue(&IDiaSymbol::get_baseType); -} - -DIAResult DIASymbol::getBitPosition() { - return InternalGetDIAValue(&IDiaSymbol::get_bitPosition); -} - -DIAResult DIASymbol::getBuiltInKind() { - return InternalGetDIAValue(&IDiaSymbol::get_builtInKind); -} - -DIAResult DIASymbol::getCallingConvention() { - return InternalGetDIAValue( - &IDiaSymbol::get_callingConvention); -} - -DIAResult DIASymbol::getClassParentId() { - return InternalGetDIAValue(&IDiaSymbol::get_classParentId); -} - -DIAResult DIASymbol::isCode() { - return InternalGetDIAValue(&IDiaSymbol::get_code); -} - -DIAResult DIASymbol::isCompilerGenerated() { - return InternalGetDIAValue(&IDiaSymbol::get_compilerGenerated); -} - -DIAResult DIASymbol::getCompilerName() { - return InternalGetDIAStringValue(&IDiaSymbol::get_compilerName); -} - -DIAResult DIASymbol::hasConstructor() { - return InternalGetDIAValue(&IDiaSymbol::get_constructor); -} - -DIAResult DIASymbol::isConstType() { - return InternalGetDIAValue(&IDiaSymbol::get_constType); -} - -DIAResult DIASymbol::getCount() { - return InternalGetDIAValue(&IDiaSymbol::get_count); -} - -DIAResult DIASymbol::getCountLiveRanges() { - return InternalGetDIAValue(&IDiaSymbol::get_countLiveRanges); -} - -DIAResult DIASymbol::hasCustomCallingConvention() { - return InternalGetDIAValue(&IDiaSymbol::get_customCallingConvention); -} - -DIAResult DIASymbol::getDataKind() { - return InternalGetDIAValue(&IDiaSymbol::get_dataKind); -} - -DIAResult DIASymbol::isEditAndContinueEnabled() { - return InternalGetDIAValue(&IDiaSymbol::get_editAndContinueEnabled); -} - -DIAResult DIASymbol::hasFarReturn() { - return InternalGetDIAValue(&IDiaSymbol::get_farReturn); -} - -DIAResult DIASymbol::getFrontEndMajor() { - return InternalGetDIAValue(&IDiaSymbol::get_frontEndMajor); -} - -DIAResult DIASymbol::getFrontEndMinor() { - return InternalGetDIAValue(&IDiaSymbol::get_frontEndMinor); -} - -DIAResult DIASymbol::getFrontEndBuild() { - return InternalGetDIAValue(&IDiaSymbol::get_frontEndBuild); -} - -DIAResult DIASymbol::getFrontEndQFE() { - return InternalGetDIAValue(&IDiaSymbol::get_frontEndQFE); -} - -DIAResult DIASymbol::isFunction() { - return InternalGetDIAValue(&IDiaSymbol::get_function); -} - -DIAResult DIASymbol::getGuid() { - return InternalGetDIAValue(&IDiaSymbol::get_guid); -} - -DIAResult DIASymbol::hasAlloca() { - return InternalGetDIAValue(&IDiaSymbol::get_hasAlloca); -} - -DIAResult DIASymbol::hasAssignmentOperator() { - return InternalGetDIAValue(&IDiaSymbol::get_hasAssignmentOperator); -} - -DIAResult DIASymbol::hasCastOperator() { - return InternalGetDIAValue(&IDiaSymbol::get_hasCastOperator); -} - -DIAResult DIASymbol::hasDebugInfo() { - return InternalGetDIAValue(&IDiaSymbol::get_hasDebugInfo); -} - -DIAResult DIASymbol::hasEH() { - return InternalGetDIAValue(&IDiaSymbol::get_hasEH); -} - -DIAResult DIASymbol::hasEHa() { - return InternalGetDIAValue(&IDiaSymbol::get_hasEHa); -} - -DIAResult DIASymbol::hasInlAsm() { - return InternalGetDIAValue(&IDiaSymbol::get_hasInlAsm); -} - -DIAResult DIASymbol::hasLongJump() { - return InternalGetDIAValue(&IDiaSymbol::get_hasLongJump); -} - -DIAResult DIASymbol::hasManagedCode() { - return InternalGetDIAValue(&IDiaSymbol::get_hasManagedCode); -} - -DIAResult DIASymbol::hasNestedTypes() { - return InternalGetDIAValue(&IDiaSymbol::get_hasNestedTypes); -} - -DIAResult DIASymbol::hasSecurityChecks() { - return InternalGetDIAValue(&IDiaSymbol::get_hasSecurityChecks); -} - -DIAResult DIASymbol::hasSEH() { - return InternalGetDIAValue(&IDiaSymbol::get_hasSEH); -} - -DIAResult DIASymbol::hasSetJump() { - return InternalGetDIAValue(&IDiaSymbol::get_hasSetJump); -} - -DIAResult DIASymbol::isIndirectVirtualBaseClass() { - return InternalGetDIAValue(&IDiaSymbol::get_indirectVirtualBaseClass); -} - -DIAResult DIASymbol::hasInlineAttribute() { - return InternalGetDIAValue(&IDiaSymbol::get_inlSpec); -} - -DIAResult DIASymbol::hasInterruptReturn() { - return InternalGetDIAValue(&IDiaSymbol::get_interruptReturn); -} - -DIAResult DIASymbol::isBaseVirtualFunction() { - return InternalGetDIAValue(&IDiaSymbol::get_intro); -} - -DIAResult DIASymbol::isIntrinsic() { - return InternalGetDIAValue(&IDiaSymbol::get_intrinsic); -} - -DIAResult DIASymbol::isAcceleratorGroupSharedLocal() { - return InternalGetDIAValue(&IDiaSymbol::get_isAcceleratorGroupSharedLocal); -} - -DIAResult DIASymbol::isAcceleratorPointerTagLiveRange() { - return InternalGetDIAValue(&IDiaSymbol::get_isAcceleratorPointerTagLiveRange); -} - -DIAResult DIASymbol::isAcceleratorStubFunction() { - return InternalGetDIAValue(&IDiaSymbol::get_isAcceleratorStubFunction); -} - -DIAResult DIASymbol::isAggregated() { - return InternalGetDIAValue(&IDiaSymbol::get_isAggregated); -} - -DIAResult DIASymbol::isConstructorVirtualBase() { - return InternalGetDIAValue(&IDiaSymbol::get_isConstructorVirtualBase); -} - -DIAResult DIASymbol::hasStrictGSCheck() { - return InternalGetDIAValue(&IDiaSymbol::get_strictGSCheck); -} - -DIAResult DIASymbol::isLocationControlFlowDependent() { - return InternalGetDIAValue(&IDiaSymbol::get_isLocationControlFlowDependent); -} - -DIAResult DIASymbol::hasCTypes() { - return InternalGetDIAValue(&IDiaSymbol::get_isCTypes); -} - -DIAResult DIASymbol::isCVTCIL() { - return InternalGetDIAValue(&IDiaSymbol::get_isCVTCIL); -} - -DIAResult DIASymbol::isDataAligned() { - return InternalGetDIAValue(&IDiaSymbol::get_isDataAligned); -} - -DIAResult DIASymbol::isHLSLData() { - return InternalGetDIAValue(&IDiaSymbol::get_isHLSLData); -} - -DIAResult DIASymbol::isHotpatchable() { - return InternalGetDIAValue(&IDiaSymbol::get_isHotpatchable); -} - -DIAResult DIASymbol::isLTCG() { - return InternalGetDIAValue(&IDiaSymbol::get_isLTCG); -} - -DIAResult DIASymbol::isMatrixRowMajor() { - return InternalGetDIAValue(&IDiaSymbol::get_isMatrixRowMajor); -} - -DIAResult DIASymbol::isMSILNetmodule() { - return InternalGetDIAValue(&IDiaSymbol::get_isMSILNetmodule); -} - -DIAResult DIASymbol::isMultipleInheritance() { - return InternalGetDIAValue(&IDiaSymbol::get_isMultipleInheritance); -} - -DIAResult DIASymbol::isNaked() { - return InternalGetDIAValue(&IDiaSymbol::get_isNaked); -} - -DIAResult DIASymbol::isOptimizedAway() { - return InternalGetDIAValue(&IDiaSymbol::get_isOptimizedAway); -} - -DIAResult DIASymbol::isPointerBasedOnSymbolValue() { - return InternalGetDIAValue(&IDiaSymbol::get_isPointerBasedOnSymbolValue); -} - -DIAResult DIASymbol::isPointerToDataMember() { - return InternalGetDIAValue(&IDiaSymbol::get_isPointerToDataMember); -} - -DIAResult DIASymbol::isPointerToMemberFunction() { - return InternalGetDIAValue(&IDiaSymbol::get_isPointerToMemberFunction); -} - -DIAResult DIASymbol::isReturnValue() { - return InternalGetDIAValue(&IDiaSymbol::get_isReturnValue); -} - -DIAResult DIASymbol::isSdl() { - return InternalGetDIAValue(&IDiaSymbol::get_isSdl); -} - -DIAResult DIASymbol::isSingleInheritance() { - return InternalGetDIAValue(&IDiaSymbol::get_isSingleInheritance); -} - -DIAResult DIASymbol::isSplitted() { - return InternalGetDIAValue(&IDiaSymbol::get_isSplitted); -} - -DIAResult DIASymbol::isStatic() { - return InternalGetDIAValue(&IDiaSymbol::get_isStatic); -} - -DIAResult DIASymbol::isStripped() { - return InternalGetDIAValue(&IDiaSymbol::get_isStripped); -} - -DIAResult DIASymbol::isVirtualInheritance() { - return InternalGetDIAValue(&IDiaSymbol::get_isVirtualInheritance); -} - -DIAResult DIASymbol::getLanguage() { - return InternalGetDIAValue(&IDiaSymbol::get_language); -} - -DIAResult DIASymbol::isSafeBuffers() { - return InternalGetDIAValue(&IDiaSymbol::get_isSafeBuffers); -} - -DIAResult DIASymbol::getLength() { - return InternalGetDIAValue(&IDiaSymbol::get_length); -} - -DIAResult DIASymbol::getLexicalParentId() { - return InternalGetDIAValue(&IDiaSymbol::get_lexicalParentId); -} - -DIAResult DIASymbol::getLexicalParent() { - return InternalGetDIAValue( - &IDiaSymbol::get_lexicalParent); -} - -DIAResult DIASymbol::getLocalBasePointerRegisterId() { - return InternalGetDIAValue(&IDiaSymbol::get_localBasePointerRegisterId); -} - -DIAResult DIASymbol::getLibraryName() { - return InternalGetDIAStringValue(&IDiaSymbol::get_libraryName); -} - -DIAResult DIASymbol::getLiveRangeLength() { - return InternalGetDIAValue(&IDiaSymbol::get_liveRangeLength); -} - -DIAResult DIASymbol::getLiveRangeStartAddressSection() { - return InternalGetDIAValue(&IDiaSymbol::get_liveRangeStartAddressSection); -} - -DIAResult DIASymbol::getLiveRangeStartAddressOffset() { - return InternalGetDIAValue(&IDiaSymbol::get_liveRangeStartAddressOffset); -} - -DIAResult DIASymbol::getLiveRangeStartRelativeVirtualAddress() { - return InternalGetDIAValue( - &IDiaSymbol::get_liveRangeStartRelativeVirtualAddress); -} - -DIAResult DIASymbol::getLocationType() { - return InternalGetDIAValue( - &IDiaSymbol::get_locationType); -} - -DIAResult DIASymbol::getLowerBoundId() { - return InternalGetDIAValue(&IDiaSymbol::get_lowerBoundId); -} - -DIAResult DIASymbol::getMachineType() { - return InternalGetDIAValue( - &IDiaSymbol::get_machineType); -} - -DIAResult DIASymbol::isManagedRef() { - return InternalGetDIAValue(&IDiaSymbol::get_managed); -} - -DIAResult DIASymbol::getMemorySpaceKind() { - return InternalGetDIAValue(&IDiaSymbol::get_memorySpaceKind); -} - -DIAResult DIASymbol::isMsilRef() { - return InternalGetDIAValue(&IDiaSymbol::get_msil); -} - -DIAResult DIASymbol::getName() { - return InternalGetDIAStringValue(&IDiaSymbol::get_name); -} - -DIAResult DIASymbol::isNested() { - return InternalGetDIAValue(&IDiaSymbol::get_nested); -} - -DIAResult DIASymbol::hasNoInlineAttribute() { - return InternalGetDIAValue(&IDiaSymbol::get_noInline); -} - -DIAResult DIASymbol::hasNoReturnAttribute() { - return InternalGetDIAValue(&IDiaSymbol::get_noReturn); -} - -DIAResult DIASymbol::getNoStackOrdering() { - return InternalGetDIAValue(&IDiaSymbol::get_noStackOrdering); -} - -DIAResult DIASymbol::isUnreached() { - return InternalGetDIAValue(&IDiaSymbol::get_notReached); -} - -DIAResult DIASymbol::getNumberOfAcceleratorPointerTags() { - return InternalGetDIAValue(&IDiaSymbol::get_numberOfAcceleratorPointerTags); -} - -DIAResult DIASymbol::getNumberOfModifiers() { - return InternalGetDIAValue(&IDiaSymbol::get_numberOfModifiers); -} - -DIAResult DIASymbol::getNumberOfRegisterIndices() { - return InternalGetDIAValue(&IDiaSymbol::get_numberOfRegisterIndices); -} - -DIAResult DIASymbol::getNumberOfRows() { - return InternalGetDIAValue(&IDiaSymbol::get_numberOfRows); -} - -DIAResult DIASymbol::getNumberOfColumns() { - return InternalGetDIAValue(&IDiaSymbol::get_numberOfColumns); -} - -DIAResult DIASymbol::getObjectFileName() { - return InternalGetDIAStringValue(&IDiaSymbol::get_objectFileName); -} - -DIAResult DIASymbol::getOemSymbolId() { - return InternalGetDIAValue(&IDiaSymbol::get_oemSymbolId); -} - -DIAResult DIASymbol::getOffset() { - return InternalGetDIAValue(&IDiaSymbol::get_offset); -} - -DIAResult DIASymbol::getOffsetInUdt() { - return InternalGetDIAValue(&IDiaSymbol::get_offsetInUdt); -} - -DIAResult DIASymbol::hasOptimizedCodeDebugInfo() { - return InternalGetDIAValue(&IDiaSymbol::get_optimizedCodeDebugInfo); -} - -DIAResult DIASymbol::hasOverloadedOperator() { - return InternalGetDIAValue(&IDiaSymbol::get_overloadedOperator); -} - -DIAResult DIASymbol::isPacked() { - return InternalGetDIAValue(&IDiaSymbol::get_packed); -} - -DIAResult DIASymbol::getPlatform() { - return InternalGetDIAValue(&IDiaSymbol::get_platform); -} - -DIAResult DIASymbol::isPureVirtual() { - return InternalGetDIAValue(&IDiaSymbol::get_pure); -} - -DIAResult DIASymbol::getRank() { - return InternalGetDIAValue(&IDiaSymbol::get_rank); -} - -DIAResult DIASymbol::isReference() { - return InternalGetDIAValue(&IDiaSymbol::get_reference); -} - -DIAResult DIASymbol::isRValueReference() { - return InternalGetDIAValue(&IDiaSymbol::get_RValueReference); -} - -DIAResult DIASymbol::getRegisterId() { - return InternalGetDIAValue(&IDiaSymbol::get_registerId); -} - -DIAResult DIASymbol::getRegisterType() { - return InternalGetDIAValue(&IDiaSymbol::get_registerType); -} - -DIAResult DIASymbol::getRelativeVirtualAddress() { - return InternalGetDIAValue(&IDiaSymbol::get_relativeVirtualAddress); -} - -DIAResult DIASymbol::isRestrictedType() { - return InternalGetDIAValue(&IDiaSymbol::get_restrictedType); -} - -DIAResult DIASymbol::getSamplerSlot() { - return InternalGetDIAValue(&IDiaSymbol::get_samplerSlot); -} - -DIAResult DIASymbol::isScoped() { - return InternalGetDIAValue(&IDiaSymbol::get_scoped); -} - -DIAResult DIASymbol::isRefUdt() { - return InternalGetDIAValue(&IDiaSymbol::get_isRefUdt); -} - -DIAResult DIASymbol::isValueUdt() { - return InternalGetDIAValue(&IDiaSymbol::get_isValueUdt); -} - -DIAResult DIASymbol::isInterfaceUdt() { - return InternalGetDIAValue(&IDiaSymbol::get_isInterfaceUdt); -} - -DIAResult DIASymbol::isCxxReturnUdt() { - return InternalGetDIAValue(&IDiaSymbol::get_isCxxReturnUdt); -} - -DIAResult DIASymbol::getSignature() { - return InternalGetDIAValue(&IDiaSymbol::get_signature); -} - -DIAResult DIASymbol::getSizeInUdt() { - return InternalGetDIAValue(&IDiaSymbol::get_sizeInUdt); -} - -DIAResult DIASymbol::getSlot() { - return InternalGetDIAValue(&IDiaSymbol::get_slot); -} - -DIAResult DIASymbol::getSourceFileName() { - return InternalGetDIAStringValue(&IDiaSymbol::get_sourceFileName); -} - -DIAResult DIASymbol::getStride() { - return InternalGetDIAValue(&IDiaSymbol::get_stride); -} - -DIAResult DIASymbol::getSubTypeId() { - return InternalGetDIAValue(&IDiaSymbol::get_subTypeId); -} - -DIAResult DIASymbol::getSymbolsFileName() { - return InternalGetDIAStringValue(&IDiaSymbol::get_symbolsFileName); -} - -DIAResult DIASymbol::getSymIndexId() { - return InternalGetDIAValue(&IDiaSymbol::get_symIndexId); -} - -DIAResult DIASymbol::getSymTag() { - return InternalGetDIAValue(&IDiaSymbol::get_symTag); -} - -DIAResult DIASymbol::getTargetOffset() { - return InternalGetDIAValue(&IDiaSymbol::get_targetOffset); -} - -DIAResult DIASymbol::getTargetRelativeVirtualAddress() { - return InternalGetDIAValue(&IDiaSymbol::get_targetRelativeVirtualAddress); -} - -DIAResult DIASymbol::getTargetSection() { - return InternalGetDIAValue(&IDiaSymbol::get_targetSection); -} - -DIAResult DIASymbol::getTargetVirtualAddress() { - return InternalGetDIAValue(&IDiaSymbol::get_targetVirtualAddress); -} - -DIAResult DIASymbol::getTextureSlot() { - return InternalGetDIAValue(&IDiaSymbol::get_textureSlot); -} - -DIAResult DIASymbol::getThisAdjust() { - return InternalGetDIAValue(&IDiaSymbol::get_thisAdjust); -} - -DIAResult DIASymbol::getThunkOrdinal() { - return InternalGetDIAValue( - &IDiaSymbol::get_thunkOrdinal); -} - -DIAResult DIASymbol::getTimeStamp() { - return InternalGetDIAValue(&IDiaSymbol::get_timeStamp); -} - -DIAResult DIASymbol::getToken() { - return InternalGetDIAValue(&IDiaSymbol::get_token); -} - -DIAResult DIASymbol::getUavSlot() { - return InternalGetDIAValue(&IDiaSymbol::get_uavSlot); -} - -DIAResult DIASymbol::getUdtKind() { - return InternalGetDIAValue(&IDiaSymbol::get_udtKind); -} - -DIAResult DIASymbol::isUnalignedType() { - return InternalGetDIAValue(&IDiaSymbol::get_unalignedType); -} - -DIAResult DIASymbol::getUndecoratedName() { - return InternalGetDIAStringValue(&IDiaSymbol::get_undecoratedName); -} - -DIAResult DIASymbol::getUnmodifiedTypeId() { - return InternalGetDIAValue(&IDiaSymbol::get_unmodifiedTypeId); -} - -DIAResult DIASymbol::getUpperBoundId() { - return InternalGetDIAValue(&IDiaSymbol::get_upperBoundId); -} - -DIAResult DIASymbol::isVirtual() { - return InternalGetDIAValue(&IDiaSymbol::get_virtual); -} - -DIAResult DIASymbol::getVirtualAddress() { - return InternalGetDIAValue(&IDiaSymbol::get_virtualAddress); -} - -DIAResult DIASymbol::isVirtualBaseClass() { - return InternalGetDIAValue(&IDiaSymbol::get_virtualBaseClass); -} - -DIAResult DIASymbol::getVirtualBaseDispIndex() { - return InternalGetDIAValue(&IDiaSymbol::get_virtualBaseDispIndex); -} - -DIAResult DIASymbol::getVirtualBaseOffset() { - return InternalGetDIAValue(&IDiaSymbol::get_virtualBaseOffset); -} - -DIAResult DIASymbol::getVirtualBasePointerOffset() { - return InternalGetDIAValue(&IDiaSymbol::get_virtualBasePointerOffset); -} - -DIAResult DIASymbol::getVirtualTableShapeId() { - return InternalGetDIAValue(&IDiaSymbol::get_virtualTableShapeId); -} - -DIAResult DIASymbol::isVolatileType() { - return InternalGetDIAValue(&IDiaSymbol::get_volatileType); -} diff --git a/tools/llvm-pdbdump/DIASymbol.h b/tools/llvm-pdbdump/DIASymbol.h deleted file mode 100644 index 3e908e1e754..00000000000 --- a/tools/llvm-pdbdump/DIASymbol.h +++ /dev/null @@ -1,282 +0,0 @@ -//===- DIASymbol.h - Dump debug info from a PDB file ------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// Provides a wrapper around the IDiaSymbol interface. IDiaSymbol is used to -// represent any kind of symbol from functions, to compilands, to source files. -// It provides a monolithic interface of close to 200 operations, and the set -// of operations that are valid depends on the type of the symbol. Since it is -// not clearly documented which set of operations is valid for which type of -// symbol, the best way of figuring it out is to dump every method for every -// symbol, and see which methods return errors. This wrapper provides a clean -// way of doing this without involving needing to embed lots of unsightly -// HRESULT checking at every callsite. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_TOOLS_LLVMPDBDUMP_DIASYMBOL_H -#define LLVM_TOOLS_LLVMPDBDUMP_DIASYMBOL_H - -#include "DIAExtras.h" -#include "llvm/ADT/SmallString.h" - -namespace llvm { -namespace sys { -namespace windows { - -class DIASymbol { -public: - DIASymbol(IDiaSymbol *DiaSymbol); - ~DIASymbol(); - - /// Dumps the value of every property (if it exists) with a default name. - /// This is useful for understanding what symbol types support what methods - /// during development time. - void fullDump(int IndentLevel); - -// TODO: The following methods are present on IDiaSymbol but do not yet have -// wrapper methods. -// -// HRESULT get_value(VARIANT *pRetVal) = 0; -// HRESULT get_undecoratedNameEx(DWORD undecorateOptions, BSTR *name) = 0; -// HRESULT getSrcLineOnTypeDefn(IDiaLineNumber **ppResult) = 0; -// HRESULT get_dataBytes(DWORD cbData, DWORD *pcbData, BYTE *pbData) = 0; -// HRESULT get_types(DWORD cTypes, DWORD *pcTypes, IDiaSymbol **pTypes) = 0; -// HRESULT get_typeIds(DWORD cTypeIds, DWORD *pcTypeIds, DWORD *pdwTypeIds) = 0; -// HRESULT get_numericProperties(DWORD cnt, DWORD *pcnt, -// DWORD *pProperties) = 0; -// HRESULT get_modifierValues(DWORD cnt, DWORD *pcnt, WORD *pModifiers) = 0; -// HRESULT get_acceleratorPointerTags(DWORD cnt, DWORD *pcnt, DWORD -// *pPointerTags) = 0; -// HRESULT get_hfaFloat(BOOL *pRetVal) = 0; -// HRESULT get_hfaDouble(BOOL *pRetVal) = 0; -// HRESULT get_paramBasePointerRegisterId(DWORD *pRetVal) = 0; -// HRESULT get_isWinRTPointer(BOOL *pRetVal) = 0; - -#if (_MSC_FULL_VER >= 180031101) - // These methods are only available on VS 2013 SP 4 and higher. - DIAResult isPGO(); - DIAResult hasValidPGOCounts(); - DIAResult isOptimizedForSpeed(); - DIAResult getPGOEntryCount(); - DIAResult getPGOEdgeCount(); - DIAResult getPGODynamicInstructionCount(); - DIAResult getStaticSize(); - DIAResult getFinalLiveStaticSize(); - DIAResult getPhaseName(); - DIAResult hasControlFlowCheck(); -#endif - - DIAResult getLexicalParent(); - DIAResult getClassParent(); - DIAResult getType(); - DIAResult getArrayIndexType(); - DIAResult getVirtualTableShape(); - DIAResult getLowerBound(); - DIAResult getUpperBound(); - DIAResult getObjectPointerType(); - DIAResult getContainer(); - DIAResult getVirtualBaseTableType(); - DIAResult getUnmodifiedType(); - DIAResult getSubType(); - DIAResult getBaseSymbol(); - - DIAResult getAccess(); - DIAResult getAddressOffset(); - DIAResult getAddressSection(); - DIAResult getAge(); - DIAResult getArrayIndexTypeId(); - DIAResult getBackEndBuild(); - DIAResult getBackEndMajor(); - DIAResult getBackEndMinor(); - DIAResult getBackEndQFE(); - DIAResult getBaseDataOffset(); - DIAResult getBaseDataSlot(); - DIAResult getBaseSymbolId(); - DIAResult getBaseType(); - DIAResult getBitPosition(); - DIAResult getBuiltInKind(); - DIAResult getCallingConvention(); - DIAResult getClassParentId(); - DIAResult getCompilerName(); - DIAResult getCount(); - DIAResult getCountLiveRanges(); - DIAResult getFrontEndBuild(); - DIAResult getFrontEndMajor(); - DIAResult getFrontEndMinor(); - DIAResult getFrontEndQFE(); - DIAResult getLanguage(); - DIAResult getLexicalParentId(); - DIAResult getLibraryName(); - DIAResult getLiveRangeStartAddressOffset(); - DIAResult getLiveRangeStartAddressSection(); - DIAResult getLiveRangeStartRelativeVirtualAddress(); - DIAResult getLocalBasePointerRegisterId(); - DIAResult getLowerBoundId(); - DIAResult getMemorySpaceKind(); - DIAResult getName(); - DIAResult getNumberOfAcceleratorPointerTags(); - DIAResult getNumberOfColumns(); - DIAResult getNumberOfModifiers(); - DIAResult getNumberOfRegisterIndices(); - DIAResult getNumberOfRows(); - DIAResult getObjectFileName(); - DIAResult getOemSymbolId(); - DIAResult getOffsetInUdt(); - DIAResult getPlatform(); - DIAResult getRank(); - DIAResult getRegisterId(); - DIAResult getRegisterType(); - DIAResult getRelativeVirtualAddress(); - DIAResult getSamplerSlot(); - DIAResult getSignature(); - DIAResult getSizeInUdt(); - DIAResult getSlot(); - DIAResult getSourceFileName(); - DIAResult getStride(); - DIAResult getSubTypeId(); - DIAResult getSymbolsFileName(); - DIAResult getSymIndexId(); - DIAResult getTargetOffset(); - DIAResult getTargetRelativeVirtualAddress(); - DIAResult getTargetSection(); - DIAResult getTextureSlot(); - DIAResult getTimeStamp(); - DIAResult getToken(); - DIAResult getUavSlot(); - DIAResult getUndecoratedName(); - DIAResult getUnmodifiedTypeId(); - DIAResult getUpperBoundId(); - DIAResult getVirtualBaseDispIndex(); - DIAResult getVirtualBaseOffset(); - DIAResult getVirtualTableShapeId(); - DIAResult getDataKind(); - DIAResult getSymTag(); - DIAResult getGuid(); - DIAResult getOffset(); - DIAResult getThisAdjust(); - DIAResult getVirtualBasePointerOffset(); - DIAResult getLocationType(); - DIAResult getMachineType(); - DIAResult getThunkOrdinal(); - DIAResult getLength(); - DIAResult getLiveRangeLength(); - DIAResult getTargetVirtualAddress(); - DIAResult getVirtualAddress(); - DIAResult getUdtKind(); - DIAResult hasConstructor(); - DIAResult hasCustomCallingConvention(); - DIAResult hasFarReturn(); - DIAResult isCode(); - DIAResult isCompilerGenerated(); - DIAResult isConstType(); - DIAResult isEditAndContinueEnabled(); - DIAResult isFunction(); - DIAResult getAddressTaken(); - DIAResult getNoStackOrdering(); - DIAResult hasAlloca(); - DIAResult hasAssignmentOperator(); - DIAResult hasCTypes(); - DIAResult hasCastOperator(); - DIAResult hasDebugInfo(); - DIAResult hasEH(); - DIAResult hasEHa(); - DIAResult hasInlAsm(); - DIAResult hasInlineAttribute(); - DIAResult hasInterruptReturn(); - DIAResult hasLongJump(); - DIAResult hasManagedCode(); - DIAResult hasNestedTypes(); - DIAResult hasNoInlineAttribute(); - DIAResult hasNoReturnAttribute(); - DIAResult hasOptimizedCodeDebugInfo(); - DIAResult hasOverloadedOperator(); - DIAResult hasSEH(); - DIAResult hasSecurityChecks(); - DIAResult hasSetJump(); - DIAResult hasStrictGSCheck(); - DIAResult isAcceleratorGroupSharedLocal(); - DIAResult isAcceleratorPointerTagLiveRange(); - DIAResult isAcceleratorStubFunction(); - DIAResult isAggregated(); - DIAResult isBaseVirtualFunction(); - DIAResult isCVTCIL(); - DIAResult isConstructorVirtualBase(); - DIAResult isCxxReturnUdt(); - DIAResult isDataAligned(); - DIAResult isHLSLData(); - DIAResult isHotpatchable(); - DIAResult isIndirectVirtualBaseClass(); - DIAResult isInterfaceUdt(); - DIAResult isIntrinsic(); - DIAResult isLTCG(); - DIAResult isLocationControlFlowDependent(); - DIAResult isMSILNetmodule(); - DIAResult isManagedRef(); - DIAResult isMatrixRowMajor(); - DIAResult isMsilRef(); - DIAResult isMultipleInheritance(); - DIAResult isNaked(); - DIAResult isNested(); - DIAResult isOptimizedAway(); - DIAResult isPacked(); - DIAResult isPointerBasedOnSymbolValue(); - DIAResult isPointerToDataMember(); - DIAResult isPointerToMemberFunction(); - DIAResult isPureVirtual(); - DIAResult isRValueReference(); - DIAResult isRefUdt(); - DIAResult isReference(); - DIAResult isRestrictedType(); - DIAResult isReturnValue(); - DIAResult isSafeBuffers(); - DIAResult isScoped(); - DIAResult isSdl(); - DIAResult isSingleInheritance(); - DIAResult isSplitted(); - DIAResult isStatic(); - DIAResult isStripped(); - DIAResult isUnalignedType(); - DIAResult isUnreached(); - DIAResult isValueUdt(); - DIAResult isVirtual(); - DIAResult isVirtualBaseClass(); - DIAResult isVirtualInheritance(); - DIAResult isVolatileType(); - -private: - template - DIAResult - InternalGetDIAValue(HRESULT (__stdcall IDiaSymbol::*Method)(T *)) { - T Value; - if (S_OK == (Symbol->*Method)(&Value)) - return DIAResult(U(Value)); - else - return DIAResult(); - } - - DIAResult - InternalGetDIAStringValue(HRESULT (__stdcall IDiaSymbol::*Method)(BSTR *)) { - BSTR String16; - if (S_OK == (Symbol->*Method)(&String16)) { - std::string String8; - llvm::sys::windows::BSTRToUTF8(String16, String8); - SysFreeString(String16); - return DIAResult(DIAString(String8)); - } else - return DIAResult(); - } - - IDiaSymbol *Symbol; -}; - -} // namespace windows -} // namespace sys -} // namespace llvm - -#endif diff --git a/tools/llvm-pdbdump/LLVMBuild.txt b/tools/llvm-pdbdump/LLVMBuild.txt index 29d40debd6b..487768935dd 100644 --- a/tools/llvm-pdbdump/LLVMBuild.txt +++ b/tools/llvm-pdbdump/LLVMBuild.txt @@ -19,5 +19,5 @@ type = Tool name = llvm-pdbdump parent = Tools -required_libraries = +required_libraries = DebugInfoPDB diff --git a/tools/llvm-pdbdump/Makefile b/tools/llvm-pdbdump/Makefile new file mode 100644 index 00000000000..18aafc4076f --- /dev/null +++ b/tools/llvm-pdbdump/Makefile @@ -0,0 +1,17 @@ +##===- tools/llvm-pdbdump/Makefile -------------------------*- Makefile -*-===## +# +# The LLVM Compiler Infrastructure +# +# This file is distributed under the University of Illinois Open Source +# License. See LICENSE.TXT for details. +# +##===----------------------------------------------------------------------===## + +LEVEL := ../.. +TOOLNAME := llvm-pdbdump +LINK_COMPONENTS := DebugInfoPDB Object + +# This tool has no plugins, optimize startup time. +TOOL_NO_EXPORTS := 1 + +include $(LEVEL)/Makefile.common diff --git a/tools/llvm-pdbdump/llvm-pdbdump.cpp b/tools/llvm-pdbdump/llvm-pdbdump.cpp index 2c5109888bc..e2db7f6daf9 100644 --- a/tools/llvm-pdbdump/llvm-pdbdump.cpp +++ b/tools/llvm-pdbdump/llvm-pdbdump.cpp @@ -15,6 +15,12 @@ #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/StringExtras.h" +#include "llvm/DebugInfo/PDB/PDB.h" +#include "llvm/DebugInfo/PDB/IPDBEnumChildren.h" +#include "llvm/DebugInfo/PDB/IPDBSession.h" +#include "llvm/DebugInfo/PDB/IPDBRawSymbol.h" +#include "llvm/DebugInfo/PDB/PDBSymbolExe.h" +#include "llvm/DebugInfo/PDB/PDBSymbolCompiland.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/ConvertUTF.h" #include "llvm/Support/Format.h" @@ -24,335 +30,46 @@ #include "llvm/Support/PrettyStackTrace.h" #include "llvm/Support/Signals.h" -#include "llvm-pdbdump.h" -#include "COMExtras.h" -#include "DIAExtras.h" -#include "DIASymbol.h" +#include using namespace llvm; -using namespace llvm::sys::windows; namespace opts { cl::list InputFilenames(cl::Positional, cl::desc(""), cl::OneOrMore); -cl::opt Streams("streams", cl::desc("Display data stream information")); -cl::alias StreamsShort("x", cl::desc("Alias for --streams"), - cl::aliasopt(Streams)); - -cl::opt StreamData("stream-data", - cl::desc("Dumps stream record data as bytes")); -cl::alias StreamDataShort("X", cl::desc("Alias for --stream-data"), - cl::aliasopt(StreamData)); - -cl::opt Tables("tables", - cl::desc("Display summary information for all of the " - "debug tables in the input file")); -cl::alias TablesShort("t", cl::desc("Alias for --tables"), - cl::aliasopt(Tables)); - -cl::opt SourceFiles("source-files", - cl::desc("Display a list of the source files " - "contained in the PDB")); -cl::alias SourceFilesShort("f", cl::desc("Alias for --source-files"), - cl::aliasopt(SourceFiles)); - cl::opt Compilands("compilands", cl::desc("Display a list of compilands (e.g. object " - "files) and their source file composition")); + "files) and symbols for each one.")); cl::alias CompilandsShort("c", cl::desc("Alias for --compilands"), cl::aliasopt(Compilands)); - -cl::opt Symbols("symbols", cl::desc("Display symbols")); -cl::alias SymbolsShort("s", cl::desc("Alias for --symbols"), - cl::aliasopt(Symbols)); - -cl::opt SymbolDetails("symbol-details", - cl::desc("Display symbol details")); -cl::alias SymbolDetailsShort("S", cl::desc("Alias for --symbol-details"), - cl::aliasopt(SymbolDetails)); -} - -template -static HRESULT getDIATable(IDiaSession *Session, TableType **Table) { - CComPtr EnumTables = nullptr; - HRESULT Error = S_OK; - if (FAILED(Error = Session->getEnumTables(&EnumTables))) - return Error; - - for (auto CurTable : make_com_enumerator(EnumTables)) { - TableType *ResultTable = nullptr; - if (FAILED(CurTable->QueryInterface( - __uuidof(TableType), reinterpret_cast(&ResultTable)))) - continue; - - *Table = ResultTable; - return S_OK; - } - return E_FAIL; -} - -static void dumpBasicFileInfo(StringRef Path, IDiaSession *Session) { - CComPtr GlobalScope; - HRESULT hr = Session->get_globalScope(&GlobalScope); - DIASymbol GlobalScopeSymbol(GlobalScope); - if (S_OK == hr) - GlobalScopeSymbol.getSymbolsFileName().dump("File", 0); - else - outs() << "File: " << Path << "\n"; - HANDLE FileHandle = ::CreateFile( - Path.data(), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr, - OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); - LARGE_INTEGER FileSize; - if (INVALID_HANDLE_VALUE != FileHandle) { - outs().indent(2); - if (::GetFileSizeEx(FileHandle, &FileSize)) - outs() << "Size: " << FileSize.QuadPart << " bytes\n"; - else - outs() << "Size: (Unable to obtain file size)\n"; - FILETIME ModifiedTime; - outs().indent(2); - if (::GetFileTime(FileHandle, nullptr, nullptr, &ModifiedTime)) { - ULARGE_INTEGER TimeInteger; - TimeInteger.LowPart = ModifiedTime.dwLowDateTime; - TimeInteger.HighPart = ModifiedTime.dwHighDateTime; - llvm::sys::TimeValue Time; - Time.fromWin32Time(TimeInteger.QuadPart); - outs() << "Timestamp: " << Time.str() << "\n"; - } else { - outs() << "Timestamp: (Unable to obtain time stamp)\n"; - } - ::CloseHandle(FileHandle); - } - - if (S_OK == hr) - GlobalScopeSymbol.fullDump(2); - outs() << "\n"; - outs().flush(); } -static void dumpDataStreams(IDiaSession *Session) { - CComPtr DebugStreams = nullptr; - if (FAILED(Session->getEnumDebugStreams(&DebugStreams))) - return; - - LONG Count = 0; - if (FAILED(DebugStreams->get_Count(&Count))) +static void dumpInput(StringRef Path) { + std::unique_ptr Session( + llvm::createPDBReader(PDB_ReaderType::DIA, Path)); + if (!Session) { + outs() << "Unable to create PDB reader. Check that a valid implementation"; + outs() << " is available for your platform."; return; - outs() << "Data Streams [count=" << Count << "]\n"; - - std::string Name8; - - for (auto Stream : make_com_enumerator(DebugStreams)) { - BSTR Name16; - if (FAILED(Stream->get_name(&Name16))) - continue; - if (BSTRToUTF8(Name16, Name8)) - outs() << " " << Name8; - ::SysFreeString(Name16); - if (FAILED(Stream->get_Count(&Count))) { - outs() << "\n"; - continue; - } - - outs() << " [" << Count << " records]\n"; - if (opts::StreamData) { - int RecordIndex = 0; - for (auto StreamRecord : make_com_data_record_enumerator(Stream)) { - outs() << " Record " << RecordIndex << " [" << StreamRecord.size() - << " bytes]"; - for (uint8_t byte : StreamRecord) { - outs() << " " << llvm::format_hex_no_prefix(byte, 2, true); - } - outs() << "\n"; - ++RecordIndex; - } - } } - outs() << "\n"; - outs().flush(); -} - -static void dumpDebugTables(IDiaSession *Session) { - CComPtr EnumTables = nullptr; - if (SUCCEEDED(Session->getEnumTables(&EnumTables))) { - LONG Count = 0; - if (FAILED(EnumTables->get_Count(&Count))) - return; - - outs() << "Debug Tables [count=" << Count << "]\n"; - std::string Name8; - for (auto Table : make_com_enumerator(EnumTables)) { - BSTR Name16; - if (FAILED(Table->get_name(&Name16))) - continue; - if (BSTRToUTF8(Name16, Name8)) - outs() << " " << Name8; - ::SysFreeString(Name16); - if (SUCCEEDED(Table->get_Count(&Count))) { - outs() << " [" << Count << " items]\n"; - } else - outs() << "\n"; - } - } - outs() << "\n"; - outs().flush(); -} - -static void dumpSourceFiles(IDiaSession *Session) { - CComPtr EnumSourceFileList; - if (FAILED(getDIATable(Session, &EnumSourceFileList))) - return; - - LONG SourceFileCount = 0; - EnumSourceFileList->get_Count(&SourceFileCount); - - outs() << "Dumping source files [" << SourceFileCount << " files]\n"; - for (auto SourceFile : make_com_enumerator(EnumSourceFileList)) { - CComBSTR SourceFileName; - if (S_OK != SourceFile->get_fileName(&SourceFileName)) - continue; - outs().indent(2); - std::string SourceFileName8; - BSTRToUTF8(SourceFileName, SourceFileName8); - outs() << SourceFileName8 << "\n"; - } - outs() << "\n"; + auto GlobalScope(Session->getGlobalScope()); + GlobalScope->dump(outs(), 0, PDB_DumpLevel::Normal); outs().flush(); -} - -static void dumpCompilands(IDiaSession *Session) { - CComPtr EnumSourceFileList; - if (FAILED(getDIATable(Session, &EnumSourceFileList))) - return; - - LONG SourceFileCount = 0; - EnumSourceFileList->get_Count(&SourceFileCount); - - CComPtr GlobalScope; - HRESULT hr = Session->get_globalScope(&GlobalScope); - DIASymbol GlobalScopeSymbol(GlobalScope); - if (S_OK != hr) - return; - - CComPtr EnumCompilands; - if (S_OK != - GlobalScope->findChildren(SymTagCompiland, nullptr, nsNone, - &EnumCompilands)) - return; - - LONG CompilandCount = 0; - EnumCompilands->get_Count(&CompilandCount); - outs() << "Dumping compilands [" << CompilandCount - << " compilands containing " << SourceFileCount << " source files]\n"; - - for (auto Compiland : make_com_enumerator(EnumCompilands)) { - DIASymbol CompilandSymbol(Compiland); - outs().indent(2); - outs() << CompilandSymbol.getName().value() << "\n"; - CComPtr EnumFiles; - if (S_OK != Session->findFile(Compiland, nullptr, nsNone, &EnumFiles)) - continue; - - for (auto SourceFile : make_com_enumerator(EnumFiles)) { - DWORD ChecksumType = 0; - DWORD ChecksumSize = 0; - std::vector Checksum; - outs().indent(4); - SourceFile->get_checksumType(&ChecksumType); - if (S_OK == SourceFile->get_checksum(0, &ChecksumSize, nullptr)) { - Checksum.resize(ChecksumSize); - if (S_OK == - SourceFile->get_checksum(ChecksumSize, &ChecksumSize, - &Checksum[0])) { - outs() << "[" << ((ChecksumType == HashMD5) ? "MD5 " : "SHA-1") - << ": "; - for (auto byte : Checksum) - outs() << format_hex_no_prefix(byte, 2, true); - outs() << "] "; - } + if (opts::Compilands) { + auto Compilands = GlobalScope->findChildren(PDB_SymType::Compiland); + if (Compilands) { + while (auto Compiland = Compilands->getNext()) { + Compiland->dump(outs(), 0, PDB_DumpLevel::Normal); } - CComBSTR SourceFileName; - if (S_OK != SourceFile->get_fileName(&SourceFileName)) - continue; - - std::string SourceFileName8; - BSTRToUTF8(SourceFileName, SourceFileName8); - outs() << SourceFileName8 << "\n"; } } - - outs() << "\n"; outs().flush(); } -static void dumpSymbols(IDiaSession *Session) { - CComPtr EnumSymbols; - if (FAILED(getDIATable(Session, &EnumSymbols))) - return; - - LONG SymbolCount = 0; - EnumSymbols->get_Count(&SymbolCount); - - outs() << "Dumping symbols [" << SymbolCount << " symbols]\n"; - int UnnamedSymbolCount = 0; - for (auto Symbol : make_com_enumerator(EnumSymbols)) { - DIASymbol SymbolSymbol(Symbol); - DIAResult SymbolName = SymbolSymbol.getName(); - if (!SymbolName.hasValue() || SymbolName.value().empty()) { - ++UnnamedSymbolCount; - outs() << " (Unnamed symbol)\n"; - } else { - outs() << " " << SymbolSymbol.getName().value() << "\n"; - } - if (opts::SymbolDetails) - SymbolSymbol.fullDump(4); - } - outs() << "(Found " << UnnamedSymbolCount << " unnamed symbols)\n"; - outs().flush(); -} - -static void dumpInput(StringRef Path) { - SmallVector Path16String; - llvm::convertUTF8ToUTF16String(Path, Path16String); - wchar_t *Path16 = reinterpret_cast(Path16String.data()); - CComPtr source; - HRESULT hr = - ::CoCreateInstance(CLSID_DiaSource, nullptr, CLSCTX_INPROC_SERVER, - __uuidof(IDiaDataSource), (void **)&source); - if (FAILED(hr)) - return; - if (FAILED(source->loadDataFromPdb(Path16))) - return; - CComPtr Session; - if (FAILED(source->openSession(&Session))) - return; - - dumpBasicFileInfo(Path, Session); - if (opts::Streams || opts::StreamData) { - dumpDataStreams(Session); - } - - if (opts::Tables) { - dumpDebugTables(Session); - } - - if (opts::SourceFiles) { - dumpSourceFiles(Session); - } - - if (opts::Compilands) { - dumpCompilands(Session); - } - - if (opts::Symbols || opts::SymbolDetails) { - dumpSymbols(Session); - } -} - int main(int argc_, const char *argv_[]) { // Print a stack trace if we signal out. sys::PrintStackTraceOnErrorSignal(); diff --git a/tools/llvm-pdbdump/llvm-pdbdump.h b/tools/llvm-pdbdump/llvm-pdbdump.h deleted file mode 100644 index e73289cc00d..00000000000 --- a/tools/llvm-pdbdump/llvm-pdbdump.h +++ /dev/null @@ -1,32 +0,0 @@ -//===- llvm-pdbdump.h - Common includes for llvm-pdbdump --------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// Common defines and header includes for all llvm-pdbdump. The definitions -// here configure the necessary #defines and include system headers in the -// proper order for using DIA. -//===----------------------------------------------------------------------===// - -#ifndef LLVM_TOOLS_LLVMPDBDUMP_LLVMPDBDUMP_H -#define LLVM_TOOLS_LLVMPDBDUMP_LLVMPDBDUMP_H - -#define NTDDI_VERSION NTDDI_VISTA -#define _WIN32_WINNT _WIN32_WINNT_VISTA -#define WINVER _WIN32_WINNT_VISTA -#ifndef NOMINMAX -#define NOMINMAX -#endif - -// atlbase.h has to come before windows.h -#include -#include - -// DIA headers must come after windows headers. -#include -#include - -#endif \ No newline at end of file diff --git a/unittests/DebugInfo/PDB/PDBApiTest.cpp b/unittests/DebugInfo/PDB/PDBApiTest.cpp index 5c9b377ba4b..fd65d10dfed 100644 --- a/unittests/DebugInfo/PDB/PDBApiTest.cpp +++ b/unittests/DebugInfo/PDB/PDBApiTest.cpp @@ -7,7 +7,6 @@ // //===----------------------------------------------------------------------===// -#include #include #include "llvm/DebugInfo/PDB/IPDBEnumChildren.h" @@ -51,16 +50,6 @@ #include "gtest/gtest.h" using namespace llvm; -namespace std { - template<> - struct hash { - public: - std::size_t operator()(PDB_SymType Symbol) const { - return std::hash()(static_cast(Symbol)); - } - }; -} - namespace { #define MOCK_SYMBOL_ACCESSOR(Func) \ @@ -82,17 +71,26 @@ class MockSession : public IPDBSession { getSourceFileById(uint32_t SymbolId) const override { return nullptr; } - std::unique_ptr getDebugStreams() const override { + std::unique_ptr getAllSourceFiles() const override { + return nullptr; + } + std::unique_ptr getSourceFilesForCompiland( + const PDBSymbolCompiland &Compiland) const override { return nullptr; } }; class MockRawSymbol : public IPDBRawSymbol { public: - MockRawSymbol(PDB_SymType SymType) : Type(SymType) {} + MockRawSymbol(const IPDBSession &PDBSession, PDB_SymType SymType) + : Session(PDBSession), Type(SymType) {} - void dump(llvm::raw_ostream &OS) const override {} + void dump(raw_ostream &OS, int Indent, PDB_DumpLevel Level) const override {} + std::unique_ptr + findChildren(PDB_SymType Type) const override { + return nullptr; + } std::unique_ptr findChildren(PDB_SymType Type, StringRef Name, PDB_NameSearchFlags Flags) const override { @@ -206,6 +204,7 @@ public: MOCK_SYMBOL_ACCESSOR(hasDebugInfo) MOCK_SYMBOL_ACCESSOR(hasEH) MOCK_SYMBOL_ACCESSOR(hasEHa) + MOCK_SYMBOL_ACCESSOR(hasFramePointer) MOCK_SYMBOL_ACCESSOR(hasInlAsm) MOCK_SYMBOL_ACCESSOR(hasInlineAttribute) MOCK_SYMBOL_ACCESSOR(hasInterruptReturn) @@ -270,6 +269,7 @@ public: MOCK_SYMBOL_ACCESSOR(isVolatileType) private: + const IPDBSession &Session; PDB_SymType Type; }; @@ -334,7 +334,7 @@ private: std::unique_ptr Session; void InsertItemWithTag(PDB_SymType Tag) { - auto RawSymbol = std::unique_ptr(new MockRawSymbol(Tag)); + auto RawSymbol = std::make_unique(*Session, Tag); auto Symbol = PDBSymbol::create(*Session, std::move(RawSymbol)); SymbolMap.insert(std::make_pair(Tag, std::move(Symbol))); } -- 2.34.1