xcode 中断 _NSLockError() 以进行调试......如何?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1299785/
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
Break on _NSLockError() to debug ... How to?
提问by Nobik
During debugging the console always spits me an error message: "Break on _NSLockError() to debug"
在调试过程中,控制台总是向我吐出一条错误消息:“Break on _NSLockError() to debug”
My assumption is: in XCode i have to appear a certain breackpoint, so that the debugger stops at the point where this error occurs.
我的假设是:在 XCode 中,我必须出现某个断点,以便调试器在发生此错误的位置停止。
How can i make this?
我怎样才能做到这一点?
采纳答案by diciu
1/ From the menu choose Build -> Build and Debug
1/ 从菜单中选择 Build -> Build and Debug
2/ Click the "GDB" icon - you will be switched to the "Debugger console"
2/ 单击“GDB”图标 - 您将切换到“调试器控制台”
3/ Press Control+C to interrupt your binary. You will get the gdb prompt.
3/ 按 Control+C 中断您的二进制文件。你会得到 gdb 提示。
4/ type in "b _NSLockError" and continue execution after setting the breakpoint.
4/ 输入“b _NSLockError”,设置断点后继续执行。
(gdb) b _NSLockError
Breakpoint 8 at 0x911db1a9
(gdb) c
Continuing.
5/ you can interact with GDB just as it was running from console, i.e. you can Ctrl+C again and view current breakpoints:
5/ 您可以像从控制台运行一样与 GDB 交互,即您可以再次 Ctrl+C 并查看当前断点:
(gdb) info breakpo
Num Type Disp Enb Address What
8 breakpoint keep y 0x911db1a9 <_NSLockError+9>
回答by Opsimath
Using the Xcode 4 GUI:
使用 Xcode 4 GUI:
- Open the Breakpoints navigator (Command+6 or View>Navigators>Show Breakpoint Navigator)
- Click '+' in bottom left corner and choose 'Add Symbolic Breakpoint...'
- Enter '_NSLockError' in the Symbol field
- Enter 'Foundation' in the Module field
- Click 'Done'
- 打开 Breakpoints 导航器(Command+6 或 View>Navigators>Show Breakpoint Navigator)
- 单击左下角的“+”并选择“添加符号断点...”
- 在符号字段中输入“_NSLockError”
- 在模块字段中输入“基础”
- 点击“完成”
As above the debugger will break on the lock which results in a deadlock so you can check the callstack and hopefully determine where the original lock occurred.
如上所述,调试器将在锁上中断,从而导致死锁,因此您可以检查调用堆栈并希望确定原始锁发生的位置。
回答by Simon Woodside
To do this automatically for your project in XCode:
要在 XCode 中为您的项目自动执行此操作:
- In Xcode, Option-Command-B to open the Breakpoints window (or Run>Show>Breakpoints).
- Where it says "Double-Click for Symbol", double click... and paste in "_NSLockError".
- Click anywhere else in the window, and your new entry will automatically be updated (or just add it manually) with Module = "Foundation" (without the quotes)
- Build & Go and you will now drop into the debugger automatically when you hit an automatically-detected deadlock.
- 在 Xcode 中,Option-Command-B 打开 Breakpoints 窗口(或 Run>Show>Breakpoints)。
- 在它说“双击符号”的地方,双击...并粘贴“_NSLockError”。
- 单击窗口中的任何其他位置,您的新条目将使用 Module = "Foundation" (不带引号)自动更新(或手动添加)
- Build & Go,当您遇到自动检测到的死锁时,您现在将自动进入调试器。