summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorNico Weber <nicolasweber@gmx.de>2016-04-01 22:21:51 +0000
committerNico Weber <nicolasweber@gmx.de>2016-04-01 22:21:51 +0000
commit73853ab4f86d3013f1d075b45e19287a5b2100a7 (patch)
tree530795858ad4566d9a5582486902b94293835f6a /llvm/lib
parentcf0961f5ea0269e2a921ed6775190deda74785dd (diff)
downloadbcm5719-llvm-73853ab4f86d3013f1d075b45e19287a5b2100a7.tar.gz
bcm5719-llvm-73853ab4f86d3013f1d075b45e19287a5b2100a7.zip
Make DIASession work if msdia*.dll isn't registered.
This fixes various symbolization test failures for me when I build with a hermetic VS2015 without having run the 2015 installer. http://reviews.llvm.org/D18707 llvm-svn: 265193
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/DebugInfo/PDB/DIA/DIASession.cpp43
1 files changed, 34 insertions, 9 deletions
diff --git a/llvm/lib/DebugInfo/PDB/DIA/DIASession.cpp b/llvm/lib/DebugInfo/PDB/DIA/DIASession.cpp
index 5e58bb4008f..60894bbd0ce 100644
--- a/llvm/lib/DebugInfo/PDB/DIA/DIASession.cpp
+++ b/llvm/lib/DebugInfo/PDB/DIA/DIASession.cpp
@@ -18,9 +18,38 @@
#include "llvm/DebugInfo/PDB/PDBSymbolExe.h"
#include "llvm/Support/ConvertUTF.h"
+#include <diacreate.h>
+
using namespace llvm;
-namespace {}
+namespace {
+
+bool LoadDIA(CComPtr<IDiaDataSource>& DiaDataSource) {
+ if (SUCCEEDED(CoCreateInstance(CLSID_DiaSource, nullptr, CLSCTX_INPROC_SERVER,
+ IID_IDiaDataSource,
+ reinterpret_cast<LPVOID *>(&DiaDataSource))))
+ return true;
+
+ // If the CoCreateInstance call above failed, msdia*.dll is not registered.
+ // Try loading the DLL corresponding to the #included DIA SDK.
+#if !defined(_MSC_VER)
+ return false;
+#else
+ const wchar_t *msdia_dll = nullptr;
+#if _MSC_VER == 1900
+ msdia_dll = L"msdia140.dll"; // VS2015
+#elif _MSC_VER == 1800
+ msdia_dll = L"msdia120.dll"; // VS2013
+#else
+#error "Unknown Visual Studio version."
+#endif
+ return msdia_dll &&
+ SUCCEEDED(NoRegCoCreate(msdia_dll, CLSID_DiaSource, IID_IDiaDataSource,
+ reinterpret_cast<LPVOID *>(&DiaDataSource)));
+#endif
+}
+
+}
DIASession::DIASession(CComPtr<IDiaSession> DiaSession) : Session(DiaSession) {}
@@ -30,10 +59,7 @@ PDB_ErrorCode DIASession::createFromPdb(StringRef Path,
CComPtr<IDiaSession> DiaSession;
// 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 *>(&DiaDataSource));
- if (FAILED(Result))
+ if (!LoadDIA(DiaDataSource))
return PDB_ErrorCode::NoPdbImpl;
llvm::SmallVector<UTF16, 128> Path16;
@@ -41,6 +67,7 @@ PDB_ErrorCode DIASession::createFromPdb(StringRef Path,
return PDB_ErrorCode::InvalidPath;
const wchar_t *Path16Str = reinterpret_cast<const wchar_t*>(Path16.data());
+ HRESULT Result;
if (FAILED(Result = DiaDataSource->loadDataFromPdb(Path16Str))) {
if (Result == E_PDB_NOT_FOUND)
return PDB_ErrorCode::InvalidPath;
@@ -71,10 +98,7 @@ PDB_ErrorCode DIASession::createFromExe(StringRef Path,
CComPtr<IDiaSession> DiaSession;
// 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 *>(&DiaDataSource));
- if (FAILED(Result))
+ if (!LoadDIA(DiaDataSource))
return PDB_ErrorCode::NoPdbImpl;
llvm::SmallVector<UTF16, 128> Path16;
@@ -82,6 +106,7 @@ PDB_ErrorCode DIASession::createFromExe(StringRef Path,
return PDB_ErrorCode::InvalidPath;
const wchar_t *Path16Str = reinterpret_cast<const wchar_t *>(Path16.data());
+ HRESULT Result;
if (FAILED(Result =
DiaDataSource->loadDataForExe(Path16Str, nullptr, nullptr))) {
if (Result == E_PDB_NOT_FOUND)
OpenPOWER on IntegriCloud