This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: RFC: next/finish/etc -vs- exceptions


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]