mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-05 08:46:02 +02:00
Bug 359783 - [run control] SteppingController step timeout doesn't work
when container is resumed
This commit is contained in:
parent
c09afdc574
commit
d643d3b26e
1 changed files with 67 additions and 27 deletions
|
@ -13,6 +13,7 @@ package org.eclipse.cdt.dsf.debug.ui.viewmodel;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -117,6 +118,28 @@ public final class SteppingController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class TimeOutRunnable extends DsfRunnable{
|
||||||
|
|
||||||
|
TimeOutRunnable(IExecutionDMContext dmc) {
|
||||||
|
fDmc = dmc;
|
||||||
|
}
|
||||||
|
|
||||||
|
private final IExecutionDMContext fDmc;
|
||||||
|
|
||||||
|
public void run() {
|
||||||
|
fTimedOutFutures.remove(fDmc);
|
||||||
|
|
||||||
|
if (getSession().isActive()) {
|
||||||
|
fTimedOutFlags.put(fDmc, Boolean.TRUE);
|
||||||
|
enableStepping(fDmc);
|
||||||
|
// Issue the stepping time-out event.
|
||||||
|
getSession().dispatchEvent(
|
||||||
|
new SteppingTimedOutEvent(fDmc),
|
||||||
|
null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private final DsfSession fSession;
|
private final DsfSession fSession;
|
||||||
private final DsfServicesTracker fServicesTracker;
|
private final DsfServicesTracker fServicesTracker;
|
||||||
|
|
||||||
|
@ -406,6 +429,15 @@ public final class SteppingController {
|
||||||
updateLastStepTime(execCtx);
|
updateLastStepTime(execCtx);
|
||||||
|
|
||||||
getRunControl().step(execCtx, stepType, new RequestMonitor(getExecutor(), null) {
|
getRunControl().step(execCtx, stepType, new RequestMonitor(getExecutor(), null) {
|
||||||
|
@Override
|
||||||
|
protected void handleSuccess() {
|
||||||
|
fTimedOutFlags.put(execCtx, Boolean.FALSE);
|
||||||
|
// We shouldn't have a stepping timeout running unless
|
||||||
|
// running/stopped events are out of order.
|
||||||
|
assert !fTimedOutFutures.containsKey(execCtx);
|
||||||
|
fTimedOutFutures.put(execCtx, getExecutor().schedule(new TimeOutRunnable(execCtx), fStepTimeout, TimeUnit.MILLISECONDS));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void handleFailure() {
|
protected void handleFailure() {
|
||||||
// in case of a failed step - enable stepping again (bug 265267)
|
// in case of a failed step - enable stepping again (bug 265267)
|
||||||
|
@ -578,12 +610,29 @@ public final class SteppingController {
|
||||||
public void eventDispatched(final ISuspendedDMEvent e) {
|
public void eventDispatched(final ISuspendedDMEvent e) {
|
||||||
// Take care of the stepping time out
|
// Take care of the stepping time out
|
||||||
IExecutionDMContext dmc = e.getDMContext();
|
IExecutionDMContext dmc = e.getDMContext();
|
||||||
boolean timedout = fTimedOutFlags.remove(dmc) == Boolean.TRUE;
|
for (Iterator<Map.Entry<IExecutionDMContext, Boolean>> itr = fTimedOutFlags.entrySet().iterator(); itr.hasNext();) {
|
||||||
ScheduledFuture<?> future = fTimedOutFutures.remove(dmc);
|
Map.Entry<IExecutionDMContext,Boolean> entry = itr.next();
|
||||||
if (future != null) future.cancel(false);
|
IExecutionDMContext nextDmc = entry.getKey();
|
||||||
|
if (nextDmc.equals(dmc) || DMContexts.isAncestorOf(nextDmc, dmc)) {
|
||||||
|
if (entry.getValue()) {
|
||||||
|
// after step timeout do not process queued steps
|
||||||
|
fStepQueues.remove(dmc);
|
||||||
|
}
|
||||||
|
itr.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (timedout || e.getReason() != StateChangeReason.STEP) {
|
for (Iterator<Map.Entry<IExecutionDMContext, ScheduledFuture<?>>> itr = fTimedOutFutures.entrySet().iterator(); itr.hasNext();) {
|
||||||
// after step timeout or any other suspend reason do not process queued steps
|
Map.Entry<IExecutionDMContext, ScheduledFuture<?>> entry = itr.next();
|
||||||
|
IExecutionDMContext nextDmc = entry.getKey();
|
||||||
|
if (nextDmc.equals(dmc) || DMContexts.isAncestorOf(entry.getKey(), dmc)) {
|
||||||
|
entry.getValue().cancel(false);
|
||||||
|
itr.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (e.getReason() != StateChangeReason.STEP) {
|
||||||
|
// after any non-step suspend reason do not process queued steps for given context
|
||||||
fStepQueues.remove(dmc);
|
fStepQueues.remove(dmc);
|
||||||
} else {
|
} else {
|
||||||
// Check if there's a step pending, if so execute it
|
// Check if there's a step pending, if so execute it
|
||||||
|
@ -596,28 +645,19 @@ public final class SteppingController {
|
||||||
if (e.getReason().equals(StateChangeReason.STEP)) {
|
if (e.getReason().equals(StateChangeReason.STEP)) {
|
||||||
final IExecutionDMContext dmc = e.getDMContext();
|
final IExecutionDMContext dmc = e.getDMContext();
|
||||||
fTimedOutFlags.put(dmc, Boolean.FALSE);
|
fTimedOutFlags.put(dmc, Boolean.FALSE);
|
||||||
// We shouldn't have a stepping timeout running unless we get two
|
|
||||||
// stepping events in a row without a suspended, which would be a
|
|
||||||
// protocol error.
|
|
||||||
assert !fTimedOutFutures.containsKey(dmc);
|
|
||||||
fTimedOutFutures.put(
|
|
||||||
dmc,
|
|
||||||
getExecutor().schedule(
|
|
||||||
new DsfRunnable() { public void run() {
|
|
||||||
fTimedOutFutures.remove(dmc);
|
|
||||||
|
|
||||||
if (getSession().isActive()) {
|
|
||||||
fTimedOutFlags.put(dmc, Boolean.TRUE);
|
|
||||||
enableStepping(dmc);
|
|
||||||
// Issue the stepping time-out event.
|
|
||||||
getSession().dispatchEvent(
|
|
||||||
new SteppingTimedOutEvent(dmc),
|
|
||||||
null);
|
|
||||||
}
|
|
||||||
}},
|
|
||||||
fStepTimeout, TimeUnit.MILLISECONDS)
|
|
||||||
);
|
|
||||||
|
|
||||||
|
// Find any time-out futures for contexts that are children of the
|
||||||
|
// resumed context, and cancel them as they'll be replaced.
|
||||||
|
for (Iterator<Map.Entry<IExecutionDMContext, ScheduledFuture<?>>> itr = fTimedOutFutures.entrySet().iterator(); itr.hasNext();) {
|
||||||
|
Map.Entry<IExecutionDMContext, ScheduledFuture<?>> entry = itr.next();
|
||||||
|
if (DMContexts.isAncestorOf(entry.getKey(), dmc) && !dmc.equals(entry.getKey())) {
|
||||||
|
entry.getValue().cancel(false);
|
||||||
|
itr.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fTimedOutFutures.put(dmc, getExecutor().schedule(new TimeOutRunnable(dmc), fStepTimeout, TimeUnit.MILLISECONDS));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue