Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Daniel Berlin <dberlin@dberlin.org>
To: Daniel Jacobowitz <drow@mvista.com>
Cc: Paul Dubuc <pdubuc@cas.org>, <gdb@sources.redhat.com>
Subject: Re: catchpoints
Date: Thu, 18 Jul 2002 14:02:00 -0000	[thread overview]
Message-ID: <Pine.LNX.4.44.0207181640170.24156-100000@dberlin.org> (raw)
In-Reply-To: <20020718201329.GA15774@nevyn.them.org>

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
> > 


  reply	other threads:[~2002-07-18 21:02 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-07-18 13:00 catchpoints Paul Dubuc
2002-07-18 13:05 ` catchpoints Daniel Jacobowitz
2002-07-18 13:09   ` catchpoints Daniel Berlin
2002-07-18 13:13     ` catchpoints Daniel Jacobowitz
2002-07-18 14:02       ` Daniel Berlin [this message]
2002-07-18 13:17     ` catchpoints Paul Dubuc
2002-07-18 13:21       ` catchpoints Daniel Jacobowitz
2002-07-18 13:40         ` catchpoints Paul Dubuc
2002-07-18 13:43           ` catchpoints Daniel Jacobowitz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.44.0207181640170.24156-100000@dberlin.org \
    --to=dberlin@dberlin.org \
    --cc=drow@mvista.com \
    --cc=gdb@sources.redhat.com \
    --cc=pdubuc@cas.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox