I've seen explanation regarding p
vs po
. But can't seem to notice the difference between p
and e
(which is short for expression
if I'm correct).
They even have an identical help message in lldb:
Evaluate an expression on the current thread. Displays any returned value with LLDB's default formatting.
As far as I see, the only difference is that e = expression
, p = expression --
.
So yeah, what's the difference? When is it better to use one over another? Thanks!
The basic lldb command is expr
or e
for short.
The expr
command takes options that control result formatting and how the expression is run (e.g. whether the expression ignores breakpoints while running). And then it takes the expression to run.
There needs to be some way to disambiguate the expression from the options. For instance, if the expression is pre-decrementing the format
variable (--format
), that string could equally well be specifying the --format
option. lldb follows the Unix command-line solution, where --
means: the end of options, and the beginning of the real arguments. So if you were doing the former, you would say:
(lldb) expr -- --format
That is why p
exists. Since it is an alias for expr --
, this then becomes:
(lldb) p --format
p
is the convenient way to run expr
when you know you don't need to provide any options. Whatever you type will be the expression you are running. You only need to use expr
if you want to provide options.
There's more about the general operation of lldb's command line here: