This is the mail archive of the mailing list for the Archer project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Simple exception use-case

Some pointers for this topic... I've looked at it several times so I
may be able to give you a head start :-)

On Mon, Jul 28, 2008 at 01:52:25PM +0100, Phil Muldoon wrote:
> <snip useful info>
> Raised exceptions may be caught:
>    catch throw - all exceptions, when thrown
>    catch throw <exceptname>  - a particular exception, when thrown
>    catch catch - all exceptions, when caught
>    catch catch <exceptname>  - a particular exception, when caught

I suspect the named versions do not work for C++ (iirc they did for
HP-UX at one time, and/or do for Ada).

> Well I think it is "throw simple", that is the last line shown. But it  
> would be neat if the catch would print the actual throw line, like a  
> simple breakpoint. Shown below:

Making GDB do this is not too complicated.  There is a caveat - the
last time I tried it, it broke Eclipse.  Having the debugger stop with
a frame other than the innermost selected is a little tricky but there
may be a better way to do it than I tried; there's more state change
notifications in GDB than there were at the time.

> Catchpoint 1 (exception thrown), 0x000000333d0c3d70 in __cxa_throw ()  
> from /usr/lib64/
> (gdb) s
> Single stepping until exit from function __cxa_throw,
> which has no line number information.
> Exception: simple exception occurred
> Program exited normally.
> Well maybe not.  I'm not sure why I lost control of the inferior.

GDB has this problem with both longjmp and longjmp-alikes.  Pedro
nearly fixed the longjmp problem but was, in the end, defeated by some
complexities of glibc's pointer mangling; you can find discussion in
this spring's gdb-patches archives.  DWARF unwinding uses a
longjmp-alike, GCC's __builtin_eh_return, which has the same problem.

GDB expects when you step over or out of a function that it can
shortcut by placing a breakpoint at the return address.  So it has to
be taught about functions with abnormal control flow.  Reference:

> gdb simple
> GNU gdb Fedora (6.8-11.fc9)
> (gdb) catch catch
> Function "__cxa_begin_catch" not defined.
> (gdb) catch throw
> Function "__cxa_throw" not defined.

IIRC this is because GDB does not (did not?) use pending breakpoints.
Try again after starting the program, so libstdc++ is loaded.  If it's
still broken it's an easy fix.

Daniel Jacobowitz

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]