Xcode 4.2 调试不象征堆栈调用 [英] Xcode 4.2 debug doesn't symbolicate stack call

查看:33
本文介绍了Xcode 4.2 调试不象征堆栈调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 iOS 5 模拟器/设备中调试 Xcode 4.2 时遇到问题.如预期的那样,以下代码崩溃了:

I have a problem with Xcode 4.2 debugging in an iOS 5 simulator/device. The following code crashes, as expected:

NSArray *arr=[NSArray array];
[arr objectAtIndex:100];

在 iOS 4 中,我得到了一个有用的十六进制数堆栈跟踪.但在 iOS 5 中,它只是给了我:

In iOS 4, I get a useful stack trace of hex numbers. But in iOS 5, it just gives me:

*** First throw call stack:
(0x16b4052 0x1845d0a 0x16a0674 0x294c 0x6f89d6 0x6f98a6 0x708743 0x7091f8 0x7fcaa9 0x2257fa9 0x16881c5 0x15ed022 0x15eb90a 0x15eadb4 0x15eaccb 0x6f02a7 0x6faa93 0x2889 0x2805)

谢谢.

推荐答案

我尝试过的任何方法都无法解决此问题(尝试了两种编译器、两种调试器等)为 iOS 5 更新升级 XCode 后,似乎没有任何堆栈跟踪.

Nothing I tried would fix this (tried both compilers, both debuggers, etc.) After upgrading XCode for the iOS 5 update, no stack traces seemed to work.

但是,我找到了一个有效的解决方法 - 创建我自己的异常处理程序(这对于其他原因也很有用).首先,创建一个函数来处理错误并将其输出到控制台(以及您想用它做的任何其他事情):

However, I have found an effective work-around - creating my own exception handler (which is also useful for other reasons). First, create a function that will handle the error and output it to the console (as well as whatever else you want to do with it):

void uncaughtExceptionHandler(NSException *exception) {
    NSLog(@"CRASH: %@", exception);
    NSLog(@"Stack Trace: %@", [exception callStackSymbols]);
    // Internal error reporting
}

接下来,将异常处理程序添加到您的应用委托:

Next, add the exception handler to your app delegate:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{   
    NSSetUncaughtExceptionHandler(&uncaughtExceptionHandler);
    // Normal launch stuff
}

就是这样!

如果这不起作用,那么只有两个可能的原因:

If this doesn't work, then there are only two possible reasons:

  1. 有些东西覆盖了您的 NSSetUncaughtExceptionHandler 调用(整个应用程序只能有一个处理程序).例如,一些 3rd 方库设置了自己的 uncaughtExceptionHandler.因此,尝试在 didFinishLaunchingWithOptions 函数的末尾设置它(或有选择地禁用 3rd 方库).或者更好的是,在 NSSetUncaughtExceptionHandler 上设置一个符号断点以快速查看谁在调用它.您可能想要做的是修改您当前的一个,而不是添加另一个.
  2. 您实际上并没有遇到异常(例如,EXC_BAD_ACCESS不是异常;感谢@Erik B 的评论,如下)
  1. Something is overwriting your NSSetUncaughtExceptionHandler call (there can be only one handler for your entire app). For example, some 3rd party libraries set their own uncaughtExceptionHandler. So, try setting it at the END of your didFinishLaunchingWithOptions function (or selectively disabling 3rd party libraries). Or better yet, set a symbolic break point on NSSetUncaughtExceptionHandler to quickly see who is calling it. What you may want to do is to modify your current one rather than adding another one.
  2. You're not actually encountering an exception (for example, EXC_BAD_ACCESS is not an exception; credit to @Erik B's comments, below)

这篇关于Xcode 4.2 调试不象征堆栈调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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