From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19157 invoked by alias); 13 Jan 2005 19:48:38 -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 19050 invoked from network); 13 Jan 2005 19:48:32 -0000 Received: from unknown (HELO nimbus.ott.qnx.com) (209.226.137.76) by sourceware.org with SMTP; 13 Jan 2005 19:48:32 -0000 Received: from [10.12.1.181] (dhcpa181.ott.qnx.com [10.12.1.181]) by nimbus.ott.qnx.com with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2653.13) id CW5W90C3; Thu, 13 Jan 2005 14:48:32 -0500 Message-ID: <41E6D165.9010102@qnx.com> Date: Thu, 13 Jan 2005 19:48:00 -0000 From: Kris Warkentin User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) MIME-Version: 1.0 To: Andrew Cagney CC: gdb@sources.redhat.com Subject: Re: TRY_CATCH() References: <41E5BBE0.8000604@redhat.com> In-Reply-To: <41E5BBE0.8000604@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2005-01/txt/msg00069.txt.bz2 Andrew Cagney wrote: >PS: I recall this being proposed years ago, but the mechanism proposed >at the time had a more cumbersom syntax, from memory something like: > > TRY_BEGIN > ... do stuff ... > TRY_END; > > I saw something similar to this that worked really well but was not quite as generic. Basically you would have to add a 'TryStack' member to whatever data structure you were planning to capture exceptions on. The TryStack was a stack of jmp_bufs. Then you'd do something like if((error = TRY(mystruct)) == 0){ do_stuff(mystruct); TRY_END(mystruct->try_stack); } else{ CATCH(mystruct, error); handle_error(); } The TRY would push a new jmp_buf onto the TryStack and the TRY_END and CATCH would pop one. The various macros would be like #define TRY(foo) is try_push(foo->try_stack) and so on. It's actually quite clever: If something THROWs, it also pops but CATCH only pops if the error value is zero so that you can have multiple tries and catches on a single block. Anyway, interesting stuff. cheers, Kris