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

醉酒当歌 提交于 2019-12-01 16:13:17
Pang

In Xcode 6:

Step 1:
On the Navigator on the left, go to Breakpoint Navigator (command ⌘ + 7):

Step 2:
Click the + button on the bottom left (Add a new breakpoint),
then choose Add Symbolic Breakpoint...:

Step 3:
In Symbol, type NSLog.

Alternatively, you can do the same thing in DebugBreakpointsCreate Symbolic Breakpoint.

Fo Xcode 5, see this.

If you want to break on a certain log message you can use:

This example will break on every log containing the word "Warning".

Update: On newer devices use $x0. Simulator and older use $r0. $arg0 should do for all cases.

In the breakpoint navigator (command+6) add (on the bottom, there is a Plus symbol) a symbolic breakpoint and use NSLog as symbol.

According to this you can set that kind of breakpoint by doing so in the lldb console:

breakpoint set --name NSLog

One way to do this using Xcode could be to put a breakpoint in the main function or on you AppDelegate applicationDidFinishLaunchin (read: as soon as possible). Then, you run your app, and when it pauses on said breakpoint, you have access to the lldb console: you type the above line and hit return, and lldb prints something like this:

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

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!