diff options
author | Martin Storsjö <martin@martin.st> | 2019-10-30 23:57:40 +0200 |
---|---|---|
committer | Martin Storsjö <martin@martin.st> | 2019-10-31 11:26:21 +0200 |
commit | 3db1d138b1172b5855f35ab74dbf3bf327f517d2 (patch) | |
tree | 5635ff3b8f4030479070c997cee3dc315798d064 /lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp | |
parent | a42967f63c96b30dd6873ceb7b2932eb7cf2cd05 (diff) | |
download | bcm5719-llvm-3db1d138b1172b5855f35ab74dbf3bf327f517d2.tar.gz bcm5719-llvm-3db1d138b1172b5855f35ab74dbf3bf327f517d2.zip |
[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
Diffstat (limited to 'lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp')
-rw-r--r-- | lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp b/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp index deec50dafb4..37e1120838f 100644 --- a/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp +++ b/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp @@ -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; } |