From a1c17ecdcf0306e5e2c172670651b5a4045adbe0 Mon Sep 17 00:00:00 2001 From: Pawel Piech Date: Thu, 3 Aug 2006 23:26:02 +0000 Subject: [PATCH] Framework changed based on MI prototype fixes. --- .../dsf/ui/model/DataViewModelSchemaNode.java | 2 +- .../dd/dsf/ui/model/ViewModelDelta.java | 22 ++++- .../dd/dsf/ui/model/ViewModelProvider.java | 6 +- .../org/eclipse/dd/dsf/concurrent/Done.java | 20 ++++- .../eclipse/dd/dsf/debug/IBackEndProcess.java | 2 +- .../eclipse/dd/dsf/debug/IBreakpoints.java | 80 +++++-------------- .../org/eclipse/dd/dsf/debug/IModules.java | 1 + .../dd/dsf/debug/INativeProcesses.java | 20 +++++ .../org/eclipse/dd/dsf/debug/IRunControl.java | 13 +-- .../src/org/eclipse/dd/dsf/debug/IStack.java | 11 +++ .../org/eclipse/dd/dsf/model/AbstractDMC.java | 2 +- .../src/org/eclipse/dd/dsf/model/DMCs.java | 12 +-- .../dd/dsf/model/IDataModelService.java | 8 ++ .../dd/dsf/service/AbstractDsfService.java | 19 +++-- 14 files changed, 135 insertions(+), 83 deletions(-) diff --git a/plugins/org.eclipse.dd.dsf.ui/src/org/eclipse/dd/dsf/ui/model/DataViewModelSchemaNode.java b/plugins/org.eclipse.dd.dsf.ui/src/org/eclipse/dd/dsf/ui/model/DataViewModelSchemaNode.java index 94fced13b5a..61a8355957c 100644 --- a/plugins/org.eclipse.dd.dsf.ui/src/org/eclipse/dd/dsf/ui/model/DataViewModelSchemaNode.java +++ b/plugins/org.eclipse.dd.dsf.ui/src/org/eclipse/dd/dsf/ui/model/DataViewModelSchemaNode.java @@ -149,7 +149,7 @@ abstract public class DataViewModelSchemaNode implements IViewModelSchemaNode { childNodeDone); } else { getElements( - (IViewModelContext)parent.getElement(), + parent.getVMC(), new GetDataDone() { public void run() { if (!getStatus().isOK()) { fExecutor.execute(done); diff --git a/plugins/org.eclipse.dd.dsf.ui/src/org/eclipse/dd/dsf/ui/model/ViewModelDelta.java b/plugins/org.eclipse.dd.dsf.ui/src/org/eclipse/dd/dsf/ui/model/ViewModelDelta.java index d1802b98d00..eb0dbf87004 100644 --- a/plugins/org.eclipse.dd.dsf.ui/src/org/eclipse/dd/dsf/ui/model/ViewModelDelta.java +++ b/plugins/org.eclipse.dd.dsf.ui/src/org/eclipse/dd/dsf/ui/model/ViewModelDelta.java @@ -82,10 +82,13 @@ public class ViewModelDelta extends ModelDelta { * only needed for creating delta nodes for parent elements in the tree * if the VMC elements are not at the root of the tree. * @param element Element to create the delta for. + * @param vmcElement Optional VMC element for this node, it can be used + * by other nodes in the delta to set their VMC parent element correctly. */ - public ViewModelDelta(Object element) { + public ViewModelDelta(Object element, IViewModelContext vmcElement) { super(element, IModelDelta.NO_CHANGE); fElement = element; + fVmcElement = vmcElement; } @@ -109,7 +112,6 @@ public class ViewModelDelta extends ModelDelta { fFlags |= flags; } - public IViewModelContext getVMC() { return fVmcElement; } /** @@ -160,6 +162,22 @@ public class ViewModelDelta extends ModelDelta { return node; } + /** + * Adds a node to the delta for a non-VMC element. This is used to + * construct the root branch of the delta before it is handed off to + * ViewModelProvider.handleDataModelEvent() + * @param element Element in the asynchronous view to create the new node for. + * @param vmcElement Optional VMC element for this node, it can be used + * by other nodes in the delta to set their VMC parent element correctly. + * @return Returns the added delta node. + */ + public ViewModelDelta addNode(Object element, IViewModelContext vmcElement) { + ViewModelDelta node = new ViewModelDelta(element, vmcElement); + node.setParent(this); + addDelta(node); + return node; + } + /** * Sets the parent delta of this delta * diff --git a/plugins/org.eclipse.dd.dsf.ui/src/org/eclipse/dd/dsf/ui/model/ViewModelProvider.java b/plugins/org.eclipse.dd.dsf.ui/src/org/eclipse/dd/dsf/ui/model/ViewModelProvider.java index 40473f2b181..7a054a3457a 100644 --- a/plugins/org.eclipse.dd.dsf.ui/src/org/eclipse/dd/dsf/ui/model/ViewModelProvider.java +++ b/plugins/org.eclipse.dd.dsf.ui/src/org/eclipse/dd/dsf/ui/model/ViewModelProvider.java @@ -175,7 +175,9 @@ public class ViewModelProvider extends AbstractModelProxy childNode.getElements( vmc, doneTracker.add( new GetDataDone() { public void run() { - monitor.addChildren(getData()); + if (getStatus().isOK()) { + monitor.addChildren(getData()); + } doneTracker.doneDone(this); }})); } @@ -203,7 +205,7 @@ public class ViewModelProvider extends AbstractModelProxy fProxyActive++; } - public void dipose() { + public void dispose() { fProxyActive--; super.dispose(); } diff --git a/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/concurrent/Done.java b/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/concurrent/Done.java index e36dbb23cee..74d9cc58df8 100644 --- a/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/concurrent/Done.java +++ b/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/concurrent/Done.java @@ -13,6 +13,7 @@ package org.eclipse.dd.dsf.concurrent; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.MultiStatus; import org.eclipse.core.runtime.Status; +import org.eclipse.dd.dsf.DsfPlugin; /** * Base class for Riverbed service method-completion callbacks. By default @@ -44,5 +45,22 @@ abstract public class Done extends DsfRunnable { status.merge(subStatus); fStatus = status; } - + + /** + * Convenience method which checks for error in done, and propagates it + * to caller's client done. + * @return Returns true if there was an error that was propagated and + * the caller can stop processing result. + */ + protected boolean propagateErrorToClient(DsfExecutor executor, Done clientDone, int code, String message) { + if (clientDone.getStatus().getSeverity() == IStatus.CANCEL) { + return true; + } + if (!getStatus().isOK()) { + clientDone.setErrorStatus(DsfPlugin.PLUGIN_ID, code, message, getStatus()); + executor.execute(clientDone); + return true; + } + return false; + } } diff --git a/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/debug/IBackEndProcess.java b/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/debug/IBackEndProcess.java index 49fcf560b4e..f8dae4b15df 100644 --- a/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/debug/IBackEndProcess.java +++ b/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/debug/IBackEndProcess.java @@ -21,7 +21,7 @@ public interface IBackEndProcess extends IDsfService { /** * Event indicating that the back end process has terminated. */ - public interface ExitedEvent {} + public interface IExitedEvent {} /** * Returns the instance of the java process object representing the back diff --git a/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/debug/IBreakpoints.java b/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/debug/IBreakpoints.java index 01ee465b7ab..68d8dbf9bd5 100644 --- a/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/debug/IBreakpoints.java +++ b/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/debug/IBreakpoints.java @@ -1,65 +1,27 @@ +/******************************************************************************* + * Copyright (c) 2006 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; -import org.eclipse.dd.dsf.concurrent.GetDataDone; -import org.eclipse.dd.dsf.model.IDataModelContext; -import org.eclipse.dd.dsf.model.IDataModelData; -import org.eclipse.dd.dsf.model.IDataModelEvent; -import org.eclipse.dd.dsf.model.IDataModelService; -import org.eclipse.debug.core.model.IBreakpoint; +import org.eclipse.dd.dsf.service.IDsfService; /** - * Breakpoint service provides access to information about breakpoints that - * are planted on a target. It's the reposnsibility of the debugger - * implementation to retrieve static breakpoint data from platform APIs and to - * install them on the target. + * Note: This interface is just a place-holder. */ -public interface IBreakpoints extends IDataModelService { - /** - * Data Model Context for a breakpoint objects. Breakpoints service only - * with respect to running processes/threads, therefore the breakpoint - * context will always have an IExecutionDMC as one of its ancestors. - */ - public interface IBreakpointDMC extends IDataModelContext {} - - /** Indicates that the state of given breakpoint has changed. */ - public interface BreakpointChangedEvent extends IDataModelEvent {} - - /** Indicates that given breakpoint was hit, by the given execution context. */ - public interface BreakpointHitEvent extends BreakpointChangedEvent { - IRunControl.IExecutionDMC getExecutionDMC(); - } - - /** Common breakpoint state data. */ - public interface BreakpointData extends IDataModelData { - /** Installed status values of a breakpoint. */ - public enum Status { FILTERED_OUT, INSTALLED, FAILED_TO_INSTALL, PENDING_INSTALL, PENDING_UNINSTALL } - - /** Returns the corresponding platform debug model breakpoint object. */ - IBreakpoint getBreakpoint(); - - /** Returns current installed status of this breakpoint */ - Status getStatus(); - - /** - * Returns error message (if any) with respect to current status of - * the breakpoint. - */ - String getErrorMessage(); - - /** - * Returns a warning message (if any) with respect to current status of - * the breakpoint. - */ - String getWarningMessage(); - } - - /** - * Retrieves all breakpoints for given execution context. - */ - void getBreakpoints(IRunControl.IExecutionDMC execCtx, GetDataDone done); - - /** - * Retrieves all breakpoints for given platform breakpoint object. - */ - void getBreakpoints(IBreakpoint bp, GetDataDone done); +public interface IBreakpoints extends IDsfService { + + public class BreakpointEvent { + public final int fLineNumber; + public BreakpointEvent(int line) { + fLineNumber = line; + } + } } + diff --git a/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/debug/IModules.java b/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/debug/IModules.java index 737ff7a54eb..803dd2f0558 100644 --- a/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/debug/IModules.java +++ b/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/debug/IModules.java @@ -3,6 +3,7 @@ package org.eclipse.dd.dsf.debug; import java.math.BigInteger; import org.eclipse.dd.dsf.concurrent.GetDataDone; +import org.eclipse.dd.dsf.debug.IMemory.IAddress; import org.eclipse.dd.dsf.model.IDataModelContext; import org.eclipse.dd.dsf.model.IDataModelData; import org.eclipse.dd.dsf.model.IDataModelEvent; diff --git a/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/debug/INativeProcesses.java b/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/debug/INativeProcesses.java index 54081096a7b..e2eae52fca2 100644 --- a/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/debug/INativeProcesses.java +++ b/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/debug/INativeProcesses.java @@ -61,6 +61,12 @@ public interface INativeProcesses extends IDataModelService { * @param done Return token with the process context. */ void debugNewProcess(String file, GetDataDone done); + + /** + * Retrieves the list of processes which are currently under + * debugger control. + */ + void getProcessesBeingDebugged(GetDataDone done); /** * Returns a thread context for given run control execution context. @@ -68,4 +74,18 @@ public interface INativeProcesses extends IDataModelService { * @return Corresponding thread context. */ IThreadDMC getThreadForExecutionContext(IRunControl.IExecutionDMC execCtx); + + /** + * Checks whether the given process or thread can be terminated. + * @param thread Thread or process to terminate. + * @param done Return token. + */ + void canTerminate(IThreadDMC thread, GetDataDone done); + + /** + * Terminates the selected process or thread. + * @param thread Thread or process to terminate. + * @param done Return token. + */ + void terminate(IThreadDMC thread, Done done); } diff --git a/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/debug/IRunControl.java b/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/debug/IRunControl.java index e68ed472007..6b0d9d20df6 100644 --- a/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/debug/IRunControl.java +++ b/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/debug/IRunControl.java @@ -33,21 +33,21 @@ public interface IRunControl extends IDataModelService public interface IContainerDMC extends IExecutionDMC {} /** Flag indicating reason context state change. */ - public enum StateChangeReason { USER_REQUEST, STEP, BREAKPOINT, EXCEPTION, CONTAINER }; + public enum StateChangeReason { UNKNOWN, USER_REQUEST, STEP, BREAKPOINT, EXCEPTION, CONTAINER }; /** * Events signaling a state changes. */ - public interface SuspendedEvent extends IDataModelEvent { + public interface ISuspendedEvent extends IDataModelEvent { StateChangeReason getReason(); } - public interface ResumedEvent extends IDataModelEvent { + public interface IResumedEvent extends IDataModelEvent { StateChangeReason getReason(); } - public interface ContainerSuspendedEvent extends IDataModelEvent { + public interface IContainerSuspendedEvent extends IDataModelEvent { StateChangeReason getReason(); } - public interface ContainerResumedEvent extends IDataModelEvent { + public interface IContainerResumedEvent extends IDataModelEvent { StateChangeReason getReason(); } public interface IStartedEvent extends IDataModelEvent { @@ -81,7 +81,8 @@ public interface IRunControl extends IDataModelService void suspend(IExecutionDMC context, Done done); public enum StepType { STEP_OVER, STEP_INTO, STEP_RETURN }; boolean isStepping(IExecutionDMC context); - void canStep(IExecutionDMC context); + boolean canStep(IExecutionDMC context); void step(IExecutionDMC context, StepType stepType, Done done); + boolean canInstructionStep(IExecutionDMC context); void instructionStep(IExecutionDMC context, StepType stepType, Done done); } diff --git a/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/debug/IStack.java b/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/debug/IStack.java index 34c0d56ecee..0275dc5d7f0 100644 --- a/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/debug/IStack.java +++ b/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/debug/IStack.java @@ -1,6 +1,7 @@ package org.eclipse.dd.dsf.debug; import org.eclipse.dd.dsf.concurrent.GetDataDone; +import org.eclipse.dd.dsf.debug.IMemory.IAddress; import org.eclipse.dd.dsf.model.IDataModelContext; import org.eclipse.dd.dsf.model.IDataModelData; import org.eclipse.dd.dsf.model.IDataModelService; @@ -24,6 +25,7 @@ public interface IStack extends IDataModelService { public interface IFrameData extends IDataModelData { IAddress getAddress(); String getFile(); + String getFunction(); int getLine(); int getColumn(); } @@ -44,6 +46,15 @@ public interface IStack extends IDataModelService { String getValue(); } + /** + * Returns whether the stack frames can be retrieved for given thread. + *
+ * TODO: I'm not sure if this method should be async. It assumes that the + * implementation can determine if stack is available based on process + * state information. + */ + boolean isStackAvailable(IRunControl.IExecutionDMC execContext); + /** * Retrieves list of stack frames for the given execution context. Request * will fail if the stack frame data is not available. diff --git a/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/model/AbstractDMC.java b/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/model/AbstractDMC.java index 08e03569c18..ecc291300e0 100644 --- a/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/model/AbstractDMC.java +++ b/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/model/AbstractDMC.java @@ -21,7 +21,7 @@ import org.eclipse.dd.dsf.service.DsfSession; * @param Data model data that this context is for. */ public class AbstractDMC extends PlatformObject - implements IDataModelContext + implements IDataModelContext { private final String fSessionId; private final String fServiceFilter; diff --git a/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/model/DMCs.java b/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/model/DMCs.java index 5aa60ef4d2b..14d77050f14 100644 --- a/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/model/DMCs.java +++ b/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/model/DMCs.java @@ -26,17 +26,19 @@ public class DMCs { */ @SuppressWarnings("unchecked") public static V getAncestorOfType(IDataModelContext ctx, Class ancestorType) { + if (ancestorType.isAssignableFrom(ctx.getClass())) { + return (V)ctx; + } + for (IDataModelContext parent : ctx.getParents()) { - if (parent.getClass().equals(ancestorType)) { + if (ancestorType.isAssignableFrom(parent.getClass())) { return (V)parent; } } for (IDataModelContext parent : ctx.getParents()) { - if (parent.getClass().equals(ancestorType)) { - V ancestor = getAncestorOfType(parent, ancestorType); - if (ancestor != null) return ancestor; - } + V ancestor = getAncestorOfType(parent, ancestorType); + if (ancestor != null) return ancestor; } return null; } diff --git a/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/model/IDataModelService.java b/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/model/IDataModelService.java index da587a61fe2..dd39a162707 100644 --- a/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/model/IDataModelService.java +++ b/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/model/IDataModelService.java @@ -10,6 +10,7 @@ *******************************************************************************/ package org.eclipse.dd.dsf.model; +import org.eclipse.dd.dsf.concurrent.GetDataDone; import org.eclipse.dd.dsf.service.IDsfService; /** @@ -26,4 +27,11 @@ public interface IDataModelService extends IDsfService, IDataModelData { * service are changed. */ IDataModelContext getServiceContext(); + + /** + * Retrieves model data object for given context. This method makes it + * un-necessary for every model service to declare a separate method + * for retrieving model data of specific type. + */ + void getModelData(IDataModelContext dmc, GetDataDone done); } diff --git a/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/service/AbstractDsfService.java b/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/service/AbstractDsfService.java index 3c4d6b95487..196e66c1bed 100644 --- a/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/service/AbstractDsfService.java +++ b/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/service/AbstractDsfService.java @@ -10,6 +10,7 @@ *******************************************************************************/ package org.eclipse.dd.dsf.service; +import java.util.Arrays; import java.util.Dictionary; import java.util.Enumeration; @@ -91,13 +92,21 @@ abstract public class AbstractDsfService */ @SuppressWarnings("unchecked") protected void register(String[] classes, Dictionary properties) { - String[] newClasses = new String[classes.length + 2]; - System.arraycopy(classes, 0, newClasses, 2, classes.length); - newClasses[0] = IDsfService.class.getName(); - newClasses[1] = getClass().getName(); + if (!Arrays.asList(classes).contains(IDsfService.class.getName())) { + String[] newClasses = new String[classes.length + 1]; + System.arraycopy(classes, 0, newClasses, 1, classes.length); + newClasses[0] = IDsfService.class.getName(); + classes = newClasses; + } + if (!Arrays.asList(classes).contains(getClass().getName())) { + String[] newClasses = new String[classes.length + 1]; + System.arraycopy(classes, 0, newClasses, 1, classes.length); + newClasses[0] = getClass().getName(); + classes = newClasses; + } properties.put(PROP_SESSION_ID, getSession().getId()); fProperties = properties; - fRegistration = getBundleContext().registerService(newClasses, this, properties); + fRegistration = getBundleContext().registerService(classes, this, properties); fRegistration.getReference().getProperty(Constants.OBJECTCLASS); fFilter = generateFilter(fProperties); fProperties.put(Constants.OBJECTCLASS, fRegistration.getReference().getProperty(Constants.OBJECTCLASS));