async intermediate continuations handling fix

Pedro Alves pedro@codesourcery.com
Tue Apr 8 19:06:00 GMT 2008


The async mode uses intermediate continuations to implement the multiple
steps of a "step $n"-like operation.

In fetch_inferior_event, we decide if we're still in the middle of
a step multi, and if so, run the intermediate continuations.
It is the step_1_continuation's (an intermediate continuation)
job to decrease $n, and step one more time if $n is still >0.
It is also the continuations job to disable the longjmp
breakpoints.  This means that even in the 'step 1' case, or
'-exec-step, or next, or -exec-next', we also install an
intermediate continuation to disable the longjmp
breakpoints.

There are a couple of bugs related to this in the
current codebase. When we install the continuation, we
forget to run it on the last iteration step.  This means
that everytime we do a step, a new continuation is
placed in the queue, and it's never ran, even in the step 1
case.

Another problem, is that if a step command is interrupted
by a user breakpoint, we also leave the intermediate
continuations in the queue.

In the step n case, this is quite noticeable.  If the user
issues a 'step 2' command, and it is interrupted by a 
breakpoint, and then the user issues another 'step 2',
the continuations from the previous step will still
be in place.  When the first step in the 'step 2' command
finishes, the intermediate continuations are ran.  Now
there are two copies of step_1_continuation registered, 
both will run.  The second one will try to resume the inferior,
and it is already running...

To fix this we should also run the continuations in the
INF_EXEC_COMPLETE case.  The continuations themselves
are responsible for detecting if they should go on, or
if the step was interrupted.  That's already done,
but the checking will need a further tweak a bit
further down the non-stop series.

New test included that fails in async mode without
this patch.  A few iterations were needed to trigger
an error reliably.

Tested on x86_64-unknown-linux-gnu.

-- 
Pedro Alves
-------------- next part --------------
A non-text attachment was scrubbed...
Name: async_multi_step.diff
Type: text/x-diff
Size: 4563 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/gdb-patches/attachments/20080408/ac90b88a/attachment.bin>


More information about the Gdb-patches mailing list