[Lldb-commits] [lldb] 4deea65 - [lldb] Make sure we don't drop asynchronous output when sourcing files
Pavel Labath via lldb-commits
lldb-commits at lists.llvm.org
Tue Mar 3 02:18:57 PST 2020
Author: Pavel Labath
Date: 2020-03-03T11:18:41+01:00
New Revision: 4deea65249d5df2965d4df90ec9cf221bcf9a13e
URL: https://github.com/llvm/llvm-project/commit/4deea65249d5df2965d4df90ec9cf221bcf9a13e
DIFF: https://github.com/llvm/llvm-project/commit/4deea65249d5df2965d4df90ec9cf221bcf9a13e.diff
LOG: [lldb] Make sure we don't drop asynchronous output when sourcing files
Summary:
If a command from a sourced file produces asynchronous output, this
output often does not make its way to the user. This happens because the
asynchronous output machinery relies on the iohandler stack to ensure
the output does not interfere with the things the iohandler is doing.
However, if this happens near the end of the command stream then by the
time the asynchronous output is produced we may already have already
started tearing down the sourcing session. Specifically, we may already
pop the relevant iohandler, leaving the stack empty.
This patch makes sure this kind of output gets printed by adding a
fallback to IOHandlerStack::PrintAsync to print the output directly if
the stack is empty. This is safe because if we have no iohandlers then
there is nothing to synchronize.
Reviewers: JDevlieghere, clayborg
Subscribers: lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D75454
Added:
lldb/test/Shell/Commands/command-thread-select.test
Modified:
lldb/source/Core/IOHandler.cpp
Removed:
################################################################################
diff --git a/lldb/source/Core/IOHandler.cpp b/lldb/source/Core/IOHandler.cpp
index 939c87c1b15e..933da6bfbf75 100644
--- a/lldb/source/Core/IOHandler.cpp
+++ b/lldb/source/Core/IOHandler.cpp
@@ -125,6 +125,8 @@ void IOHandlerStack::PrintAsync(Stream *stream, const char *s, size_t len) {
std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (m_top)
m_top->PrintAsync(stream, s, len);
+ else
+ stream->Write(s, len);
}
}
diff --git a/lldb/test/Shell/Commands/command-thread-select.test b/lldb/test/Shell/Commands/command-thread-select.test
new file mode 100644
index 000000000000..3b48452eea82
--- /dev/null
+++ b/lldb/test/Shell/Commands/command-thread-select.test
@@ -0,0 +1,17 @@
+# RUN: %clang_host -g %S/Inputs/main.c -o %t
+# RUN: %lldb %t -s %s -o exit | FileCheck %s
+
+b main
+# CHECK-LABEL: b main
+# CHECK: Breakpoint 1: where = {{.*}}`main
+
+run
+# CHECK-LABEL: run
+# CHECK: Process {{.*}} stopped
+# CHECK: stop reason = breakpoint 1
+# CHECK: frame #0: {{.*}}`main at main.c
+
+thread select 1
+# CHECK-LABEL: thread select 1
+# CHECK: stop reason = breakpoint 1
+# CHECK: frame #0: {{.*}}`main at main.c
More information about the lldb-commits
mailing list