[Lldb-commits] [PATCH] D47232: Break dependency from Expression -> Commands

Jim Ingham via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Wed May 23 10:23:30 PDT 2018

jingham added a subscriber: zturner.
jingham added a comment.

The expression command had two modes before introducing the REPL.  You can do:

(lldb) expr -- some C expression

or you can do:

(lldb) expr
Enter expressions, then terminate with an empty line to evaluate:

  1: first C expression
  2: Second C Expression

The second only differs from the first in that it pushes an IOHandler to deal with gathering the entered text that the user typed up to the point where they type an empty expression.

The repl adds a third mode:

(lldb) expr -r --

  1> let a = 10

a: Int = 10

  2> print(a)



Which works the same as "expr --toplevel" with the addition of a fancier IOHandler that looks for complete expressions and evaluates each completed expression as it sees it.  I'm glossing over a few details here (like the fact that ":" will switch you to the lldb command interpreter), but for the most part that's all it is.

Note, there's another "repl" that lldb provides:

> lldb --repl

Which packages up "make a target out of a  little victim program we've stashed away in LLDB.framework, set a breakpoint in it, run to the breakpoint and then execute "expr -r --".  So there's also a little bit to support that.  But I don't think that materially changes how you should understand the REPL.  And then most people actually access this for swift by invoking "swift" with no arguments, but the swift driver with no arguments just turns around and exec's "lldb --repl" so that doesn't add much besides convenience.



More information about the lldb-commits mailing list