Show the stack backtrace for the current thread. (lldb) expr -u 0 - function_with_a_breakpoint() (lldb) settings set target.prefer-dynamic run-targetĬall a function to stop at a breakpoint in the function. (lldb) expr -d run-target - someCPPObjectPtrOrReference Print the dynamic type of the result of an expression. Print the Objective-C description of an object. LLDB evaluates a variable declaration expression as you would write it in C: (lldb) print (int) printf ("Print nine: %d.", 4 + 5)Ĭreate and assign a value to a convenience variable.
(lldb) expr (int) printf ("Print nine: %d.", 4 + 5) (gdb) call (int) printf ("Print nine: %d.", 4 + 5) Or if you don’t want to see void returns: (gdb) print (int) printf ("Print nine: %d.", 4 + 5) (lldb) ta st a -c M圜lass -o "fr v *this"Įvaluate a generalized expression in the current frame. (lldb) target stop-hook add -classname M圜lass -one-liner "frame variable *this" (lldb) ta st a -n main -o "fr v argc argv"ĭisplay the variable *this only when you stop in the C class named M圜lass. (lldb) target stop-hook add -name main -one-liner "frame variable argc argv" (lldb) target stop-hook add -one-liner "frame variable argc argv"ĭisplay the variables argc and argv only when you stop in the function named main. Show the global/static variables defined in the current source file.ĭisplay the variables argc and argv every time you stop. Show the contents of the global variable baz. Show the contents of the local variable bar formatted as hex. Show the contents of the local variable bar. Show the local variables for the current frame. Show the arguments and local variables for the current frame. This command takes “raw” input, evaluated as an expression returning an unsigned integer pointing to the start of the region, after the option terminator ( -). Note: The size of the region to watch for defaults to the pointer size if no -x byte_size is specified. (lldb) watchpoint set expression - my_ptr Set a watchpoint on a memory location when it is written to. (lldb) watchpoint set variable global_var Set a watchpoint on a variable when it is written to. (lldb) br s -p regular-expression -f file (lldb) breakpoint set -source-pattern regular-expression -file SourceFile (gdb) shell grep -e -n pattern source-file Set a breakpoint by a regular expression on a source file’s contents. (lldb) breakpoint set -regex regular-expression Set a breakpoint by a regular expression on a function name. (Note: This will break on any C or C++ functions named count.) Set a breakpoint at all Objective-C methods whose selector is count. Set a breakpoint at an Objective-C function:. (Note: This will break on any C functions named main.)
Set a breakpoint at all C++ methods whose basename is main. (lldb) breakpoint set -file test.c -line 12 Set a breakpoint in file test.c at line 12. Set a breakpoint at all functions named main. Step out of the currently selected frame.īacktrace and disassemble every time you stop.Įnter your stop hook command(s). (lldb) process attach -name a.out -waitforĪttach to a remote GDB protocol server running on the system eorgadd, port 8000.Īttach to a remote GDB protocol server running on the local system, port 8000.Īttach to a Darwin kernel in kdp mode on the system eorgadd.ĭo a source-level single step in the currently selected thread.ĭo a source-level single step over in the currently selected thread.ĭo an instruction-level single step in the currently selected thread.ĭo an instruction-level single step over in the currently selected thread. Wait for a process named a.out to launch and attach. Set environment variables for process and launch process in one command.Īttach to the process with process ID 123. (lldb) settings set target.env-vars DEBUG=1 Set environment variables for process before launching. (lldb) process launch -tty=/dev/ttys006. Launch a process with arguments in an existing Terminal window, /dev/ttys006 (OS X only). Launch a process with arguments in a new terminal window (OS X only). Launch process a.out with arguments 1 2 3 without having to supply the args every time.