Skip to content

[lldb] Fix error : unknown error while starting lldb's C/C++ repl #153560

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Aug 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lldb/source/Commands/CommandObjectExpression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -640,9 +640,15 @@ void CommandObjectExpression::DoExecute(llvm::StringRef command,
repl_sp->SetValueObjectDisplayOptions(m_varobj_options);
}

if (!expr.empty()) {
result.GetOutputStream().Printf(
"Warning: trailing input is ignored in --repl mode\n");
}

IOHandlerSP io_handler_sp(repl_sp->GetIOHandler());
io_handler_sp->SetIsDone(false);
debugger.RunIOHandlerAsync(io_handler_sp);
return;
} else {
repl_error = Status::FromErrorStringWithFormat(
"Couldn't create a REPL for %s",
Expand Down
10 changes: 10 additions & 0 deletions lldb/test/API/repl/clang/TestClangREPL.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,16 @@ def test_basic_completion(self):

self.quit()

# Re-enter the REPL with trailing input to trigger warning.
self.child.send("expression --repl -l c -- 3 + 3\n")
self.child.expect_exact("Warning: trailing input is ignored in --repl mode\n")
self.child.expect_exact("1>")

# Evaluate another expression after warning.
self.expect_repl("4 + 4", substrs=["(int) $3 = 8"])

self.quit()

# PExpect uses many timeouts internally and doesn't play well
# under ASAN on a loaded machine..
@skipIfAsan
Expand Down
Loading