1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

[243611] - [commands] Add an ICommandControlService interface.

This commit is contained in:
Pawel Piech 2008-08-08 17:42:23 +00:00
parent 6497fcf2f7
commit 1fbfd51fac
13 changed files with 158 additions and 59 deletions

View file

@ -14,7 +14,10 @@ import org.eclipse.dd.dsf.concurrent.DataRequestMonitor;
/**
* API for sending commands to the debugger and for receiving command results
* and asynchronous events.
* and asynchronous events. The command control may be implemented by a service
* or a non-service object.
*
* @see ICommandControlService
*/
public interface ICommandControl {

View file

@ -0,0 +1,67 @@
/*******************************************************************************
* Copyright (c) 2008 Wind River Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Wind River Systems - initial API and implementation
*******************************************************************************/
package org.eclipse.dd.dsf.debug.service.command;
import org.eclipse.dd.dsf.datamodel.IDMContext;
import org.eclipse.dd.dsf.datamodel.IDMEvent;
import org.eclipse.dd.dsf.service.IDsfService;
/**
* Service which acts as a command control.
*
* @since 1.1
*/
public interface ICommandControlService extends ICommandControl, IDsfService {
/**
* Context representing a command control service. All contexts which
* originate from a given command control service, should have that
* control's context in their hierarchy.
*
* @see ICommandControlService#getContext()
*/
public interface ICommandControlDMContext extends IDMContext {
/**
* Returns the ID of the command control that this context
* represents.
*/
public String getCommandControlId();
}
/**
* Event indicating that the back end process has started.
*/
public interface ICommandControlInitializedDMEvent extends IDMEvent<ICommandControlDMContext> {};
/**
* Event indicating that the back end process has terminated.
*/
public interface ICommandControlShutdownDMEvent extends IDMEvent<ICommandControlDMContext> {};
/**
* Returns the identifier of this command control service. It can be used
* to distinguish between multiple instances of command control services.
*/
public String getId();
/**
* returns the context representing this command control.
*/
public ICommandControlDMContext getContext();
/**
* Returns whether this command control is currently active. A command
* control service is active if it has been initialized and has not yet
* shut down.
* @return
*/
public boolean isActive();
}

View file

@ -25,14 +25,14 @@ import org.eclipse.dd.dsf.debug.service.IRunControl;
import org.eclipse.dd.dsf.debug.service.IProcesses.IProcessDMContext;
import org.eclipse.dd.dsf.debug.service.IProcesses.IThreadDMData;
import org.eclipse.dd.dsf.debug.service.IRunControl.IContainerDMContext;
import org.eclipse.dd.dsf.debug.service.command.ICommandControlService.ICommandControlShutdownDMEvent;
import org.eclipse.dd.dsf.debug.service.command.ICommandControlService.ICommandControlInitializedDMEvent;
import org.eclipse.dd.dsf.service.DsfSession;
import org.eclipse.dd.dsf.ui.concurrent.ViewerDataRequestMonitor;
import org.eclipse.dd.dsf.ui.viewmodel.VMDelta;
import org.eclipse.dd.dsf.ui.viewmodel.datamodel.AbstractDMVMProvider;
import org.eclipse.dd.dsf.ui.viewmodel.datamodel.IDMVMContext;
import org.eclipse.dd.gdb.internal.provisional.service.command.GDBControl;
import org.eclipse.dd.mi.service.command.AbstractMIControl.BackendExitedEvent;
import org.eclipse.dd.mi.service.command.AbstractMIControl.BackendStartedEvent;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IChildrenUpdate;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementCompareRequest;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementMementoProvider;
@ -127,9 +127,9 @@ public class ContainerVMNode extends AbstractContainerVMNode
@Override
public int getDeltaFlags(Object e) {
if (e instanceof BackendExitedEvent) {
if (e instanceof ICommandControlShutdownDMEvent) {
return IModelDelta.CONTENT;
} else if (e instanceof BackendStartedEvent) {
} else if (e instanceof ICommandControlInitializedDMEvent) {
return IModelDelta.EXPAND;
}
return super.getDeltaFlags(e);
@ -137,9 +137,9 @@ public class ContainerVMNode extends AbstractContainerVMNode
@Override
public void buildDelta(Object e, final VMDelta parentDelta, final int nodeOffset, final RequestMonitor requestMonitor) {
if (e instanceof BackendExitedEvent) {
if (e instanceof ICommandControlShutdownDMEvent) {
parentDelta.setFlags(parentDelta.getFlags() | IModelDelta.CONTENT);
} else if (e instanceof BackendStartedEvent) {
} else if (e instanceof ICommandControlInitializedDMEvent) {
parentDelta.addNode(createVMContext(((IDMEvent<?>)e).getDMContext()), IModelDelta.EXPAND);
} else {
super.buildDelta(e, parentDelta, nodeOffset, requestMonitor);

View file

@ -16,12 +16,12 @@ import org.eclipse.dd.dsf.debug.internal.provisional.ui.viewmodel.launch.Abstrac
import org.eclipse.dd.dsf.debug.internal.provisional.ui.viewmodel.launch.LaunchRootVMNode;
import org.eclipse.dd.dsf.debug.internal.provisional.ui.viewmodel.launch.StackFramesVMNode;
import org.eclipse.dd.dsf.debug.internal.provisional.ui.viewmodel.launch.StandardProcessVMNode;
import org.eclipse.dd.dsf.debug.service.command.ICommandControlService.ICommandControlShutdownDMEvent;
import org.eclipse.dd.dsf.debug.service.command.ICommandControlService.ICommandControlInitializedDMEvent;
import org.eclipse.dd.dsf.service.DsfSession;
import org.eclipse.dd.dsf.ui.viewmodel.AbstractVMAdapter;
import org.eclipse.dd.dsf.ui.viewmodel.IRootVMNode;
import org.eclipse.dd.dsf.ui.viewmodel.IVMNode;
import org.eclipse.dd.mi.service.command.AbstractMIControl.BackendExitedEvent;
import org.eclipse.dd.mi.service.command.AbstractMIControl.BackendStartedEvent;
import org.eclipse.dd.mi.service.command.MIInferiorProcess.InferiorExitedDMEvent;
import org.eclipse.dd.mi.service.command.MIInferiorProcess.InferiorStartedDMEvent;
import org.eclipse.debug.core.DebugPlugin;
@ -75,8 +75,8 @@ public class LaunchVMProvider extends AbstractLaunchVMProvider
// Never skip the process lifecycle events.
if (eventToSkip instanceof InferiorExitedDMEvent ||
eventToSkip instanceof InferiorStartedDMEvent ||
eventToSkip instanceof BackendStartedEvent ||
eventToSkip instanceof BackendExitedEvent)
eventToSkip instanceof ICommandControlInitializedDMEvent ||
eventToSkip instanceof ICommandControlShutdownDMEvent)
{
return false;
}

View file

@ -32,6 +32,7 @@ import org.eclipse.dd.dsf.concurrent.ThreadSafeAndProhibitedFromDsfExecutor;
import org.eclipse.dd.dsf.debug.model.DsfMemoryBlockRetrieval;
import org.eclipse.dd.dsf.debug.service.IDsfDebugServicesFactory;
import org.eclipse.dd.dsf.debug.service.IMemory.IMemoryDMContext;
import org.eclipse.dd.dsf.debug.service.command.ICommandControlService.ICommandControlShutdownDMEvent;
import org.eclipse.dd.dsf.service.DsfServiceEventHandler;
import org.eclipse.dd.dsf.service.DsfServicesTracker;
import org.eclipse.dd.dsf.service.DsfSession;
@ -39,7 +40,6 @@ import org.eclipse.dd.gdb.internal.GdbPlugin;
import org.eclipse.dd.gdb.internal.provisional.service.command.GDBControl;
import org.eclipse.dd.mi.service.command.AbstractCLIProcess;
import org.eclipse.dd.mi.service.command.MIInferiorProcess;
import org.eclipse.dd.mi.service.command.AbstractMIControl.BackendExitedEvent;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunchConfiguration;
@ -185,7 +185,7 @@ public class GdbLaunch extends Launch
///////////////////////////////////////////////////////////////////////////
// IServiceEventListener
@DsfServiceEventHandler public void eventDispatched(BackendExitedEvent event) {
@DsfServiceEventHandler public void eventDispatched(ICommandControlShutdownDMEvent event) {
shutdownSession(new RequestMonitor(ImmediateExecutor.getInstance(), null));
}

View file

@ -38,6 +38,7 @@ import org.eclipse.dd.dsf.concurrent.DsfRunnable;
import org.eclipse.dd.dsf.concurrent.IDsfStatusConstants;
import org.eclipse.dd.dsf.concurrent.RequestMonitor;
import org.eclipse.dd.dsf.concurrent.Sequence;
import org.eclipse.dd.dsf.datamodel.AbstractDMEvent;
import org.eclipse.dd.dsf.debug.service.command.ICommandControl;
import org.eclipse.dd.dsf.service.DsfServiceEventHandler;
import org.eclipse.dd.dsf.service.DsfSession;
@ -72,6 +73,27 @@ import org.osgi.framework.BundleContext;
*/
public class GDBControl extends AbstractMIControl {
/**
* Event indicating that the back end process has started.
*/
public static class GDBControlInitializedDMEvent extends AbstractDMEvent<ICommandControlDMContext>
implements ICommandControlInitializedDMEvent
{
public GDBControlInitializedDMEvent(GDBControlDMContext context) {
super(context);
}
}
/**
* Event indicating that the back end process has terminated.
*/
public static class GDBControlShutdownDMEvent extends AbstractDMEvent<ICommandControlDMContext>
implements ICommandControlShutdownDMEvent
{
public GDBControlShutdownDMEvent(GDBControlDMContext context) {
super(context);
}
}
private static int fgInstanceCounter = 0;
private final GDBControlDMContext fControlDmc;
@ -98,7 +120,7 @@ public class GDBControl extends AbstractMIControl {
private PTY fPty;
public GDBControl(DsfSession session, ILaunchConfiguration config) {
super(session);
super(session, "gdbcontrol[" + ++fgInstanceCounter + "]"); //$NON-NLS-1$ //$NON-NLS-2$
fSessionType = LaunchUtils.getSessionType(config);
fAttach = LaunchUtils.getIsAttach(config);
fGdbPath = LaunchUtils.getGDBPath(config);
@ -107,18 +129,18 @@ public class GDBControl extends AbstractMIControl {
} catch (CoreException e) {
fExecPath = new Path(""); //$NON-NLS-1$
}
fControlDmc = new GDBControlDMContext(session.getId(), "gdbcontrol[" + ++fgInstanceCounter + "]"); //$NON-NLS-1$ //$NON-NLS-2$
fControlDmc = new GDBControlDMContext(session.getId(), getId());
}
@Deprecated
public GDBControl(DsfSession session, IPath gdbPath, IPath execPath, SessionType sessionType, boolean attach, int gdbLaunchTimeout) {
super(session);
super(session, "gdbcontrol[" + ++fgInstanceCounter + "]"); //$NON-NLS-1$ //$NON-NLS-2$
fSessionType = sessionType;
fAttach = attach;
fGdbPath = gdbPath;
fExecPath = execPath;
fGDBLaunchTimeout = gdbLaunchTimeout;
fControlDmc = new GDBControlDMContext(session.getId(), "gdbcontrol[" + ++fgInstanceCounter + "]"); //$NON-NLS-1$ //$NON-NLS-2$
fControlDmc = new GDBControlDMContext(session.getId(), getId());
}
@Override
@ -174,6 +196,10 @@ public class GDBControl extends AbstractMIControl {
return fControlDmc;
}
public ICommandControlDMContext getContext() {
return fControlDmc;
}
/**
* More strongly typed version of {@link #getControlDMContext()}.
*/
@ -418,7 +444,7 @@ public class GDBControl extends AbstractMIControl {
}
@DsfServiceEventHandler
public void eventDispatched(BackendExitedEvent e) {
public void eventDispatched(ICommandControlShutdownDMEvent e) {
// Handle our "GDB Exited" event and stop processing commands.
stopCommandProcessing();
}
@ -445,7 +471,7 @@ public class GDBControl extends AbstractMIControl {
Thread.interrupted();
} finally {
fExited = true;
getSession().dispatchEvent(new BackendExitedEvent(fControlDmc) {}, getProperties());
getSession().dispatchEvent(new GDBControlShutdownDMEvent(fControlDmc) {}, getProperties());
}
}
}
@ -717,7 +743,7 @@ public class GDBControl extends AbstractMIControl {
public void initialize(final RequestMonitor requestMonitor) {
getSession().addServiceEventListener(GDBControl.this, null);
register(new String[]{ ICommandControl.class.getName(), AbstractMIControl.class.getName() }, new Hashtable<String,String>());
getSession().dispatchEvent(new BackendStartedEvent(getGDBDMContext()), getProperties());
getSession().dispatchEvent(new GDBControlInitializedDMEvent(getGDBDMContext()), getProperties());
requestMonitor.done();
}

View file

@ -27,11 +27,11 @@ import org.eclipse.dd.dsf.datamodel.DMContexts;
import org.eclipse.dd.dsf.datamodel.IDMContext;
import org.eclipse.dd.dsf.debug.service.IBreakpoints;
import org.eclipse.dd.dsf.debug.service.command.ICommandControl;
import org.eclipse.dd.dsf.debug.service.command.ICommandControlService.ICommandControlShutdownDMEvent;
import org.eclipse.dd.dsf.service.AbstractDsfService;
import org.eclipse.dd.dsf.service.DsfServiceEventHandler;
import org.eclipse.dd.dsf.service.DsfSession;
import org.eclipse.dd.mi.internal.MIPlugin;
import org.eclipse.dd.mi.service.command.AbstractMIControl.BackendExitedEvent;
import org.eclipse.dd.mi.service.command.commands.MIBreakAfter;
import org.eclipse.dd.mi.service.command.commands.MIBreakCondition;
import org.eclipse.dd.mi.service.command.commands.MIBreakDelete;
@ -271,13 +271,13 @@ public class MIBreakpoints extends AbstractDsfService implements IBreakpoints
}
}
// Not used, kept for API compatibility. BackendExitedEvent is used instead
// Not used, kept for API compatibility. ICommandControlShutdownDMEvent is used instead
@DsfServiceEventHandler
public void eventDispatched(MIGDBExitEvent e) {
}
@DsfServiceEventHandler
public void eventDispatched(BackendExitedEvent e) {
public void eventDispatched(ICommandControlShutdownDMEvent e) {
}
///////////////////////////////////////////////////////////////////////////

View file

@ -63,6 +63,7 @@ import org.eclipse.dd.dsf.debug.service.IRunControl.IContainerDMContext;
import org.eclipse.dd.dsf.debug.service.IRunControl.IExecutionDMContext;
import org.eclipse.dd.dsf.debug.service.ISourceLookup.ISourceLookupDMContext;
import org.eclipse.dd.dsf.debug.service.command.ICommandControl;
import org.eclipse.dd.dsf.debug.service.command.ICommandControlService.ICommandControlShutdownDMEvent;
import org.eclipse.dd.dsf.service.AbstractDsfService;
import org.eclipse.dd.dsf.service.DsfServiceEventHandler;
import org.eclipse.dd.dsf.service.DsfSession;
@ -72,7 +73,6 @@ import org.eclipse.dd.mi.service.MIBreakpoints.BreakpointRemovedEvent;
import org.eclipse.dd.mi.service.MIBreakpoints.BreakpointUpdatedEvent;
import org.eclipse.dd.mi.service.MIBreakpoints.MIBreakpointDMContext;
import org.eclipse.dd.mi.service.breakpoint.actions.BreakpointActionAdapter;
import org.eclipse.dd.mi.service.command.AbstractMIControl.BackendExitedEvent;
import org.eclipse.dd.mi.service.command.events.MIBreakpointHitEvent;
import org.eclipse.dd.mi.service.command.events.MIGDBExitEvent;
import org.eclipse.dd.mi.service.command.events.MIWatchpointScopeEvent;
@ -1228,14 +1228,14 @@ public class MIBreakpointsManager extends AbstractDsfService implements IBreakpo
// Session exit
//-------------------------------------------------------------------------
// Not used, kept for API compatibility. BackendExitedEvent is used instead
// Not used, kept for API compatibility. ICommandControlShutdownDMEvent is used instead
@DsfServiceEventHandler
public void eventDispatched(MIGDBExitEvent e) {
terminated();
}
@DsfServiceEventHandler
public void eventDispatched(BackendExitedEvent e) {
public void eventDispatched(ICommandControlShutdownDMEvent e) {
terminated();
}

View file

@ -24,12 +24,12 @@ import org.eclipse.dd.dsf.datamodel.IDMEvent;
import org.eclipse.dd.dsf.debug.service.IRunControl;
import org.eclipse.dd.dsf.debug.service.IStack.IFrameDMContext;
import org.eclipse.dd.dsf.debug.service.command.CommandCache;
import org.eclipse.dd.dsf.debug.service.command.ICommandControlService.ICommandControlShutdownDMEvent;
import org.eclipse.dd.dsf.service.AbstractDsfService;
import org.eclipse.dd.dsf.service.DsfServiceEventHandler;
import org.eclipse.dd.dsf.service.DsfSession;
import org.eclipse.dd.mi.internal.MIPlugin;
import org.eclipse.dd.mi.service.command.AbstractMIControl;
import org.eclipse.dd.mi.service.command.AbstractMIControl.BackendExitedEvent;
import org.eclipse.dd.mi.service.command.commands.MIExecContinue;
import org.eclipse.dd.mi.service.command.commands.MIExecFinish;
import org.eclipse.dd.mi.service.command.commands.MIExecInterrupt;
@ -404,14 +404,14 @@ public class MIRunControl extends AbstractDsfService implements IRunControl
fStepping = false;
}
// Not used, kept for API compatibility. BackendExitedEvent is used instead
// Not used, kept for API compatibility. ICommandControlShutdownDMEvent is used instead
@DsfServiceEventHandler
public void eventDispatched(MIGDBExitEvent e) {
fTerminated = true;
}
@DsfServiceEventHandler
public void eventDispatched(BackendExitedEvent e) {
public void eventDispatched(ICommandControlShutdownDMEvent e) {
fTerminated = true;
}

View file

@ -30,12 +30,12 @@ import org.eclipse.dd.dsf.debug.service.IProcesses.IProcessDMContext;
import org.eclipse.dd.dsf.debug.service.IProcesses.IThreadDMContext;
import org.eclipse.dd.dsf.debug.service.IStack.IFrameDMContext;
import org.eclipse.dd.dsf.debug.service.command.CommandCache;
import org.eclipse.dd.dsf.debug.service.command.ICommandControlService.ICommandControlShutdownDMEvent;
import org.eclipse.dd.dsf.service.AbstractDsfService;
import org.eclipse.dd.dsf.service.DsfServiceEventHandler;
import org.eclipse.dd.dsf.service.DsfSession;
import org.eclipse.dd.mi.internal.MIPlugin;
import org.eclipse.dd.mi.service.command.AbstractMIControl;
import org.eclipse.dd.mi.service.command.AbstractMIControl.BackendExitedEvent;
import org.eclipse.dd.mi.service.command.commands.MIExecContinue;
import org.eclipse.dd.mi.service.command.commands.MIExecFinish;
import org.eclipse.dd.mi.service.command.commands.MIExecInterrupt;
@ -781,7 +781,7 @@ public class MIRunControlNS extends AbstractDsfService implements IRunControl
}
@DsfServiceEventHandler
public void eventDispatched(BackendExitedEvent e) {
public void eventDispatched(ICommandControlShutdownDMEvent e) {
fTerminated = true;
}

View file

@ -30,13 +30,12 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.dd.dsf.concurrent.DataRequestMonitor;
import org.eclipse.dd.dsf.concurrent.DsfRunnable;
import org.eclipse.dd.dsf.datamodel.AbstractDMEvent;
import org.eclipse.dd.dsf.datamodel.DMContexts;
import org.eclipse.dd.dsf.datamodel.IDMContext;
import org.eclipse.dd.dsf.debug.service.IRunControl;
import org.eclipse.dd.dsf.debug.service.IStack.IFrameDMContext;
import org.eclipse.dd.dsf.debug.service.command.ICommand;
import org.eclipse.dd.dsf.debug.service.command.ICommandControl;
import org.eclipse.dd.dsf.debug.service.command.ICommandControlService;
import org.eclipse.dd.dsf.debug.service.command.ICommandListener;
import org.eclipse.dd.dsf.debug.service.command.ICommandResult;
import org.eclipse.dd.dsf.debug.service.command.ICommandToken;
@ -65,28 +64,10 @@ import org.eclipse.dd.mi.service.command.output.MIValue;
* Extending classes need to implement the initialize() and shutdown() methods.
*/
public abstract class AbstractMIControl extends AbstractDsfService
implements ICommandControl
implements ICommandControlService
{
final static String PROP_INSTANCE_ID = MIPlugin.PLUGIN_ID + ".miControlInstanceId"; //$NON-NLS-1$
/**
* Event indicating that the back end process has started.
*/
public static class BackendStartedEvent extends AbstractDMEvent<MIControlDMContext> {
public BackendStartedEvent(MIControlDMContext context) {
super(context);
}
}
/**
* Event indicating that the back end process has terminated.
*/
public static class BackendExitedEvent extends AbstractDMEvent<MIControlDMContext> {
public BackendExitedEvent(MIControlDMContext context) {
super(context);
}
}
/*
* Thread control variables for the transmit and receive threads.
*/
@ -126,12 +107,16 @@ public abstract class AbstractMIControl extends AbstractDsfService
*/
private boolean fStoppedCommandProcessing = false;
/*
* Public constructor.
*/
private String fId;
public AbstractMIControl(DsfSession session) {
super(session);
fId = "<no id>"; //$NON-NLS-1$
}
public AbstractMIControl(DsfSession session, String id) {
super(session);
fId = id;
}
/**
@ -363,6 +348,14 @@ public abstract class AbstractMIControl extends AbstractDsfService
abstract public MIControlDMContext getControlDMContext();
public boolean isActive() {
return !fStoppedCommandProcessing;
}
public String getId() {
return fId;
}
/*
* These are the service routines which perform the various callouts back to the listeners.
*/

View file

@ -14,14 +14,16 @@ import org.eclipse.dd.dsf.datamodel.AbstractDMContext;
import org.eclipse.dd.dsf.datamodel.DMContexts;
import org.eclipse.dd.dsf.datamodel.IDMContext;
import org.eclipse.dd.dsf.debug.service.command.ICommandControl;
import org.eclipse.dd.dsf.debug.service.command.ICommandControlService.ICommandControlDMContext;
import org.eclipse.dd.dsf.service.IDsfService;
import org.osgi.framework.Constants;
/**
*
*/
public class MIControlDMContext extends AbstractDMContext {
public class MIControlDMContext extends AbstractDMContext
implements ICommandControlDMContext
{
private final String fCommandControlFilter;
private final String fCommandControlId;
@ -45,14 +47,18 @@ public class MIControlDMContext extends AbstractDMContext {
return fCommandControlFilter;
}
public String getCommandControlId() {
return fCommandControlId;
}
@Override
public boolean equals(Object obj) {
return baseEquals(obj) && fCommandControlFilter.equals(((MIControlDMContext)obj).fCommandControlFilter);
return baseEquals(obj) && fCommandControlId.equals(((MIControlDMContext)obj).fCommandControlId);
}
@Override
public int hashCode() {
return baseHashCode() + fCommandControlFilter.hashCode();
return baseHashCode() + fCommandControlId.hashCode();
}
@Override

View file

@ -13,11 +13,15 @@
package org.eclipse.dd.mi.service.command.events;
import org.eclipse.dd.dsf.concurrent.Immutable;
import org.eclipse.dd.dsf.debug.service.command.ICommandControlService;
import org.eclipse.dd.mi.service.command.MIControlDMContext;
/**
* Gdb Session terminated.
*
* @deprecated This event is not used in DSF-GDB as it has been replaced by
* {@link ICommandControlService.ICommandControlShutdownDMEvent}.
*/
@Immutable
public class MIGDBExitEvent extends MIEvent<MIControlDMContext> {