Provide DIA implementation of DebugInfoPDB.

This implements DebugInfoPDB when the DIA SDK is present on the system.
Specifically, this means that the following conditions are met:
  1) You are building on Windows.
  2) You are building with MSVC.
  3) Visual Studio did not corrupt the installation of DIA due to a
     known issue with side-by-side installations of VS2012 and VS2013.
If all of these conditions are true, you will be able to pass a value
of PDB_Reader::DIA to PDB::createPdbReader().

There are no tests for this yet, as any test will be in the form of a
lit test which tests the llvm-pdbdump.exe, which still needs to be
rewritten in terms of this library.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@228747 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Zachary Turner 2015-02-10 21:17:52 +00:00
parent beded8f64d
commit 8ffa03cd98
27 changed files with 1874 additions and 18 deletions

View File

@ -0,0 +1,33 @@
//===- DIADataStream.h - DIA implementation of IPDBDataStream ---*- 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_DIA_DIADATASTREAM_H
#define LLVM_DEBUGINFO_PDB_DIA_DIADATASTREAM_H
#include "DIASupport.h"
#include "llvm/DebugInfo/PDB/IPDBDataStream.h"
namespace llvm {
class DIADataStream : public IPDBDataStream {
public:
explicit DIADataStream(CComPtr<IDiaEnumDebugStreamData> DiaStreamData);
uint32_t getRecordCount() const override;
std::string getName() const override;
llvm::Optional<RecordType> getItemAtIndex(uint32_t Index) const override;
bool getNext(RecordType &Record) override;
void reset() override;
DIADataStream *clone() const override;
private:
CComPtr<IDiaEnumDebugStreamData> StreamData;
};
}
#endif

View File

@ -0,0 +1,35 @@
//==- DIAEnumDebugStreams.h - DIA Debug Stream Enumerator impl ---*- 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_DIA_DIAENUMDEBUGSTREAMS_H
#define LLVM_DEBUGINFO_PDB_DIA_DIAENUMDEBUGSTREAMS_H
#include "DIASupport.h"
#include "llvm/DebugInfo/PDB/IPDBEnumChildren.h"
namespace llvm {
class IPDBDataStream;
class DIAEnumDebugStreams : public IPDBEnumChildren<IPDBDataStream> {
public:
explicit DIAEnumDebugStreams(CComPtr<IDiaEnumDebugStreams> DiaEnumerator);
uint32_t getChildCount() const override;
ChildTypePtr getChildAtIndex(uint32_t Index) const override;
ChildTypePtr getNext() override;
void reset() override;
DIAEnumDebugStreams *clone() const override;
private:
CComPtr<IDiaEnumDebugStreams> Enumerator;
};
}
#endif

View File

@ -0,0 +1,35 @@
//==- DIAEnumLineNumbers.h - DIA Line Number Enumerator impl -----*- 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_DIA_DIAENUMLINENUMBERS_H
#define LLVM_DEBUGINFO_PDB_DIA_DIAENUMLINENUMBERS_H
#include "DIASupport.h"
#include "llvm/DebugInfo/PDB/IPDBEnumChildren.h"
namespace llvm {
class IPDBLineNumber;
class DIAEnumLineNumbers : public IPDBEnumChildren<IPDBLineNumber> {
public:
explicit DIAEnumLineNumbers(CComPtr<IDiaEnumLineNumbers> DiaEnumerator);
uint32_t getChildCount() const override;
ChildTypePtr getChildAtIndex(uint32_t Index) const override;
ChildTypePtr getNext() override;
void reset() override;
DIAEnumLineNumbers *clone() const override;
private:
CComPtr<IDiaEnumLineNumbers> Enumerator;
};
}
#endif

View File

@ -0,0 +1,37 @@
//==- DIAEnumSourceFiles.h - DIA Source File Enumerator impl -----*- 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_DIA_DIAENUMSOURCEFILES_H
#define LLVM_DEBUGINFO_PDB_DIA_DIAENUMSOURCEFILES_H
#include "DIASupport.h"
#include "llvm/DebugInfo/PDB/IPDBEnumChildren.h"
namespace llvm {
class DIASession;
class DIAEnumSourceFiles : public IPDBEnumChildren<IPDBSourceFile> {
public:
explicit DIAEnumSourceFiles(const DIASession &PDBSession,
CComPtr<IDiaEnumSourceFiles> DiaEnumerator);
uint32_t getChildCount() const override;
ChildTypePtr getChildAtIndex(uint32_t Index) const override;
ChildTypePtr getNext() override;
void reset() override;
DIAEnumSourceFiles *clone() const override;
private:
const DIASession &Session;
CComPtr<IDiaEnumSourceFiles> Enumerator;
};
}
#endif

View File

@ -0,0 +1,37 @@
//==- DIAEnumSymbols.h - DIA Symbol Enumerator impl --------------*- 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_DIA_DIAENUMSYMBOLS_H
#define LLVM_DEBUGINFO_PDB_DIA_DIAENUMSYMBOLS_H
#include "DIASupport.h"
#include "llvm/DebugInfo/PDB/IPDBEnumChildren.h"
namespace llvm {
class DIASession;
class DIAEnumSymbols : public IPDBEnumChildren<PDBSymbol> {
public:
explicit DIAEnumSymbols(const DIASession &Session,
CComPtr<IDiaEnumSymbols> DiaEnumerator);
uint32_t getChildCount() const override;
std::unique_ptr<PDBSymbol> getChildAtIndex(uint32_t Index) const override;
std::unique_ptr<PDBSymbol> getNext() override;
void reset() override;
DIAEnumSymbols *clone() const override;
private:
const DIASession &Session;
CComPtr<IDiaEnumSymbols> Enumerator;
};
}
#endif

View File

@ -0,0 +1,39 @@
//===- DIALineNumber.h - DIA implementation of IPDBLineNumber ---*- 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_DIA_DIALINENUMBER_H
#define LLVM_DEBUGINFO_PDB_DIA_DIALINENUMBER_H
#include "DIASupport.h"
#include "llvm/DebugInfo/PDB/IPDBLineNumber.h"
namespace llvm {
class DIALineNumber : public IPDBLineNumber {
public:
explicit DIALineNumber(CComPtr<IDiaLineNumber> DiaLineNumber);
uint32_t getLineNumber() const override;
uint32_t getLineNumberEnd() const override;
uint32_t getColumnNumber() const override;
uint32_t getColumnNumberEnd() const override;
uint32_t getAddressSection() const override;
uint32_t getAddressOffset() const override;
uint32_t getRelativeVirtualAddress() const override;
uint64_t getVirtualAddress() const override;
uint32_t getLength() const override;
uint32_t getSourceFileId() const override;
uint32_t getCompilandId() const override;
bool isStatement() const override;
private:
CComPtr<IDiaLineNumber> LineNumber;
};
}
#endif

View File

@ -0,0 +1,198 @@
//===- DIARawSymbol.h - DIA implementation of IPDBRawSymbol ----*- 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_DIA_DIARAWSYMBOL_H
#define LLVM_DEBUGINFO_PDB_DIA_DIARAWSYMBOL_H
#include "DIASupport.h"
#include "llvm/DebugInfo/PDB/IPDBRawSymbol.h"
namespace llvm {
class DIASession;
class DIARawSymbol : public IPDBRawSymbol {
public:
DIARawSymbol(const DIASession &PDBSession, CComPtr<IDiaSymbol> DiaSymbol);
void dump(llvm::raw_ostream &OS) const override;
std::unique_ptr<IPDBEnumSymbols>
findChildren(PDB_SymType Type, StringRef Name,
PDB_NameSearchFlags Flags) const override;
std::unique_ptr<IPDBEnumSymbols>
findChildrenByRVA(PDB_SymType Type, StringRef Name, PDB_NameSearchFlags Flags,
uint32_t RVA) const override;
std::unique_ptr<IPDBEnumSymbols>
findInlineFramesByRVA(uint32_t RVA) const override;
void getDataBytes(llvm::SmallVector<uint8_t, 32> &bytes) const override;
void getFrontEndVersion(VersionInfo &Version) const override;
void getBackEndVersion(VersionInfo &Version) const override;
PDB_MemberAccess getAccess() const override;
uint32_t getAddressOffset() const override;
uint32_t getAddressSection() const override;
uint32_t getAge() const override;
uint32_t getArrayIndexTypeId() const override;
uint32_t getBaseDataOffset() const override;
uint32_t getBaseDataSlot() const override;
uint32_t getBaseSymbolId() const override;
PDB_BuiltinType getBuiltinType() const override;
uint32_t getBitPosition() const override;
PDB_CallingConv getCallingConvention() const override;
uint32_t getClassParentId() const override;
std::string getCompilerName() const override;
uint32_t getCount() const override;
uint32_t getCountLiveRanges() const override;
PDB_Lang getLanguage() const override;
uint32_t getLexicalParentId() const override;
std::string getLibraryName() const override;
uint32_t getLiveRangeStartAddressOffset() const override;
uint32_t getLiveRangeStartAddressSection() const override;
uint32_t getLiveRangeStartRelativeVirtualAddress() const override;
uint32_t getLocalBasePointerRegisterId() const override;
uint32_t getLowerBoundId() const override;
uint32_t getMemorySpaceKind() const override;
std::string getName() const override;
uint32_t getNumberOfAcceleratorPointerTags() const override;
uint32_t getNumberOfColumns() const override;
uint32_t getNumberOfModifiers() const override;
uint32_t getNumberOfRegisterIndices() const override;
uint32_t getNumberOfRows() const override;
std::string getObjectFileName() const override;
uint32_t getOemId() const override;
uint32_t getOemSymbolId() const override;
uint32_t getOffsetInUdt() const override;
PDB_Cpu getPlatform() const override;
uint32_t getRank() const override;
uint32_t getRegisterId() const override;
uint32_t getRegisterType() const override;
uint32_t getRelativeVirtualAddress() const override;
uint32_t getSamplerSlot() const override;
uint32_t getSignature() const override;
uint32_t getSizeInUdt() const override;
uint32_t getSlot() const override;
std::string getSourceFileName() const override;
uint32_t getStride() const override;
uint32_t getSubTypeId() const override;
std::string getSymbolsFileName() const override;
uint32_t getSymIndexId() const override;
uint32_t getTargetOffset() const override;
uint32_t getTargetRelativeVirtualAddress() const override;
uint64_t getTargetVirtualAddress() const override;
uint32_t getTargetSection() const override;
uint32_t getTextureSlot() const override;
uint32_t getTimeStamp() const override;
uint32_t getToken() const override;
uint32_t getTypeId() const override;
uint32_t getUavSlot() const override;
std::string getUndecoratedName() const override;
uint32_t getUnmodifiedTypeId() const override;
uint32_t getUpperBoundId() const override;
uint32_t getVirtualBaseDispIndex() const override;
uint32_t getVirtualBaseOffset() const override;
uint32_t getVirtualTableShapeId() const override;
PDB_DataKind getDataKind() const override;
PDB_SymType getSymTag() const override;
PDB_UniqueId getGuid() const override;
int32_t getOffset() const override;
int32_t getThisAdjust() const override;
int32_t getVirtualBasePointerOffset() const override;
PDB_LocType getLocationType() const override;
PDB_Machine getMachineType() const override;
PDB_ThunkOrdinal getThunkOrdinal() const override;
uint64_t getLength() const override;
uint64_t getLiveRangeLength() const override;
uint64_t getVirtualAddress() const override;
PDB_UdtType getUdtKind() const override;
bool hasConstructor() const override;
bool hasCustomCallingConvention() const override;
bool hasFarReturn() const override;
bool isCode() const override;
bool isCompilerGenerated() const override;
bool isConstType() const override;
bool isEditAndContinueEnabled() const override;
bool isFunction() const override;
bool getAddressTaken() const override;
bool getNoStackOrdering() const override;
bool hasAlloca() const override;
bool hasAssignmentOperator() const override;
bool hasCTypes() const override;
bool hasCastOperator() const override;
bool hasDebugInfo() const override;
bool hasEH() const override;
bool hasEHa() const override;
bool hasInlAsm() const override;
bool hasInlineAttribute() const override;
bool hasInterruptReturn() const override;
bool hasLongJump() const override;
bool hasManagedCode() const override;
bool hasNestedTypes() const override;
bool hasNoInlineAttribute() const override;
bool hasNoReturnAttribute() const override;
bool hasOptimizedCodeDebugInfo() const override;
bool hasOverloadedOperator() const override;
bool hasSEH() const override;
bool hasSecurityChecks() const override;
bool hasSetJump() const override;
bool hasStrictGSCheck() const override;
bool isAcceleratorGroupSharedLocal() const override;
bool isAcceleratorPointerTagLiveRange() const override;
bool isAcceleratorStubFunction() const override;
bool isAggregated() const override;
bool isIntroVirtualFunction() const override;
bool isCVTCIL() const override;
bool isConstructorVirtualBase() const override;
bool isCxxReturnUdt() const override;
bool isDataAligned() const override;
bool isHLSLData() const override;
bool isHotpatchable() const override;
bool isIndirectVirtualBaseClass() const override;
bool isInterfaceUdt() const override;
bool isIntrinsic() const override;
bool isLTCG() const override;
bool isLocationControlFlowDependent() const override;
bool isMSILNetmodule() const override;
bool isMatrixRowMajor() const override;
bool isManagedCode() const override;
bool isMSILCode() const override;
bool isMultipleInheritance() const override;
bool isNaked() const override;
bool isNested() const override;
bool isOptimizedAway() const override;
bool isPacked() const override;
bool isPointerBasedOnSymbolValue() const override;
bool isPointerToDataMember() const override;
bool isPointerToMemberFunction() const override;
bool isPureVirtual() const override;
bool isRValueReference() const override;
bool isRefUdt() const override;
bool isReference() const override;
bool isRestrictedType() const override;
bool isReturnValue() const override;
bool isSafeBuffers() const override;
bool isScoped() const override;
bool isSdl() const override;
bool isSingleInheritance() const override;
bool isSplitted() const override;
bool isStatic() const override;
bool hasPrivateSymbols() const override;
bool isUnalignedType() const override;
bool isUnreached() const override;
bool isValueUdt() const override;
bool isVirtual() const override;
bool isVirtualBaseClass() const override;
bool isVirtualInheritance() const override;
bool isVolatileType() const override;
private:
const DIASession &Session;
CComPtr<IDiaSymbol> Symbol;
};
}
#endif

View File

@ -0,0 +1,38 @@
//===- DIASession.h - DIA implementation of IPDBSession ---------*- 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_DIA_DIASESSION_H
#define LLVM_DEBUGINFO_PDB_DIA_DIASESSION_H
#include "DIASupport.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/DebugInfo/PDB/IPDBSession.h"
namespace llvm {
class DIASession : public IPDBSession {
public:
explicit DIASession(CComPtr<IDiaSession> DiaSession);
static DIASession *createFromPdb(StringRef Path);
uint64_t getLoadAddress() const override;
void setLoadAddress(uint64_t Address) override;
std::unique_ptr<PDBSymbolExe> getGlobalScope() const override;
std::unique_ptr<PDBSymbol> getSymbolById(uint32_t SymbolId) const override;
std::unique_ptr<IPDBSourceFile>
getSourceFileById(uint32_t FileId) const override;
std::unique_ptr<IPDBEnumDataStreams> getDebugStreams() const override;
private:
CComPtr<IDiaSession> Session;
};
}
#endif

View File

@ -0,0 +1,36 @@
//===- DIASourceFile.h - DIA implementation of IPDBSourceFile ---*- 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_DIA_DIASOURCEFILE_H
#define LLVM_DEBUGINFO_PDB_DIA_DIASOURCEFILE_H
#include "DIASupport.h"
#include "llvm/DebugInfo/PDB/IPDBSourceFile.h"
namespace llvm {
class DIASession;
class DIASourceFile : public IPDBSourceFile {
public:
explicit DIASourceFile(const DIASession &Session,
CComPtr<IDiaSourceFile> DiaSourceFile);
std::string getFileName() const override;
uint32_t getUniqueId() const override;
std::string getChecksum() const override;
PDB_Checksum getChecksumType() const override;
std::unique_ptr<IPDBEnumSymbols> getCompilands() const override;
private:
const DIASession &Session;
CComPtr<IDiaSourceFile> SourceFile;
};
}
#endif

View File

@ -0,0 +1,33 @@
//===- DIASupport.h - Common header includes for DIA ------------*- 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 LLVMDebugInfoPDBDIA. The
// definitions here configure the necessary #defines and include system headers
// in the proper order for using DIA.
//===----------------------------------------------------------------------===//
#ifndef LLVM_DEBUGINFO_PDB_DIA_DIASUPPORT_H
#define LLVM_DEBUGINFO_PDB_DIA_DIASUPPORT_H
// Require at least Vista
#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 <atlbase.h>
#include <windows.h>
// DIA headers must come after windows headers.
#include <cvconst.h>
#include <dia2.h>
#endif // LLVM_DEBUGINFO_PDB_DIA_DIASUPPORT_H

View File

@ -31,7 +31,7 @@ public:
virtual llvm::Optional<RecordType> getItemAtIndex(uint32_t Index) const = 0;
virtual bool getNext(RecordType &Record) = 0;
virtual void reset() = 0;
virtual std::unique_ptr<IPDBDataStream> clone() const = 0;
virtual IPDBDataStream *clone() const = 0;
};
}

View File

@ -18,7 +18,7 @@ namespace llvm {
template <typename ChildType> class IPDBEnumChildren {
public:
typedef std::unique_ptr<ChildType> ChildTypePtr;
typedef std::unique_ptr<IPDBEnumChildren<ChildType>> MyTypePtr;
typedef IPDBEnumChildren<ChildType> MyType;
virtual ~IPDBEnumChildren() {}
@ -26,7 +26,7 @@ public:
virtual ChildTypePtr getChildAtIndex(uint32_t Index) const = 0;
virtual ChildTypePtr getNext() = 0;
virtual void reset() = 0;
virtual MyTypePtr clone() const = 0;
virtual MyType *clone() const = 0;
};
}

View File

@ -27,8 +27,9 @@ public:
virtual uint64_t getLoadAddress() const = 0;
virtual void setLoadAddress(uint64_t Address) = 0;
virtual std::unique_ptr<PDBSymbolExe> getGlobalScope() const = 0;
virtual std::unique_ptr<PDBSymbol> getSymbolById() const = 0;
virtual std::unique_ptr<IPDBSourceFile> getSourceFileById() const = 0;
virtual std::unique_ptr<PDBSymbol> getSymbolById(uint32_t SymbolId) const = 0;
virtual std::unique_ptr<IPDBSourceFile>
getSourceFileById(uint32_t FileId) const = 0;
virtual std::unique_ptr<IPDBEnumDataStreams> getDebugStreams() const = 0;
};

View File

@ -11,6 +11,7 @@
#define LLVM_DEBUGINFO_PDB_IPDBSOURCEFILE_H
#include <memory>
#include <string>
#include "PDBTypes.h"
@ -26,7 +27,7 @@ public:
virtual uint32_t getUniqueId() const = 0;
virtual std::string getChecksum() const = 0;
virtual PDB_Checksum getChecksumType() const = 0;
virtual std::unique_ptr<IPDBEnumCompilands> getCompilands() const = 0;
virtual std::unique_ptr<IPDBEnumSymbols> getCompilands() const = 0;
};
}

View File

@ -12,8 +12,6 @@
#include <string>
#include "llvm/Support/COFF.h"
#include "PDBSymbol.h"
#include "PDBTypes.h"

View File

@ -11,6 +11,7 @@
#define LLVM_DEBUGINFO_PDB_PDBTYPES_H
#include <stdint.h>
#include "llvm/Config/llvm-config.h"
namespace llvm {
@ -28,7 +29,6 @@ class IPDBSourceFile;
typedef IPDBEnumChildren<PDBSymbol> IPDBEnumSymbols;
typedef IPDBEnumChildren<IPDBSourceFile> IPDBEnumSourceFiles;
typedef IPDBEnumChildren<IPDBDataStream> IPDBEnumDataStreams;
typedef IPDBEnumChildren<PDBSymbolCompiland> IPDBEnumCompilands;
class PDBSymbolExe;
class PDBSymbolCompiland;
@ -65,10 +65,7 @@ class PDBSymbolUnknown;
/// 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
DIA = 0,
};
/// Defines a 128-bit unique identifier. This maps to a GUID on Windows, but
@ -177,14 +174,14 @@ enum class PDB_Machine {
Am33 = 0x13,
Amd64 = 0x8664,
Arm = 0x1C0,
Armnt = 0x1C4,
ArmNT = 0x1C4,
Ebc = 0xEBC,
I386 = 0x14C,
x86 = 0x14C,
Ia64 = 0x200,
M32r = 0x9041,
M32R = 0x9041,
Mips16 = 0x266,
MipsFPU = 0x366,
MipsFPU16 = 0x466,
MipsFpu = 0x366,
MipsFpu16 = 0x466,
PowerPC = 0x1F0,
PowerPCFP = 0x1F1,
R4000 = 0x166,

View File

@ -1,3 +1,34 @@
macro(add_pdb_impl_folder group)
list(APPEND PDB_IMPL_SOURCES ${ARGN})
source_group(${group} FILES ${ARGN})
endmacro()
if(HAVE_DIA_SDK)
include_directories(${MSVC_DIA_SDK_DIR}/include)
set(LIBPDB_LINK_FOLDERS "${MSVC_DIA_SDK_DIR}\\lib")
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
set(LIBPDB_LINK_FOLDERS "${LIBPDB_LINK_FOLDERS}\\amd64")
endif()
set(LIBPDB_ADDITIONAL_LIBRARIES "${LIBPDB_LINK_FOLDERS}\\diaguids.lib")
add_pdb_impl_folder(DIA
DIA/DIADataStream.cpp
DIA/DIAEnumDebugStreams.cpp
DIA/DIAEnumLineNumbers.cpp
DIA/DIAEnumSourceFiles.cpp
DIA/DIAEnumSymbols.cpp
DIA/DIALineNumber.cpp
DIA/DIARawSymbol.cpp
DIA/DIASession.cpp
DIA/DIASourceFile.cpp
)
set(LIBPDB_ADDITIONAL_HEADER_DIRS "../../../include/llvm/DebugInfo/PDB/DIA/")
endif()
list(APPEND LIBPDB_ADDITIONAL_HEADER_DIRS "../../../include/llvm/DebugInfo/PDB")
add_llvm_library(LLVMDebugInfoPDB
PDB.cpp
PDBInterfaceAnchors.cpp
@ -33,4 +64,10 @@ add_llvm_library(LLVMDebugInfoPDB
PDBSymbolTypeVTableShape.cpp
PDBSymbolUnknown.cpp
PDBSymbolUsingNamespace.cpp
${PDB_IMPL_SOURCES}
ADDITIONAL_HEADER_DIRS
${LIBPDB_ADDITIONAL_HEADER_DIRS}
)
target_link_libraries(LLVMDebugInfoPDB INTERFACE "${LIBPDB_ADDITIONAL_LIBRARIES}")

View File

@ -0,0 +1,74 @@
//===- DIADataStream.cpp - DIA implementation of IPDBDataStream -*- 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/DIA/DIADataStream.h"
#include "llvm/Support/ConvertUTF.h"
using namespace llvm;
DIADataStream::DIADataStream(CComPtr<IDiaEnumDebugStreamData> DiaStreamData)
: StreamData(DiaStreamData) {}
uint32_t DIADataStream::getRecordCount() const {
LONG Count = 0;
return (S_OK == StreamData->get_Count(&Count)) ? Count : 0;
}
std::string DIADataStream::getName() const {
CComBSTR Name16;
if (S_OK != StreamData->get_name(&Name16))
return std::string();
std::string Name8;
llvm::ArrayRef<char> Name16Bytes(reinterpret_cast<char *>(Name16.m_str),
Name16.ByteLength());
if (!llvm::convertUTF16ToUTF8String(Name16Bytes, Name8))
return std::string();
return Name8;
}
llvm::Optional<DIADataStream::RecordType>
DIADataStream::getItemAtIndex(uint32_t Index) const {
RecordType Record;
DWORD RecordSize = 0;
StreamData->Item(Index, 0, &RecordSize, nullptr);
if (RecordSize == 0)
return llvm::Optional<RecordType>();
Record.resize(RecordSize);
if (S_OK != StreamData->Item(Index, RecordSize, &RecordSize, &Record[0]))
return llvm::Optional<RecordType>();
return Record;
}
bool DIADataStream::getNext(RecordType &Record) {
Record.clear();
DWORD RecordSize = 0;
ULONG CountFetched = 0;
StreamData->Next(1, 0, &RecordSize, nullptr, &CountFetched);
if (RecordSize == 0)
return false;
Record.resize(RecordSize);
if (S_OK ==
StreamData->Next(1, RecordSize, &RecordSize, &Record[0], &CountFetched))
return false;
return true;
}
void DIADataStream::reset() { StreamData->Reset(); }
DIADataStream *DIADataStream::clone() const {
CComPtr<IDiaEnumDebugStreamData> EnumeratorClone;
if (S_OK != StreamData->Clone(&EnumeratorClone))
return nullptr;
return new DIADataStream(EnumeratorClone);
}

View File

@ -0,0 +1,53 @@
//==- DIAEnumDebugStreams.cpp - DIA Debug Stream Enumerator impl -*- 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/PDBSymbol.h"
#include "llvm/DebugInfo/PDB/DIA/DIAEnumDebugStreams.h"
#include "llvm/DebugInfo/PDB/DIA/DIADataStream.h"
using namespace llvm;
DIAEnumDebugStreams::DIAEnumDebugStreams(
CComPtr<IDiaEnumDebugStreams> DiaEnumerator)
: Enumerator(DiaEnumerator) {}
uint32_t DIAEnumDebugStreams::getChildCount() const {
LONG Count = 0;
return (S_OK == Enumerator->get_Count(&Count)) ? Count : 0;
}
std::unique_ptr<IPDBDataStream>
DIAEnumDebugStreams::getChildAtIndex(uint32_t Index) const {
CComPtr<IDiaEnumDebugStreamData> Item;
VARIANT VarIndex;
VarIndex.vt = VT_I4;
VarIndex.lVal = Index;
if (S_OK != Enumerator->Item(VarIndex, &Item))
return nullptr;
return std::unique_ptr<IPDBDataStream>(new DIADataStream(Item));
}
std::unique_ptr<IPDBDataStream> DIAEnumDebugStreams::getNext() {
CComPtr<IDiaEnumDebugStreamData> Item;
ULONG NumFetched = 0;
if (S_OK != Enumerator->Next(1, &Item, &NumFetched))
return nullptr;
return std::unique_ptr<IPDBDataStream>(new DIADataStream(Item));
}
void DIAEnumDebugStreams::reset() { Enumerator->Reset(); }
DIAEnumDebugStreams *DIAEnumDebugStreams::clone() const {
CComPtr<IDiaEnumDebugStreams> EnumeratorClone;
if (S_OK != Enumerator->Clone(&EnumeratorClone))
return nullptr;
return new DIAEnumDebugStreams(EnumeratorClone);
}

View File

@ -0,0 +1,50 @@
//==- DIAEnumLineNumbers.cpp - DIA Line Number Enumerator impl ---*- 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/PDBSymbol.h"
#include "llvm/DebugInfo/PDB/DIA/DIAEnumLineNumbers.h"
#include "llvm/DebugInfo/PDB/DIA/DIALineNumber.h"
using namespace llvm;
DIAEnumLineNumbers::DIAEnumLineNumbers(
CComPtr<IDiaEnumLineNumbers> DiaEnumerator)
: Enumerator(DiaEnumerator) {}
uint32_t DIAEnumLineNumbers::getChildCount() const {
LONG Count = 0;
return (S_OK == Enumerator->get_Count(&Count)) ? Count : 0;
}
std::unique_ptr<IPDBLineNumber>
DIAEnumLineNumbers::getChildAtIndex(uint32_t Index) const {
CComPtr<IDiaLineNumber> Item;
if (S_OK != Enumerator->Item(Index, &Item))
return nullptr;
return std::unique_ptr<IPDBLineNumber>(new DIALineNumber(Item));
}
std::unique_ptr<IPDBLineNumber> DIAEnumLineNumbers::getNext() {
CComPtr<IDiaLineNumber> Item;
ULONG NumFetched = 0;
if (S_OK != Enumerator->Next(1, &Item, &NumFetched))
return nullptr;
return std::unique_ptr<IPDBLineNumber>(new DIALineNumber(Item));
}
void DIAEnumLineNumbers::reset() { Enumerator->Reset(); }
DIAEnumLineNumbers *DIAEnumLineNumbers::clone() const {
CComPtr<IDiaEnumLineNumbers> EnumeratorClone;
if (S_OK != Enumerator->Clone(&EnumeratorClone))
return nullptr;
return new DIAEnumLineNumbers(EnumeratorClone);
}

View File

@ -0,0 +1,50 @@
//==- DIAEnumSourceFiles.cpp - DIA Source File Enumerator impl ---*- 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/PDBSymbol.h"
#include "llvm/DebugInfo/PDB/DIA/DIAEnumSourceFiles.h"
#include "llvm/DebugInfo/PDB/DIA/DIASourceFile.h"
using namespace llvm;
DIAEnumSourceFiles::DIAEnumSourceFiles(
const DIASession &PDBSession, CComPtr<IDiaEnumSourceFiles> DiaEnumerator)
: Session(PDBSession), Enumerator(DiaEnumerator) {}
uint32_t DIAEnumSourceFiles::getChildCount() const {
LONG Count = 0;
return (S_OK == Enumerator->get_Count(&Count)) ? Count : 0;
}
std::unique_ptr<IPDBSourceFile>
DIAEnumSourceFiles::getChildAtIndex(uint32_t Index) const {
CComPtr<IDiaSourceFile> Item;
if (S_OK != Enumerator->Item(Index, &Item))
return nullptr;
return std::unique_ptr<IPDBSourceFile>(new DIASourceFile(Session, Item));
}
std::unique_ptr<IPDBSourceFile> DIAEnumSourceFiles::getNext() {
CComPtr<IDiaSourceFile> Item;
ULONG NumFetched = 0;
if (S_OK != Enumerator->Next(1, &Item, &NumFetched))
return nullptr;
return std::unique_ptr<IPDBSourceFile>(new DIASourceFile(Session, Item));
}
void DIAEnumSourceFiles::reset() { Enumerator->Reset(); }
DIAEnumSourceFiles *DIAEnumSourceFiles::clone() const {
CComPtr<IDiaEnumSourceFiles> EnumeratorClone;
if (S_OK != Enumerator->Clone(&EnumeratorClone))
return nullptr;
return new DIAEnumSourceFiles(Session, EnumeratorClone);
}

View File

@ -0,0 +1,54 @@
//==- DIAEnumSymbols.cpp - DIA Symbol Enumerator impl ------------*- 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/PDBSymbol.h"
#include "llvm/DebugInfo/PDB/DIA/DIAEnumSymbols.h"
#include "llvm/DebugInfo/PDB/DIA/DIARawSymbol.h"
#include "llvm/DebugInfo/PDB/DIA/DIASession.h"
using namespace llvm;
DIAEnumSymbols::DIAEnumSymbols(const DIASession &PDBSession,
CComPtr<IDiaEnumSymbols> DiaEnumerator)
: Session(PDBSession), Enumerator(DiaEnumerator) {}
uint32_t DIAEnumSymbols::getChildCount() const {
LONG Count = 0;
return (S_OK == Enumerator->get_Count(&Count)) ? Count : 0;
}
std::unique_ptr<PDBSymbol>
DIAEnumSymbols::getChildAtIndex(uint32_t Index) const {
CComPtr<IDiaSymbol> Item;
if (S_OK != Enumerator->Item(Index, &Item))
return nullptr;
std::unique_ptr<DIARawSymbol> RawSymbol(new DIARawSymbol(Session, Item));
return std::unique_ptr<PDBSymbol>(PDBSymbol::create(Session, std::move(RawSymbol)));
}
std::unique_ptr<PDBSymbol> DIAEnumSymbols::getNext() {
CComPtr<IDiaSymbol> Item;
ULONG NumFetched = 0;
if (S_OK != Enumerator->Next(1, &Item, &NumFetched))
return nullptr;
std::unique_ptr<DIARawSymbol> RawSymbol(new DIARawSymbol(Session, Item));
return std::unique_ptr<PDBSymbol>(
PDBSymbol::create(Session, std::move(RawSymbol)));
}
void DIAEnumSymbols::reset() { Enumerator->Reset(); }
DIAEnumSymbols *DIAEnumSymbols::clone() const {
CComPtr<IDiaEnumSymbols> EnumeratorClone;
if (S_OK != Enumerator->Clone(&EnumeratorClone))
return nullptr;
return new DIAEnumSymbols(Session, EnumeratorClone);
}

View File

@ -0,0 +1,75 @@
//===- DIALineNumber.cpp - DIA implementation of IPDBLineNumber -*- 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/DIA/DIALineNumber.h"
using namespace llvm;
DIALineNumber::DIALineNumber(CComPtr<IDiaLineNumber> DiaLineNumber)
: LineNumber(DiaLineNumber) {}
uint32_t DIALineNumber::getLineNumber() const {
DWORD Line = 0;
return (S_OK == LineNumber->get_lineNumber(&Line)) ? Line : 0;
}
uint32_t DIALineNumber::getLineNumberEnd() const {
DWORD LineEnd = 0;
return (S_OK == LineNumber->get_lineNumberEnd(&LineEnd)) ? LineEnd : 0;
}
uint32_t DIALineNumber::getColumnNumber() const {
DWORD Column = 0;
return (S_OK == LineNumber->get_columnNumber(&Column)) ? Column : 0;
}
uint32_t DIALineNumber::getColumnNumberEnd() const {
DWORD ColumnEnd = 0;
return (S_OK == LineNumber->get_columnNumberEnd(&ColumnEnd)) ? ColumnEnd : 0;
}
uint32_t DIALineNumber::getAddressSection() const {
DWORD Section = 0;
return (S_OK == LineNumber->get_addressSection(&Section)) ? Section : 0;
}
uint32_t DIALineNumber::getAddressOffset() const {
DWORD Offset = 0;
return (S_OK == LineNumber->get_addressOffset(&Offset)) ? Offset : 0;
}
uint32_t DIALineNumber::getRelativeVirtualAddress() const {
DWORD RVA = 0;
return (S_OK == LineNumber->get_relativeVirtualAddress(&RVA)) ? RVA : 0;
}
uint64_t DIALineNumber::getVirtualAddress() const {
ULONGLONG Addr = 0;
return (S_OK == LineNumber->get_virtualAddress(&Addr)) ? Addr : 0;
}
uint32_t DIALineNumber::getLength() const {
DWORD Length = 0;
return (S_OK == LineNumber->get_length(&Length)) ? Length : 0;
}
uint32_t DIALineNumber::getSourceFileId() const {
DWORD Id = 0;
return (S_OK == LineNumber->get_sourceFileId(&Id)) ? Id : 0;
}
uint32_t DIALineNumber::getCompilandId() const {
DWORD Id = 0;
return (S_OK == LineNumber->get_compilandId(&Id)) ? Id : 0;
}
bool DIALineNumber::isStatement() const {
BOOL Statement = 0;
return (S_OK == LineNumber->get_statement(&Statement)) ? Statement : false;
}

View File

@ -0,0 +1,776 @@
//===- DIARawSymbol.cpp - DIA implementation of IPDBRawSymbol ---*- 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/DIA/DIAEnumSymbols.h"
#include "llvm/DebugInfo/PDB/DIA/DIARawSymbol.h"
#include "llvm/DebugInfo/PDB/DIA/DIASession.h"
#include "llvm/Support/ConvertUTF.h"
#include "llvm/Support/raw_ostream.h"
using namespace llvm;
namespace {
template <typename ArgType, typename RetType = ArgType>
RetType PrivateGetDIAValue(IDiaSymbol *Symbol,
HRESULT (__stdcall IDiaSymbol::*Method)(ArgType *)) {
ArgType Value;
if (S_OK == (Symbol->*Method)(&Value))
return static_cast<RetType>(Value);
return RetType();
}
std::string
PrivateGetDIAValue(IDiaSymbol *Symbol,
HRESULT (__stdcall IDiaSymbol::*Method)(BSTR *)) {
CComBSTR Result16;
if (S_OK != (Symbol->*Method)(&Result16))
return std::string();
const char *SrcBytes = reinterpret_cast<const char *>(Result16.m_str);
llvm::ArrayRef<char> SrcByteArray(SrcBytes, Result16.ByteLength());
std::string Result8;
if (!llvm::convertUTF16ToUTF8String(SrcByteArray, Result8))
return std::string();
return Result8;
}
PDB_UniqueId
PrivateGetDIAValue(IDiaSymbol *Symbol,
HRESULT (__stdcall IDiaSymbol::*Method)(GUID *)) {
GUID Result;
if (S_OK != (Symbol->*Method)(&Result))
return PDB_UniqueId();
static_assert(sizeof(PDB_UniqueId) == sizeof(GUID),
"PDB_UniqueId is the wrong size!");
PDB_UniqueId IdResult;
::memcpy(&IdResult, &Result, sizeof(GUID));
return IdResult;
}
}
DIARawSymbol::DIARawSymbol(const DIASession &PDBSession,
CComPtr<IDiaSymbol> DiaSymbol)
: Session(PDBSession), Symbol(DiaSymbol) {}
void DIARawSymbol::dump(llvm::raw_ostream &OS) const {}
std::unique_ptr<IPDBEnumSymbols>
DIARawSymbol::findChildren(PDB_SymType Type, StringRef Name,
PDB_NameSearchFlags Flags) const {
llvm::SmallVector<UTF16, 32> Name16;
llvm::convertUTF8ToUTF16String(Name, Name16);
enum SymTagEnum EnumVal = static_cast<enum SymTagEnum>(Type);
DWORD CompareFlags = static_cast<DWORD>(Flags);
wchar_t *Name16Str = reinterpret_cast<wchar_t *>(Name16.data());
CComPtr<IDiaEnumSymbols> DiaEnumerator;
if (S_OK !=
Symbol->findChildren(EnumVal, Name16Str, CompareFlags, &DiaEnumerator))
return nullptr;
return std::make_unique<DIAEnumSymbols>(Session, DiaEnumerator);
}
std::unique_ptr<IPDBEnumSymbols>
DIARawSymbol::findChildrenByRVA(PDB_SymType Type, StringRef Name,
PDB_NameSearchFlags Flags, uint32_t RVA) const {
llvm::SmallVector<UTF16, 32> Name16;
llvm::convertUTF8ToUTF16String(Name, Name16);
enum SymTagEnum EnumVal = static_cast<enum SymTagEnum>(Type);
DWORD CompareFlags = static_cast<DWORD>(Flags);
wchar_t *Name16Str = reinterpret_cast<wchar_t *>(Name16.data());
CComPtr<IDiaEnumSymbols> DiaEnumerator;
if (S_OK !=
Symbol->findChildrenExByRVA(EnumVal, Name16Str, CompareFlags, RVA,
&DiaEnumerator))
return nullptr;
return std::make_unique<DIAEnumSymbols>(Session, DiaEnumerator);
}
std::unique_ptr<IPDBEnumSymbols>
DIARawSymbol::findInlineFramesByRVA(uint32_t RVA) const {
CComPtr<IDiaEnumSymbols> DiaEnumerator;
if (S_OK != Symbol->findInlineFramesByRVA(RVA, &DiaEnumerator))
return nullptr;
return std::make_unique<DIAEnumSymbols>(Session, DiaEnumerator);
}
void DIARawSymbol::getDataBytes(llvm::SmallVector<uint8_t, 32> &bytes) const {
bytes.clear();
DWORD DataSize = 0;
Symbol->get_dataBytes(0, &DataSize, nullptr);
if (DataSize == 0)
return;
bytes.resize(DataSize);
Symbol->get_dataBytes(DataSize, &DataSize, bytes.data());
}
PDB_MemberAccess DIARawSymbol::getAccess() const {
return PrivateGetDIAValue<DWORD, PDB_MemberAccess>(Symbol,
&IDiaSymbol::get_access);
}
uint32_t DIARawSymbol::getAddressOffset() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_addressOffset);
}
uint32_t DIARawSymbol::getAddressSection() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_addressSection);
}
uint32_t DIARawSymbol::getAge() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_age);
}
uint32_t DIARawSymbol::getArrayIndexTypeId() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_arrayIndexTypeId);
}
void DIARawSymbol::getBackEndVersion(VersionInfo &Version) const {
Version.Major = PrivateGetDIAValue(Symbol, &IDiaSymbol::get_backEndMajor);
Version.Minor = PrivateGetDIAValue(Symbol, &IDiaSymbol::get_backEndMinor);
Version.Build = PrivateGetDIAValue(Symbol, &IDiaSymbol::get_backEndBuild);
Version.QFE = PrivateGetDIAValue(Symbol, &IDiaSymbol::get_backEndQFE);
}
uint32_t DIARawSymbol::getBaseDataOffset() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_baseDataOffset);
}
uint32_t DIARawSymbol::getBaseDataSlot() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_baseDataSlot);
}
uint32_t DIARawSymbol::getBaseSymbolId() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_baseSymbolId);
}
PDB_BuiltinType DIARawSymbol::getBuiltinType() const {
return PrivateGetDIAValue<DWORD, PDB_BuiltinType>(
Symbol, &IDiaSymbol::get_builtInKind);
}
uint32_t DIARawSymbol::getBitPosition() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_bitPosition);
}
PDB_CallingConv DIARawSymbol::getCallingConvention() const {
return PrivateGetDIAValue<DWORD, PDB_CallingConv>(
Symbol, &IDiaSymbol::get_callingConvention);
}
uint32_t DIARawSymbol::getClassParentId() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_classParentId);
}
std::string DIARawSymbol::getCompilerName() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_compilerName);
}
uint32_t DIARawSymbol::getCount() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_count);
}
uint32_t DIARawSymbol::getCountLiveRanges() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_countLiveRanges);
}
void DIARawSymbol::getFrontEndVersion(VersionInfo &Version) const {
Version.Major = PrivateGetDIAValue(Symbol, &IDiaSymbol::get_frontEndMajor);
Version.Minor = PrivateGetDIAValue(Symbol, &IDiaSymbol::get_frontEndMinor);
Version.Build = PrivateGetDIAValue(Symbol, &IDiaSymbol::get_frontEndBuild);
Version.QFE = PrivateGetDIAValue(Symbol, &IDiaSymbol::get_frontEndQFE);
}
PDB_Lang DIARawSymbol::getLanguage() const {
return PrivateGetDIAValue<DWORD, PDB_Lang>(Symbol, &IDiaSymbol::get_count);
}
uint32_t DIARawSymbol::getLexicalParentId() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_lexicalParentId);
}
std::string DIARawSymbol::getLibraryName() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_libraryName);
}
uint32_t DIARawSymbol::getLiveRangeStartAddressOffset() const {
return PrivateGetDIAValue(Symbol,
&IDiaSymbol::get_liveRangeStartAddressOffset);
}
uint32_t DIARawSymbol::getLiveRangeStartAddressSection() const {
return PrivateGetDIAValue(Symbol,
&IDiaSymbol::get_liveRangeStartAddressSection);
}
uint32_t DIARawSymbol::getLiveRangeStartRelativeVirtualAddress() const {
return PrivateGetDIAValue(
Symbol, &IDiaSymbol::get_liveRangeStartRelativeVirtualAddress);
}
uint32_t DIARawSymbol::getLocalBasePointerRegisterId() const {
return PrivateGetDIAValue(Symbol,
&IDiaSymbol::get_localBasePointerRegisterId);
}
uint32_t DIARawSymbol::getLowerBoundId() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_lowerBoundId);
}
uint32_t DIARawSymbol::getMemorySpaceKind() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_memorySpaceKind);
}
std::string DIARawSymbol::getName() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_name);
}
uint32_t DIARawSymbol::getNumberOfAcceleratorPointerTags() const {
return PrivateGetDIAValue(Symbol,
&IDiaSymbol::get_numberOfAcceleratorPointerTags);
}
uint32_t DIARawSymbol::getNumberOfColumns() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_numberOfColumns);
}
uint32_t DIARawSymbol::getNumberOfModifiers() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_numberOfModifiers);
}
uint32_t DIARawSymbol::getNumberOfRegisterIndices() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_numberOfRegisterIndices);
}
uint32_t DIARawSymbol::getNumberOfRows() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_numberOfRows);
}
std::string DIARawSymbol::getObjectFileName() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_objectFileName);
}
uint32_t DIARawSymbol::getOemId() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_oemId);
}
uint32_t DIARawSymbol::getOemSymbolId() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_oemSymbolId);
}
uint32_t DIARawSymbol::getOffsetInUdt() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_offsetInUdt);
}
PDB_Cpu DIARawSymbol::getPlatform() const {
return PrivateGetDIAValue<DWORD, PDB_Cpu>(Symbol, &IDiaSymbol::get_platform);
}
uint32_t DIARawSymbol::getRank() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_rank);
}
uint32_t DIARawSymbol::getRegisterId() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_registerId);
}
uint32_t DIARawSymbol::getRegisterType() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_registerType);
}
uint32_t DIARawSymbol::getRelativeVirtualAddress() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_relativeVirtualAddress);
}
uint32_t DIARawSymbol::getSamplerSlot() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_samplerSlot);
}
uint32_t DIARawSymbol::getSignature() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_signature);
}
uint32_t DIARawSymbol::getSizeInUdt() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_sizeInUdt);
}
uint32_t DIARawSymbol::getSlot() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_slot);
}
std::string DIARawSymbol::getSourceFileName() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_sourceFileName);
}
uint32_t DIARawSymbol::getStride() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_stride);
}
uint32_t DIARawSymbol::getSubTypeId() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_subTypeId);
}
std::string DIARawSymbol::getSymbolsFileName() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_symbolsFileName);
}
uint32_t DIARawSymbol::getSymIndexId() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_symIndexId);
}
uint32_t DIARawSymbol::getTargetOffset() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_targetOffset);
}
uint32_t DIARawSymbol::getTargetRelativeVirtualAddress() const {
return PrivateGetDIAValue(Symbol,
&IDiaSymbol::get_targetRelativeVirtualAddress);
}
uint64_t DIARawSymbol::getTargetVirtualAddress() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_targetVirtualAddress);
}
uint32_t DIARawSymbol::getTargetSection() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_targetSection);
}
uint32_t DIARawSymbol::getTextureSlot() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_textureSlot);
}
uint32_t DIARawSymbol::getTimeStamp() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_timeStamp);
}
uint32_t DIARawSymbol::getToken() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_token);
}
uint32_t DIARawSymbol::getTypeId() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_typeId);
}
uint32_t DIARawSymbol::getUavSlot() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_uavSlot);
}
std::string DIARawSymbol::getUndecoratedName() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_undecoratedName);
}
uint32_t DIARawSymbol::getUnmodifiedTypeId() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_unmodifiedTypeId);
}
uint32_t DIARawSymbol::getUpperBoundId() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_upperBoundId);
}
uint32_t DIARawSymbol::getVirtualBaseDispIndex() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_virtualBaseDispIndex);
}
uint32_t DIARawSymbol::getVirtualBaseOffset() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_virtualBaseOffset);
}
uint32_t DIARawSymbol::getVirtualTableShapeId() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_virtualTableShapeId);
}
PDB_DataKind DIARawSymbol::getDataKind() const {
return PrivateGetDIAValue<DWORD, PDB_DataKind>(Symbol,
&IDiaSymbol::get_dataKind);
}
PDB_SymType DIARawSymbol::getSymTag() const {
return PrivateGetDIAValue<DWORD, PDB_SymType>(Symbol,
&IDiaSymbol::get_symTag);
}
PDB_UniqueId DIARawSymbol::getGuid() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_guid);
}
int32_t DIARawSymbol::getOffset() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_offset);
}
int32_t DIARawSymbol::getThisAdjust() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_thisAdjust);
}
int32_t DIARawSymbol::getVirtualBasePointerOffset() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_virtualBasePointerOffset);
}
PDB_LocType DIARawSymbol::getLocationType() const {
return PrivateGetDIAValue<DWORD, PDB_LocType>(Symbol,
&IDiaSymbol::get_locationType);
}
PDB_Machine DIARawSymbol::getMachineType() const {
return PrivateGetDIAValue<DWORD, PDB_Machine>(Symbol,
&IDiaSymbol::get_machineType);
}
PDB_ThunkOrdinal DIARawSymbol::getThunkOrdinal() const {
return PrivateGetDIAValue<DWORD, PDB_ThunkOrdinal>(
Symbol, &IDiaSymbol::get_thunkOrdinal);
}
uint64_t DIARawSymbol::getLength() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_length);
}
uint64_t DIARawSymbol::getLiveRangeLength() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_liveRangeLength);
}
uint64_t DIARawSymbol::getVirtualAddress() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_virtualAddress);
}
PDB_UdtType DIARawSymbol::getUdtKind() const {
return PrivateGetDIAValue<DWORD, PDB_UdtType>(Symbol,
&IDiaSymbol::get_udtKind);
}
bool DIARawSymbol::hasConstructor() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_constructor);
}
bool DIARawSymbol::hasCustomCallingConvention() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_customCallingConvention);
}
bool DIARawSymbol::hasFarReturn() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_farReturn);
}
bool DIARawSymbol::isCode() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_code);
}
bool DIARawSymbol::isCompilerGenerated() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_compilerGenerated);
}
bool DIARawSymbol::isConstType() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_constType);
}
bool DIARawSymbol::isEditAndContinueEnabled() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_editAndContinueEnabled);
}
bool DIARawSymbol::isFunction() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_function);
}
bool DIARawSymbol::getAddressTaken() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_stride);
}
bool DIARawSymbol::getNoStackOrdering() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_noStackOrdering);
}
bool DIARawSymbol::hasAlloca() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_hasAlloca);
}
bool DIARawSymbol::hasAssignmentOperator() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_hasAssignmentOperator);
}
bool DIARawSymbol::hasCTypes() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_isCTypes);
}
bool DIARawSymbol::hasCastOperator() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_hasCastOperator);
}
bool DIARawSymbol::hasDebugInfo() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_hasDebugInfo);
}
bool DIARawSymbol::hasEH() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_hasEH);
}
bool DIARawSymbol::hasEHa() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_hasEHa);
}
bool DIARawSymbol::hasInlAsm() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_hasInlAsm);
}
bool DIARawSymbol::hasInlineAttribute() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_inlSpec);
}
bool DIARawSymbol::hasInterruptReturn() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_interruptReturn);
}
bool DIARawSymbol::hasLongJump() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_hasLongJump);
}
bool DIARawSymbol::hasManagedCode() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_hasManagedCode);
}
bool DIARawSymbol::hasNestedTypes() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_hasNestedTypes);
}
bool DIARawSymbol::hasNoInlineAttribute() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_noInline);
}
bool DIARawSymbol::hasNoReturnAttribute() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_noReturn);
}
bool DIARawSymbol::hasOptimizedCodeDebugInfo() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_optimizedCodeDebugInfo);
}
bool DIARawSymbol::hasOverloadedOperator() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_overloadedOperator);
}
bool DIARawSymbol::hasSEH() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_hasSEH);
}
bool DIARawSymbol::hasSecurityChecks() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_hasSecurityChecks);
}
bool DIARawSymbol::hasSetJump() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_hasSetJump);
}
bool DIARawSymbol::hasStrictGSCheck() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_strictGSCheck);
}
bool DIARawSymbol::isAcceleratorGroupSharedLocal() const {
return PrivateGetDIAValue(Symbol,
&IDiaSymbol::get_isAcceleratorGroupSharedLocal);
}
bool DIARawSymbol::isAcceleratorPointerTagLiveRange() const {
return PrivateGetDIAValue(Symbol,
&IDiaSymbol::get_isAcceleratorPointerTagLiveRange);
}
bool DIARawSymbol::isAcceleratorStubFunction() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_isAcceleratorStubFunction);
}
bool DIARawSymbol::isAggregated() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_isAggregated);
}
bool DIARawSymbol::isIntroVirtualFunction() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_intro);
}
bool DIARawSymbol::isCVTCIL() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_isCVTCIL);
}
bool DIARawSymbol::isConstructorVirtualBase() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_isConstructorVirtualBase);
}
bool DIARawSymbol::isCxxReturnUdt() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_isCxxReturnUdt);
}
bool DIARawSymbol::isDataAligned() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_isDataAligned);
}
bool DIARawSymbol::isHLSLData() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_isHLSLData);
}
bool DIARawSymbol::isHotpatchable() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_isHotpatchable);
}
bool DIARawSymbol::isIndirectVirtualBaseClass() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_indirectVirtualBaseClass);
}
bool DIARawSymbol::isInterfaceUdt() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_isInterfaceUdt);
}
bool DIARawSymbol::isIntrinsic() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_intrinsic);
}
bool DIARawSymbol::isLTCG() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_isLTCG);
}
bool DIARawSymbol::isLocationControlFlowDependent() const {
return PrivateGetDIAValue(Symbol,
&IDiaSymbol::get_isLocationControlFlowDependent);
}
bool DIARawSymbol::isMSILNetmodule() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_isMSILNetmodule);
}
bool DIARawSymbol::isMatrixRowMajor() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_isMatrixRowMajor);
}
bool DIARawSymbol::isManagedCode() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_managed);
}
bool DIARawSymbol::isMSILCode() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_msil);
}
bool DIARawSymbol::isMultipleInheritance() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_isMultipleInheritance);
}
bool DIARawSymbol::isNaked() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_isNaked);
}
bool DIARawSymbol::isNested() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_nested);
}
bool DIARawSymbol::isOptimizedAway() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_isOptimizedAway);
}
bool DIARawSymbol::isPacked() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_packed);
}
bool DIARawSymbol::isPointerBasedOnSymbolValue() const {
return PrivateGetDIAValue(Symbol,
&IDiaSymbol::get_isPointerBasedOnSymbolValue);
}
bool DIARawSymbol::isPointerToDataMember() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_isPointerToDataMember);
}
bool DIARawSymbol::isPointerToMemberFunction() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_isPointerToMemberFunction);
}
bool DIARawSymbol::isPureVirtual() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_pure);
}
bool DIARawSymbol::isRValueReference() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_RValueReference);
}
bool DIARawSymbol::isRefUdt() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_isRefUdt);
}
bool DIARawSymbol::isReference() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_reference);
}
bool DIARawSymbol::isRestrictedType() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_restrictedType);
}
bool DIARawSymbol::isReturnValue() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_isReturnValue);
}
bool DIARawSymbol::isSafeBuffers() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_isSafeBuffers);
}
bool DIARawSymbol::isScoped() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_scoped);
}
bool DIARawSymbol::isSdl() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_isSdl);
}
bool DIARawSymbol::isSingleInheritance() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_isSingleInheritance);
}
bool DIARawSymbol::isSplitted() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_isSplitted);
}
bool DIARawSymbol::isStatic() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_isStatic);
}
bool DIARawSymbol::hasPrivateSymbols() const {
// hasPrivateSymbols is the opposite of isStripped, but we expose
// hasPrivateSymbols as a more intuitive interface.
return !PrivateGetDIAValue(Symbol, &IDiaSymbol::get_isStripped);
}
bool DIARawSymbol::isUnalignedType() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_unalignedType);
}
bool DIARawSymbol::isUnreached() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_notReached);
}
bool DIARawSymbol::isValueUdt() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_isValueUdt);
}
bool DIARawSymbol::isVirtual() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_virtual);
}
bool DIARawSymbol::isVirtualBaseClass() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_virtualBaseClass);
}
bool DIARawSymbol::isVirtualInheritance() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_isVirtualInheritance);
}
bool DIARawSymbol::isVolatileType() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_volatileType);
}

View File

@ -0,0 +1,94 @@
//===- DIASession.cpp - DIA implementation of IPDBSession -------*- 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/DIA/DIAEnumDebugStreams.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;
namespace {}
DIASession::DIASession(CComPtr<IDiaSession> DiaSession) : Session(DiaSession) {}
DIASession *DIASession::createFromPdb(StringRef Path) {
CComPtr<IDiaDataSource> DataSource;
CComPtr<IDiaSession> Session;
// We assume that CoInitializeEx has already been called by the executable.
HRESULT Result = ::CoCreateInstance(CLSID_DiaSource, nullptr,
CLSCTX_INPROC_SERVER, IID_IDiaDataSource,
reinterpret_cast<LPVOID *>(&DataSource));
if (FAILED(Result))
return nullptr;
llvm::SmallVector<UTF16, 128> Path16;
if (!llvm::convertUTF8ToUTF16String(Path, Path16))
return nullptr;
const wchar_t *Path16Str = reinterpret_cast<const wchar_t*>(Path16.data());
if (FAILED(DataSource->loadDataFromPdb(Path16Str)))
return nullptr;
if (FAILED(DataSource->openSession(&Session)))
return nullptr;
return new DIASession(Session);
}
uint64_t DIASession::getLoadAddress() const {
uint64_t LoadAddress;
bool success = (S_OK == Session->get_loadAddress(&LoadAddress));
return (success) ? LoadAddress : 0;
}
void DIASession::setLoadAddress(uint64_t Address) {
Session->put_loadAddress(Address);
}
std::unique_ptr<PDBSymbolExe> DIASession::getGlobalScope() const {
CComPtr<IDiaSymbol> GlobalScope;
if (S_OK != Session->get_globalScope(&GlobalScope))
return nullptr;
auto RawSymbol = std::make_unique<DIARawSymbol>(*this, GlobalScope);
auto PdbSymbol(PDBSymbol::create(*this, std::move(RawSymbol)));
std::unique_ptr<PDBSymbolExe> ExeSymbol(
static_cast<PDBSymbolExe *>(PdbSymbol.release()));
return ExeSymbol;
}
std::unique_ptr<PDBSymbol> DIASession::getSymbolById(uint32_t SymbolId) const {
CComPtr<IDiaSymbol> LocatedSymbol;
if (S_OK != Session->symbolById(SymbolId, &LocatedSymbol))
return nullptr;
auto RawSymbol = std::make_unique<DIARawSymbol>(*this, LocatedSymbol);
return PDBSymbol::create(*this, std::move(RawSymbol));
}
std::unique_ptr<IPDBSourceFile>
DIASession::getSourceFileById(uint32_t FileId) const {
CComPtr<IDiaSourceFile> LocatedFile;
if (S_OK != Session->findFileById(FileId, &LocatedFile))
return nullptr;
return std::make_unique<DIASourceFile>(*this, LocatedFile);
}
std::unique_ptr<IPDBEnumDataStreams> DIASession::getDebugStreams() const {
CComPtr<IDiaEnumDebugStreams> DiaEnumerator;
if (S_OK != Session->getEnumDebugStreams(&DiaEnumerator))
return nullptr;
return std::unique_ptr<IPDBEnumDataStreams>(
new DIAEnumDebugStreams(DiaEnumerator));
}

View File

@ -0,0 +1,67 @@
//===- DIASourceFile.cpp - DIA implementation of IPDBSourceFile -*- 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/DIA/DIAEnumSymbols.h"
#include "llvm/DebugInfo/PDB/DIA/DIASession.h"
#include "llvm/DebugInfo/PDB/DIA/DIASourceFile.h"
#include "llvm/Support/ConvertUTF.h"
using namespace llvm;
DIASourceFile::DIASourceFile(const DIASession &PDBSession,
CComPtr<IDiaSourceFile> DiaSourceFile)
: Session(PDBSession), SourceFile(DiaSourceFile) {}
std::string DIASourceFile::getFileName() const {
CComBSTR FileName16;
HRESULT Result = SourceFile->get_fileName(&FileName16);
if (S_OK != Result)
return std::string();
std::string FileName8;
llvm::ArrayRef<char> FileNameBytes(reinterpret_cast<char *>(FileName16.m_str),
FileName16.ByteLength());
llvm::convertUTF16ToUTF8String(FileNameBytes, FileName8);
return FileName8;
}
uint32_t DIASourceFile::getUniqueId() const {
DWORD Id;
return (S_OK == SourceFile->get_uniqueId(&Id)) ? Id : 0;
}
std::string DIASourceFile::getChecksum() const {
DWORD ByteSize = 0;
HRESULT Result = SourceFile->get_checksum(0, &ByteSize, nullptr);
if (ByteSize == 0)
return std::string();
std::vector<BYTE> ChecksumBytes(ByteSize);
Result = SourceFile->get_checksum(ByteSize, &ByteSize, &ChecksumBytes[0]);
if (S_OK != Result)
return std::string();
return std::string(ChecksumBytes.begin(), ChecksumBytes.end());
}
PDB_Checksum DIASourceFile::getChecksumType() const {
DWORD Type;
HRESULT Result = SourceFile->get_checksumType(&Type);
if (S_OK != Result)
return PDB_Checksum::None;
return static_cast<PDB_Checksum>(Type);
}
std::unique_ptr<IPDBEnumSymbols> DIASourceFile::getCompilands() const {
CComPtr<IDiaEnumSymbols> DiaEnumerator;
HRESULT Result = SourceFile->get_compilands(&DiaEnumerator);
if (S_OK != Result)
return nullptr;
return std::unique_ptr<IPDBEnumSymbols>(
new DIAEnumSymbols(Session, DiaEnumerator));
}

View File

@ -7,15 +7,23 @@
//
//===----------------------------------------------------------------------===//
#include "llvm/Config/config.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/DebugInfo/PDB/PDB.h"
#include "llvm/DebugInfo/PDB/IPDBSession.h"
#if HAVE_DIA_SDK
#include "llvm/DebugInfo/PDB/DIA/DIASession.h"
#endif
using namespace llvm;
std::unique_ptr<IPDBSession> llvm::createPDBReader(PDB_ReaderType Type,
StringRef Path) {
// Create the correct concrete instance type based on the value of Type.
#if HAVE_DIA_SDK
return std::unique_ptr<DIASession>(DIASession::createFromPdb(Path));
#endif
return nullptr;
}