What is an exception breakpoint in Xcode

独自空忆成欢 提交于 2019-12-06 03:08:12

It's just a GUI wrapper around setting a symbolic breakpoint on objc_exception_throw.

objc_exception_throw is just a C function that is used to raise all exceptions. So it's just like breaking on any function.

You don't get log messages any more because the debugger stops when the exception is thrown. If you continue from there, the exception will eventually be handled by the application which logs it by default. If you don't continue, though, you won't get any logs.

There's a Wikipedia article on breakpoints.

Xcode is just offering a GUI to use the standard debugger, gdb. So you might also want to read up on debuggers, and gdb.

Because developers often have no idea where a bug is hiding in your program, sometimes you wish that Xcode would tell you which line of code is causing an uncaught exception that results in a crash. This is when exception breakpoints are helpful.

To add one, open the breakpoint navigator and click on the + in the lower-left corner of the window. From the contextual menu, select Exception Breakpoint. A new exception breakpoint is created and a pop-up appears. Set it so that it catches all exceptions on throw.

Now when your app throws an exception, Xcode will take you to the line that directly causes the exception to be raised.

As you pointed out however, it won't log details about the exception to the console yet. This is because the application has not crashed yet. To see the crash and any related console message, continue program execution in the debug bar until you see the crash.

Source: iOS Programming: The Big Nerd Ranch Guide, 6th Edition

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