Skip to content

Commit

Permalink
[lldb] Save the edited line before clearing it in Editline::PrintAsync (
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
karzanWang authored Mar 11, 2024
1 parent 9a9aa41 commit 501bc10
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions lldb/source/Host/common/Editline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1597,6 +1597,7 @@ bool Editline::GetLines(int first_line_number, StringList &lines,
void Editline::PrintAsync(Stream *stream, const char *s, size_t len) {
std::lock_guard<std::recursive_mutex> guard(m_output_mutex);
if (m_editor_status == EditorStatus::Editing) {
SaveEditedLine();
MoveCursor(CursorLocation::EditingCursor, CursorLocation::BlockStart);
fprintf(m_output_file, ANSI_CLEAR_BELOW);
}
Expand Down

0 comments on commit 501bc10

Please sign in to comment.