Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

xcode

llvm

I paused my app and tried printing something to the console. (e.g. po foo()). After doing so, I got the following message:

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

However, there are no breakpoints in that function. Why is it showing me this error and not executing the function?

This is on Xcode 4.6.

like image 670
Senseful Avatar asked Aug 01 '13 06:08

Senseful


1 Answers

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.

like image 74
Senseful Avatar answered Oct 17 '22 15:10

Senseful