Skip to content

Commit 00ffd8b

Browse files
authored
[lldb] Fix error : unknown error while starting lldb's C/C++ repl (llvm#153560)
Fixes llvm#153157 The proposed solution has been discussed here (llvm#153157 (comment)) This is what we would be seeing now ``` base) anutosh491@Anutoshs-MacBook-Air bin % ./lldb /Users/anutosh491/work/xeus-cpp/a.out (lldb) target create "/Users/anutosh491/work/xeus-cpp/a.out" Current executable set to '/Users/anutosh491/work/xeus-cpp/a.out' (arm64). (lldb) b main Breakpoint 1: where = a.out`main, address = 0x0000000100003f90 (lldb) r Process 71227 launched: '/Users/anutosh491/work/xeus-cpp/a.out' (arm64) Process 71227 stopped * thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1 frame #0: 0x0000000100003f90 a.out`main a.out`main: -> 0x100003f90 <+0>: sub sp, sp, #0x10 0x100003f94 <+4>: str wzr, [sp, #0xc] 0x100003f98 <+8>: str w0, [sp, #0x8] 0x100003f9c <+12>: str x1, [sp] (lldb) expression --repl -l c -- 1> 1 + 1 (int) $0 = 2 2> 2 + 2 (int) $1 = 4 ``` ``` base) anutosh491@Anutoshs-MacBook-Air bin % ./lldb /Users/anutosh491/work/xeus-cpp/a.out (lldb) target create "/Users/anutosh491/work/xeus-cpp/a.out" Current executable set to '/Users/anutosh491/work/xeus-cpp/a.out' (arm64). (lldb) b main Breakpoint 1: where = a.out`main, address = 0x0000000100003f90 (lldb) r Process 71355 launched: '/Users/anutosh491/work/xeus-cpp/a.out' (arm64) Process 71355 stopped * thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1 frame #0: 0x0000000100003f90 a.out`main a.out`main: -> 0x100003f90 <+0>: sub sp, sp, #0x10 0x100003f94 <+4>: str wzr, [sp, #0xc] 0x100003f98 <+8>: str w0, [sp, #0x8] 0x100003f9c <+12>: str x1, [sp] (lldb) expression --repl -l c -- 3 + 3 Warning: trailing input is ignored in --repl mode 1> 1 + 1 (int) $0 = 2 ```
1 parent 144736b commit 00ffd8b

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

lldb/source/Commands/CommandObjectExpression.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -640,9 +640,15 @@ void CommandObjectExpression::DoExecute(llvm::StringRef command,
640640
repl_sp->SetValueObjectDisplayOptions(m_varobj_options);
641641
}
642642

643+
if (!expr.empty()) {
644+
result.GetOutputStream().Printf(
645+
"Warning: trailing input is ignored in --repl mode\n");
646+
}
647+
643648
IOHandlerSP io_handler_sp(repl_sp->GetIOHandler());
644649
io_handler_sp->SetIsDone(false);
645650
debugger.RunIOHandlerAsync(io_handler_sp);
651+
return;
646652
} else {
647653
repl_error = Status::FromErrorStringWithFormat(
648654
"Couldn't create a REPL for %s",

lldb/test/API/repl/clang/TestClangREPL.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,16 @@ def test_basic_completion(self):
5656

5757
self.quit()
5858

59+
# Re-enter the REPL with trailing input to trigger warning.
60+
self.child.send("expression --repl -l c -- 3 + 3\n")
61+
self.child.expect_exact("Warning: trailing input is ignored in --repl mode\n")
62+
self.child.expect_exact("1>")
63+
64+
# Evaluate another expression after warning.
65+
self.expect_repl("4 + 4", substrs=["(int) $3 = 8"])
66+
67+
self.quit()
68+
5969
# PExpect uses many timeouts internally and doesn't play well
6070
# under ASAN on a loaded machine..
6171
@skipIfAsan

0 commit comments

Comments
 (0)