From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3002 invoked by alias); 26 Nov 2009 06:40:25 -0000 Received: (qmail 2991 invoked by uid 22791); 26 Nov 2009 06:40:23 -0000 X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL,BAYES_00,SARE_MSGID_LONG40,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mail-pw0-f49.google.com (HELO mail-pw0-f49.google.com) (209.85.160.49) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 26 Nov 2009 06:40:17 +0000 Received: by pwj21 with SMTP id 21so355916pwj.8 for ; Wed, 25 Nov 2009 22:40:16 -0800 (PST) MIME-Version: 1.0 Received: by 10.142.7.3 with SMTP id 3mr953630wfg.126.1259217616270; Wed, 25 Nov 2009 22:40:16 -0800 (PST) In-Reply-To: References: <20091125162458.GF26004@adacore.com> From: Hui Zhu Date: Thu, 26 Nov 2009 06:40:00 -0000 Message-ID: Subject: Re: [RFA] let record_resume fail immediately on error To: Tom Tromey , Joel Brobecker , Michael Snyder Cc: "gdb-patches@sourceware.org" Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 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: 2009-11/txt/msg00566.txt.bz2 Hi guys, What about following change: Change record_message to record_message (struct regcache *regcache, enum target_signal signal) static int record_message_wrapper_safe(struct regcache *regcache, enum target_signal signal) { struct record_message_args args; args.regcache =3D regcache; args.signal =3D signal; return catch_errors (record_message_wrapper, &args, NULL, RETURN_MASK_ALL= ); } static int record_message_wrapper (void *args) { return record_message (args->regcache, args->signal); } record_resume will call record_message. record_wait will call record_message_wrapper_safe Do you think it's OK? Thanks, Hui On Thu, Nov 26, 2009 at 01:58, Tom Tromey wrote: >>>>>> "Joel" =3D=3D Joel Brobecker writes: > >>> I don't like use TRY_CATCH or catch_errors directly. > > Joel> I confess that I don't like catch_errors, because of the need to > Joel> artificially create a container type that contains all the function > Joel> parameters. > > In this code, we already have the container type and untyped trampoline > function. > > The problem I have with it is that there are direct calls to the untyped > trampoline function. > > I think the general approach for using catch_errors in gdb ought to be: > > * Have a properly-typed function that does all the work. > * If you need catch_errors, introduce a new type to hold the actual > =A0arguments, and write an untyped trampoline function. =A0Then, *only* > =A0call this trampoline function via catch_errors. > * ... However, prefer TRY_CATCH in most cases, because it does not > =A0require a new type and is generally safer (though not completely > =A0safe). > > And FWIW, I think this rule is generally followed in practice. > > My reason for the above is that it is generally best to write a > type-safe program and let the compiler diagnose errors. =A0We can't do > this for catch_errors, due to limitations in C, but we can at least > limit the damage. > > > Also, this patch introduces an argument indicating whether or not to > catch. =A0This is bad, because it is confusing, but also particularly bad > in this case because the actual argument is always a constant. > > Tom >