[Lldb-commits] [PATCH] D127922: [lldb] Introduce the concept of a log handler (NFC)

Jonas Devlieghere via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu Jun 16 10:36:57 PDT 2022


JDevlieghere marked 3 inline comments as done.
JDevlieghere added inline comments.


================
Comment at: lldb/source/Utility/Log.cpp:323-324
   if (options.Test(LLDB_LOG_OPTION_THREADSAFE)) {
     static std::recursive_mutex g_LogThreadedMutex;
     std::lock_guard<std::recursive_mutex> guard(g_LogThreadedMutex);
+    handler_sp->Emit(message);
----------------
clayborg wrote:
> Since we are improving stuff here, should we add a mutex to each handler and use the handler specific mutex if needed?
Yup, I think that makes sense


================
Comment at: lldb/source/Utility/Log.cpp:325
     std::lock_guard<std::recursive_mutex> guard(g_LogThreadedMutex);
-    *stream_sp << message;
-    stream_sp->flush();
+    handler_sp->Emit(message);
+    handler_sp->Flush();
----------------
clayborg wrote:
> Will this copy the string? The Emit() calls take a "std::string", maybe we should switch it to "const std::string &" to avoid any copies?
Yeah,  was planning on `std::move`-ing everything but I already found a few cases where that doesn't work. This should indeed take a reference. 


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

https://reviews.llvm.org/D127922



More information about the lldb-commits mailing list