Does LLDB have convenience variables ($var)?

an0 picture an0 · Jun 25, 2012 · Viewed 12.5k times · Source

Does LLDB have convenience variables? If so, how do I use them? If not, is there anything similar that I can use?

Reference: http://software.intel.com/sites/products/documentation/hpc/atom/application/debugger/commands143.html

Answer

an0 picture an0 · Feb 11, 2013

I finally figured it out myself. Run help expr in LLDB and you will see:

User defined variables: You can define your own variables for convenience or to be used in subsequent expressions. You define them the same way you would define variables in C. If the first character of your user defined variable is a $, then the variable's value will be available in future expressions, otherwise it will just be available in the current expression.

So expr int $foo = 5 is what I want.