mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-10-19 02:52:53 +02:00
[llvm-pdbdump] Print a better error message when PDB loading fails.
Differential Revision: http://reviews.llvm.org/D19234 llvm-svn: 266772
This commit is contained in:
parent
4fdd2658f9
commit
a1935c25dc
@ -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,
|
||||
|
@ -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))
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user