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

[206932] Made ICommandControl independent from the IDsfService class.

This commit is contained in:
Pawel Piech 2008-04-01 20:46:11 +00:00
parent 19e920c433
commit 706d77cc0c
13 changed files with 63 additions and 66 deletions

View file

@ -28,6 +28,7 @@ import org.eclipse.dd.dsf.concurrent.IDsfStatusConstants;
import org.eclipse.dd.dsf.datamodel.DMContexts; import org.eclipse.dd.dsf.datamodel.DMContexts;
import org.eclipse.dd.dsf.datamodel.IDMContext; import org.eclipse.dd.dsf.datamodel.IDMContext;
import org.eclipse.dd.dsf.debug.internal.DsfDebugPlugin; import org.eclipse.dd.dsf.debug.internal.DsfDebugPlugin;
import org.eclipse.dd.dsf.service.DsfSession;
/** /**
* This is a utility class for caching results of MI Commands. Return MIInfo * This is a utility class for caching results of MI Commands. Return MIInfo
@ -106,6 +107,10 @@ public class CommandCache implements ICommandListener
public IStatus getStatus() { return fStatus; } public IStatus getStatus() { return fStatus; }
} }
private DsfSession fSession;
private ICommandControl fCommandControl;
/* /*
* This class contains 5 significant lists. * This class contains 5 significant lists.
* *
@ -139,11 +144,8 @@ public class CommandCache implements ICommandListener
* created. When the coalesced commands completes the results will be decomposed * created. When the coalesced commands completes the results will be decomposed
* when back into individual results from this command. * when back into individual results from this command.
*/ */
private Set<IDMContext> fUnavailableContexts = new HashSet<IDMContext>(); private Set<IDMContext> fUnavailableContexts = new HashSet<IDMContext>();
private ICommandControl fCommandControl;
private Map<IDMContext, HashMap<CommandInfo, CommandResultInfo>> fCachedContexts = new HashMap<IDMContext, HashMap<CommandInfo, CommandResultInfo>>(); private Map<IDMContext, HashMap<CommandInfo, CommandResultInfo>> fCachedContexts = new HashMap<IDMContext, HashMap<CommandInfo, CommandResultInfo>>();
private ArrayList<CommandInfo> fPendingQCommandsSent = new ArrayList<CommandInfo>(); private ArrayList<CommandInfo> fPendingQCommandsSent = new ArrayList<CommandInfo>();
@ -152,7 +154,8 @@ public class CommandCache implements ICommandListener
private ArrayList<CommandInfo> fPendingQWaitingForCoalescedCompletion = new ArrayList<CommandInfo>(); private ArrayList<CommandInfo> fPendingQWaitingForCoalescedCompletion = new ArrayList<CommandInfo>();
public CommandCache(ICommandControl control) { public CommandCache(DsfSession session, ICommandControl control) {
fSession = session;
fCommandControl = control; fCommandControl = control;
/* /*
@ -232,7 +235,7 @@ public class CommandCache implements ICommandListener
* well as its cache status. * well as its cache status.
*/ */
public <V extends ICommandResult> void execute(ICommand<V> command, DataRequestMonitor<V> rm) { public <V extends ICommandResult> void execute(ICommand<V> command, DataRequestMonitor<V> rm) {
assert fCommandControl.getExecutor().isInExecutorThread(); assert fSession.getExecutor().isInExecutorThread();
// Cast the generic ?'s to concrete types in the cache implementation. // Cast the generic ?'s to concrete types in the cache implementation.
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@ -315,7 +318,7 @@ public class CommandCache implements ICommandListener
fCommandControl.queueCommand( fCommandControl.queueCommand(
finalCachedCmd.getCommand(), finalCachedCmd.getCommand(),
new DataRequestMonitor<ICommandResult>(fCommandControl.getExecutor(), null) { new DataRequestMonitor<ICommandResult>(fSession.getExecutor(), null) {
@Override @Override
public void handleCompleted() { public void handleCompleted() {

View file

@ -11,13 +11,12 @@
package org.eclipse.dd.dsf.debug.service.command; package org.eclipse.dd.dsf.debug.service.command;
import org.eclipse.dd.dsf.concurrent.DataRequestMonitor; import org.eclipse.dd.dsf.concurrent.DataRequestMonitor;
import org.eclipse.dd.dsf.service.IDsfService;
/** /**
* API for sending commands to the debugger and for receiving command results * API for sending commands to the debugger and for receiving command results
* and asynchronous events. * and asynchronous events.
*/ */
public interface ICommandControl extends IDsfService{ public interface ICommandControl {
/** /**
* Adds the specified command to the queue of commands to be processed. * Adds the specified command to the queue of commands to be processed.

View file

@ -73,7 +73,7 @@ public class DsfServicesTracker {
private BundleContext fBundleContext; private BundleContext fBundleContext;
private Map<ServiceKey,ServiceReference> fServiceReferences = new HashMap<ServiceKey,ServiceReference>(); private Map<ServiceKey,ServiceReference> fServiceReferences = new HashMap<ServiceKey,ServiceReference>();
private Map<ServiceReference,IDsfService> fServices = new HashMap<ServiceReference,IDsfService>(); private Map<ServiceReference,Object> fServices = new HashMap<ServiceReference,Object>();
private String fServiceFilter; private String fServiceFilter;
/** /**
@ -125,7 +125,7 @@ public class DsfServicesTracker {
* @param serviceClass class of the desired service * @param serviceClass class of the desired service
* @return instance of the desired service, null if not found * @return instance of the desired service, null if not found
*/ */
public <V extends IDsfService> V getService(Class<V> serviceClass) { public <V> V getService(Class<V> serviceClass) {
return getService(serviceClass, null); return getService(serviceClass, null);
} }
@ -140,7 +140,7 @@ public class DsfServicesTracker {
* @return instance of the desired service, null if not found * @return instance of the desired service, null if not found
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public <V extends IDsfService> V getService(Class<V> serviceClass, String filter) { public <V> V getService(Class<V> serviceClass, String filter) {
ServiceReference serviceRef = getServiceReference(serviceClass, filter); ServiceReference serviceRef = getServiceReference(serviceClass, filter);
if (serviceRef == null) { if (serviceRef == null) {
return null; return null;

View file

@ -122,7 +122,7 @@ public class PDAServicesShutdownSequence extends Sequence {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private void shutdownService(Class clazz, final RequestMonitor requestMonitor) { private void shutdownService(Class clazz, final RequestMonitor requestMonitor) {
IDsfService service = fTracker.getService(clazz); IDsfService service = (IDsfService)fTracker.getService(clazz);
if (service != null) { if (service != null) {
service.shutdown(new RequestMonitor(getExecutor(), requestMonitor) { service.shutdown(new RequestMonitor(getExecutor(), requestMonitor) {
@Override @Override

View file

@ -189,7 +189,7 @@ public class PDAExpressions extends AbstractDsfService implements IExpressions {
private void doInitialize(final RequestMonitor rm) { private void doInitialize(final RequestMonitor rm) {
fCommandControl = getServicesTracker().getService(PDACommandControl.class); fCommandControl = getServicesTracker().getService(PDACommandControl.class);
fStack = getServicesTracker().getService(IStack.class); fStack = getServicesTracker().getService(IStack.class);
fCommandCache = new CommandCache(fCommandControl); fCommandCache = new CommandCache(getSession(), fCommandControl);
getSession().addServiceEventListener(this, null); getSession().addServiceEventListener(this, null);

View file

@ -195,7 +195,7 @@ public class PDAStack extends AbstractDsfService implements IStack {
fRunControl = getServicesTracker().getService(IRunControl.class); fRunControl = getServicesTracker().getService(IRunControl.class);
// Create the commands cache // Create the commands cache
fCommandCache = new CommandCache(fCommandControl); fCommandCache = new CommandCache(getSession(), fCommandControl);
// Register to listen for run control events, to clear cache accordingly. // Register to listen for run control events, to clear cache accordingly.
getSession().addServiceEventListener(this, null); getSession().addServiceEventListener(this, null);

View file

@ -160,7 +160,7 @@ public class ShutdownSequence extends Sequence {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private void shutdownService(Class clazz, final RequestMonitor requestMonitor) { private void shutdownService(Class clazz, final RequestMonitor requestMonitor) {
IDsfService service = fTracker.getService(clazz); IDsfService service = (IDsfService)fTracker.getService(clazz);
if (service != null) { if (service != null) {
service.shutdown(new RequestMonitor(getExecutor(), requestMonitor) { service.shutdown(new RequestMonitor(getExecutor(), requestMonitor) {
@Override @Override

View file

@ -452,7 +452,7 @@ public class ExpressionService extends AbstractDsfService implements IExpression
// Create the meta command cache which will use the variable manager // Create the meta command cache which will use the variable manager
// to actually send MI commands to the back-end // to actually send MI commands to the back-end
fExpressionCache = new CommandCache(varManager); fExpressionCache = new CommandCache(getSession(), varManager);
requestMonitor.done(); requestMonitor.done();
} }
@ -467,7 +467,7 @@ public class ExpressionService extends AbstractDsfService implements IExpression
@Override @Override
public void shutdown(RequestMonitor requestMonitor) { public void shutdown(RequestMonitor requestMonitor) {
unregister(); unregister();
varManager.shutdown(); varManager.dispose();
getSession().removeServiceEventListener(this); getSession().removeServiceEventListener(this);
super.shutdown(requestMonitor); super.shutdown(requestMonitor);
} }

View file

@ -438,7 +438,7 @@ public class MIMemory extends AbstractDsfService implements IMemory {
public MIMemoryCache() { public MIMemoryCache() {
// Create the command cache // Create the command cache
fCommandCache = new CommandCache(getServicesTracker().getService(ICommandControl.class)); fCommandCache = new CommandCache(getSession(), getServicesTracker().getService(ICommandControl.class));
// Create the memory block cache // Create the memory block cache
fMemoryBlockList = new SortedMemoryBlockList(); fMemoryBlockList = new SortedMemoryBlockList();
} }

View file

@ -60,7 +60,7 @@ public class MIModules extends AbstractDsfService implements IModules {
private void doInitialize(RequestMonitor requestMonitor) { private void doInitialize(RequestMonitor requestMonitor) {
// Cache for holding Modules data // Cache for holding Modules data
fModulesCache = new CommandCache(getServicesTracker().getService(ICommandControl.class)); fModulesCache = new CommandCache(getSession(), getServicesTracker().getService(ICommandControl.class));
/* /*
* Make ourselves known so clients can use us. * Make ourselves known so clients can use us.
*/ */

View file

@ -171,8 +171,8 @@ public class MIRegisters extends AbstractDsfService implements IRegisters {
/* /*
* Create the lower level register cache. * Create the lower level register cache.
*/ */
fRegisterValueCache = new CommandCache(getServicesTracker().getService(ICommandControl.class)); fRegisterValueCache = new CommandCache(getSession(), getServicesTracker().getService(ICommandControl.class));
fRegisterNameCache = new CommandCache(getServicesTracker().getService(ICommandControl.class)); fRegisterNameCache = new CommandCache(getSession(), getServicesTracker().getService(ICommandControl.class));
/* /*
* Signup so we see events. We use these events to decide how to manage * Signup so we see events. We use these events to decide how to manage

View file

@ -285,7 +285,7 @@ public class MIRunControl extends AbstractDsfService implements IRunControl
private void doInitialize(final RequestMonitor rm) { private void doInitialize(final RequestMonitor rm) {
fConnection = getServicesTracker().getService(ICommandControl.class); fConnection = getServicesTracker().getService(ICommandControl.class);
fMICommandCache = new CommandCache(fConnection); fMICommandCache = new CommandCache(getSession(), fConnection);
getSession().addServiceEventListener(this, null); getSession().addServiceEventListener(this, null);
//register(new String[]{IRunControl.class.getName(), MIRunControl.class.getName()}, new Hashtable<String,String>()); //register(new String[]{IRunControl.class.getName(), MIRunControl.class.getName()}, new Hashtable<String,String>());

View file

@ -41,7 +41,6 @@ import org.eclipse.dd.dsf.debug.service.command.ICommandControl;
import org.eclipse.dd.dsf.debug.service.command.ICommandListener; 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.ICommandResult;
import org.eclipse.dd.dsf.debug.service.command.IEventListener; import org.eclipse.dd.dsf.debug.service.command.IEventListener;
import org.eclipse.dd.dsf.service.AbstractDsfService;
import org.eclipse.dd.dsf.service.DsfServiceEventHandler; import org.eclipse.dd.dsf.service.DsfServiceEventHandler;
import org.eclipse.dd.dsf.service.DsfServicesTracker; import org.eclipse.dd.dsf.service.DsfServicesTracker;
import org.eclipse.dd.dsf.service.DsfSession; import org.eclipse.dd.dsf.service.DsfSession;
@ -81,7 +80,6 @@ import org.eclipse.dd.mi.service.command.output.MIVarListChildrenInfo;
import org.eclipse.dd.mi.service.command.output.MIVarSetFormatInfo; import org.eclipse.dd.mi.service.command.output.MIVarSetFormatInfo;
import org.eclipse.dd.mi.service.command.output.MIVarShowAttributesInfo; import org.eclipse.dd.mi.service.command.output.MIVarShowAttributesInfo;
import org.eclipse.dd.mi.service.command.output.MIVarUpdateInfo; import org.eclipse.dd.mi.service.command.output.MIVarUpdateInfo;
import org.osgi.framework.BundleContext;
/** /**
* Manages a list of variable objects as created through GDB/MI commands. * Manages a list of variable objects as created through GDB/MI commands.
@ -195,7 +193,7 @@ import org.osgi.framework.BundleContext;
* with a specified format, therefore allowing us to never use -var-set-format, and * with a specified format, therefore allowing us to never use -var-set-format, and
* consequently, to easily keep the display format of all variable objects to natural. * consequently, to easily keep the display format of all variable objects to natural.
*/ */
public class MIVariableManager extends AbstractDsfService implements ICommandControl { public class MIVariableManager implements ICommandControl {
/** /**
@ -353,7 +351,7 @@ public class MIVariableManager extends AbstractDsfService implements ICommandCon
updatesPending.add(rm); updatesPending.add(rm);
} else { } else {
currentState = STATE_UPDATING; currentState = STATE_UPDATING;
getRootToUpdate().update(new DataRequestMonitor<Boolean>(getExecutor(), rm) { getRootToUpdate().update(new DataRequestMonitor<Boolean>(fSession.getExecutor(), rm) {
@Override @Override
protected void handleCompleted() { protected void handleCompleted() {
currentState = STATE_READY; currentState = STATE_READY;
@ -412,7 +410,7 @@ public class MIVariableManager extends AbstractDsfService implements ICommandCon
} else { } else {
fCommandControl.queueCommand( fCommandControl.queueCommand(
new MIVarShowAttributes(fControlDmc, getGdbName()), new MIVarShowAttributes(fControlDmc, getGdbName()),
new DataRequestMonitor<MIVarShowAttributesInfo>(getExecutor(), rm) { new DataRequestMonitor<MIVarShowAttributesInfo>(fSession.getExecutor(), rm) {
@Override @Override
protected void handleSuccess() { protected void handleSuccess() {
editable = getData().isEditable(); editable = getData().isEditable();
@ -457,14 +455,14 @@ public class MIVariableManager extends AbstractDsfService implements ICommandCon
IExpressionDMContext addrCxt = fExpressionService.createExpression(exprCxt, "&(" + exprCxt.getExpression() + ")"); //$NON-NLS-1$//$NON-NLS-2$ IExpressionDMContext addrCxt = fExpressionService.createExpression(exprCxt, "&(" + exprCxt.getExpression() + ")"); //$NON-NLS-1$//$NON-NLS-2$
final FormattedValueDMContext formatCxt = new FormattedValueDMContext( final FormattedValueDMContext formatCxt = new FormattedValueDMContext(
fExpressionService.getSession().getId(), fSession.getId(),
addrCxt, addrCxt,
dmc.getFormatID() dmc.getFormatID()
); );
getVariable( getVariable(
addrCxt, addrCxt,
new DataRequestMonitor<MIVariableObject>(getExecutor(), rm) { new DataRequestMonitor<MIVariableObject>(fSession.getExecutor(), rm) {
@Override @Override
protected void handleSuccess() { protected void handleSuccess() {
getData().getValue(formatCxt, rm); getData().getValue(formatCxt, rm);
@ -483,7 +481,7 @@ public class MIVariableManager extends AbstractDsfService implements ICommandCon
} }
if (locked) { if (locked) {
operationsPending.add(new RequestMonitor(getExecutor(), rm) { operationsPending.add(new RequestMonitor(fSession.getExecutor(), rm) {
@Override @Override
protected void handleSuccess() { protected void handleSuccess() {
getValue(dmc, rm); getValue(dmc, rm);
@ -500,7 +498,7 @@ public class MIVariableManager extends AbstractDsfService implements ICommandCon
// We must first set the new format and then evaluate the variable // We must first set the new format and then evaluate the variable
fCommandControl.queueCommand( fCommandControl.queueCommand(
new MIVarSetFormat(fControlDmc, getGdbName(), dmc.getFormatID()), new MIVarSetFormat(fControlDmc, getGdbName(), dmc.getFormatID()),
new DataRequestMonitor<MIVarSetFormatInfo>(getExecutor(), rm) { new DataRequestMonitor<MIVarSetFormatInfo>(fSession.getExecutor(), rm) {
@Override @Override
protected void handleCompleted() { protected void handleCompleted() {
if (isSuccess()) { if (isSuccess()) {
@ -536,7 +534,7 @@ public class MIVariableManager extends AbstractDsfService implements ICommandCon
private void evaluate(final DataRequestMonitor<FormattedValueDMData> rm) { private void evaluate(final DataRequestMonitor<FormattedValueDMData> rm) {
fCommandControl.queueCommand( fCommandControl.queueCommand(
new MIVarEvaluateExpression(fControlDmc, getGdbName()), new MIVarEvaluateExpression(fControlDmc, getGdbName()),
new DataRequestMonitor<MIVarEvaluateExpressionInfo>(getExecutor(), rm) { new DataRequestMonitor<MIVarEvaluateExpressionInfo>(fSession.getExecutor(), rm) {
@Override @Override
protected void handleCompleted() { protected void handleCompleted() {
if (isSuccess()) { if (isSuccess()) {
@ -573,7 +571,7 @@ public class MIVariableManager extends AbstractDsfService implements ICommandCon
if (!getCurrentFormat().equals(IFormattedValues.NATURAL_FORMAT)) { if (!getCurrentFormat().equals(IFormattedValues.NATURAL_FORMAT)) {
fCommandControl.queueCommand( fCommandControl.queueCommand(
new MIVarSetFormat(fControlDmc, getGdbName(), IFormattedValues.NATURAL_FORMAT), new MIVarSetFormat(fControlDmc, getGdbName(), IFormattedValues.NATURAL_FORMAT),
new DataRequestMonitor<MIVarSetFormatInfo>(getExecutor(), null) { new DataRequestMonitor<MIVarSetFormatInfo>(fSession.getExecutor(), null) {
@Override @Override
protected void handleCompleted() { protected void handleCompleted() {
if (isSuccess()) { if (isSuccess()) {
@ -639,13 +637,13 @@ public class MIVariableManager extends AbstractDsfService implements ICommandCon
// Also no need to lock the object, since getting the children won't affect other operations // Also no need to lock the object, since getting the children won't affect other operations
fCommandControl.queueCommand( fCommandControl.queueCommand(
new MIVarListChildren(fControlDmc, getGdbName()), new MIVarListChildren(fControlDmc, getGdbName()),
new DataRequestMonitor<MIVarListChildrenInfo>(getExecutor(), rm) { new DataRequestMonitor<MIVarListChildrenInfo>(fSession.getExecutor(), rm) {
@Override @Override
protected void handleSuccess() { protected void handleSuccess() {
MIVar[] children = getData().getMIVars(); MIVar[] children = getData().getMIVars();
final List<ExpressionInfo> realChildren = new ArrayList<ExpressionInfo>(); final List<ExpressionInfo> realChildren = new ArrayList<ExpressionInfo>();
final CountingRequestMonitor countingRm = new CountingRequestMonitor(getExecutor(), rm) { final CountingRequestMonitor countingRm = new CountingRequestMonitor(fSession.getExecutor(), rm) {
@Override @Override
protected void handleSuccess() { protected void handleSuccess() {
// Store the children in our variable object cache // Store the children in our variable object cache
@ -676,7 +674,7 @@ public class MIVariableManager extends AbstractDsfService implements ICommandCon
numSubRequests++; numSubRequests++;
final DataRequestMonitor<String> childPathRm = final DataRequestMonitor<String> childPathRm =
new DataRequestMonitor<String>(getExecutor(), countingRm) { new DataRequestMonitor<String>(fSession.getExecutor(), countingRm) {
@Override @Override
protected void handleSuccess() { protected void handleSuccess() {
String childFullExpression = getData(); String childFullExpression = getData();
@ -727,7 +725,7 @@ public class MIVariableManager extends AbstractDsfService implements ICommandCon
// get the children of this child to get the real children // get the children of this child to get the real children
childVar.getChildren( childVar.getChildren(
exprDmc, exprDmc,
new DataRequestMonitor<ExpressionInfo[]>(getExecutor(), countingRm) { new DataRequestMonitor<ExpressionInfo[]>(fSession.getExecutor(), countingRm) {
@Override @Override
protected void handleSuccess() { protected void handleSuccess() {
ExpressionInfo[] vars = getData(); ExpressionInfo[] vars = getData();
@ -756,7 +754,7 @@ public class MIVariableManager extends AbstractDsfService implements ICommandCon
// can get from -var-info-path-expression starting from GDB 6.7 // can get from -var-info-path-expression starting from GDB 6.7
fCommandControl.queueCommand( fCommandControl.queueCommand(
new MIVarInfoPathExpression(fControlDmc, child.getVarName()), new MIVarInfoPathExpression(fControlDmc, child.getVarName()),
new DataRequestMonitor<MIVarInfoPathExpressionInfo>(getExecutor(), childPathRm) { new DataRequestMonitor<MIVarInfoPathExpressionInfo>(fSession.getExecutor(), childPathRm) {
@Override @Override
protected void handleCompleted() { protected void handleCompleted() {
if (isSuccess()) { if (isSuccess()) {
@ -883,7 +881,7 @@ public class MIVariableManager extends AbstractDsfService implements ICommandCon
// No need to be in ready state or to lock the object // No need to be in ready state or to lock the object
fCommandControl.queueCommand( fCommandControl.queueCommand(
new MIVarAssign(fControlDmc, getGdbName(), value), new MIVarAssign(fControlDmc, getGdbName(), value),
new DataRequestMonitor<MIVarAssignInfo>(getExecutor(), rm) { new DataRequestMonitor<MIVarAssignInfo>(fSession.getExecutor(), rm) {
@Override @Override
protected void handleSuccess() { protected void handleSuccess() {
// We must also mark all variable objects // We must also mark all variable objects
@ -960,7 +958,7 @@ public class MIVariableManager extends AbstractDsfService implements ICommandCon
fCommandControl.queueCommand( fCommandControl.queueCommand(
new MIVarCreate(exprCtx, exprCtx.getExpression()), new MIVarCreate(exprCtx, exprCtx.getExpression()),
new DataRequestMonitor<MIVarCreateInfo>(getExecutor(), rm) { new DataRequestMonitor<MIVarCreateInfo>(fSession.getExecutor(), rm) {
@Override @Override
protected void handleCompleted() { protected void handleCompleted() {
if (isSuccess()) { if (isSuccess()) {
@ -1016,7 +1014,7 @@ public class MIVariableManager extends AbstractDsfService implements ICommandCon
// Creation failed, inform anyone waiting. // Creation failed, inform anyone waiting.
while (updatesPending.size() > 0) { while (updatesPending.size() > 0) {
RequestMonitor rm = updatesPending.poll(); RequestMonitor rm = updatesPending.poll();
rm.setStatus(new Status(IStatus.ERROR, MIPlugin.PLUGIN_ID, INVALID_HANDLE, rm.setStatus(new Status(IStatus.ERROR, MIPlugin.PLUGIN_ID, IDsfStatusConstants.INVALID_HANDLE,
"Unable to create variable object", null)); //$NON-NLS-1$ "Unable to create variable object", null)); //$NON-NLS-1$
rm.done(); rm.done();
} }
@ -1057,7 +1055,7 @@ public class MIVariableManager extends AbstractDsfService implements ICommandCon
// var-set-format command. This is done in the getValue() method // var-set-format command. This is done in the getValue() method
fCommandControl.queueCommand( fCommandControl.queueCommand(
new MIVarUpdate(fControlDmc, getGdbName()), new MIVarUpdate(fControlDmc, getGdbName()),
new DataRequestMonitor<MIVarUpdateInfo>(getExecutor(), rm) { new DataRequestMonitor<MIVarUpdateInfo>(fSession.getExecutor(), rm) {
@Override @Override
protected void handleCompleted() { protected void handleCompleted() {
currentState = STATE_READY; currentState = STATE_READY;
@ -1127,7 +1125,7 @@ public class MIVariableManager extends AbstractDsfService implements ICommandCon
if (getGdbName() != null) { if (getGdbName() != null) {
fCommandControl.queueCommand( fCommandControl.queueCommand(
new MIVarDelete(fControlDmc, getGdbName()), new MIVarDelete(fControlDmc, getGdbName()),
new DataRequestMonitor<MIVarDeleteInfo>(getExecutor(), null)); new DataRequestMonitor<MIVarDeleteInfo>(fSession.getExecutor(), null));
// Nothing to do in the requestMonitor, since the object was already // Nothing to do in the requestMonitor, since the object was already
// removed from our list before calling this method. // removed from our list before calling this method.
@ -1199,7 +1197,7 @@ public class MIVariableManager extends AbstractDsfService implements ICommandCon
// from the StackService command cache after the first time. // from the StackService command cache after the first time.
fStackService.getStackDepth( fStackService.getStackDepth(
execCtx, 0, execCtx, 0,
new DataRequestMonitor<Integer>(getExecutor(), rm) { new DataRequestMonitor<Integer>(fSession.getExecutor(), rm) {
@Override @Override
protected void handleSuccess() { protected void handleSuccess() {
fFrameId = new Integer(getData() - frameCtx.getLevel()); fFrameId = new Integer(getData() - frameCtx.getLevel());
@ -1294,6 +1292,8 @@ public class MIVariableManager extends AbstractDsfService implements ICommandCon
} }
} }
private final DsfSession fSession;
/** Provides access to the GDB/MI back-end */ /** Provides access to the GDB/MI back-end */
private final ICommandControl fCommandControl; private final ICommandControl fCommandControl;
// The stack service needs to be used to get information such // The stack service needs to be used to get information such
@ -1326,7 +1326,7 @@ public class MIVariableManager extends AbstractDsfService implements ICommandCon
* The service tracker that can be used to find other services * The service tracker that can be used to find other services
*/ */
public MIVariableManager(DsfSession session, DsfServicesTracker tracker) { public MIVariableManager(DsfSession session, DsfServicesTracker tracker) {
super(session); fSession = session;
lruVariableList = new LRUVariableCache(); lruVariableList = new LRUVariableCache();
fCommandControl = tracker.getService(ICommandControl.class); fCommandControl = tracker.getService(ICommandControl.class);
fStackService = tracker.getService(IStack.class); fStackService = tracker.getService(IStack.class);
@ -1334,11 +1334,11 @@ public class MIVariableManager extends AbstractDsfService implements ICommandCon
fControlDmc = ((AbstractMIControl)fCommandControl).getControlDMContext(); fControlDmc = ((AbstractMIControl)fCommandControl).getControlDMContext();
// Register to receive service events for this session. // Register to receive service events for this session.
getSession().addServiceEventListener(this, null); fSession.addServiceEventListener(this, null);
} }
public void shutdown() { public void dispose() {
getSession().removeServiceEventListener(this); fSession.removeServiceEventListener(this);
} }
/** /**
@ -1360,7 +1360,7 @@ public class MIVariableManager extends AbstractDsfService implements ICommandCon
final VariableObjectId id = new VariableObjectId(); final VariableObjectId id = new VariableObjectId();
id.generateId( id.generateId(
exprCtx, exprCtx,
new RequestMonitor(getExecutor(), rm) { new RequestMonitor(fSession.getExecutor(), rm) {
@Override @Override
protected void handleSuccess() { protected void handleSuccess() {
getVariable(id, exprCtx, rm); getVariable(id, exprCtx, rm);
@ -1381,7 +1381,7 @@ public class MIVariableManager extends AbstractDsfService implements ICommandCon
// We have found a varObject, but it may not be updated yet. // We have found a varObject, but it may not be updated yet.
// Updating the object will also tell us if it is out-of-scope // Updating the object will also tell us if it is out-of-scope
// and if we should re-create it. // and if we should re-create it.
varObj.update(new DataRequestMonitor<Boolean>(getExecutor(), rm) { varObj.update(new DataRequestMonitor<Boolean>(fSession.getExecutor(), rm) {
@Override @Override
protected void handleSuccess() { protected void handleSuccess() {
@ -1441,7 +1441,7 @@ public class MIVariableManager extends AbstractDsfService implements ICommandCon
// Note that this will replace any old entry with the same id. // Note that this will replace any old entry with the same id.
lruVariableList.put(id, newVarObj); lruVariableList.put(id, newVarObj);
newVarObj.create(exprCtx, new RequestMonitor(getExecutor(), rm) { newVarObj.create(exprCtx, new RequestMonitor(fSession.getExecutor(), rm) {
@Override @Override
protected void handleCompleted() { protected void handleCompleted() {
if (isSuccess()) { if (isSuccess()) {
@ -1479,7 +1479,7 @@ public class MIVariableManager extends AbstractDsfService implements ICommandCon
getVariable( getVariable(
ctx, ctx,
new DataRequestMonitor<MIVariableObject>(getExecutor(), rm) { new DataRequestMonitor<MIVariableObject>(fSession.getExecutor(), rm) {
@Override @Override
protected void handleSuccess() { protected void handleSuccess() {
getData().writeValue(expressionValue, formatId, rm); getData().writeValue(expressionValue, formatId, rm);
@ -1502,7 +1502,7 @@ public class MIVariableManager extends AbstractDsfService implements ICommandCon
getVariable( getVariable(
exprCtx, exprCtx,
new DataRequestMonitor<MIVariableObject>(getExecutor(), drm) { new DataRequestMonitor<MIVariableObject>(fSession.getExecutor(), drm) {
@Override @Override
protected void handleSuccess() { protected void handleSuccess() {
drm.setData( drm.setData(
@ -1521,11 +1521,11 @@ public class MIVariableManager extends AbstractDsfService implements ICommandCon
getVariable( getVariable(
exprCtx, exprCtx,
new DataRequestMonitor<MIVariableObject>(getExecutor(), drm) { new DataRequestMonitor<MIVariableObject>(fSession.getExecutor(), drm) {
@Override @Override
protected void handleSuccess() { protected void handleSuccess() {
getData().getAttributes( getData().getAttributes(
new DataRequestMonitor<Boolean>(getExecutor(), drm) { new DataRequestMonitor<Boolean>(fSession.getExecutor(), drm) {
@Override @Override
protected void handleSuccess() { protected void handleSuccess() {
drm.setData(new ExprMetaGetAttributesInfo(getData())); drm.setData(new ExprMetaGetAttributesInfo(getData()));
@ -1544,12 +1544,12 @@ public class MIVariableManager extends AbstractDsfService implements ICommandCon
getVariable( getVariable(
exprCtx, exprCtx,
new DataRequestMonitor<MIVariableObject>(getExecutor(), drm) { new DataRequestMonitor<MIVariableObject>(fSession.getExecutor(), drm) {
@Override @Override
protected void handleSuccess() { protected void handleSuccess() {
getData().getValue( getData().getValue(
valueCtx, valueCtx,
new DataRequestMonitor<FormattedValueDMData>(getExecutor(), drm) { new DataRequestMonitor<FormattedValueDMData>(fSession.getExecutor(), drm) {
@Override @Override
protected void handleSuccess() { protected void handleSuccess() {
drm.setData( drm.setData(
@ -1567,12 +1567,12 @@ public class MIVariableManager extends AbstractDsfService implements ICommandCon
getVariable( getVariable(
exprCtx, exprCtx,
new DataRequestMonitor<MIVariableObject>(getExecutor(), drm) { new DataRequestMonitor<MIVariableObject>(fSession.getExecutor(), drm) {
@Override @Override
protected void handleSuccess() { protected void handleSuccess() {
getData().getChildren( getData().getChildren(
exprCtx, exprCtx,
new DataRequestMonitor<ExpressionInfo[]>(getExecutor(), drm) { new DataRequestMonitor<ExpressionInfo[]>(fSession.getExecutor(), drm) {
@Override @Override
protected void handleSuccess() { protected void handleSuccess() {
drm.setData(new ExprMetaGetChildrenInfo(getData())); drm.setData(new ExprMetaGetChildrenInfo(getData()));
@ -1589,11 +1589,11 @@ public class MIVariableManager extends AbstractDsfService implements ICommandCon
getVariable( getVariable(
exprCtx, exprCtx,
new DataRequestMonitor<MIVariableObject>(getExecutor(), drm) { new DataRequestMonitor<MIVariableObject>(fSession.getExecutor(), drm) {
@Override @Override
protected void handleSuccess() { protected void handleSuccess() {
getData().getChildrenCount( getData().getChildrenCount(
new DataRequestMonitor<Integer>(getExecutor(), drm) { new DataRequestMonitor<Integer>(fSession.getExecutor(), drm) {
@Override @Override
protected void handleSuccess() { protected void handleSuccess() {
drm.setData(new ExprMetaGetChildCountInfo(getData())); drm.setData(new ExprMetaGetChildCountInfo(getData()));
@ -1650,11 +1650,6 @@ public class MIVariableManager extends AbstractDsfService implements ICommandCon
} }
} }
@Override
protected BundleContext getBundleContext() {
return MIPlugin.getBundleContext();
}
private void markAllOutOfDate() { private void markAllOutOfDate() {
MIRootVariableObject root; MIRootVariableObject root;
while ((root = updatedRootList.poll()) != null) { while ((root = updatedRootList.poll()) != null) {