Skip to content

Commit 501bc10

Browse files
authored
[lldb] Save the edited line before clearing it in Editline::PrintAsync (llvm#84154)
If the `m_editor_status` is `EditorStatus::Editing`, PrintAsync clears the currently edited line. In some situations, the edited line is not saved. After the stream flushes, PrintAsync tries to display the unsaved line, causing the loss of the edited line. The issue arose while I was debugging REPRLRun in [Fuzzilli](https://github.com/googleprojectzero/fuzzilli). I started LLDB and attempted to set a breakpoint in libreprl-posix.c. I entered `breakpoint set -f lib` and used the "tab" key for command completion. After completion, the edited line was flushed, leaving a blank line.
1 parent 9a9aa41 commit 501bc10

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

lldb/source/Host/common/Editline.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1597,6 +1597,7 @@ bool Editline::GetLines(int first_line_number, StringList &lines,
15971597
void Editline::PrintAsync(Stream *stream, const char *s, size_t len) {
15981598
std::lock_guard<std::recursive_mutex> guard(m_output_mutex);
15991599
if (m_editor_status == EditorStatus::Editing) {
1600+
SaveEditedLine();
16001601
MoveCursor(CursorLocation::EditingCursor, CursorLocation::BlockStart);
16011602
fprintf(m_output_file, ANSI_CLEAR_BELOW);
16021603
}

0 commit comments

Comments
 (0)