summaryrefslogtreecommitdiffstats
path: root/llvm/lib/DebugInfo/PDB
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/DebugInfo/PDB')
-rw-r--r--llvm/lib/DebugInfo/PDB/DIA/DIAError.cpp31
-rw-r--r--llvm/lib/DebugInfo/PDB/DIA/DIASession.cpp9
-rw-r--r--llvm/lib/DebugInfo/PDB/GenericError.cpp55
-rw-r--r--llvm/lib/DebugInfo/PDB/Native/NativeSession.cpp1
-rw-r--r--llvm/lib/DebugInfo/PDB/Native/PDBFile.cpp2
-rw-r--r--llvm/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp1
-rw-r--r--llvm/lib/DebugInfo/PDB/Native/RawError.cpp30
-rw-r--r--llvm/lib/DebugInfo/PDB/PDB.cpp6
8 files changed, 33 insertions, 102 deletions
diff --git a/llvm/lib/DebugInfo/PDB/DIA/DIAError.cpp b/llvm/lib/DebugInfo/PDB/DIA/DIAError.cpp
index 0da877b0fba..819651f7778 100644
--- a/llvm/lib/DebugInfo/PDB/DIA/DIAError.cpp
+++ b/llvm/lib/DebugInfo/PDB/DIA/DIAError.cpp
@@ -11,14 +11,13 @@ using namespace llvm::pdb;
class DIAErrorCategory : public std::error_category {
public:
const char *name() const noexcept override { return "llvm.pdb.dia"; }
-
std::string message(int Condition) const override {
switch (static_cast<dia_error_code>(Condition)) {
case dia_error_code::could_not_create_impl:
- return "Failed to connect to DIA at runtime. Verify that Visual Studio "
+ return "Failed to connect to DIA at runtime. Verify that Visual Studio "
"is properly installed, or that msdiaXX.dll is in your PATH.";
case dia_error_code::invalid_file_format:
- return "Unable to load PDB. The file has an unrecognized format.";
+ return "Unable to load PDB. The file has an unrecognized format.";
case dia_error_code::invalid_parameter:
return "The parameter is incorrect.";
case dia_error_code::already_loaded:
@@ -32,27 +31,7 @@ public:
}
};
-static ManagedStatic<DIAErrorCategory> Category;
-
-char DIAError::ID = 0;
-
-DIAError::DIAError(dia_error_code C) : DIAError(C, "") {}
-
-DIAError::DIAError(StringRef Context)
- : DIAError(dia_error_code::unspecified, Context) {}
-
-DIAError::DIAError(dia_error_code C, StringRef Context) : Code(C) {
- ErrMsg = "DIA Error: ";
- std::error_code EC = convertToErrorCode();
- ErrMsg += EC.message() + " ";
- if (!Context.empty())
- ErrMsg += Context;
-}
-
-void DIAError::log(raw_ostream &OS) const { OS << ErrMsg << "\n"; }
-
-StringRef DIAError::getErrorMessage() const { return ErrMsg; }
+static llvm::ManagedStatic<DIAErrorCategory> DIACategory;
+const std::error_category &llvm::pdb::DIAErrCategory() { return *DIACategory; }
-std::error_code DIAError::convertToErrorCode() const {
- return std::error_code(static_cast<int>(Code), *Category);
-}
+char DIAError::ID;
diff --git a/llvm/lib/DebugInfo/PDB/DIA/DIASession.cpp b/llvm/lib/DebugInfo/PDB/DIA/DIASession.cpp
index d81f59400eb..f133b7ff77f 100644
--- a/llvm/lib/DebugInfo/PDB/DIA/DIASession.cpp
+++ b/llvm/lib/DebugInfo/PDB/DIA/DIASession.cpp
@@ -42,7 +42,7 @@ static Error ErrorFromHResult(HRESULT Result, const char *Str, Ts &&... Args) {
switch (Result) {
case E_PDB_NOT_FOUND:
- return make_error<GenericError>(generic_error_code::invalid_path, Context);
+ return errorCodeToError(std::error_code(ENOENT, std::generic_category()));
case E_PDB_FORMAT:
return make_error<DIAError>(dia_error_code::invalid_file_format, Context);
case E_INVALIDARG:
@@ -71,8 +71,7 @@ static Error LoadDIA(CComPtr<IDiaDataSource> &DiaDataSource) {
// 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 llvm::make_error<GenericError>(
- "DIA is only supported when using MSVC.");
+ return llvm::make_error<PDBError>(pdb_error_code::dia_failed_loading);
#else
const wchar_t *msdia_dll = nullptr;
#if _MSC_VER >= 1900 && _MSC_VER < 2000
@@ -104,7 +103,7 @@ Error DIASession::createFromPdb(StringRef Path,
llvm::SmallVector<UTF16, 128> Path16;
if (!llvm::convertUTF8ToUTF16String(Path, Path16))
- return make_error<GenericError>(generic_error_code::invalid_path);
+ return make_error<PDBError>(pdb_error_code::invalid_utf8_path, Path);
const wchar_t *Path16Str = reinterpret_cast<const wchar_t *>(Path16.data());
HRESULT HR;
@@ -130,7 +129,7 @@ Error DIASession::createFromExe(StringRef Path,
llvm::SmallVector<UTF16, 128> Path16;
if (!llvm::convertUTF8ToUTF16String(Path, Path16))
- return make_error<GenericError>(generic_error_code::invalid_path, Path);
+ return make_error<PDBError>(pdb_error_code::invalid_utf8_path, Path);
const wchar_t *Path16Str = reinterpret_cast<const wchar_t *>(Path16.data());
HRESULT HR;
diff --git a/llvm/lib/DebugInfo/PDB/GenericError.cpp b/llvm/lib/DebugInfo/PDB/GenericError.cpp
index 2a677b9abe2..b6e668a74eb 100644
--- a/llvm/lib/DebugInfo/PDB/GenericError.cpp
+++ b/llvm/lib/DebugInfo/PDB/GenericError.cpp
@@ -14,55 +14,34 @@
using namespace llvm;
using namespace llvm::pdb;
-namespace {
// FIXME: This class is only here to support the transition to llvm::Error. It
// will be removed once this transition is complete. Clients should prefer to
// deal with the Error value directly, rather than converting to error_code.
-class GenericErrorCategory : public std::error_category {
+class PDBErrorCategory : public std::error_category {
public:
const char *name() const noexcept override { return "llvm.pdb"; }
-
std::string message(int Condition) const override {
- switch (static_cast<generic_error_code>(Condition)) {
- case generic_error_code::unspecified:
+ switch (static_cast<pdb_error_code>(Condition)) {
+ case pdb_error_code::unspecified:
return "An unknown error has occurred.";
- case generic_error_code::type_server_not_found:
- return "Type server PDB was not found.";
- case generic_error_code::dia_sdk_not_present:
- return "LLVM was not compiled with support for DIA. This usually means "
+ case pdb_error_code::type_server_not_found:
+ return "Type server PDB was not found.";
+ case pdb_error_code::dia_sdk_not_present:
+ return "LLVM was not compiled with support for DIA. This usually means "
"that you are not using MSVC, or your Visual Studio "
- "installation "
- "is corrupt.";
- case generic_error_code::invalid_path:
- return "Unable to load PDB. Make sure the file exists and is readable.";
+ "installation is corrupt.";
+ case pdb_error_code::dia_failed_loading:
+ return "DIA is only supported when using MSVC.";
+ case pdb_error_code::invalid_utf8_path:
+ return "The PDB file path is an invalid UTF8 sequence.";
+ case pdb_error_code::signature_out_of_date:
+ return "The signature does not match; the file(s) might be out of date";
}
llvm_unreachable("Unrecognized generic_error_code");
}
};
-} // end anonymous namespace
-
-static ManagedStatic<GenericErrorCategory> Category;
-
-char GenericError::ID = 0;
-
-GenericError::GenericError(generic_error_code C) : GenericError(C, "") {}
-
-GenericError::GenericError(StringRef Context)
- : GenericError(generic_error_code::unspecified, Context) {}
-
-GenericError::GenericError(generic_error_code C, StringRef Context) : Code(C) {
- ErrMsg = "PDB Error: ";
- std::error_code EC = convertToErrorCode();
- if (Code != generic_error_code::unspecified)
- ErrMsg += EC.message() + " ";
- if (!Context.empty())
- ErrMsg += Context;
-}
-
-void GenericError::log(raw_ostream &OS) const { OS << ErrMsg << "\n"; }
-StringRef GenericError::getErrorMessage() const { return ErrMsg; }
+static llvm::ManagedStatic<PDBErrorCategory> PDBCategory;
+const std::error_category &llvm::pdb::PDBErrCategory() { return *PDBCategory; }
-std::error_code GenericError::convertToErrorCode() const {
- return std::error_code(static_cast<int>(Code), *Category);
-}
+char PDBError::ID;
diff --git a/llvm/lib/DebugInfo/PDB/Native/NativeSession.cpp b/llvm/lib/DebugInfo/PDB/Native/NativeSession.cpp
index 086da13135c..bf66f1c3f42 100644
--- a/llvm/lib/DebugInfo/PDB/Native/NativeSession.cpp
+++ b/llvm/lib/DebugInfo/PDB/Native/NativeSession.cpp
@@ -11,7 +11,6 @@
#include "llvm/ADT/STLExtras.h"
#include "llvm/DebugInfo/CodeView/TypeIndex.h"
-#include "llvm/DebugInfo/PDB/GenericError.h"
#include "llvm/DebugInfo/PDB/IPDBEnumChildren.h"
#include "llvm/DebugInfo/PDB/IPDBSourceFile.h"
#include "llvm/DebugInfo/PDB/Native/NativeBuiltinSymbol.h"
diff --git a/llvm/lib/DebugInfo/PDB/Native/PDBFile.cpp b/llvm/lib/DebugInfo/PDB/Native/PDBFile.cpp
index c5ce3e0091f..a1f8786ff12 100644
--- a/llvm/lib/DebugInfo/PDB/Native/PDBFile.cpp
+++ b/llvm/lib/DebugInfo/PDB/Native/PDBFile.cpp
@@ -125,7 +125,7 @@ Error PDBFile::parseFileHeaders() {
if (auto EC = Reader.readObject(SB)) {
consumeError(std::move(EC));
return make_error<RawError>(raw_error_code::corrupt_file,
- "Does not contain superblock");
+ "MSF superblock is missing");
}
if (auto EC = msf::validateSuperBlock(*SB))
diff --git a/llvm/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp b/llvm/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp
index e164e7cf1c5..1612d74eba2 100644
--- a/llvm/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp
+++ b/llvm/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp
@@ -12,7 +12,6 @@
#include "llvm/ADT/BitVector.h"
#include "llvm/DebugInfo/MSF/MSFBuilder.h"
-#include "llvm/DebugInfo/PDB/GenericError.h"
#include "llvm/DebugInfo/PDB/Native/DbiStream.h"
#include "llvm/DebugInfo/PDB/Native/DbiStreamBuilder.h"
#include "llvm/DebugInfo/PDB/Native/GSIStreamBuilder.h"
diff --git a/llvm/lib/DebugInfo/PDB/Native/RawError.cpp b/llvm/lib/DebugInfo/PDB/Native/RawError.cpp
index 548289fff3d..dec9797088f 100644
--- a/llvm/lib/DebugInfo/PDB/Native/RawError.cpp
+++ b/llvm/lib/DebugInfo/PDB/Native/RawError.cpp
@@ -5,14 +5,12 @@
using namespace llvm;
using namespace llvm::pdb;
-namespace {
// FIXME: This class is only here to support the transition to llvm::Error. It
// will be removed once this transition is complete. Clients should prefer to
// deal with the Error value directly, rather than converting to error_code.
class RawErrorCategory : public std::error_category {
public:
const char *name() const noexcept override { return "llvm.pdb.raw"; }
-
std::string message(int Condition) const override {
switch (static_cast<raw_error_code>(Condition)) {
case raw_error_code::unspecified:
@@ -46,30 +44,8 @@ public:
llvm_unreachable("Unrecognized raw_error_code");
}
};
-} // end anonymous namespace
-
-static ManagedStatic<RawErrorCategory> Category;
-
-char RawError::ID = 0;
-
-RawError::RawError(raw_error_code C) : RawError(C, "") {}
-
-RawError::RawError(const std::string &Context)
- : RawError(raw_error_code::unspecified, Context) {}
-
-RawError::RawError(raw_error_code C, const std::string &Context) : Code(C) {
- ErrMsg = "Native PDB Error: ";
- std::error_code EC = convertToErrorCode();
- if (Code != raw_error_code::unspecified)
- ErrMsg += EC.message() + " ";
- if (!Context.empty())
- ErrMsg += Context;
-}
-
-void RawError::log(raw_ostream &OS) const { OS << ErrMsg << "\n"; }
-const std::string &RawError::getErrorMessage() const { return ErrMsg; }
+static llvm::ManagedStatic<RawErrorCategory> RawCategory;
+const std::error_category &llvm::pdb::RawErrCategory() { return *RawCategory; }
-std::error_code RawError::convertToErrorCode() const {
- return std::error_code(static_cast<int>(Code), *Category);
-}
+char RawError::ID;
diff --git a/llvm/lib/DebugInfo/PDB/PDB.cpp b/llvm/lib/DebugInfo/PDB/PDB.cpp
index 40f5ae9ba84..fc1ad8bcd7c 100644
--- a/llvm/lib/DebugInfo/PDB/PDB.cpp
+++ b/llvm/lib/DebugInfo/PDB/PDB.cpp
@@ -29,7 +29,7 @@ Error llvm::pdb::loadDataForPDB(PDB_ReaderType Type, StringRef Path,
MemoryBuffer::getFileOrSTDIN(Path, /*FileSize=*/-1,
/*RequiresNullTerminator=*/false);
if (!ErrorOrBuffer)
- return make_error<GenericError>(generic_error_code::invalid_path, Path);
+ return errorCodeToError(ErrorOrBuffer.getError());
return NativeSession::createFromPdb(std::move(*ErrorOrBuffer), Session);
}
@@ -37,7 +37,7 @@ Error llvm::pdb::loadDataForPDB(PDB_ReaderType Type, StringRef Path,
#if LLVM_ENABLE_DIA_SDK
return DIASession::createFromPdb(Path, Session);
#else
- return make_error<GenericError>("DIA is not installed on the system");
+ return make_error<PDBError>(pdb_error_code::dia_sdk_not_present);
#endif
}
@@ -50,6 +50,6 @@ Error llvm::pdb::loadDataForEXE(PDB_ReaderType Type, StringRef Path,
#if LLVM_ENABLE_DIA_SDK
return DIASession::createFromExe(Path, Session);
#else
- return make_error<GenericError>("DIA is not installed on the system");
+ return make_error<PDBError>(pdb_error_code::dia_sdk_not_present);
#endif
}
OpenPOWER on IntegriCloud