Is there a way to set a breakpoint at the beginning of any NSLog statement?

Some part of the large code base prints strange NSLog expressions, and I'm trying to determine where it NSLog from. Is there a way to put 1 breakpoint at the beginning of every NSLog call so that I can see where it is being called from, instead of manually setting breakpoints in all the places that call NSLog ?

+7
source share
4 answers

In Xcode 6 :

Step 1 :
On the Left Navigator, select Breakpoint Navigator ( command ⌘ + 7 ):

Step 2 :
Click the + button in the lower left corner ( Add new breakpoint )
then select Add Symbolic Breakpoint ... :

screenshot for steps 1 and 2

Step 3 :
In Symbol, enter NSLog .

screenshot for step 3

Alternatively, you can do the same in Debug β†’ Breakpoints β†’ Create Symbolic Breakpoint .

Fo Xcode 5 , see.

+14
source

If you want to break a specific log message, you can use:

enter image description here

This example will be broken down into each log containing the word "Warning."

+5
source

In the breakpoint navigator ( command + 6 ), add (at the bottom of the plus sign) a symbolic breakpoint and use NSLog as the character.

+4
source

According to this, you can set such a breakpoint by doing this in the lldb console:

 breakpoint set --name NSLog 

One way to do this with Xcode is to set a breakpoint in the main function or on you AppDelegate applicationDidFinishLaunchin (read: as soon as possible). Then you launch your application, and when it stops at the specified breakpoint, you have access to the lldb console: you enter the above line and press return, and lldb prints something like this:

 Breakpoint 3: where = Foundation`NSLog, address = 0x32a3da08 

At this point, you resume your application and it will pause again when NSLog is called (pay attention to the call stack using the Debug Navigator).

+2
source

All Articles