From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28137 invoked by alias); 28 Nov 2009 00:29:56 -0000 Received: (qmail 28129 invoked by uid 22791); 28 Nov 2009 00:29:55 -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; Sat, 28 Nov 2009 00:29:49 +0000 Received: by pwi1 with SMTP id 1so939798pwi.8 for ; Fri, 27 Nov 2009 16:29:48 -0800 (PST) MIME-Version: 1.0 Received: by 10.142.6.39 with SMTP id 39mr170089wff.316.1259368188048; Fri, 27 Nov 2009 16:29:48 -0800 (PST) In-Reply-To: References: <20091125162458.GF26004@adacore.com> From: Hui Zhu Date: Sat, 28 Nov 2009 00:29: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/msg00587.txt.bz2 Hey guys, I know I must be so anxious with this patch. Sorry for it. I have another patch follow this patch that is reviewing too. Update patch to fit with code always a hard thing for me. If you can give me some comment about this idea, it will really help me a l= ot. Thanks a lot. Hui On Thu, Nov 26, 2009 at 14:39, Hui Zhu wrote: > 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, > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 enum target_signal signal) > { > =A0struct record_message_args args; > > =A0args.regcache =3D regcache; > =A0args.signal =3D signal; > =A0return catch_errors (record_message_wrapper, &args, NULL, RETURN_MASK_= ALL); > } > > static int > record_message_wrapper (void *args) > { > =A0return 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 >> >