1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 14:42:11 +02:00

Bug 338171: StartOrRestartSequence_7_0 is being called for older GDBs

This commit is contained in:
Marc Khouzam 2011-02-25 02:20:34 +00:00
parent 21fb967107
commit 9efc3961a2
6 changed files with 62 additions and 43 deletions

View file

@ -136,7 +136,7 @@ public class GdbRestartCommand implements IRestartHandler {
} catch (CoreException e) {} } catch (CoreException e) {}
procService.restart(containerDmc, attributes, procService.restart(containerDmc, attributes,
new RequestMonitor(fExecutor, null) { new DataRequestMonitor<IContainerDMContext>(fExecutor, null) {
@Override @Override
protected void handleCompleted() { protected void handleCompleted() {
fRequest.done(); fRequest.done();

View file

@ -20,7 +20,6 @@ import org.eclipse.cdt.dsf.concurrent.IDsfStatusConstants;
import org.eclipse.cdt.dsf.concurrent.ImmediateExecutor; import org.eclipse.cdt.dsf.concurrent.ImmediateExecutor;
import org.eclipse.cdt.dsf.concurrent.ReflectionSequence; import org.eclipse.cdt.dsf.concurrent.ReflectionSequence;
import org.eclipse.cdt.dsf.concurrent.RequestMonitor; import org.eclipse.cdt.dsf.concurrent.RequestMonitor;
import org.eclipse.cdt.dsf.concurrent.Sequence;
import org.eclipse.cdt.dsf.datamodel.DMContexts; import org.eclipse.cdt.dsf.datamodel.DMContexts;
import org.eclipse.cdt.dsf.datamodel.IDMContext; import org.eclipse.cdt.dsf.datamodel.IDMContext;
import org.eclipse.cdt.dsf.debug.service.IBreakpoints.IBreakpointsTargetDMContext; import org.eclipse.cdt.dsf.debug.service.IBreakpoints.IBreakpointsTargetDMContext;
@ -40,8 +39,10 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.Status;
/** /**
* This sequence is used to start debugging a new process.
*
* @since 4.0 * @since 4.0
*/ */
public class DebugNewProcessSequence extends ReflectionSequence { public class DebugNewProcessSequence extends ReflectionSequence {
private final static String INVALID = "invalid"; //$NON-NLS-1$ private final static String INVALID = "invalid"; //$NON-NLS-1$
@ -267,23 +268,20 @@ public class DebugNewProcessSequence extends ReflectionSequence {
@Execute @Execute
public void stepStartExecution(final RequestMonitor rm) { public void stepStartExecution(final RequestMonitor rm) {
if (fBackend.getSessionType() != SessionType.CORE) { if (fBackend.getSessionType() != SessionType.CORE) {
ImmediateExecutor.getInstance().execute( fProcService.start(getContainerContext(), fAttributes, new DataRequestMonitor<IContainerDMContext>(ImmediateExecutor.getInstance(), rm) {
getStartOrRestartProcessSequence( @Override
getExecutor(), getContainerContext(), fAttributes, false, protected void handleSuccess() {
new DataRequestMonitor<IContainerDMContext>(ImmediateExecutor.getInstance(), rm) { assert getData() instanceof IMIContainerDMContext;
@Override
protected void handleSuccess() {
assert getData() instanceof IMIContainerDMContext;
// Set the container that we created // Set the container that we created
setContainerContext(DMContexts.getAncestorOfType(getData(), IMIContainerDMContext.class)); setContainerContext(DMContexts.getAncestorOfType(getData(), IMIContainerDMContext.class));
fDataRequestMonitor.setData(getContainerContext()); fDataRequestMonitor.setData(getContainerContext());
// Don't call fDataRequestMonitor.done(), the sequence will // Don't call fDataRequestMonitor.done(), the sequence will
// automatically do that when we call rm.done(); // automatically do that when it completes;
rm.done(); rm.done();
} }
})); });
} else { } else {
fDataRequestMonitor.setData(getContainerContext()); fDataRequestMonitor.setData(getContainerContext());
rm.done(); rm.done();
@ -300,14 +298,4 @@ public class DebugNewProcessSequence extends ReflectionSequence {
fTracker = null; fTracker = null;
rm.done(); rm.done();
} }
/**
* Return the sequence that is to be used to start or restart the specified process.
* Allows others to extend more easily.
*/
protected Sequence getStartOrRestartProcessSequence(DsfExecutor executor, IContainerDMContext containerDmc,
Map<String, Object> attributes, boolean restart,
DataRequestMonitor<IContainerDMContext> rm) {
return new StartOrRestartProcessSequence_7_0(executor, containerDmc, attributes, restart, rm);
}
} }

View file

@ -389,20 +389,26 @@ public class GDBProcesses extends MIProcesses implements IGDBProcesses {
} }
/** @since 4.0 */ /** @since 4.0 */
public void restart(IContainerDMContext containerDmc, Map<String, Object> attributes, RequestMonitor rm) { public void restart(IContainerDMContext containerDmc, Map<String, Object> attributes, DataRequestMonitor<IContainerDMContext> rm) {
startOrRestart(containerDmc, attributes, true, rm); startOrRestart(containerDmc, attributes, true, rm);
} }
/** @since 4.0 */
public void start(IContainerDMContext containerDmc, Map<String, Object> attributes, DataRequestMonitor<IContainerDMContext> rm) {
startOrRestart(containerDmc, attributes, false, rm);
}
/** /**
* Insert breakpoint at entry if set, and start or restart the program. * Insert breakpoint at entry if set, and start or restart the program.
* *
* @since 4.0 * @since 4.0
*/ */
protected void startOrRestart(final IContainerDMContext containerDmc, Map<String, Object> attributes, protected void startOrRestart(final IContainerDMContext containerDmc, Map<String, Object> attributes,
boolean restart, final RequestMonitor requestMonitor) { boolean restart, final DataRequestMonitor<IContainerDMContext> requestMonitor) {
if (fBackend.getIsAttachSession()) { if (fBackend.getIsAttachSession()) {
// When attaching to a running process, we do not need to set a breakpoint or // When attaching to a running process, we do not need to set a breakpoint or
// start the program; it is left up to the user. // start the program; it is left up to the user.
requestMonitor.setData(containerDmc);
requestMonitor.done(); requestMonitor.done();
return; return;
} }
@ -416,7 +422,8 @@ public class GDBProcesses extends MIProcesses implements IGDBProcesses {
// the ^connect // the ^connect
getSession().dispatchEvent(new ContainerStartedDMEvent(containerDmc), getProperties()); getSession().dispatchEvent(new ContainerStartedDMEvent(containerDmc), getProperties());
} }
super.handleSuccess(); requestMonitor.setData(containerDmc);
requestMonitor.done();
} }
}; };

View file

@ -1125,11 +1125,21 @@ public class GDBProcesses_7_0 extends AbstractDsfService
} }
/** @since 4.0 */ /** @since 4.0 */
public void restart(IContainerDMContext containerDmc, Map<String, Object> attributes, RequestMonitor rm) { public void restart(IContainerDMContext containerDmc, Map<String, Object> attributes, DataRequestMonitor<IContainerDMContext> rm) {
startOrRestart(containerDmc, attributes, true, rm);
}
/** @since 4.0 */
public void start(IContainerDMContext containerDmc, Map<String, Object> attributes, DataRequestMonitor<IContainerDMContext> rm) {
startOrRestart(containerDmc, attributes, false, rm);
}
/** @since 4.0 */
protected void startOrRestart(IContainerDMContext containerDmc, Map<String, Object> attributes,
boolean restart, DataRequestMonitor<IContainerDMContext> rm) {
ImmediateExecutor.getInstance().execute( ImmediateExecutor.getInstance().execute(
getStartOrRestartProcessSequence( getStartOrRestartProcessSequence(
getExecutor(), containerDmc, attributes, true, getExecutor(), containerDmc, attributes, restart, rm));
new DataRequestMonitor<IContainerDMContext>(ImmediateExecutor.getInstance(), rm)));
} }
/** /**

View file

@ -14,7 +14,6 @@ package org.eclipse.cdt.dsf.gdb.service;
import java.util.Map; import java.util.Map;
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor; import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
import org.eclipse.cdt.dsf.concurrent.RequestMonitor;
import org.eclipse.cdt.dsf.debug.service.IRunControl.IContainerDMContext; import org.eclipse.cdt.dsf.debug.service.IRunControl.IContainerDMContext;
import org.eclipse.cdt.dsf.mi.service.IMIContainerDMContext; import org.eclipse.cdt.dsf.mi.service.IMIContainerDMContext;
import org.eclipse.cdt.dsf.mi.service.IMIExecutionDMContext; import org.eclipse.cdt.dsf.mi.service.IMIExecutionDMContext;
@ -72,9 +71,24 @@ public interface IGDBProcesses extends IMIProcesses {
* @param containerDmc The process that should be restarted * @param containerDmc The process that should be restarted
* @param attributes Different attributes that affect the restart operation. This is * @param attributes Different attributes that affect the restart operation. This is
* usually the launch configuration attributes * usually the launch configuration attributes
* @param rm The requetMonitor that indicates that the restart request has been completed. * @param rm The requetMonitor that indicates that the restart request has been completed. It will
* contain the IContainerDMContext fully filled with the data of the restarted process.
* *
* @since 4.0 * @since 4.0
*/ */
void restart(IContainerDMContext containerDmc, Map<String, Object> attributes, RequestMonitor rm); void restart(IContainerDMContext containerDmc, Map<String, Object> attributes, DataRequestMonitor<IContainerDMContext> rm);
/**
* Request that the specified process be started.
*
* @param containerDmc The process that should be started.
* @param attributes Different attributes that affect the start operation. This is
* usually the launch configuration attributes
* @param rm The requestMonitor that indicates that the start request has been completed. It will
* contain the IContainerDMContext fully filled with the data of the newly started process.
*
* @since 4.0
*/
void start(IContainerDMContext containerDmc, Map<String, Object> attributes, DataRequestMonitor<IContainerDMContext> rm);
} }

View file

@ -621,9 +621,9 @@ public class SyncUtil {
MIStoppedEvent.class); MIStoppedEvent.class);
// Perform the restart // Perform the restart
Query<Object> query2 = new Query<Object>() { Query<IContainerDMContext> query2 = new Query<IContainerDMContext>() {
@Override @Override
protected void execute(final DataRequestMonitor<Object> rm) { protected void execute(final DataRequestMonitor<IContainerDMContext> rm) {
fGdbControl.initInferiorInputOutput(new RequestMonitor(ImmediateExecutor.getInstance(), rm) { fGdbControl.initInferiorInputOutput(new RequestMonitor(ImmediateExecutor.getInstance(), rm) {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override