This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: RFC: next/finish/etc -vs- exceptions
- From: Pedro Alves <pedro at codesourcery dot com>
- To: gdb-patches at sourceware dot org
- Cc: Tom Tromey <tromey at redhat dot com>, Daniel Jacobowitz <drow at false dot org>, Joel Brobecker <brobecker at adacore dot com>
- Date: Fri, 12 Jun 2009 23:08:36 +0100
- Subject: Re: RFC: next/finish/etc -vs- exceptions
- References: <m37hzzzgk7.fsf@fleche.redhat.com> <m38wjx9o7l.fsf@fleche.redhat.com> <200906122252.52837.pedro@codesourcery.com>
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 ...
>
> On Friday 12 June 2009 21:44:30, Tom Tromey wrote:
> > +/* A continuation callback for until_next_command. ?*/
> > +
> > +static void
> > +until_next_continuation (void *arg)
> > +{
> > + ?struct thread_info *tp = arg;
> > + ?delete_longjmp_breakpoint (tp->num);
>
> 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...
>
> > +}
> > +
> > ?/* Proceed until we reach a different source line with pc greater than
> > ? ? our current one or exit the function. ?We skip calls in both cases.
> > ?
> > @@ -1170,6 +1181,8 @@ until_next_command (int from_tty)
> > ? ?struct symbol *func;
> > ? ?struct symtab_and_line sal;
> > ? ?struct thread_info *tp = inferior_thread ();
> > + ?int thread = tp->num;
> > + ?struct cleanup *old_chain;
> > ?
> > ? ?clear_proceed_status ();
> > ?
> > @@ -1205,7 +1218,18 @@ until_next_command (int from_tty)
> > ?
> > ? ?tp->step_multi = 0;??????????/* Only one call to proceed */
> > ?
> > + ?tp->initiating_frame = set_exception_breakpoint (frame);
>
>
> > + ?old_chain = make_cleanup (delete_longjmp_breakpoint_cleanup, &thread);
> > +
> > ? ?proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 1);
> > +
> > + ?if (target_can_async_p () && is_running (inferior_ptid))
> > + ? ?{
> > + ? ? ?discard_cleanups (old_chain);
> > + ? ? ?add_continuation (tp, until_next_continuation, tp, NULL);
> > + ? ?}
> > + ?else
> > + ? ?do_cleanups (old_chain);
>
> 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.
>
This principle is valid, but your code is actually fine, because
TP continuations are always run with TP being valid.
--
Pedro Alves