Index: include/llvm/DebugInfo/PDB/IPDBDataStream.h =================================================================== --- /dev/null +++ include/llvm/DebugInfo/PDB/IPDBDataStream.h @@ -0,0 +1,35 @@ +//===- IPDBDataStream.h - base interface for child enumerator -*- 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_IPDBDATASTREAM_H +#define LLVM_DEBUGINFO_PDB_IPDBDATASTREAM_H + +#include "llvm/ADT/SmallVector.h" +#include "llvm/ADT/Optional.h" + +#include "PDBTypes.h" + +namespace llvm { + +class IPDBDataStream { +public: + typedef llvm::SmallVector RecordType; + + virtual ~IPDBDataStream(); + + virtual uint32_t getRecordCount() const = 0; + virtual std::string getName() const = 0; + virtual llvm::Optional getItemAtIndex(uint32_t Index) const = 0; + virtual bool getNext(RecordType &Record) = 0; + virtual void reset() = 0; + virtual std::unique_ptr clone() const = 0; +}; +} + +#endif Index: include/llvm/DebugInfo/PDB/IPDBEnumChildren.h =================================================================== --- /dev/null +++ include/llvm/DebugInfo/PDB/IPDBEnumChildren.h @@ -0,0 +1,32 @@ +//===- IPDBEnumChildren.h - base interface for child enumerator -*- 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_IPDBENUMCHILDREN_H +#define LLVM_DEBUGINFO_PDB_IPDBENUMCHILDREN_H + +#include "PDBTypes.h" + +namespace llvm { + +template class IPDBEnumChildren { +public: + typedef std::unique_ptr ChildTypePtr; + typedef std::unique_ptr> MyTypePtr; + + virtual ~IPDBEnumChildren() {} + + virtual uint32_t getChildCount() const = 0; + virtual ChildTypePtr getChildAtIndex(uint32_t Index) const = 0; + virtual ChildTypePtr getNext() = 0; + virtual void reset() = 0; + virtual MyTypePtr clone() const = 0; +}; +} + +#endif Index: include/llvm/DebugInfo/PDB/IPDBLineNumber.h =================================================================== --- /dev/null +++ include/llvm/DebugInfo/PDB/IPDBLineNumber.h @@ -0,0 +1,36 @@ +//===- IPDBLineNumber.h - base interface for PDB line no. info ---*- 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_IPDBLINENUMBER_H +#define LLVM_DEBUGINFO_PDB_IPDBLINENUMBER_H + +#include "PDBTypes.h" + +namespace llvm { + +class IPDBLineNumber { +public: + virtual ~IPDBLineNumber(); + + virtual uint32_t getLineNumber() const = 0; + virtual uint32_t getLineNumberEnd() const = 0; + virtual uint32_t getColumnNumber() const = 0; + virtual uint32_t getColumnNumberEnd() const = 0; + virtual uint32_t getAddressSection() const = 0; + virtual uint32_t getAddressOffset() const = 0; + virtual uint32_t getRelativeVirtualAddress() const = 0; + virtual uint64_t getVirtualAddress() const = 0; + virtual uint32_t getLength() const = 0; + virtual uint32_t getSourceFileId() const = 0; + virtual uint32_t getCompilandId() const = 0; + virtual bool isStatement() const = 0; +}; +} + +#endif Index: include/llvm/DebugInfo/PDB/IPDBRawSymbol.h =================================================================== --- /dev/null +++ include/llvm/DebugInfo/PDB/IPDBRawSymbol.h @@ -0,0 +1,198 @@ +//===- IPDBRawSymbol.h - base interface for PDB symbol types ----*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_IPDBRAWSYMBOL_H +#define LLVM_DEBUGINFO_PDB_IPDBRAWSYMBOL_H + +#include + +#include "llvm/ADT/StringRef.h" +#include "llvm/Support/COFF.h" +#include "PDBTypes.h" + +namespace llvm { + +class IPDBRawSymbol { +public: + virtual ~IPDBRawSymbol(); + + virtual std::unique_ptr + findChildren(PDB_SymType Type, StringRef Name, + PDB_NameSearchFlags Flags) const = 0; + virtual std::unique_ptr + findChildrenByRVA(PDB_SymType Type, StringRef Name, PDB_NameSearchFlags Flags, + uint32_t RVA) const = 0; + virtual std::unique_ptr + findInlineFramesByRVA(uint32_t RVA) const = 0; + + virtual PDB_MemberAccess getAccess() const = 0; + virtual uint32_t getAddressOffset() const = 0; + virtual uint32_t getAddressSection() const = 0; + virtual uint32_t getAge() const = 0; + virtual uint32_t getArrayIndexTypeId() const = 0; + virtual uint32_t getBackEndBuild() const = 0; + virtual uint32_t getBackEndMajor() const = 0; + virtual uint32_t getBackEndMinor() const = 0; + virtual uint32_t getBaseDataOffset() const = 0; + virtual uint32_t getBaseDataSlot() const = 0; + virtual uint32_t getBaseSymbolId() const = 0; + virtual PDB_BuiltinType getBuiltinType() const = 0; + virtual uint32_t getBitPosition() const = 0; + virtual PDB_CallingConv getCallingConvention() const = 0; + virtual uint32_t getClassParentId() const = 0; + virtual std::string getCompilerName() const = 0; + virtual uint32_t getCount() const = 0; + virtual uint32_t getCountLiveRanges() const = 0; + virtual uint32_t getFrontEndBuild() const = 0; + virtual uint32_t getFrontEndMajor() const = 0; + virtual uint32_t getFrontEndMinor() const = 0; + virtual PDB_Lang getLanguage() const = 0; + virtual uint32_t getLexicalParentId() const = 0; + virtual std::string getLibraryName() const = 0; + 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 uint32_t getLowerBoundId() const = 0; + virtual uint32_t getMemorySpaceKind() const = 0; + virtual std::string getName() const = 0; + virtual uint32_t getNumberOfAcceleratorPointerTags() const = 0; + virtual uint32_t getNumberOfColumns() const = 0; + virtual uint32_t getNumberOfModifiers() const = 0; + virtual uint32_t getNumberOfRegisterIndices() const = 0; + virtual uint32_t getNumberOfRows() const = 0; + virtual std::string getObjectFileName() const = 0; + virtual uint32_t getOemSymbolId() const = 0; + 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 uint32_t getRegisterType() const = 0; + virtual uint32_t getRelativeVirtualAddress() const = 0; + virtual uint32_t getSamplerSlot() const = 0; + virtual uint32_t getSignature() const = 0; + virtual uint32_t getSizeInUdt() const = 0; + virtual uint32_t getSlot() const = 0; + virtual std::string getSourceFileName() const = 0; + virtual uint32_t getStride() const = 0; + virtual uint32_t getSubTypeId() const = 0; + virtual std::string getSymbolsFileName() const = 0; + virtual uint32_t getSymIndexId() const = 0; + virtual uint32_t getTargetOffset() const = 0; + virtual uint32_t getTargetRelativeVirtualAddress() const = 0; + virtual uint32_t getTargetSection() const = 0; + virtual uint32_t getTextureSlot() const = 0; + virtual uint32_t getTimeStamp() const = 0; + virtual uint32_t getToken() const = 0; + virtual uint32_t getTypeId() const = 0; + virtual uint32_t getUavSlot() const = 0; + virtual std::string getUndecoratedName() const = 0; + virtual uint32_t getUnmodifiedTypeId() const = 0; + virtual uint32_t getUpperBoundId() const = 0; + virtual uint32_t getVirtualBaseDispIndex() const = 0; + virtual uint32_t getVirtualBaseOffset() const = 0; + virtual uint32_t getVirtualTableShapeId() const = 0; + virtual PDB_DataKind getDataKind() const = 0; + virtual PDB_SymType getSymTag() const = 0; + virtual PDB_UniqueId getGuid() const = 0; + virtual int32_t getOffset() const = 0; + virtual int32_t getThisAdjust() const = 0; + virtual int32_t getVirtualBasePointerOffset() const = 0; + virtual PDB_LocType getLocationType() const = 0; + virtual COFF::MachineTypes getMachineType() const = 0; + virtual PDB_ThunkOrdinal getThunkOrdinal() const = 0; + virtual uint64_t getLength() const = 0; + virtual uint64_t getLiveRangeLength() const = 0; + virtual uint64_t getTargetVirtualAddress() const = 0; + virtual uint64_t getVirtualAddress() const = 0; + virtual PDB_UdtType getUdtKind() const = 0; + virtual bool hasConstructor() const = 0; + virtual bool hasCustomCallingConvention() const = 0; + virtual bool hasFarReturn() const = 0; + virtual bool isCode() const = 0; + virtual bool isCompilerGenerated() const = 0; + virtual bool isConstType() const = 0; + virtual bool isEditAndContinueEnabled() const = 0; + virtual bool isFunction() const = 0; + virtual bool getAddressTaken() const = 0; + virtual bool getNoStackOrdering() const = 0; + virtual bool hasAlloca() const = 0; + virtual bool hasAssignmentOperator() const = 0; + virtual bool hasCTypes() const = 0; + virtual bool hasCastOperator() const = 0; + virtual bool hasDebugInfo() const = 0; + virtual bool hasEH() const = 0; + virtual bool hasEHa() const = 0; + virtual bool hasInlAsm() const = 0; + virtual bool hasInlineAttribute() const = 0; + virtual bool hasInterruptReturn() const = 0; + virtual bool hasLongJump() const = 0; + virtual bool hasManagedCode() const = 0; + virtual bool hasNestedTypes() const = 0; + virtual bool hasNoInlineAttribute() const = 0; + virtual bool hasNoReturnAttribute() const = 0; + virtual bool hasOptimizedCodeDebugInfo() const = 0; + virtual bool hasOverloadedOperator() const = 0; + virtual bool hasSEH() const = 0; + virtual bool hasSecurityChecks() const = 0; + virtual bool hasSetJump() const = 0; + virtual bool hasStrictGSCheck() const = 0; + virtual bool isAcceleratorGroupSharedLocal() const = 0; + virtual bool isAcceleratorPointerTagLiveRange() const = 0; + virtual bool isAcceleratorStubFunction() const = 0; + virtual bool isAggregated() const = 0; + virtual bool isIntroVirtualFunction() const = 0; + virtual bool isCVTCIL() const = 0; + virtual bool isConstructorVirtualBase() const = 0; + virtual bool isCxxReturnUdt() const = 0; + virtual bool isDataAligned() const = 0; + virtual bool isHLSLData() const = 0; + virtual bool isHotpatchable() const = 0; + virtual bool isIndirectVirtualBaseClass() const = 0; + virtual bool isInterfaceUdt() const = 0; + virtual bool isIntrinsic() const = 0; + virtual bool isLTCG() const = 0; + virtual bool isLocationControlFlowDependent() const = 0; + virtual bool isMSILNetmodule() const = 0; + virtual bool isManagedRef() const = 0; + virtual bool isMatrixRowMajor() const = 0; + virtual bool isMsilRef() const = 0; + virtual bool isMultipleInheritance() const = 0; + virtual bool isNaked() const = 0; + virtual bool isNested() const = 0; + virtual bool isOptimizedAway() const = 0; + virtual bool isPacked() const = 0; + virtual bool isPointerBasedOnSymbolValue() const = 0; + virtual bool isPointerToDataMember() const = 0; + virtual bool isPointerToMemberFunction() const = 0; + virtual bool isPureVirtual() const = 0; + virtual bool isRValueReference() const = 0; + virtual bool isRefUdt() const = 0; + virtual bool isReference() const = 0; + virtual bool isRestrictedType() const = 0; + virtual bool isReturnValue() const = 0; + virtual bool isSafeBuffers() const = 0; + virtual bool isScoped() const = 0; + virtual bool isSdl() const = 0; + virtual bool isSingleInheritance() const = 0; + virtual bool isSplitted() const = 0; + virtual bool isStatic() const = 0; + virtual bool hasPrivateSymbols() const = 0; + virtual bool isUnalignedType() const = 0; + virtual bool isUnreached() const = 0; + virtual bool isValueUdt() const = 0; + virtual bool isVirtual() const = 0; + virtual bool isVirtualBaseClass() const = 0; + virtual bool isVirtualInheritance() const = 0; + virtual bool isVolatileType() const = 0; +}; + +} // namespace llvm + +#endif Index: include/llvm/DebugInfo/PDB/IPDBSession.h =================================================================== --- /dev/null +++ include/llvm/DebugInfo/PDB/IPDBSession.h @@ -0,0 +1,34 @@ +//===- IPDBSession.h - base interface for a PDB symbol context --*- 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_IPDBSESSION_H +#define LLVM_DEBUGINFO_PDB_IPDBSESSION_H + +#include + +#include "PDBTypes.h" +#include "PDBSymbolExe.h" + +namespace llvm { + +class IPDBSession { +public: + virtual ~IPDBSession(); + + virtual uint64_t getLoadAddress() const = 0; + virtual void setLoadAddress(uint64_t Address) = 0; + virtual std::unique_ptr getGlobalScope() const = 0; + virtual std::unique_ptr getSymbolById() const = 0; + virtual std::unique_ptr getSourceFileById() const = 0; + + virtual std::unique_ptr getDebugStreams() const = 0; +}; +} + +#endif Index: include/llvm/DebugInfo/PDB/IPDBSourceFile.h =================================================================== --- /dev/null +++ include/llvm/DebugInfo/PDB/IPDBSourceFile.h @@ -0,0 +1,31 @@ +//===- IPDBSourceFile.h - 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. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_IPDBSOURCEFILE_H +#define LLVM_DEBUGINFO_PDB_IPDBSOURCEFILE_H + +#include + +#include "PDBTypes.h" + +namespace llvm { + +class IPDBSourceFile { +public: + virtual ~IPDBSourceFile(); + + virtual std::string getFileName() const = 0; + virtual uint32_t getUniqueId() const = 0; + virtual std::string getChecksum() const = 0; + virtual PDB_Checksum getChecksumType() const = 0; + virtual std::unique_ptr getCompilands() const = 0; +}; +} + +#endif \ No newline at end of file Index: include/llvm/DebugInfo/PDB/PDB.h =================================================================== --- /dev/null +++ include/llvm/DebugInfo/PDB/PDB.h @@ -0,0 +1,24 @@ +//===- PDB.h - base header file for creating a PDB reader -------*- 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_PDB_H +#define LLVM_DEBUGINFO_PDB_PDB_H + +#include + +#include "PDBTypes.h" + +namespace llvm { +class StringRef; + +std::unique_ptr createPDBReader(PDB_ReaderType Type, + StringRef Path); +} + +#endif Index: include/llvm/DebugInfo/PDB/PDBSymbol.h =================================================================== --- /dev/null +++ include/llvm/DebugInfo/PDB/PDBSymbol.h @@ -0,0 +1,51 @@ +//===- PDBSymbol.h - base class for user-facing symbol types -----*- C++-*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_IPDBSYMBOL_H +#define LLVM_DEBUGINFO_PDB_IPDBSYMBOL_H + +#include + +#include "llvm/ADT/StringRef.h" +#include "llvm/Support/Casting.h" + +#include "PDBTypes.h" + +namespace llvm { + +class IPDBRawSymbol; + +/// PDBSymbol defines the base of the inheritance hierarchy for concrete symbol +/// types (e.g. functions, executables, vtables, etc). +class PDBSymbol { +public: + PDBSymbol(std::unique_ptr Symbol); + virtual ~PDBSymbol(); + + PDB_SymType getSymTag() const; + + IPDBRawSymbol *getRawSymbol(); + const IPDBRawSymbol *getRawSymbol() const; + + std::unique_ptr + findChildren(PDB_SymType Type, StringRef Name, + PDB_NameSearchFlags Flags) const; + std::unique_ptr findChildrenByRVA(PDB_SymType Type, + StringRef Name, + PDB_NameSearchFlags Flags, + uint32_t RVA) const; + std::unique_ptr findInlineFramesByRVA(uint32_t RVA) const; + +protected: + std::unique_ptr RawSymbol; +}; + +} // namespace llvm + +#endif Index: include/llvm/DebugInfo/PDB/PDBSymbolExe.h =================================================================== --- /dev/null +++ include/llvm/DebugInfo/PDB/PDBSymbolExe.h @@ -0,0 +1,41 @@ +//===- PDBSymbolExe.h - Accessors for querying executables in a PDB ----*-===// +// +// 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_PDBSYMBOLEXE_H +#define LLVM_DEBUGINFO_PDB_PDBSYMBOLEXE_H + +#include + +#include "llvm/Support/COFF.h" + +#include "PDBSymbol.h" +#include "PDBTypes.h" + +namespace llvm { + +class PDBSymbolExe : public PDBSymbol { +public: + PDBSymbolExe(std::unique_ptr ExeSymbol); + + uint32_t getAge(); + PDB_UniqueId getGuid(); + bool hasCTypes(); + bool hasPrivateSymbols(); + COFF::MachineTypes getMachineType(); + std::string getName(); + uint32_t getSignature(); + std::string getSymbolsFileName(); + uint32_t getSymIndexId(); + + static bool classof(const PDBSymbol *S) { + return S->getSymTag() == PDB_SymType::Exe; + } +}; +} + +#endif Index: include/llvm/DebugInfo/PDB/PDBSymbolFunc.h =================================================================== --- /dev/null +++ include/llvm/DebugInfo/PDB/PDBSymbolFunc.h @@ -0,0 +1,70 @@ +//===- PDBFunction.h - class representing a function instance ---*- 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_PDBSYMBOLFUNC_H +#define LLVM_DEBUGINFO_PDB_PDBSYMBOLFUNC_H + +#include "PDBSymbol.h" +#include "PDBTypes.h" + +namespace llvm { + +class PDBFunction : public PDBSymbol { +public: + PDBFunction(std::unique_ptr FuncSymbol); + + PDB_MemberAccess getAccess(); + uint32_t getAddressOffset(); + uint32_t getAddressSection(); + uint32_t getClassParentId(); + bool isConstType(); + bool hasCustomCallingConvention(); + bool hasFarReturn(); + bool hasAlloca(); + bool hasEH(); + bool hasEHa(); + bool hasInlAsm(); + bool hasLongJump(); + bool hasSEH(); + bool hasSecurityChecks(); + bool hasSetJump(); + bool hasInterruptReturn(); + bool isIntroVirtualFunction(); + bool hasInlineAttribute(); + bool isNaked(); + bool isStatic(); + uint64_t getLength(); + uint32_t getLexicalParentId(); + PDB_LocType getLocationType(); + std::string getName(); + bool hasNoInlineAttribute(); + bool hasNoReturnAttribute(); + bool isUnreached(); + bool getNoStackOrdering(); + bool hasOptimizedCodeDebugInfo(); + bool isPureVirtual(); + uint32_t getRelativeVirtualAddress(); + uint32_t getSymIndexId(); + uint32_t getToken(); + uint32_t getTypeId(); + bool isUnalignedType(); + std::string getUndecoratedName(); + bool isVirtual(); + uint64_t getVirtualAddress(); + uint32_t getVirtualBaseOffset(); + bool isVolatileType(); + + static bool classof(const PDBSymbol *S) { + return S->getSymTag() == PDB_SymType::Function; + } +}; + +}; // namespace llvm + +#endif // LLVM_DEBUGINFO_PDB_PDBFUNCTION_H Index: include/llvm/DebugInfo/PDB/PDBTypes.h =================================================================== --- /dev/null +++ include/llvm/DebugInfo/PDB/PDBTypes.h @@ -0,0 +1,321 @@ +//===- PDBTypes.h - Defines enums for various fields contained in PDB ---*-===// +// +// 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_PDBTYPES_H +#define LLVM_DEBUGINFO_PDB_PDBTYPES_H + +namespace llvm { + +class IPDBDataStream; +template class IPDBEnumChildren; +class IPDBRawSymbol; +class IPDBSession; +class IPDBSourceFile; + +typedef IPDBEnumChildren IPDBEnumSymbols; +typedef IPDBEnumChildren IPDBEnumSourceFiles; +typedef IPDBEnumChildren IPDBEnumDataStreams; + +class PDBFunction; +class PDBExecutable; + +/// Specifies which PDB reader implementation is to be used. Only a value +/// of PDB_ReaderType::DIA is supported. +enum class PDB_ReaderType { + SystemDefault = 0, +#if defined(_MSC_VER) + DIA = 1, +#endif +}; + +/// 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. +struct PDB_UniqueId { + uint64_t HighPart; + uint64_t LowPart; +}; + +/// An enumeration indicating the type of data contained in this table. +enum class PDB_TableType { + Symbols, + SourceFiles, + LineNumbers, + SectionContribs, + Segments, + InjectedSources, + FrameData +}; + +/// Defines flags used for enumerating child symbols. This corresponds to the +/// NameSearchOptions enumeration which is documented here: +/// https://msdn.microsoft.com/en-us/library/yat28ads.aspx +enum PDB_NameSearchFlags { + NS_Default = 0x0, + NS_CaseSensitive = 0x1, + NS_CaseInsensitive = 0x2, + NS_FileNameExtMatch = 0x4, + NS_Regex = 0x8, + NS_UndecoratedName = 0x10 +}; + +/// Specifies the hash algorithm that a source file from a PDB was hashed with. +/// This corresponds to the CV_SourceChksum_t enumeration and are documented +/// here: https://msdn.microsoft.com/en-us/library/e96az21x.aspx +enum class PDB_Checksum { None = 0, MD5 = 1, SHA1 = 2 }; + +/// These values correspond to the CV_CPU_TYPE_e enumeration, and are documented +/// here: https://msdn.microsoft.com/en-us/library/b2fc64ek.aspx +enum class PDB_Cpu { + Intel8080 = 0x0, + Intel8086 = 0x1, + Intel80286 = 0x2, + Intel80386 = 0x3, + Intel80486 = 0x4, + Pentium = 0x5, + PentiumPro = 0x6, + Pentium3 = 0x7, + MIPS = 0x10, + MIPS16 = 0x11, + MIPS32 = 0x12, + MIPS64 = 0x13, + MIPSI = 0x14, + MIPSII = 0x15, + MIPSIII = 0x16, + MIPSIV = 0x17, + MIPSV = 0x18, + M68000 = 0x20, + M68010 = 0x21, + M68020 = 0x22, + M68030 = 0x23, + M68040 = 0x24, + Alpha = 0x30, + Alpha21164 = 0x31, + Alpha21164A = 0x32, + Alpha21264 = 0x33, + Alpha21364 = 0x34, + PPC601 = 0x40, + PPC603 = 0x41, + PPC604 = 0x42, + PPC620 = 0x43, + PPCFP = 0x44, + PPCBE = 0x45, + SH3 = 0x50, + SH3E = 0x51, + SH3DSP = 0x52, + SH4 = 0x53, + SHMedia = 0x54, + ARM3 = 0x60, + ARM4 = 0x61, + ARM4T = 0x62, + ARM5 = 0x63, + ARM5T = 0x64, + ARM6 = 0x65, + ARM_XMAC = 0x66, + ARM_WMMX = 0x67, + ARM7 = 0x68, + Omni = 0x70, + Ia64 = 0x80, + Ia64_2 = 0x81, + CEE = 0x90, + AM33 = 0xa0, + M32R = 0xb0, + TriCore = 0xc0, + X64 = 0xd0, + EBC = 0xe0, + Thumb = 0xf0, + ARMNT = 0xf4, + D3D11_Shader = 0x100, +}; + +/// These values correspond to the CV_call_e enumeration, and are documented +/// at the following locations: +/// https://msdn.microsoft.com/en-us/library/b2fc64ek.aspx +/// https://msdn.microsoft.com/en-us/library/windows/desktop/ms680207(v=vs.85).aspx +/// +enum class PDB_CallingConv { + NearCdecl = 0x00, + FarCdecl = 0x01, + NearPascal = 0x02, + FarPascal = 0x03, + NearFastcall = 0x04, + FarFastcall = 0x05, + Skipped = 0x06, + NearStdcall = 0x07, + FarStdcall = 0x08, + NearSyscall = 0x09, + FarSyscall = 0x0a, + Thiscall = 0x0b, + MipsCall = 0x0c, + Generic = 0x0d, + Alphacall = 0x0e, + Ppccall = 0x0f, + SuperHCall = 0x10, + Armcall = 0x11, + AM33call = 0x12, + Tricall = 0x13, + Sh5call = 0x14, + M32R = 0x15, + Clrcall = 0x16, + Inline = 0x17, + NearVectorcall = 0x18, + Reserved = 0x19, +}; + +/// These values correspond to the CV_CFL_LANG enumeration, and are documented +/// here: https://msdn.microsoft.com/en-us/library/bw3aekw6.aspx +enum class PDB_Lang { + C = 0x00, + Cpp = 0x01, + Fortran = 0x02, + Masm = 0x03, + Pascal = 0x04, + Basic = 0x05, + Cobol = 0x06, + Link = 0x07, + Cvtres = 0x08, + Cvtpgd = 0x09, + CSharp = 0x0a, + VB = 0x0b, + ILAsm = 0x0c, + Java = 0x0d, + JScript = 0x0e, + MSIL = 0x0f, + HLSL = 0x10 +}; + +/// These values correspond to the DataKind enumeration, and are documented +/// here: https://msdn.microsoft.com/en-us/library/b2x2t313.aspx +enum class PDB_DataKind { + Unknown, + Local, + StaticLocal, + Param, + ObjectPtr, + FileStatic, + Global, + Member, + StaticMember, + Constant +}; + +/// These values correspond to the SymTagEnum enumeration, and are documented +/// here: https://msdn.microsoft.com/en-us/library/bkedss5f.aspx +enum class PDB_SymType { + None, + Exe, + Compiland, + CompilandDetails, + CompilandEnv, + Function, + Block, + Data, + Annotation, + Label, + PublicSymbol, + UDT, + Enum, + FunctionSig, + PointerType, + ArrayType, + BuiltinType, + Typedef, + BaseClass, + Friend, + FunctionArg, + FuncDebugStart, + FuncDebugEnd, + UsingNamespace, + VTableShape, + VTable, + Custom, + Thunk, + CustomType, + ManagedType, + Dimension, + CallSite, + InlineSite, + BaseInterface, + VectorType, + MatrixType, + HLSLType, + Caller, + Callee, + Max +}; + +/// These values correspond to the LocationType enumeration, and are documented +/// here: https://msdn.microsoft.com/en-us/library/f57kaez3.aspx +enum class PDB_LocType { + Null, + Static, + TLS, + RegRel, + ThisRel, + Enregistered, + BitField, + Slot, + IlRel, + MetaData, + Constant, + Max +}; + +/// These values correspond to the THUNK_ORDINAL enumeration, and are documented +/// here: https://msdn.microsoft.com/en-us/library/dh0k8hft.aspx +enum class PDB_ThunkOrdinal { + Standard, + ThisAdjustor, + Vcall, + Pcode, + UnknownLoad, + TrampIncremental, + BranchIsland +}; + +/// These values correspond to the UdtKind enumeration, and are documented +/// here: https://msdn.microsoft.com/en-us/library/wcstk66t.aspx +enum class PDB_UdtType { Struct, Class, Union, Interface }; + +/// These values correspond to the StackFrameTypeEnum enumeration, and are +/// documented here: https://msdn.microsoft.com/en-us/library/bc5207xw.aspx. +enum class PDB_StackFrameType { FPO, KernelTrap, KernelTSS, EBP, FrameData }; + +/// These values correspond to the StackFrameTypeEnum enumeration, and are +/// documented here: https://msdn.microsoft.com/en-us/library/bc5207xw.aspx. +enum class PDB_MemoryType { Code, Data, Stack, HeapCode }; + +/// These values correspond to the Basictype enumeration, and are documented +/// here: https://msdn.microsoft.com/en-us/library/4szdtzc3.aspx +enum class PDB_BuiltinType { + None = 0, + Void = 1, + Char = 2, + WCharT = 3, + Int = 6, + UInt = 7, + Float = 8, + BCD = 9, + Bool = 10, + Long = 13, + ULong = 14, + Currency = 25, + Date = 26, + Variant = 27, + Complex = 28, + Bitfield = 29, + BSTR = 30, + HResult = 31 +}; + +enum class PDB_MemberAccess { Private = 1, Protected = 2, Public = 3 }; + +} // namespace llvm + +#endif Index: lib/DebugInfo/CMakeLists.txt =================================================================== --- lib/DebugInfo/CMakeLists.txt +++ lib/DebugInfo/CMakeLists.txt @@ -1,2 +1,5 @@ -add_subdirectory(DWARF) \ No newline at end of file +add_subdirectory(DWARF) +if (MSVC) + add_subdirectory(PDB) +endif() \ No newline at end of file Index: lib/DebugInfo/LLVMBuild.txt =================================================================== --- lib/DebugInfo/LLVMBuild.txt +++ lib/DebugInfo/LLVMBuild.txt @@ -16,7 +16,7 @@ ;===------------------------------------------------------------------------===; [common] -subdirectories = DWARF +subdirectories = DWARF PDB [component_0] type = Group Index: lib/DebugInfo/PDB/CMakeLists.txt =================================================================== --- /dev/null +++ lib/DebugInfo/PDB/CMakeLists.txt @@ -0,0 +1,34 @@ + +if(MSVC AND NOT(MSVC_VERSION LESS 1800)) + set(MSVC_DIA_SDK_DIR "$ENV{VSINSTALLDIR}DIA SDK") + + # 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}) + 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() + set(LIBPDB_ADDITIONAL_LIBRARIES "diaguids") + endif() +endif() + +add_llvm_library(LLVMDebugInfoPDB + PDB.cpp + PDBInterfaceAnchors.cpp + PDBSymbol.cpp + PDBSymbolExe.cpp + PDBSymbolFunc.cpp + ) + +target_link_libraries(LLVMDebugInfoPDB INTERFACE "${LIBPDB_ADDITIONAL_LIBRARIES}") +set(LLVM_LINK_COMPONENTS + Support + ) Index: lib/DebugInfo/PDB/LLVMBuild.txt =================================================================== --- /dev/null +++ lib/DebugInfo/PDB/LLVMBuild.txt @@ -0,0 +1,23 @@ +;===- ./lib/DebugInfo/PDB/LLVMBuild.txt ------------------------*- Conf -*--===; +; +; The LLVM Compiler Infrastructure +; +; This file is distributed under the University of Illinois Open Source +; License. See LICENSE.TXT for details. +; +;===------------------------------------------------------------------------===; +; +; This is an LLVMBuild description file for the components in this subdirectory. +; +; For more information on the LLVMBuild system, please see: +; +; http://llvm.org/docs/LLVMBuild.html +; +;===------------------------------------------------------------------------===; + +[component_0] +type = Library +name = DebugInfoPDB +parent = DebugInfo +required_libraries = Support + Index: lib/DebugInfo/PDB/PDB.cpp =================================================================== --- /dev/null +++ lib/DebugInfo/PDB/PDB.cpp @@ -0,0 +1,21 @@ +//===- PDB.cpp - base header file for creating a PDB reader -----*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "llvm/ADT/StringRef.h" + +#include "llvm/DebugInfo/PDB/PDB.h" +#include "llvm/DebugInfo/PDB/IPDBSession.h" + +using namespace llvm; + +std::unique_ptr llvm::createPDBReader(PDB_ReaderType Type, + StringRef Path) { + // Create the correct concrete instance type based on the value of Type. + return std::unique_ptr(); +} Index: lib/DebugInfo/PDB/PDBInterfaceAnchors.cpp =================================================================== --- /dev/null +++ lib/DebugInfo/PDB/PDBInterfaceAnchors.cpp @@ -0,0 +1,30 @@ +//===- PDBInterfaceAnchors.h - defines class anchor funcions ----*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// Class anchors are necessary per the LLVM Coding style guide, to ensure that +// the vtable is only generated in this object file, and not in every object +// file that incldues the corresponding header. +//===----------------------------------------------------------------------===// + +#include "llvm/DebugInfo/PDB/IPDBDataStream.h" +#include "llvm/DebugInfo/PDB/IPDBLineNumber.h" +#include "llvm/DebugInfo/PDB/IPDBSession.h" +#include "llvm/DebugInfo/PDB/IPDBSourceFile.h" +#include "llvm/DebugInfo/PDB/IPDBRawSymbol.h" + +using namespace llvm; + +IPDBSession::~IPDBSession() {} + +IPDBDataStream::~IPDBDataStream() {} + +IPDBRawSymbol::~IPDBRawSymbol() {} + +IPDBSourceFile::~IPDBSourceFile() {} + +IPDBLineNumber::~IPDBLineNumber() {} Index: lib/DebugInfo/PDB/PDBSymbol.cpp =================================================================== --- /dev/null +++ lib/DebugInfo/PDB/PDBSymbol.cpp @@ -0,0 +1,45 @@ +//===- PDBSymbol.cpp - base class for user-facing symbol types --*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include +#include + +#include "llvm/DebugInfo/PDB/IPDBEnumChildren.h" +#include "llvm/DebugInfo/PDB/IPDBRawSymbol.h" +#include "llvm/DebugInfo/PDB/PDBSymbol.h" + +using namespace llvm; + +PDBSymbol::PDBSymbol(std::unique_ptr Symbol) + : RawSymbol(std::move(Symbol)) {} + +PDBSymbol::~PDBSymbol() {} + +PDB_SymType PDBSymbol::getSymTag() const { return RawSymbol->getSymTag(); } + +IPDBRawSymbol *PDBSymbol::getRawSymbol() { return RawSymbol.get(); } + +const IPDBRawSymbol *PDBSymbol::getRawSymbol() const { return RawSymbol.get(); } + +std::unique_ptr +PDBSymbol::findChildren(PDB_SymType Type, StringRef Name, + PDB_NameSearchFlags Flags) const { + return RawSymbol->findChildren(Type, Name, Flags); +} + +std::unique_ptr +PDBSymbol::findChildrenByRVA(PDB_SymType Type, StringRef Name, + PDB_NameSearchFlags Flags, uint32_t RVA) const { + return RawSymbol->findChildrenByRVA(Type, Name, Flags, RVA); +} + +std::unique_ptr +PDBSymbol::findInlineFramesByRVA(uint32_t RVA) const { + return RawSymbol->findInlineFramesByRVA(RVA); +} Index: lib/DebugInfo/PDB/PDBSymbolExe.cpp =================================================================== --- /dev/null +++ lib/DebugInfo/PDB/PDBSymbolExe.cpp @@ -0,0 +1,43 @@ +//===- PDBSymbolExe.cpp - Accessors for querying executables in a PDB ---*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include + +#include "llvm/DebugInfo/PDB/IPDBRawSymbol.h" +#include "llvm/DebugInfo/PDB/PDBSymbol.h" +#include "llvm/DebugInfo/PDB/PDBSymbolExe.h" + +using namespace llvm; + +PDBSymbolExe::PDBSymbolExe(std::unique_ptr ExeSymbol) + : PDBSymbol(std::move(ExeSymbol)) {} + +uint32_t PDBSymbolExe::getAge() { return RawSymbol->getAge(); } + +PDB_UniqueId PDBSymbolExe::getGuid() { return RawSymbol->getGuid(); } + +bool PDBSymbolExe::hasCTypes() { return RawSymbol->hasCTypes(); } + +bool PDBSymbolExe::hasPrivateSymbols() { + return RawSymbol->hasPrivateSymbols(); +} + +COFF::MachineTypes PDBSymbolExe::getMachineType() { + return RawSymbol->getMachineType(); +} + +std::string PDBSymbolExe::getName() { return RawSymbol->getName(); } + +uint32_t PDBSymbolExe::getSignature() { return RawSymbol->getSignature(); } + +std::string PDBSymbolExe::getSymbolsFileName() { + return RawSymbol->getSymbolsFileName(); +} + +uint32_t PDBSymbolExe::getSymIndexId() { return RawSymbol->getSymIndexId(); } Index: lib/DebugInfo/PDB/PDBSymbolFunc.cpp =================================================================== --- /dev/null +++ lib/DebugInfo/PDB/PDBSymbolFunc.cpp @@ -0,0 +1,133 @@ +//===- PDBSymbolFunc.cpp - Accessors for querying functions in a PDB ----*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include + +#include "llvm/DebugInfo/PDB/IPDBRawSymbol.h" +#include "llvm/DebugInfo/PDB/PDBSymbol.h" +#include "llvm/DebugInfo/PDB/PDBSymbolFunc.h" + +using namespace llvm; + +PDBFunction::PDBFunction(std::unique_ptr FuncSymbol) + : PDBSymbol(std::move(FuncSymbol)) {} + +PDB_MemberAccess PDBFunction::getAccess() { return RawSymbol->getAccess(); } + +uint32_t PDBFunction::getAddressOffset() { + return RawSymbol->getAddressOffset(); +} + +uint32_t PDBFunction::getAddressSection() { + return RawSymbol->getAddressSection(); +} + +uint32_t PDBFunction::getClassParentId() { + return RawSymbol->getClassParentId(); +} + +bool PDBFunction::isConstType() { return RawSymbol->isConstType(); } + +bool PDBFunction::hasCustomCallingConvention() { + return RawSymbol->hasCustomCallingConvention(); +} + +bool PDBFunction::hasFarReturn() { return RawSymbol->hasFarReturn(); } + +bool PDBFunction::hasAlloca() { return RawSymbol->hasAlloca(); } + +bool PDBFunction::hasEH() { return RawSymbol->hasEH(); } + +bool PDBFunction::hasEHa() { return RawSymbol->hasEHa(); } + +bool PDBFunction::hasInlAsm() { return RawSymbol->hasInlAsm(); } + +bool PDBFunction::hasLongJump() { return RawSymbol->hasLongJump(); } + +bool PDBFunction::hasSEH() { return RawSymbol->hasSEH(); } + +bool PDBFunction::hasSecurityChecks() { return RawSymbol->hasSecurityChecks(); } + +bool PDBFunction::hasSetJump() { return RawSymbol->hasSetJump(); } + +bool PDBFunction::hasInterruptReturn() { + return RawSymbol->hasInterruptReturn(); +} + +bool PDBFunction::isIntroVirtualFunction() { + return RawSymbol->isIntroVirtualFunction(); +} + +bool PDBFunction::hasInlineAttribute() { + return RawSymbol->hasInlineAttribute(); +} + +bool PDBFunction::isNaked() { return RawSymbol->isNaked(); } + +bool PDBFunction::isStatic() { return RawSymbol->isStatic(); } + +uint64_t PDBFunction::getLength() { return RawSymbol->getLength(); } + +uint32_t PDBFunction::getLexicalParentId() { + return RawSymbol->getLexicalParentId(); +} + +PDB_LocType PDBFunction::getLocationType() { + return RawSymbol->getLocationType(); +} + +std::string PDBFunction::getName() { return RawSymbol->getName(); } + +bool PDBFunction::hasNoInlineAttribute() { + return RawSymbol->hasNoInlineAttribute(); +} + +bool PDBFunction::hasNoReturnAttribute() { + return RawSymbol->hasNoReturnAttribute(); +} + +bool PDBFunction::isUnreached() { return RawSymbol->isUnreached(); } + +bool PDBFunction::getNoStackOrdering() { + return RawSymbol->getNoStackOrdering(); +} + +bool PDBFunction::hasOptimizedCodeDebugInfo() { + return RawSymbol->hasOptimizedCodeDebugInfo(); +} + +bool PDBFunction::isPureVirtual() { return RawSymbol->isPureVirtual(); } + +uint32_t PDBFunction::getRelativeVirtualAddress() { + return RawSymbol->getRelativeVirtualAddress(); +} + +uint32_t PDBFunction::getSymIndexId() { return RawSymbol->getSymIndexId(); } + +uint32_t PDBFunction::getToken() { return RawSymbol->getToken(); } + +uint32_t PDBFunction::getTypeId() { return RawSymbol->getTypeId(); } + +bool PDBFunction::isUnalignedType() { return RawSymbol->isUnalignedType(); } + +std::string PDBFunction::getUndecoratedName() { + return RawSymbol->getUndecoratedName(); +} + +bool PDBFunction::isVirtual() { return RawSymbol->isVirtual(); } + +uint64_t PDBFunction::getVirtualAddress() { + return RawSymbol->getVirtualAddress(); +} + +uint32_t PDBFunction::getVirtualBaseOffset() { + return RawSymbol->getVirtualBaseOffset(); +} + +bool PDBFunction::isVolatileType() { return RawSymbol->isVolatileType(); }