[Lldb-commits] [PATCH] D48463: Prevent dead locking when calling PrintAsync

Greg Clayton via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Fri Jun 22 11:23:43 PDT 2018


clayborg added inline comments.


================
Comment at: source/Core/Debugger.cpp:988-1004
+  bool should_forward = false;
+  {
+    // We check if any user requested to delay output to a later time
+    // (which is designated by m_delayed_output_counter being not 0).
+    std::lock_guard<std::mutex> guard(m_delayed_output_mutex);
+    if (m_delayed_output_counter != 0) {
+      // We want to delay messages, so push them to the buffer.
----------------
Can this code become:

```
// We check if any user requested to delay output to a later time
// (which is designated by m_delayed_output_counter being not 0).
{
  std::lock_guard<std::mutex> guard(m_delayed_output_mutex);
  if (m_delayed_output_counter != 0) {
    // We want to delay messages, so push them to the buffer.
    m_delayed_output.emplace_back(std::string(s, len), is_stdout);
      return;
  }
}
lldb::StreamFileSP stream = is_stdout ? GetOutputFile() : GetErrorFile();
m_input_reader_stack.PrintAsync(stream.get(), s, len);
```


================
Comment at: source/Core/IOHandler.cpp:358
+  // lldb code that will be called from here (possibly in another thread).
+  Debugger::MessageDelayScope buffer_scope(m_debugger);
+
----------------
So anytime we have a "(lldb)" prompt we won't be able to output something?


https://reviews.llvm.org/D48463





More information about the lldb-commits mailing list