[Lldb-commits] [PATCH] D69646: [LLDB] [PECOFF] Fix error handling for executables that object::createBinary error out on

Martin Storsjö via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu Oct 31 01:44:13 PDT 2019


mstorsjo marked an inline comment as done.
mstorsjo added inline comments.


================
Comment at: lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp:175-179
+    std::string msg = errorToErrorCode(binary.takeError()).message();
+    LLDB_LOGF(log,
+              "ObjectFilePECOFF::GetModuleSpecifications() - failed to create binary "
+              "for file (%s): %s",
+              file ? file.GetPath().c_str() : "<NULL>", msg.c_str());
----------------
labath wrote:
> There's an LLDB_LOG_ERROR macro, which makes sure to "handle" the error even if logging is disabled. It also handles all the `.c_str()` stuff *and* is able to prepend the name of the caller to the log message (if one requests that when enabling logging). So, overall, this could just be:
> `LLDB_LOG_ERROR(log, binary.takeError(), "Failed to create binary for file ({1}): {0}", file)`
Oh, awesome, that's much neater.


Repository:
  rLLDB LLDB

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69646/new/

https://reviews.llvm.org/D69646





More information about the lldb-commits mailing list