Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debugging an Exception in XCode 4

I'm struggling to get to the bottom of an exception thrown as a result of a method call on a AVAudioRecorder instance. I have an Exception Breakpoint set up, but I'm unable to glean any useful information from the stack trace. The point at which the exception is thrown is during a call to:

[recorder prepareToRecord];

If I turn breakpoints off the application runs fine seemingly without any negative effects. The recorder functions normally. Just to be clear, the specifics of the situation are not so important. It is more a case of 'What should I be doing in a situation like this to solve the problem?' I can't see any way of learning any more about the problem with the tools at hand. Documentation on ACBaseCodec seems stale and doesn't shed any light on what might cause the exception to be thrown.

Stack trace from Debug Navigator:

Debug Navigator

Stack trace from individual thread:

enter image description here

Is there any way to know what has caused this exception?

like image 470
Undistraction Avatar asked Aug 11 '11 13:08

Undistraction


People also ask

How do I debug an exception?

Tell the debugger to break when an exception is thrown In the Exception Settings window (Debug > Windows > Exception Settings), expand the node for a category of exceptions, such as Common Language Runtime Exceptions. Then select the check box for a specific exception within that category, such as System.

How do you breakpoint in Xcode?

Navigate to a line in your code where you want execution to pause, then click the gutter or line number in the source editor to set a breakpoint. Xcode displays a breakpoint icon to indicate the location. Drag a breakpoint up or down to move it to another location; drag it away from the gutter to remove it.

What is exception breakpoint in Xcode?

An exception breakpoint is a type of breakpoint that is created when some exception occurs in the code. On occurrence of such exception our application stops at that given condition causing the exception and we can access all variables in scope at that breakpoint.


2 Answers

Unfortunately I think AVAudioPlayer and AVAudioRecorder appear to use C++ exceptions as part of their normal processing flow in prepareTo.... So if you enable a break on all exceptions there is no real way to avoid stopping there. You can probably just keep continuing and get through it. Another possible workaround is to only enable Objective-C exceptions as it appears to be throwing C++ exceptions. That is what I did. Sorry it is not an answer, why they made that design decision for prepareTo... is beyond me.

like image 199
Ray Fix Avatar answered Nov 15 '22 05:11

Ray Fix


If the program fails when the debugger is active, there might be a race condition in a thread. Also, you might want to try setting NSZombieEnabled to true or running the program in Instruments to see if any memory issues are causing problems. Is the recorder object retained?

I have seen some instances where a program crashed with no debugger running, yet ran normally when the debugger was active, but I have never seen a situation like this.

Is the debugger logging any messages?

like image 35
Julian Ceipek Avatar answered Nov 15 '22 06:11

Julian Ceipek