Xcode 4.2 debug不符号堆栈调用 [英] Xcode 4.2 debug doesn't symbolicate stack call

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

问题描述

我在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)

谢谢。

推荐答案

我没试过会解决这个问题(试过两个编译器,两个调试器等)
升级XCode for iOS后5更新,没有堆栈跟踪似乎工作。

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
}

接下来,将异常处理程序添加到你的app委托:

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 调用(整个应用程序只能有一个处理程序)。例如,某些第三方库设置了自己的uncaughtExceptionHandler。因此,尝试在 didFinishLaunchingWithOptions 函数的END处设置它(或选择性地禁用第三方库)。或者更好的是,在 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 debug不符号堆栈调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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