Skip to content

Commit c231deb

Browse files
committed
[lldb] Use the debugger's asynchronous output stream for progress events.
Use the debugger's asynchronous output stream for printing progress events. This allows the active IOHandler to be in charge of printing them and doing the necessary synchronization. Differential revision: https://reviews.llvm.org/D121502
1 parent 3568333 commit c231deb

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

lldb/source/Core/Debugger.cpp

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1750,45 +1750,47 @@ void Debugger::HandleProgressEvent(const lldb::EventSP &event_sp) {
17501750
// Determine whether the current output file is an interactive terminal with
17511751
// color support. We assume that if we support ANSI escape codes we support
17521752
// vt100 escape codes.
1753-
File &output = GetOutputFile();
1754-
if (!output.GetIsInteractive() || !output.GetIsTerminalWithColors())
1753+
File &file = GetOutputFile();
1754+
if (!file.GetIsInteractive() || !file.GetIsTerminalWithColors())
17551755
return;
17561756

1757+
StreamSP output = GetAsyncOutputStream();
1758+
17571759
// Print over previous line, if any.
1758-
output.Printf("\r");
1760+
output->Printf("\r");
17591761

17601762
if (data->GetCompleted()) {
17611763
// Clear the current line.
1762-
output.Printf("\x1B[2K");
1763-
output.Flush();
1764+
output->Printf("\x1B[2K");
1765+
output->Flush();
17641766
return;
17651767
}
17661768

17671769
const bool use_color = GetUseColor();
17681770
llvm::StringRef ansi_prefix = GetShowProgressAnsiPrefix();
17691771
if (!ansi_prefix.empty())
1770-
output.Printf(
1772+
output->Printf(
17711773
"%s", ansi::FormatAnsiTerminalCodes(ansi_prefix, use_color).c_str());
17721774

17731775
// Print the progress message.
17741776
std::string message = data->GetMessage();
17751777
if (data->GetTotal() != UINT64_MAX) {
1776-
output.Printf("[%" PRIu64 "/%" PRIu64 "] %s...", data->GetCompleted(), data->GetTotal(),
1777-
message.c_str());
1778+
output->Printf("[%" PRIu64 "/%" PRIu64 "] %s...", data->GetCompleted(),
1779+
data->GetTotal(), message.c_str());
17781780
} else {
1779-
output.Printf("%s...", message.c_str());
1781+
output->Printf("%s...", message.c_str());
17801782
}
17811783

17821784
llvm::StringRef ansi_suffix = GetShowProgressAnsiSuffix();
17831785
if (!ansi_suffix.empty())
1784-
output.Printf(
1786+
output->Printf(
17851787
"%s", ansi::FormatAnsiTerminalCodes(ansi_suffix, use_color).c_str());
17861788

17871789
// Clear until the end of the line.
1788-
output.Printf("\x1B[K\r");
1790+
output->Printf("\x1B[K\r");
17891791

17901792
// Flush the output.
1791-
output.Flush();
1793+
output->Flush();
17921794
}
17931795

17941796
bool Debugger::HasIOHandlerThread() { return m_io_handler_thread.IsJoinable(); }

0 commit comments

Comments
 (0)