objective-c 如何向 objc_exception_throw 添加断点?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1163981/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to add a breakpoint to objc_exception_throw?
提问by Rahul Vyas
this was the answer from the brad larson on this SOquestion
这是从这个布拉德·拉尔森的答案 SO问题
If you add two breakpoints, you should be able to debug these exceptions. To do this, go to Run | Show | Breakpoints and create two global breakpoints (I do them globally because they are so useful in all my applications). The first should be named "objc_exception_throw" and its location should be "libobjc.A.dylib". The second should be "-[NSException raise]" and its location should be "CoreFoundation".
如果添加两个断点,您应该能够调试这些异常。为此,请转到运行 | 显示 | 断点并创建两个全局断点(我全局执行它们,因为它们在我的所有应用程序中都非常有用)。第一个应命名为“objc_exception_throw”,其位置应为“libobjc.A.dylib”。第二个应该是“-[NSException raise]”,它的位置应该是“CoreFoundation”。
Now, if you start debugging your application with breakpoints enabled, it should break on the throw of these exceptions. You should then be able to see the chain of events that led to the exception within the debugger.
现在,如果您在启用断点的情况下开始调试应用程序,它应该会在抛出这些异常时中断。然后,您应该能够在调试器中看到导致异常的事件链。
now in this answer i want to ask how do i add location mentioned???
现在在这个答案中我想问一下我如何添加提到的位置???
回答by h4xxr
I think Brad's answer is pretty clear; hopefully this can help if you're not finding it clear.
我认为布拉德的回答很清楚;如果您不清楚,希望这会有所帮助。
In Xcode, from the top menu click on Run > Show > Breakpoints. A new window pops up.
在 Xcode 中,从顶部菜单中单击 Run > Show > Breakpoints。弹出一个新窗口。
Select "global breakpoints" in the left hand menu. There should be a box on the right under the "Breakpoint" column with the text "Double-Click for symbol". Single-click in this box and type in "objc_exception_throw".
在左侧菜单中选择“全局断点”。在“断点”列下的右侧应该有一个框,其中包含“双击符号”文本。单击此框并键入“objc_exception_throw”。
Then, single-click in the space next to "objc_exception_throw" under the "location" column. A box will appear for you to type in the location (in this case, "libobjc.A.dylib"). I've made a screenshot that will hopefully help:
然后,单击“位置”列下“objc_exception_throw”旁边的空间。将出现一个框供您输入位置(在本例中为“libobjc.A.dylib”)。我做了一个截图,希望能有所帮助:


回答by Valerii Pavlov
In Xcode 4 this great breakpoint can be added via "+" button on Breakpoints section (? + 6)
在 Xcode 4 中,可以通过 Breakpoints 部分的“+”按钮添加这个很棒的断点(?+ 6)


回答by user3812138
in Xcode 6 -- from top menu
在 Xcode 6 中——从顶部菜单
Debug > Breakpoints > Create Exception Breakpoint
调试 > 断点 > 创建异常断点
回答by Ameer Sheikh
I would also like to recommend adding the +[NSException raise:format:arguments:]breakpoint and its location should be CoreFoundation.
我还想建议添加+[NSException raise:format:arguments:]断点,它的位置应该是CoreFoundation.

