Re: debugging exceptions!
Re: debugging exceptions!
- Subject: Re: debugging exceptions!
- From: James Bucanek <email@hidden>
- Date: Mon, 21 Nov 2005 16:02:14 -0700
Markian Hlynka wrote on Monday, November 21, 2005:
>I think I see. You're saying that the debugger is waiting for the
>throw to return and come back to the next line, which of course it
>doesn't because the throw unravelled the stack and ended up in the
>appropriate catch block, right?
Basically, yes. The debugger doesn't know it's a throw. The debugger just sees a function call. It sets a temporary breakpoint at the instruction following the call and let's the program run, assuming that it will eventually return and hit the breakpoint.
Throws in most C languages relay on longjmp, which fiddles with the stack and changes the program counter register unexpectedly. The debugger can't anticipate this anymore than it can catch a thread switch. (I once implemented my own exception handling scheme, which was kind of fun, so I had a chance to play around with how this works.)
>So, if I'm stepping through the code and hit a throw and want to
>follow it, will it make any difference to step _into instead of over?
No, you'd just be stepping through the throw mechanism, which is going to be really hard without the source to the library, and not all that helpful anyway.
What I usually end up doing is setting breakpoints in the catch clauses that could catch the throw, then merrily step through the code. If an exception it thrown, the breakpoint in the catch will get it.
Like I also said, you can also enable the debugger to catch all C++ breakpoints, or set a symbolic breakpoint on the Objective-C method -[NSException raise], before you step over any code that might throw an exception.
James
--
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:
This email sent to email@hidden