【iOS】LLDB调试指南

LLDB命令结构

1
<command> [<subcommand> [<subcommand>...]] <action> [-options [option-value]] [argument [argument...]]

to set a breakpoint in file test.c at line 12 you enter:

1
(lldb) breakpoint set --file test.c --line 12

here is a partial listing of the command options for the breakpoint set command, listing the canonical form in parentheses:

1
2
3
4
5
6
7
8
breakpoint set
-M <method> ( --method <method> )
-S <selector> ( --selector <selector> )
-b <function-name> ( --basename <function-name> )
-f <filename> ( --file <filename> )
-l <linenum> ( --line <linenum> )
-n <function-name> ( --name <function-name> )

To set the same file and line breakpoint in LLDB, enter:

(lldb) breakpoint set --file foo.c --line 12

To set a breakpoint on a function named foo in LLDB, enter:

(lldb) breakpoint set --name foo

Setting breakpoints by name is even more powerful in LLDB than in GDB because you can specify that you want to set a breakpoint at a function by method name. To set a breakpoint on all C++ methods named foo, enter:

(lldb) breakpoint set --method foo

To set a breakpoint on Objective-C selectors named alignLeftEdges:, enter:

(lldb) breakpoint set --selector alignLeftEdges:

You can limit any breakpoints to a specific executable image by using the --shlib expression.

(lldb) breakpoint set --shlib foo.dylib --name foo