[LLDB] [PECOFF] Fix error handling for executables that object::createBinary errors out on
llvm::object::createBinary returns an Expected<>, which requires not only checking the object for success, but also requires consuming the Error, if one was set. Use LLDB_LOG_ERROR for this case, and change an existing similar log statement to use it as well, to make sure the Error is consumed even if the log channel is disabled. Differential Revision: https://reviews.llvm.org/D69646
This commit is contained in:
@@ -167,9 +167,15 @@ size_t ObjectFilePECOFF::GetModuleSpecifications(
|
||||
if (!data_sp || !ObjectFilePECOFF::MagicBytesMatch(data_sp))
|
||||
return initial_count;
|
||||
|
||||
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_OBJECT));
|
||||
|
||||
auto binary = llvm::object::createBinary(file.GetPath());
|
||||
if (!binary)
|
||||
|
||||
if (!binary) {
|
||||
LLDB_LOG_ERROR(log, binary.takeError(),
|
||||
"Failed to create binary for file ({1}): {0}", file);
|
||||
return initial_count;
|
||||
}
|
||||
|
||||
if (!binary->getBinary()->isCOFF() &&
|
||||
!binary->getBinary()->isCOFFImportFile())
|
||||
@@ -242,11 +248,8 @@ bool ObjectFilePECOFF::CreateBinary() {
|
||||
|
||||
auto binary = llvm::object::createBinary(m_file.GetPath());
|
||||
if (!binary) {
|
||||
LLDB_LOGF(log,
|
||||
"ObjectFilePECOFF::CreateBinary() - failed to create binary "
|
||||
"for file (%s): %s",
|
||||
m_file ? m_file.GetPath().c_str() : "<NULL>",
|
||||
errorToErrorCode(binary.takeError()).message().c_str());
|
||||
LLDB_LOG_ERROR(log, binary.takeError(),
|
||||
"Failed to create binary for file ({1}): {0}", m_file);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user