From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17674 invoked by alias); 12 Jun 2009 22:07:22 -0000 Received: (qmail 17666 invoked by uid 22791); 12 Jun 2009 22:07:21 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL,BAYES_00,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (65.74.133.4) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 12 Jun 2009 22:07:16 +0000 Received: (qmail 11389 invoked from network); 12 Jun 2009 22:07:13 -0000 Received: from unknown (HELO orlando.local) (pedro@127.0.0.2) by mail.codesourcery.com with ESMTPA; 12 Jun 2009 22:07:13 -0000 From: Pedro Alves To: gdb-patches@sourceware.org Subject: Re: RFC: next/finish/etc -vs- exceptions Date: Fri, 12 Jun 2009 22:07:00 -0000 User-Agent: KMail/1.9.10 Cc: Tom Tromey , Daniel Jacobowitz , Joel Brobecker References: <200906122252.52837.pedro@codesourcery.com> In-Reply-To: <200906122252.52837.pedro@codesourcery.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Message-Id: <200906122308.36882.pedro@codesourcery.com> 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-06/txt/msg00344.txt.bz2 On Friday 12 June 2009 22:52:52, Pedro Alves wrote: > [Reviewing bits and pieces instead of the whole patch at once] And I'll stop here, get some sleep, and then get back ... >=20 > On Friday 12 June 2009 21:44:30, Tom Tromey wrote: > > +/* A continuation callback for until_next_command. =A0*/ > > + > > +static void > > +until_next_continuation (void *arg) > > +{ > > + =A0struct thread_info *tp =3D arg; > > + =A0delete_longjmp_breakpoint (tp->num); >=20 > This is broken, in that there's no guarantee that TP is still a > valid pointer here. Somehow, I read this as being the cleanup that the do_cleanups call below runs... >=20 > > +} > > + > > =A0/* Proceed until we reach a different source line with pc greater th= an > > =A0 =A0 our current one or exit the function. =A0We skip calls in both = cases. > > =A0 > > @@ -1170,6 +1181,8 @@ until_next_command (int from_tty) > > =A0 =A0struct symbol *func; > > =A0 =A0struct symtab_and_line sal; > > =A0 =A0struct thread_info *tp =3D inferior_thread (); > > + =A0int thread =3D tp->num; > > + =A0struct cleanup *old_chain; > > =A0 > > =A0 =A0clear_proceed_status (); > > =A0 > > @@ -1205,7 +1218,18 @@ until_next_command (int from_tty) > > =A0 > > =A0 =A0tp->step_multi =3D 0;=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0/* Only one c= all to proceed */ > > =A0 > > + =A0tp->initiating_frame =3D set_exception_breakpoint (frame); >=20 >=20 > > + =A0old_chain =3D make_cleanup (delete_longjmp_breakpoint_cleanup, &th= read); > > + > > =A0 =A0proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 1); > > + > > + =A0if (target_can_async_p () && is_running (inferior_ptid)) > > + =A0 =A0{ > > + =A0 =A0 =A0discard_cleanups (old_chain); > > + =A0 =A0 =A0add_continuation (tp, until_next_continuation, tp, NULL); > > + =A0 =A0} > > + =A0else > > + =A0 =A0do_cleanups (old_chain); >=20 > In sync execution mode, between that `proceed' and this do_cleanups, a > lot happens. TP may exit, or the whole process for the matter. > So, after `proceed', any TP pointer is invalid. Any other code > doing the same thing is equally broken. >=20 This principle is valid, but your code is actually fine, because TP continuations are always run with TP being valid. --=20 Pedro Alves