This is the mail archive of the
gdb@sources.redhat.com
mailing list for the GDB project.
Re: catchpoints
- From: Daniel Berlin <dberlin at dberlin dot org>
- To: Daniel Jacobowitz <drow at mvista dot com>
- Cc: Paul Dubuc <pdubuc at cas dot org>, <gdb at sources dot redhat dot com>
- Date: Thu, 18 Jul 2002 17:02:40 -0400 (EDT)
- Subject: Re: catchpoints
On Thu, 18 Jul 2002, Daniel Jacobowitz wrote:
> On Thu, Jul 18, 2002 at 04:09:01PM -0400, Daniel Berlin wrote:
> > On Thu, 18 Jul 2002, Daniel Jacobowitz wrote:
> >
> > > On Thu, Jul 18, 2002 at 04:00:43PM -0400, Paul Dubuc wrote:
> > > > I'm using gdb 5.2 on Solaris 8 to debug code compiled with g++ 2.95.3.
> > > > When I try to enter 'catch throw' or 'catch catch' commands I get a
> > > > message that says
> > > >
> > > > no runtime support for this
> > > >
> > > > Does this mean I need to rebuild gdb to support these commands or is it
> > > > just that they aren't supported for this OS or compiler?
> > > >
> > > > I can't find any info in the manual about this.
> > >
> > > I believe they're only supported on HP/UX (and none of the HP/UX
> > > support works quite right any more...). I don't think anyone has tried
> > > to implement them on GCC code yet.
> >
> > Actually, I did, and had it working just fine.
> > It's actually not that difficult, but it is ABI specific.
>
> Have you still got the code to do this?
I don't think so, it was done when i was working on GDB for BeOS, which
was over a year and a half ago.
> I'd like to see it. Although
> I've got a pretty good idea how it's done now that I look over the
> code.
For general catch/throw, for gcc 3.1, you breakpoint _cxa_begin_catch,
with the bp_catch_catch type, and _cxa_throw, with the bp_catch_throw
type.
You need to modify catch_exception_command_1 to breakpoint these.
You also need a generic get_current_exception_event that fills in the
record by looking at the location one or two levels up the stack frame,
which will be the throw or catch location.
At least, it used to be.
I'm sure the throw will still be like that, the catch location might be a
bit
different to handle.
We can also catch specific exceptions only (which would require extending
the syntax of catch a bit) by looking at the exceptionType field of the
exceptionObject local variable in cxa_begin_catch, which will be a
std::type_info structure, where we can get the mangled name from.
Same with throw, except the type_info is passed in to the throw routine as
an argument, so you don't have to wait for a local variable to be set up
(or cast the argument to _Unwind_Exception * yerself, which is what that
local variable is init'd to anyway).
THe other option to get the type is to call __cxa_current_exception_type,
which will do this all for you and hand you the type_info. While I think
is also part of the ABI, i only see __cxa_begin_catch/throw/end_catch in
Intel's exception library, so it might not be.
All of these routine names are specified as part of the C++ ABI, so they
would be the same in any other compiler using the C++ ABI.
Lastly, throw the generic exception routine in whatever targets you like,
and it'll all just work.
It didn't takek more than about 2 hours to do when i originally did it.
Just look at libstdc++-v3/libsupc++/eh_* if you need more information on
how the routines work/the arguments/etc
--Dan
> >