From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31285 invoked by alias); 31 Dec 2006 21:37:16 -0000 Received: (qmail 31277 invoked by uid 22791); 31 Dec 2006 21:37:15 -0000 X-Spam-Check-By: sourceware.org Received: from nevyn.them.org (HELO nevyn.them.org) (66.93.172.17) by sourceware.org (qpsmtpd/0.31.1) with ESMTP; Sun, 31 Dec 2006 21:37:10 +0000 Received: from drow by nevyn.them.org with local (Exim 4.63) (envelope-from ) id 1H18Md-0006zF-RM; Sun, 31 Dec 2006 16:37:07 -0500 Date: Sun, 31 Dec 2006 21:37:00 -0000 From: Daniel Jacobowitz To: Joel Brobecker Cc: gdb-patches@sourceware.org Subject: Re: [RFC/RFA] Add support for catch Ada exceptions Message-ID: <20061231213707.GA26604@nevyn.them.org> Mail-Followup-To: Joel Brobecker , gdb-patches@sourceware.org References: <20061230032111.GB27642@adacore.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20061230032111.GB27642@adacore.com> User-Agent: Mutt/1.5.13 (2006-08-11) X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2006-12/txt/msg00423.txt.bz2 This is quite elegant really. On Sat, Dec 30, 2006 at 07:21:11AM +0400, Joel Brobecker wrote: > Hello, > > Here is a patch that adds support for "catch"-ing Ada exceptions. > There are 3 different kinds of commands I am introducing: > > - catch exception [exception name] > If the exception name is omitted, then all Ada exception are caught. > > - catch exception unhandled > This catchpoint will stop if the program raises an exception > that is not handled (and eventually causes the task or program death) > > - catch exception assert > This catchpoint stops the program when assertions in the program > fail. With GNAT, they are inserted like this: > > [code] > pragma Assert (boolean_EXPRESSION); > [code] > > They are activated only if the unit was compiled with assertions > enabled. This sounds an awful lot like "catch throw" and "catch catch" for C++. I realize you'll want different terms, but should we make them share a common mechanism? Also, is this more like "catch catch" or "catch throw"? I think it's more like "catch throw" from your example, i.e. stops you at the raise site. If so, the other alternative may be useful too (if there's any way to implement that in Ada). If not, that's not a big deal. Depends on your exceptions implementation. If possible, I'd like to have the same command work for both C++ and Ada in a mixed binary. I don't think it's possible to throw exceptions between them yet, but I'm sure it's been talked about. On the other hand, if this makes things too complex, we can postpone it. > In terms of implementation, these catchpoints are implemented using > breakpoints inside known functions of the GNAT runtime. However, > when we stop at these breakpoints, it would be confusing to the user > to leave them there. This is why, after the catchpoint hit, we go up > the stack automatically, and find the first "printable" frame, that > is a frame that is not part of the GNAT runtime and that has debugging > info (see ada_find_printable_frame). Nice. I meant to do this for the C++ equivalent, too, but never got around to it. As for the breakpoints, could you please check if you really need new bp_* constants? It's hard to spot in the history of breakpoint.c, but when I implemented something similar for C++, I added a "virtual table" that let us mark the breakpoint as a normal bp_breakpoint, and that simplified the change a bit. Search for handle_gnu_v3_exceptions. You're already using the virtual table, I see. I couldn't tell from the breakpoint.c changes quite why you needed new bp constants. I guess avoiding printing the condition might be one reason? The existing cases for "bp_catch_catch" and "bp_catch_throw" date back to HP/UX, which used a rather different OS mechanism to intercept exceptions, I believe. Treating them as normal breakpoints scales better and I think it will simplify the patch. Suppressing the "breakpoint also set at" for things with a custom set of breakpoint ops might be good for the C++ version too, just like your FIXME. -- Daniel Jacobowitz CodeSourcery