From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29272 invoked by alias); 18 Jul 2002 21:02:43 -0000 Mailing-List: contact gdb-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sources.redhat.com Received: (qmail 29260 invoked from network); 18 Jul 2002 21:02:42 -0000 Received: from unknown (HELO www.dberlin.org) (138.88.48.221) by sources.redhat.com with SMTP; 18 Jul 2002 21:02:42 -0000 Received: by www.dberlin.org (Postfix, from userid 503) id B5857189B5CC; Thu, 18 Jul 2002 17:02:41 -0400 (EDT) Received: from localhost (localhost.localdomain [127.0.0.1]) by www.dberlin.org (Postfix) with ESMTP id 77410180636F; Thu, 18 Jul 2002 17:02:40 -0400 (EDT) Date: Thu, 18 Jul 2002 14:02:00 -0000 From: Daniel Berlin To: Daniel Jacobowitz Cc: Paul Dubuc , Subject: Re: catchpoints In-Reply-To: <20020718201329.GA15774@nevyn.them.org> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam-Status: No, hits=-2.9 required=5.0 tests=IN_REP_TO,AWL version=2.40 X-Spam-Level: X-SW-Source: 2002-07/txt/msg00191.txt.bz2 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 > >