Xcode Exception Breakpoint Doesn't Print Details of the Exception Being Thrown

XCode: Find out what exception was thrown while stopped at an exception breakpoint

Are you sure you have the correct stack frame selected (i.e. the objc_exception_throw frame)?

According to this answer, your po $x0 should work.

Xcode debugger doesn't print object also not showing any error message

After checking all the buttons in debugger window, found there is button at bottom (default selected "All Output") which popup drop-down when we click on it.

This was set to 'Target Output' which causing the problem. Select option either 'All Output' or 'Debugger Output', then we can get values of variable/object when we say po variable/object.

Solution

Debugging in XCode: Exception Breakpoints

You don't have much control over where that breakpoint triggers. Once you've hit the breakpoint though, you can use the bt command to print the current stack trace.


EDIT: With the backtrace...

It looks like UIDocument's -saveToURL:forSaveOperation:completionHandler: method is the culprit. I've never used the class before, so I can't help too much. If you're calling that method anywhere in your code (like from a block?), you could also put a breakpoint there, in anticipation of the failure.

Execution was interrupted, reason: breakpoint when trying to print something from the Xcode console

It turns out that the breakpoint in question (2.1) was the All Exceptions breakpoint. The method I was calling raised an exception, which caused the All Exceptions breakpoint to be hit. po will stop execution once a breakpoint is reached (see this answer for more info).

If you disable the All Exceptions breakpoint and run it again, it is more clear that there was an exception:

error: Execution was interrupted, reason: signal SIGSTOP.
The process has been returned to the state before execution.

If you always leave the All Exceptions breakpoint enabled, then the message can be ambiguous: did it reach a breakpoint because there really was a breakpoint somewhere along the execution path, or was an exception raised?

An alternative solution (which doesn't require disabling the All Exceptions breakpoint) is to use expr instead of po (see the link above for a description of the following flags).

Running expr -u 0 -o -- foo() produces the following output:

error: Execution was interrupted, reason: breakpoint 2.1 -2.1.
The process has been left at the point where it was interrupted.
* thread #1: tid = [...] libobjc.A.dylib`objc_exception_throw, stop reason = breakpoint 2.1 -2.1
frame #0: [...] libobjc.A.dylib`objc_exception_throw

The objc_exception_throw string is a hint that an exception was raised.

What is an exception breakpoint in Xcode

It's just a GUI wrapper around setting a symbolic breakpoint on objc_exception_throw.

objc_exception_throw is just a C function that is used to raise all exceptions. So it's just like breaking on any function.

You don't get log messages any more because the debugger stops when the exception is thrown. If you continue from there, the exception will eventually be handled by the application which logs it by default. If you don't continue, though, you won't get any logs.



Related Topics



Leave a reply



Submit