如何从 obj-c/ios 中的堆栈跟踪中获取源代码行 [英] How to get source code line from stack trace in obj-c / ios

查看:29
本文介绍了如何从 obj-c/ios 中的堆栈跟踪中获取源代码行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 NSSetUncaughtExceptionHandler 将堆栈跟踪打印到 iPhone 的本地文件中,该文件将在应用程序下次启动时发送到我们的服务器.然后我可以检查异常数据并修复错误.在某些崩溃中,我有模块名称和引发异常的函数,这些都很容易.但主要是我有这样的东西:

I use NSSetUncaughtExceptionHandler to print the stack trace to local file in iPhone, which will be sent to our server next time the app launches. Then I can examine the exception data and fix the bug. In some crashes I have the module name and the function that threw the exception, these are easy. But mostly I have something like this:

"4   libc++abi.dylib 0x35bba3c5 _ZL19safe_handler_callerPFvvE + 76",
"5   libc++abi.dylib 0x35bba451 _ZdlPv + 0",
"6   libc++abi.dylib 0x35bbb825 __cxa_current_exception_type + 0",
"7   libobjc.A.dylib 0x37bab2a9 objc_exception_rethrow + 12",
"8   CoreFoundation  0x3575a50d CFRunLoopRunSpecific + 404"

例如原因:

*** -[__NSArrayI objectAtIndex:]:空数组的索引 0 超出范围

但我的应用程序中有几十个数组,因此我需要帮助来使用从堆栈跟踪中获得的数据来查找引发异常的特定行.

but I have dozens of arrays in my app, so I need help to find the specific line that threw the exception, using the data I get from the stack trace.

有没有人知道 Apple 或其他方面的好文章/教程,我可以在其中学习解码堆栈跟踪中的数字以找到源代码中的问题行.提前致谢!

Does anyone know a good article/tutorial from Apple or other, where I can learn to decode the numbers in the stack trace to find the problematic line in the source code. Thanks in advance!

推荐答案

我强烈建议在 Xcode 中启用异常断点.它将在使您的应用程序崩溃的确切行上停止执行您的代码.所以你不必担心是哪个数组导致崩溃.*** -[__NSArrayI objectAtIndex:]:空数组的索引 0 超出范围

I strongly recommend enabling Exception Breakpoint in Xcode. It will stop execution of your code on the exact line which crashes your application. So you do not need to worry about which of the array cause of the crash. *** -[__NSArrayI objectAtIndex:]: index 0 beyond bounds for empty array

添加异常断点

  1. 转到 Xcode 上的断点部分
  2. 点击部分底部的加号唱歌
  3. 选择添加异常断点

这篇关于如何从 obj-c/ios 中的堆栈跟踪中获取源代码行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆