[Lldb-commits] [lldb] [lldb] Log errors to the system log if they would otherwise get dropped (PR #111911)

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Fri Oct 11 00:02:54 PDT 2024


================
@@ -387,6 +396,9 @@ template <typename Cat> Log *GetLog(Cat mask) {
     if (log_private && error_private) {                                        \
       log_private->FormatError(::std::move(error_private), __FILE__, __func__, \
                                __VA_ARGS__);                                   \
+    } else if (::lldb_private::Log *log_error = GetLLDBErrorLog()) {           \
----------------
labath wrote:

I'd recommend structuring this in a way that avoids evaluating `__VA_ARGS__` more than once. You could e.g. insert a `if(!log_private) log_private = GetLLDBErrorLog()` statement before this `if`.

(I know that the macro gets dynamically evaluated only once, but I was recently reading about how this innocent-looking macro in the linux kernel exploded to several dozen kilobytes of goo. We're not there yet, but this should help anyone looking at the preprocessed output, and also help the compiler generate less code)

https://github.com/llvm/llvm-project/pull/111911


More information about the lldb-commits mailing list