The most convenient way to inspect a frame's arguments and local variables is to use the "
If you need to view more complex data or change program data, you can use the general "expression" command. It takes an expression and evaluates it in the scope of the currently selected frame. For instance:
Finally, the results of the expressions are stored in persistent variables (of the form $[0-9]+) that you can use in further expressions, like:
frame variable
" command:
(lldb) frame variable
self = (SKTGraphicView *) 0x0000000100208b40
_cmd = (struct objc_selector *) 0x000000010001bae1
sender = (id) 0x00000001001264e0
selection = (NSArray *) 0x00000001001264e0
i = (NSUInteger) 0x00000001001264e0
c = (NSUInteger) 0x00000001001253b0
As you see above, if you don't specify any variable names, all arguments
and locals will be shown. If you call "frame variable
"
passing in the names of a particular local(s), only those variables
will be printed. For instance:
(lldb) frame variable self
(SKTGraphicView *) self = 0x0000000100208b40
You can also pass in a path to some subelement of one of the available locals,
and that sub-element will be printed. For instance:
(lldb) frame variable self.isa
(struct objc_class *) self.isa = 0x0000000100023730
The "frame variable
" command is not a full expression
parser but it does support a few simple operations like &, *, ->, [] (no overloaded
operators). The array brackets can be used on pointers to treat pointers
as arrays:
(lldb) frame variable *self
(SKTGraphicView *) self = 0x0000000100208b40
(NSView) NSView = {
(NSResponder) NSResponder = {
...
(lldb) frame variable &self
(SKTGraphicView **) &self = 0x0000000100304ab
(lldb) frame variable argv[0]
(char const *) argv[0] = 0x00007fff5fbffaf8 "/Projects/Sketch/build/Debug/Sketch.app/Contents/MacOS/Sketch"
The frame variable command will also perform "object printing" operations on
variables (currently we only support ObjC printing, using the object's "description" method.
Turn this on by passing the -o flag to frame variable:
(lldb) frame variable -o self
(SKTGraphicView *) self = 0x0000000100208b40 <SKTGraphicView: 0x100208b40>
You can select another frame to view with the "frame select
" command
(lldb) frame select 9
frame #9: 0x0000000100015ae3, where = Sketch`function1 + 33 at /Projects/Sketch/SKTFunctions.m:11
You can also move up and down the stack by passing the "--relative
" ("-r
")
option. And we have built-in aliases "u
" and "d
" which
behave like their gdb equivalents.
If you need to view more complex data or change program data, you can use the general "expression" command. It takes an expression and evaluates it in the scope of the currently selected frame. For instance:
(lldb) expr self
$0 = (SKTGraphicView *) 0x0000000100135430
(lldb) expr self = 0x00
$1 = (SKTGraphicView *) 0x0000000000000000
(lldb) frame var self
(SKTGraphicView *) self = 0x0000000000000000
You can also call functions:
(lldb) expr (int) printf ("I have a pointer 0x%llx.\n", self)
$2 = (int) 22
I have a pointer 0x0.
As I said above, "expression" is one of the "raw" commands. So
you don't have to quote your whole expression, nor backslash protect quotes,
etc...Finally, the results of the expressions are stored in persistent variables (of the form $[0-9]+) that you can use in further expressions, like:
(lldb) expr self = $0
$4 = (SKTGraphicView *) 0x0000000100135430