问题描述
在使用在iPad上运行的Objective-C应用程序中使用 NSAssert()
之后引发 NSInternalInconsistencyException
异常设备(在调试模式下编译),我得到类似的东西:
After using a NSAssert()
that throws a NSInternalInconsistencyException
exception in an Objective-C application running on an iPad device (compiled in debug mode), I get something similar to:
2012-05-27 02:31:36.830 appname[10821:707] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'reason'
*** First throw call stack:
(0x3800788f 0x33338259 0x38007789 0x371f13a3 0x791a1 0x79555 0x79e03 0x7a44d 0x798d3 0x737fd 0x30e19c8b 0x30e18461 0x30e0ae87 0x30e7b7d5 0x30e18e6d 0x30e127dd 0x30de0ac3 0x30de0567 0x30ddff3b 0x3644122b 0x37fdb523 0x37fdb4c5 0x37fda313 0x37f5d4a5 0x37f5d36d 0x30e1186b 0x30e0ecd5 0x7343f 0x733e4)
terminate called throwing an exception
我如何找到一个有用的堆栈跟踪,一个给我至少一个简单的列表,所有的函数被调用,直到异常是日rown?
How can I find a useful stack trace, one that gives me at least a simple list of all the functions that were called until the exception was thrown?
Xcode没有帮助:
Xcode doesn't help either:
bt
lldb 显示:
bt
in lldb
shows:
(lldb) bt
* thread #1: tid = 0x1c03, 0x30c6832c libsystem_kernel.dylib`__pthread_kill + 8, stop reason = signal SIGABRT
frame #0: 0x30c6832c libsystem_kernel.dylib`__pthread_kill + 8
frame #1: 0x331f920e libsystem_c.dylib`pthread_kill + 54
frame #2: 0x331f229e libsystem_c.dylib`abort + 94
frame #3: 0x37682f6a libc++abi.dylib`abort_message + 46
frame #4: 0x3768034c libc++abi.dylib`_ZL17default_terminatev + 24
frame #5: 0x33338356 libobjc.A.dylib`_objc_terminate + 146
frame #6: 0x376803c4 libc++abi.dylib`_ZL19safe_handler_callerPFvvE + 76
frame #7: 0x37680450 libc++abi.dylib`std::terminate() + 20
frame #8: 0x37681824 libc++abi.dylib`__cxa_rethrow + 88
frame #9: 0x333382a8 libobjc.A.dylib`objc_exception_rethrow + 12
frame #10: 0x37f5d50c CoreFoundation`CFRunLoopRunSpecific + 404
frame #11: 0x37f5d36c CoreFoundation`CFRunLoopRunInMode + 104
frame #12: 0x30e1186a UIKit`-[UIApplication _run] + 550
frame #13: 0x30e0ecd4 UIKit`UIApplicationMain + 1080
frame #14: 0x0007343e appname`main + 86 at main.m:5
这更好,但仍然不是很有用。我仍然不知道是什么导致异常被抛出。
This is better, but still not very useful. I still don't know what led to the exception being thrown.
推荐答案
一些有用的东西:
-
如果您从Xcode运行应用程序,请添加一个异常断点。在断点导航器(command-6)中,点击最左侧的+添加。这将暂停在引发异常的行上的执行,并允许您检查当前范围,堆栈等。
If you're running your app out of Xcode, add an exception breakpoint. In the breakpoint navigator (command-6) hit the '+' at the very bottom left to add. This will pause execution on the line that throws the exception and allow you to inspect the current scope, stack, etc.
如果您使用gdb,请使用 bt
打印回溯
If you're using gdb, use bt
to print the backtrace
如果您使用lldb,请使用线程追溯
而不是
If you're using lldb, use thread backtrace
instead
这篇关于Objective-C堆栈跟踪的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!