From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20098 invoked by alias); 13 Jan 2005 00:09:39 -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 19793 invoked from network); 13 Jan 2005 00:09:29 -0000 Received: from unknown (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org with SMTP; 13 Jan 2005 00:09:29 -0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.12.11/8.12.11) with ESMTP id j0D09TEZ028504 for ; Wed, 12 Jan 2005 19:09:29 -0500 Received: from localhost.redhat.com (vpn50-65.rdu.redhat.com [172.16.50.65]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id j0D09Sr17749 for ; Wed, 12 Jan 2005 19:09:28 -0500 Received: from [127.0.0.1] (localhost.localdomain [127.0.0.1]) by localhost.redhat.com (Postfix) with ESMTP id DD3777D79 for ; Wed, 12 Jan 2005 19:08:02 -0500 (EST) Message-ID: <41E5BBE0.8000604@redhat.com> Date: Thu, 13 Jan 2005 00:09:00 -0000 From: Andrew Cagney User-Agent: Mozilla Thunderbird 0.8 (X11/20041020) MIME-Version: 1.0 To: gdb@sources.redhat.com Subject: TRY_CATCH() Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2005-01/txt/msg00064.txt.bz2 Hello, The exceptions rewrite opens up a key possibility. It's now possible to define a macro such that: struct args { ... }; do_func (void *data) { struct args *args = data; ... do stuff ...; } func (...) { struct args args; args... = ...; struct exception e = catch_exception (..., func, &args, ...) switch (e.reason) ... } can be replaced with the more compact: func (...) { volatile struct exception e; TRY_CATCH (e) { ... do stuff ...; } switch (e.reason) ... } Yes I know macros a bad, m'kay. However, this offers a simple way to rewrite the code using something more like a real programming languages try/catch. Andrew 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; comments? Andrew