[Lldb-commits] [lldb] [lldb] Synchronize the debugger's stdout and stderr streams (PR #126630)

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Thu Feb 13 01:47:01 PST 2025


================
@@ -193,10 +193,12 @@ are no syntax errors may indicate that a function was declared but never called.
   Options *GetOptions() override { return &m_all_options; }
 
   void IOHandlerActivated(IOHandler &io_handler, bool interactive) override {
-    StreamFileSP output_sp(io_handler.GetOutputStreamFileSP());
-    if (output_sp && interactive) {
-      output_sp->PutCString(g_reader_instructions);
-      output_sp->Flush();
+    if (interactive) {
+      if (lldb::LockableStreamFileSP output_sp =
+              io_handler.GetOutputStreamFileSP()) {
+        LockedStreamFile locked_stream = output_sp->Lock();
+        locked_stream.PutCString(g_reader_instructions);
+      }
----------------
labath wrote:

Optional, but I think it would be reasonable to write all of these "simple" lock calls as one-liners like this
```suggestion
              io_handler.GetOutputStreamFileSP())
        output_sp->Lock().PutCString(g_reader_instructions);
```

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


More information about the lldb-commits mailing list