Xcode异常断点不会打印抛出异常的详细信息 [英] Xcode exception breakpoint doesn't print details of the exception being thrown

查看:213
本文介绍了Xcode异常断点不会打印抛出异常的详细信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我设置异常断点时,我没有收到异常消息。我如何获得异常消息?我已经知道如何获得堆栈跟踪,但不包括异常消息。

When I set an exception breakpoint, I don't get the exception message. How do I get the exception message? I already know how to get the stack trace, but that doesn't include the exception message.

过去我使用Xcode开发了iOS应用程序,当出现问题时,我会收到错误/异常。异常通常会有一个消息,例如无法取消引用null或其他任何内容。

In the past I developed iOS Apps with Xcode and when there was a problem, I'd get an error/exception. The exception would often have a message like "can't dereference null" or whatever.

现在,在过去的几周内使用Xcode 4.6.x我从未得到过异常消息。我经常会得到一个SIGABRT。我在异常断点处放置了它,它会在那里中断,但它在iOS SDK中的某个程序集中关闭,我从来没有收到消息。

Now, using Xcode 4.6.x for the past several weeks I've never gotten an exception message. I'll often get a SIGABRT. I put in the break on exception breakpoint and it will break there, but it's off in some assembly within the iOS SDK and I never get a message.

其实我是不记得上次我在调试器控制台中看到任何显示的内容。

In fact, I can't remember the last time I saw anything show up in the debugger console.

迁移到LLVM时异常信息是否消失?

Did exception info dissappear with the migration to LLVM?

让我的应用程序崩溃是非常令人沮丧的SDK不知道为什么。我检查最后一个函数以确保设置正确(分配对象等),这意味着我没有任何线索。

It's very frustrating to have my app just crash in the SDK without knowing why. I check the last function to make sure things are set up correctly (objects allocated, etc) and they are which means I'm left with no clues.

是否可能从过去保留的构建设置以某种方式关闭异常消息?

Is it possibly a build setting held over from the past is somehow turning off exception messages?

在评论中给出了一个很好的答案。这应该被提升为完整答案,因此我可以将问题标记为已回答,而其他有此常见问题的人可以找到它。为了实现这一点,需要重新打开这个问题! (在此之后我会删除这个请求。)

In the comments an excellent answer has been given. This should be promoted to full answer, and so I can mark the question answered and others who have this common issue can find it. In order for that to happen, the question needs to be reopened! (I'll delete this plea after that happens.)

推荐答案

我将在这里更新Jeff的答案:

I will update Jeff's answer here:


同时使行突出显示异常(而不是main.m中的UIApplicationMain())并查看异常原因(例如,错误:获取请求必须有实体。),执行此操作:

To have both the line causing the exception highlighted (and not UIApplicationMain() in main.m) AND to see the reason for the exception (e.g., "error: A fetch request must have an entity."), do this:


  • 在断点导航器中:

  • In the Breakpoint navigator:

  1. 添加(+),添加异常断点

  2. 选择新断点,按住Control键,编辑断点

  3. 添加操作

  4. 输入: po $ arg1

  1. Add (+), Add Exception Breakpoint
  2. Select the new breakpoint, Control-Click, Edit Breakpoint
  3. Add Action
  4. Enter: po $arg1


堆栈跟踪的相关部分将位于nagivator区域。

The relevant part of the stack trace will be in the nagivator area.

这似乎仍适用于Xcode 9

This seems to still work in Xcode 9

这是我在Xcode 6及以下版本中使用的补充。

Here is my addition for use with Xcode 6 and below.


  1. 输入: po(NSException *)$ eax

  1. Enter: po (NSException*) $eax

在Xcode 6中,您必须明确提供对象类型,因为它不是更长的推断。

In Xcode 6 you must explicitly provide the object type because it is no longer inferred.

这篇关于Xcode异常断点不会打印抛出异常的详细信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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