-
Notifications
You must be signed in to change notification settings - Fork 14.7k
Description
Hi,
I've been educating myself with the lldb REPL. So I thought of going through this example TestClangRepl.py
So 1 create a simple a.out (main returning 0) -> set breakpoint on main and run -> followed by expression --repl -l c --
to see this
anutosh491@Anutoshs-MacBook-Air SDKs % 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) breakpoint set -n main
Breakpoint 1: where = a.out`main + 24 at main.c:2:3, address = 0x0000000100003fa0
(lldb) run
Process 91181 launched: '/Users/anutosh491/work/xeus-cpp/a.out' (arm64)
Process 91181 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
frame #0: 0x0000000100003fa0 a.out`main(argc=1, argv=0x000000016fdff638) at main.c:2:3
1 int main(int argc, char **argv) {
-> 2 return 0;
3 }
Target 0: (a.out) stopped.
(lldb) expression --repl -l c --
error: unknown error
1> 1 + 1
(int) $0 = 2
Now I see this thing error: unknown error
which is probably showing up cause a return is missing here and we continue (expr
is empty! So EvaluateExpression
fails and prints this)
And I also see this
(lldb) expression --repl -l c -- 3 + 3
(int) $1 = 6
2>
Curious if this should even happen (I am guessing not cause expressions should only be evaluated inside the repl when we use --repl) . Probably can use return as I said with something like
if (!expr.empty()) {
result.GetOutputStream().Printf(
"[LOG] Warning: trailing input is ignored in --repl mode\n");
}
Tagging @JDevlieghere as I'm not sure who maintains the lldb repl code.
I could push a patch with the above solution I proposed if that makes sense. Thanks !