Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
278 views
in Technique[技术] by (71.8m points)

ios - Xcode exception breakpoint doesn't print details of the exception being thrown

SUMMARY

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.

DETAILS

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.

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.

Did exception info dissappear with the migration to LLVM?

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?

Please reopen question. It now has an answer!

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.)

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I will update Jeff's answer here:

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. Add (+), Add Exception Breakpoint
    2. Select the new breakpoint, Control-Click, Edit Breakpoint
    3. Add Action
    4. Enter: po $arg1

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

This seems to still work in Xcode 9

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

  1. Enter: po (NSException*) $eax

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...