Index: llvm/trunk/include/llvm/DebugInfo/PDB/PDBTypes.h =================================================================== --- llvm/trunk/include/llvm/DebugInfo/PDB/PDBTypes.h +++ llvm/trunk/include/llvm/DebugInfo/PDB/PDBTypes.h @@ -320,7 +320,8 @@ enum class PDB_ErrorCode { Success, - NoPdbImpl, + NoDiaSupport, + CouldNotCreateImpl, InvalidPath, InvalidFileFormat, InvalidParameter, Index: llvm/trunk/lib/DebugInfo/PDB/DIA/DIASession.cpp =================================================================== --- llvm/trunk/lib/DebugInfo/PDB/DIA/DIASession.cpp +++ llvm/trunk/lib/DebugInfo/PDB/DIA/DIASession.cpp @@ -24,17 +24,18 @@ namespace { -bool LoadDIA(CComPtr& DiaDataSource) { +PDB_ErrorCode LoadDIA(CComPtr &DiaDataSource) { if (SUCCEEDED(CoCreateInstance(CLSID_DiaSource, nullptr, CLSCTX_INPROC_SERVER, IID_IDiaDataSource, reinterpret_cast(&DiaDataSource)))) - return true; + return PDB_ErrorCode::Success; // 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 + return PDB_ErrorCode::NoDiaSupport; +#endif + const wchar_t *msdia_dll = nullptr; #if _MSC_VER == 1900 msdia_dll = L"msdia140.dll"; // VS2015 @@ -43,10 +44,12 @@ #else #error "Unknown Visual Studio version." #endif - return msdia_dll && - SUCCEEDED(NoRegCoCreate(msdia_dll, CLSID_DiaSource, IID_IDiaDataSource, - reinterpret_cast(&DiaDataSource))); -#endif + + if (SUCCEEDED(NoRegCoCreate(msdia_dll, CLSID_DiaSource, IID_IDiaDataSource, + reinterpret_cast(&DiaDataSource)))) + return PDB_ErrorCode::Success; + else + return PDB_ErrorCode::CouldNotCreateImpl; } } @@ -59,8 +62,9 @@ CComPtr DiaSession; // We assume that CoInitializeEx has already been called by the executable. - if (!LoadDIA(DiaDataSource)) - return PDB_ErrorCode::NoPdbImpl; + PDB_ErrorCode result = LoadDIA(DiaDataSource); + if (result != PDB_ErrorCode::Success) + return result; llvm::SmallVector Path16; if (!llvm::convertUTF8ToUTF16String(Path, Path16)) @@ -98,8 +102,9 @@ CComPtr DiaSession; // We assume that CoInitializeEx has already been called by the executable. - if (!LoadDIA(DiaDataSource)) - return PDB_ErrorCode::NoPdbImpl; + PDB_ErrorCode result = LoadDIA(DiaDataSource); + if (result != PDB_ErrorCode::Success) + return result; llvm::SmallVector Path16; if (!llvm::convertUTF8ToUTF16String(Path, Path16)) Index: llvm/trunk/lib/DebugInfo/PDB/PDB.cpp =================================================================== --- llvm/trunk/lib/DebugInfo/PDB/PDB.cpp +++ llvm/trunk/lib/DebugInfo/PDB/PDB.cpp @@ -26,7 +26,7 @@ #if HAVE_DIA_SDK return DIASession::createFromPdb(Path, Session); #endif - return PDB_ErrorCode::NoPdbImpl; + return PDB_ErrorCode::NoDiaSupport; } PDB_ErrorCode llvm::loadDataForEXE(PDB_ReaderType Type, StringRef Path, @@ -35,5 +35,5 @@ #if HAVE_DIA_SDK return DIASession::createFromExe(Path, Session); #endif - return PDB_ErrorCode::NoPdbImpl; + return PDB_ErrorCode::NoDiaSupport; } Index: llvm/trunk/tools/llvm-pdbdump/llvm-pdbdump.cpp =================================================================== --- llvm/trunk/tools/llvm-pdbdump/llvm-pdbdump.cpp +++ llvm/trunk/tools/llvm-pdbdump/llvm-pdbdump.cpp @@ -624,8 +624,14 @@ switch (Error) { case PDB_ErrorCode::Success: break; - case PDB_ErrorCode::NoPdbImpl: - outs() << "Reading PDBs is not supported on this platform.\n"; + case PDB_ErrorCode::NoDiaSupport: + outs() << "LLVM was not compiled with support for DIA. This usually means " + "that either LLVM was not compiled with MSVC, or your MSVC " + "installation is corrupt.\n"; + return; + case PDB_ErrorCode::CouldNotCreateImpl: + outs() << "Failed to connect to DIA at runtime. Verify that Visual Studio " + "is properly installed, or that msdiaXX.dll is in your PATH.\n"; return; case PDB_ErrorCode::InvalidPath: outs() << "Unable to load PDB at '" << Path