Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to automatically set breakpoints on all methods in Xcode?

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.

like image 469
Matrosov Oleksandr Avatar asked Feb 14 '12 10:02

Matrosov Oleksandr


People also ask

How do I set a conditional breakpoint in Xcode?

You can set a conditional break point in Xcode by setting the breakpoint normally, then control-click on it and select Edit Breakpoint (choose Run -> Show -> Breakpoints). In the breakpoint entry, there is a Condition column. Now, there are several issues to keep in mind for the condition.

How do you create a breakpoint in a method?

Press F3 and then press F9 to add a breakpoint. This adds a breakpoint to the first method found using the trick.

How do you keep breakpoints?

To set a breakpoint in source code, click in the far left margin next to a line of code. You can also select the line and press F9, select Debug > Toggle Breakpoint, or right-click and select Breakpoint > Insert breakpoint.


2 Answers

  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).

like image 115
Nikolai Ruhe Avatar answered Oct 01 '22 18:10

Nikolai Ruhe


In some cases, it is more convenient to set breakpoints only on some of the methods.

Using LLDB we can put breakpoint on all ViewDidLoad methods by name, for example.

(lldb) breakpoint set -n ViewDidLoad 

Here "-n" means by name.

Also, we can put breakpoints by selector name:

(lldb) breakpoint set -S alignLeftEdges: 

Here "-S" means by selector.

like image 39
Denis Kutlubaev Avatar answered Oct 01 '22 18:10

Denis Kutlubaev