diff options
author | Zachary Turner <zturner@google.com> | 2016-04-19 17:36:58 +0000 |
---|---|---|
committer | Zachary Turner <zturner@google.com> | 2016-04-19 17:36:58 +0000 |
commit | 23ee87bda0ca3740b1c020be9890ee55dfc8dbe4 (patch) | |
tree | 4da52e250a7adf79212712ec2d22b13c8a3c45e8 | |
parent | e0e87aff5cbaadccea2b91fa4011f199a3b14a07 (diff) | |
download | bcm5719-llvm-23ee87bda0ca3740b1c020be9890ee55dfc8dbe4.tar.gz bcm5719-llvm-23ee87bda0ca3740b1c020be9890ee55dfc8dbe4.zip |
[llvm-pdbdump] Print a better error message when PDB loading fails.
Differential Revision: http://reviews.llvm.org/D19234
llvm-svn: 266772
-rw-r--r-- | llvm/include/llvm/DebugInfo/PDB/PDBTypes.h | 3 | ||||
-rw-r--r-- | llvm/lib/DebugInfo/PDB/DIA/DIASession.cpp | 29 | ||||
-rw-r--r-- | llvm/lib/DebugInfo/PDB/PDB.cpp | 4 | ||||
-rw-r--r-- | llvm/tools/llvm-pdbdump/llvm-pdbdump.cpp | 10 |
4 files changed, 29 insertions, 17 deletions
diff --git a/llvm/include/llvm/DebugInfo/PDB/PDBTypes.h b/llvm/include/llvm/DebugInfo/PDB/PDBTypes.h index 7e39bebf576..1e42d9a6a8b 100644 --- a/llvm/include/llvm/DebugInfo/PDB/PDBTypes.h +++ b/llvm/include/llvm/DebugInfo/PDB/PDBTypes.h @@ -320,7 +320,8 @@ enum class PDB_MemberAccess { Private = 1, Protected = 2, Public = 3 }; enum class PDB_ErrorCode { Success, - NoPdbImpl, + NoDiaSupport, + CouldNotCreateImpl, InvalidPath, InvalidFileFormat, InvalidParameter, diff --git a/llvm/lib/DebugInfo/PDB/DIA/DIASession.cpp b/llvm/lib/DebugInfo/PDB/DIA/DIASession.cpp index 60894bbd0ce..89a9f510980 100644 --- a/llvm/lib/DebugInfo/PDB/DIA/DIASession.cpp +++ b/llvm/lib/DebugInfo/PDB/DIA/DIASession.cpp @@ -24,17 +24,18 @@ using namespace llvm; namespace { -bool LoadDIA(CComPtr<IDiaDataSource>& DiaDataSource) { +PDB_ErrorCode LoadDIA(CComPtr<IDiaDataSource> &DiaDataSource) { if (SUCCEEDED(CoCreateInstance(CLSID_DiaSource, nullptr, CLSCTX_INPROC_SERVER, IID_IDiaDataSource, reinterpret_cast<LPVOID *>(&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 @@ bool LoadDIA(CComPtr<IDiaDataSource>& DiaDataSource) { #else #error "Unknown Visual Studio version." #endif - return msdia_dll && - SUCCEEDED(NoRegCoCreate(msdia_dll, CLSID_DiaSource, IID_IDiaDataSource, - reinterpret_cast<LPVOID *>(&DiaDataSource))); -#endif + + if (SUCCEEDED(NoRegCoCreate(msdia_dll, CLSID_DiaSource, IID_IDiaDataSource, + reinterpret_cast<LPVOID *>(&DiaDataSource)))) + return PDB_ErrorCode::Success; + else + return PDB_ErrorCode::CouldNotCreateImpl; } } @@ -59,8 +62,9 @@ PDB_ErrorCode DIASession::createFromPdb(StringRef Path, CComPtr<IDiaSession> 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<UTF16, 128> Path16; if (!llvm::convertUTF8ToUTF16String(Path, Path16)) @@ -98,8 +102,9 @@ PDB_ErrorCode DIASession::createFromExe(StringRef Path, CComPtr<IDiaSession> 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<UTF16, 128> Path16; if (!llvm::convertUTF8ToUTF16String(Path, Path16)) diff --git a/llvm/lib/DebugInfo/PDB/PDB.cpp b/llvm/lib/DebugInfo/PDB/PDB.cpp index 613407eb134..bb4094208e2 100644 --- a/llvm/lib/DebugInfo/PDB/PDB.cpp +++ b/llvm/lib/DebugInfo/PDB/PDB.cpp @@ -26,7 +26,7 @@ PDB_ErrorCode llvm::loadDataForPDB(PDB_ReaderType Type, StringRef Path, #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 @@ PDB_ErrorCode llvm::loadDataForEXE(PDB_ReaderType Type, StringRef Path, #if HAVE_DIA_SDK return DIASession::createFromExe(Path, Session); #endif - return PDB_ErrorCode::NoPdbImpl; + return PDB_ErrorCode::NoDiaSupport; } diff --git a/llvm/tools/llvm-pdbdump/llvm-pdbdump.cpp b/llvm/tools/llvm-pdbdump/llvm-pdbdump.cpp index 940ef1b6399..7418cff511e 100644 --- a/llvm/tools/llvm-pdbdump/llvm-pdbdump.cpp +++ b/llvm/tools/llvm-pdbdump/llvm-pdbdump.cpp @@ -624,8 +624,14 @@ static void dumpInput(StringRef Path) { 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 |