[Lldb-commits] [PATCH] D127986: [lldb] Support a buffered logging mode

Greg Clayton via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu Jun 16 13:27:16 PDT 2022


clayborg added a comment.

The main questions is if we want --buffered for any log channel (file, callback, or circular). If we add a --circular flag, then we just let things accumulate in the LogHandler class.

The idea would be to add more stuff to the LogHandler base class to support this:

class LogHandler {

  bool m_circular = false; // If true, never flush unless "log dump" is called.
  size_t m_buffer_size = 0;
  // If m_buffer_size > 0 then store messages in m_buffer until size is exceeded, then flush.
  std::string m_buffer; 

};

Then we don't need "RotatingLogHandler", and then "log dump" can dump to the callback or to the file. So when the buffer is full, we flush to the virtual Emit(...) call. Just adds some extra logic to the LogHandler class' Emit(...) method to take care of the buffering.



================
Comment at: lldb/source/Commands/CommandObjectLog.cpp:166-169
+    if (m_options.log_file && m_options.buffer_size.OptionWasSet()) {
+      result.AppendError("cannot specify both a file and buffer size.");
+      return false;
+    }
----------------
Can't we build buffer size into a file based LogHandler? Have a std::string inside LogHandler and append to it until the bytes left + latest Emit() message go over the buffer size and then flush then? 


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

https://reviews.llvm.org/D127986



More information about the lldb-commits mailing list