Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: debugging exceptions!



Markian Hlynka wrote on Thursday, November 17, 2005:
>Hi! How do exceptions work in the debugger?

Pretty much the same as everything else.  ;)

>I was just debugging  
>something, and clicked "step over" when it was pointing at my  
>"throw", and it said the executable was still running... but nothing  
>was displayed in the debugger window. Did I do something wrong? Is  
>there a proper way to do this? I expect to see focus go to the catch  
>block...?

Throws in most languages are just funky flow control. Treat them like a goto statement (look up longjmp() if you want the details). They are not exceptional states or events as far as the debugger is concerned, and the debugger knows nothing about them so it can't anticipate the effect of a thrown exception in a step-over or step-into command.

When you stepped over the throw, the debugger simply placed a temporary breakpoint at the next line and let the function call at the current line execute. It's not the debugger's fault it never came back from the call.

The easiest way to catch an exception is to set a breakpoint in the code that catches the exception first. C++ has an option to break into the debugger whenever an exception is thrown (see the Debug menu). In Objective-C, you can set a global breakpoint at -[NSException raise].

-- 
James Bucanek
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/xcode-users/email@hidden

This email sent to email@hidden

References: 
 >debugging exceptions! (From: Markian Hlynka <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.