How to automatically set breakpoints on all methods in Xcode?

Matrosov Alexander picture Matrosov Alexander · Feb 14, 2012 · Viewed 12.1k times · Source

How do I automatically set breakpoints on all methods in Xcode? I want to know how my program works, and which methods invoke when I interact with the user interface.

Answer

Nikolai Ruhe picture Nikolai Ruhe · Feb 14, 2012
  1. Run your app in Xcode.
  2. Press ⌘⌃Y (Debug -> Pause).
  3. Go to the debugger console: ⌘⇧C
  4. Type breakpoint set -r . -s <PRODUCT_NAME> (insert your app's name).

lldb will answer with something like...

Breakpoint 1: 4345 locations

Now just press the Continue button.

breakpoint set is lldb's command to create breakpoints. The location is specified using a regular expression (-r) on function/method names, in this case . which matches any method. The -s option is used to limit the scope to your executable (needed to exclude frameworks).

When you run your app lldb will now break whenever the app hits a function from your main executable.

To disable the breakpoints type breakpoint delete 1 (insert proper breakpoint number).