简体   繁体   中英

Xcode 4 break on exception or assert with good call stack AND printing of the exception

Using Xcode 4.3.2. I looked at many different similar issues including this one

no-call-stack-on-exception-in-xcode-4

but cannot get the debugger (gdb or lldb) to give me a good stack trace that shows the location of the exception AND to also prints what the exception is

Setting either a symbolic exception on objc_exception_throw or an "All Exceptions" exception breakpoint, lldb would not give me a good stack trace but would show the following:

  • thread #1: tid = 0x1c03, 0x34455238 libobjc.A.dylib objc_exception_throw, stop reason = breakpoint 1.1 frame #0: 0x34455238 libobjc.A.dylib objc_exception_throw frame #1: 0x323ff788 CoreFoundation`+[NSException raise:format:arguments:] + 100

That is the whole thing, either through bt or at full magnification in the graphical breakpoint/debugger view.

If I hit continue a few time at this point it will eventually tell me the exception/assertion, for example

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '_endUndoGroupRemovingIfEmpty:: NSUndoManager 0x2b7610 is in invalid state, endUndoGrouping called with no matching begin

But I have no idea where it is at.

gdb, using the same breakpoint, WILL stop and show me where it is at, but does not print the exception text. If I hit continue a few times it does but I have lost my context of the back trace.

I would like to know how to print the exception text so I know WHY it stopped, without having to do a few continues and losing my place. I would also like to get it to stop in lldb at the point of the exception like it does in gdb.

Please try updating to Xcode 4.5. You're seeing an armv7 unwinder problem where lldb doesn't know how to unwind your stack completely. The Objective-C runtime has some functions that are difficult to unwind out of (hand-written assembly) but I just did a quick test on an iOS device with Xcode 4.5 and lldb behaved correctly when I had Xcode set an Exception Breakpoint on throw.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM