[lldb] Make some functions useful to REPLs public
authorwalter erquinigo <walter@modular.com>
Wed, 3 May 2023 02:12:43 +0000 (21:12 -0500)
committerwalter erquinigo <walter@modular.com>
Thu, 4 May 2023 19:44:03 +0000 (14:44 -0500)
`StartEventHandlerThread` and `StopEventHandlerThread` are available to the SwiftREPL even though they are protected because SwiftREPL is a friend class of Debugger. I'm developing my own REPL and having access to these functions, including `FlushProcessOutput`, is desirable.

Differential Revision: https://reviews.llvm.org/D149717

lldb/include/lldb/Core/Debugger.h

index 12c1c04..a7487e1 100644 (file)
@@ -500,6 +500,19 @@ public:
   SetDestroyCallback(lldb_private::DebuggerDestroyCallback destroy_callback,
                      void *baton);
 
+  /// Manually start the global event handler thread. It is useful to plugins
+  /// that directly use the \a lldb_private namespace and want to use the
+  /// debugger's default event handler thread instead of defining their own.
+  bool StartEventHandlerThread();
+
+  /// Manually stop the debugger's default event handler.
+  void StopEventHandlerThread();
+
+  /// Force flushing the process's pending stdout and stderr to the debugger's
+  /// asynchronous stdout and stderr streams.
+  void FlushProcessOutput(Process &process, bool flush_stdout,
+                          bool flush_stderr);
+
 protected:
   friend class CommandInterpreter;
   friend class REPL;
@@ -548,10 +561,6 @@ protected:
 
   void PrintProgress(const ProgressEventData &data);
 
-  bool StartEventHandlerThread();
-
-  void StopEventHandlerThread();
-
   void PushIOHandler(const lldb::IOHandlerSP &reader_sp,
                      bool cancel_top_handler = true);
 
@@ -587,8 +596,6 @@ protected:
 
   // Ensures two threads don't attempt to flush process output in parallel.
   std::mutex m_output_flush_mutex;
-  void FlushProcessOutput(Process &process, bool flush_stdout,
-                          bool flush_stderr);
 
   SourceManager::SourceFileCache &GetSourceFileCache() {
     return m_source_file_cache;