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

Framework changed based on MI prototype fixes.

This commit is contained in:
Pawel Piech 2006-08-03 23:26:02 +00:00
parent 83096c458b
commit a1c17ecdcf
14 changed files with 135 additions and 83 deletions

View file

@ -149,7 +149,7 @@ abstract public class DataViewModelSchemaNode implements IViewModelSchemaNode {
childNodeDone); childNodeDone);
} else { } else {
getElements( getElements(
(IViewModelContext)parent.getElement(), parent.getVMC(),
new GetDataDone<IViewModelContext[]>() { public void run() { new GetDataDone<IViewModelContext[]>() { public void run() {
if (!getStatus().isOK()) { if (!getStatus().isOK()) {
fExecutor.execute(done); fExecutor.execute(done);

View file

@ -82,10 +82,13 @@ public class ViewModelDelta extends ModelDelta {
* only needed for creating delta nodes for parent elements in the tree * only needed for creating delta nodes for parent elements in the tree
* if the VMC elements are not at the root of the tree. * if the VMC elements are not at the root of the tree.
* @param element Element to create the delta for. * @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); super(element, IModelDelta.NO_CHANGE);
fElement = element; fElement = element;
fVmcElement = vmcElement;
} }
@ -109,7 +112,6 @@ public class ViewModelDelta extends ModelDelta {
fFlags |= flags; fFlags |= flags;
} }
public IViewModelContext getVMC() { return fVmcElement; } public IViewModelContext getVMC() { return fVmcElement; }
/** /**
@ -160,6 +162,22 @@ public class ViewModelDelta extends ModelDelta {
return node; 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 * Sets the parent delta of this delta
* *

View file

@ -175,7 +175,9 @@ public class ViewModelProvider extends AbstractModelProxy
childNode.getElements( childNode.getElements(
vmc, vmc,
doneTracker.add( new GetDataDone<IViewModelContext[]>() { public void run() { doneTracker.add( new GetDataDone<IViewModelContext[]>() { public void run() {
if (getStatus().isOK()) {
monitor.addChildren(getData()); monitor.addChildren(getData());
}
doneTracker.doneDone(this); doneTracker.doneDone(this);
}})); }}));
} }
@ -203,7 +205,7 @@ public class ViewModelProvider extends AbstractModelProxy
fProxyActive++; fProxyActive++;
} }
public void dipose() { public void dispose() {
fProxyActive--; fProxyActive--;
super.dispose(); super.dispose();
} }

View file

@ -13,6 +13,7 @@ package org.eclipse.dd.dsf.concurrent;
import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.MultiStatus; import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.Status;
import org.eclipse.dd.dsf.DsfPlugin;
/** /**
* Base class for Riverbed service method-completion callbacks. By default * Base class for Riverbed service method-completion callbacks. By default
@ -45,4 +46,21 @@ abstract public class Done extends DsfRunnable {
fStatus = status; 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;
}
} }

View file

@ -21,7 +21,7 @@ public interface IBackEndProcess extends IDsfService {
/** /**
* Event indicating that the back end process has terminated. * 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 * Returns the instance of the java process object representing the back

View file

@ -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; package org.eclipse.dd.dsf.debug;
import org.eclipse.dd.dsf.concurrent.GetDataDone; import org.eclipse.dd.dsf.service.IDsfService;
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;
/** /**
* Breakpoint service provides access to information about breakpoints that * Note: This interface is just a place-holder.
* 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.
*/ */
public interface IBreakpoints extends IDataModelService { public interface IBreakpoints extends IDsfService {
/**
* 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<BreakpointData> {}
/** Indicates that the state of given breakpoint has changed. */ public class BreakpointEvent {
public interface BreakpointChangedEvent extends IDataModelEvent<IBreakpointDMC> {} public final int fLineNumber;
public BreakpointEvent(int line) {
/** Indicates that given breakpoint was hit, by the given execution context. */ fLineNumber = line;
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<IBreakpointDMC[]> done);
/**
* Retrieves all breakpoints for given platform breakpoint object.
*/
void getBreakpoints(IBreakpoint bp, GetDataDone<IBreakpointDMC[]> done);
} }

View file

@ -3,6 +3,7 @@ package org.eclipse.dd.dsf.debug;
import java.math.BigInteger; import java.math.BigInteger;
import org.eclipse.dd.dsf.concurrent.GetDataDone; 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.IDataModelContext;
import org.eclipse.dd.dsf.model.IDataModelData; import org.eclipse.dd.dsf.model.IDataModelData;
import org.eclipse.dd.dsf.model.IDataModelEvent; import org.eclipse.dd.dsf.model.IDataModelEvent;

View file

@ -62,10 +62,30 @@ public interface INativeProcesses extends IDataModelService {
*/ */
void debugNewProcess(String file, GetDataDone<IProcessDMC> done); void debugNewProcess(String file, GetDataDone<IProcessDMC> done);
/**
* Retrieves the list of processes which are currently under
* debugger control.
*/
void getProcessesBeingDebugged(GetDataDone<IProcessDMC[]> done);
/** /**
* Returns a thread context for given run control execution context. * Returns a thread context for given run control execution context.
* @param execCtx Execution context to return thread for. * @param execCtx Execution context to return thread for.
* @return Corresponding thread context. * @return Corresponding thread context.
*/ */
IThreadDMC getThreadForExecutionContext(IRunControl.IExecutionDMC execCtx); 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<Boolean> done);
/**
* Terminates the selected process or thread.
* @param thread Thread or process to terminate.
* @param done Return token.
*/
void terminate(IThreadDMC thread, Done done);
} }

View file

@ -33,21 +33,21 @@ public interface IRunControl extends IDataModelService
public interface IContainerDMC extends IExecutionDMC {} public interface IContainerDMC extends IExecutionDMC {}
/** Flag indicating reason context state change. */ /** 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. * Events signaling a state changes.
*/ */
public interface SuspendedEvent extends IDataModelEvent<IExecutionDMC> { public interface ISuspendedEvent extends IDataModelEvent<IExecutionDMC> {
StateChangeReason getReason(); StateChangeReason getReason();
} }
public interface ResumedEvent extends IDataModelEvent<IExecutionDMC> { public interface IResumedEvent extends IDataModelEvent<IExecutionDMC> {
StateChangeReason getReason(); StateChangeReason getReason();
} }
public interface ContainerSuspendedEvent extends IDataModelEvent<IExecutionDMC> { public interface IContainerSuspendedEvent extends IDataModelEvent<IExecutionDMC> {
StateChangeReason getReason(); StateChangeReason getReason();
} }
public interface ContainerResumedEvent extends IDataModelEvent<IExecutionDMC> { public interface IContainerResumedEvent extends IDataModelEvent<IExecutionDMC> {
StateChangeReason getReason(); StateChangeReason getReason();
} }
public interface IStartedEvent extends IDataModelEvent<IExecutionDMC> { public interface IStartedEvent extends IDataModelEvent<IExecutionDMC> {
@ -81,7 +81,8 @@ public interface IRunControl extends IDataModelService
void suspend(IExecutionDMC context, Done done); void suspend(IExecutionDMC context, Done done);
public enum StepType { STEP_OVER, STEP_INTO, STEP_RETURN }; public enum StepType { STEP_OVER, STEP_INTO, STEP_RETURN };
boolean isStepping(IExecutionDMC context); boolean isStepping(IExecutionDMC context);
void canStep(IExecutionDMC context); boolean canStep(IExecutionDMC context);
void step(IExecutionDMC context, StepType stepType, Done done); void step(IExecutionDMC context, StepType stepType, Done done);
boolean canInstructionStep(IExecutionDMC context);
void instructionStep(IExecutionDMC context, StepType stepType, Done done); void instructionStep(IExecutionDMC context, StepType stepType, Done done);
} }

View file

@ -1,6 +1,7 @@
package org.eclipse.dd.dsf.debug; package org.eclipse.dd.dsf.debug;
import org.eclipse.dd.dsf.concurrent.GetDataDone; 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.IDataModelContext;
import org.eclipse.dd.dsf.model.IDataModelData; import org.eclipse.dd.dsf.model.IDataModelData;
import org.eclipse.dd.dsf.model.IDataModelService; import org.eclipse.dd.dsf.model.IDataModelService;
@ -24,6 +25,7 @@ public interface IStack extends IDataModelService {
public interface IFrameData extends IDataModelData { public interface IFrameData extends IDataModelData {
IAddress getAddress(); IAddress getAddress();
String getFile(); String getFile();
String getFunction();
int getLine(); int getLine();
int getColumn(); int getColumn();
} }
@ -44,6 +46,15 @@ public interface IStack extends IDataModelService {
String getValue(); String getValue();
} }
/**
* Returns whether the stack frames can be retrieved for given thread.
* <br>
* 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 * Retrieves list of stack frames for the given execution context. Request
* will fail if the stack frame data is not available. * will fail if the stack frame data is not available.

View file

@ -21,7 +21,7 @@ import org.eclipse.dd.dsf.service.DsfSession;
* @param <V> Data model data that this context is for. * @param <V> Data model data that this context is for.
*/ */
public class AbstractDMC<V extends IDataModelData> extends PlatformObject public class AbstractDMC<V extends IDataModelData> extends PlatformObject
implements IDataModelContext implements IDataModelContext<V>
{ {
private final String fSessionId; private final String fSessionId;
private final String fServiceFilter; private final String fServiceFilter;

View file

@ -26,18 +26,20 @@ public class DMCs {
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public static <V extends IDataModelContext> V getAncestorOfType(IDataModelContext ctx, Class<V> ancestorType) { public static <V extends IDataModelContext> V getAncestorOfType(IDataModelContext ctx, Class<V> ancestorType) {
if (ancestorType.isAssignableFrom(ctx.getClass())) {
return (V)ctx;
}
for (IDataModelContext parent : ctx.getParents()) { for (IDataModelContext parent : ctx.getParents()) {
if (parent.getClass().equals(ancestorType)) { if (ancestorType.isAssignableFrom(parent.getClass())) {
return (V)parent; return (V)parent;
} }
} }
for (IDataModelContext parent : ctx.getParents()) { for (IDataModelContext parent : ctx.getParents()) {
if (parent.getClass().equals(ancestorType)) {
V ancestor = getAncestorOfType(parent, ancestorType); V ancestor = getAncestorOfType(parent, ancestorType);
if (ancestor != null) return ancestor; if (ancestor != null) return ancestor;
} }
}
return null; return null;
} }

View file

@ -10,6 +10,7 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.dd.dsf.model; package org.eclipse.dd.dsf.model;
import org.eclipse.dd.dsf.concurrent.GetDataDone;
import org.eclipse.dd.dsf.service.IDsfService; import org.eclipse.dd.dsf.service.IDsfService;
/** /**
@ -26,4 +27,11 @@ public interface IDataModelService extends IDsfService, IDataModelData {
* service are changed. * service are changed.
*/ */
IDataModelContext getServiceContext(); 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.
*/
<V extends IDataModelData> void getModelData(IDataModelContext<V> dmc, GetDataDone<V> done);
} }

View file

@ -10,6 +10,7 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.dd.dsf.service; package org.eclipse.dd.dsf.service;
import java.util.Arrays;
import java.util.Dictionary; import java.util.Dictionary;
import java.util.Enumeration; import java.util.Enumeration;
@ -91,13 +92,21 @@ abstract public class AbstractDsfService
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
protected void register(String[] classes, Dictionary properties) { protected void register(String[] classes, Dictionary properties) {
String[] newClasses = new String[classes.length + 2]; if (!Arrays.asList(classes).contains(IDsfService.class.getName())) {
System.arraycopy(classes, 0, newClasses, 2, classes.length); String[] newClasses = new String[classes.length + 1];
System.arraycopy(classes, 0, newClasses, 1, classes.length);
newClasses[0] = IDsfService.class.getName(); newClasses[0] = IDsfService.class.getName();
newClasses[1] = getClass().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()); properties.put(PROP_SESSION_ID, getSession().getId());
fProperties = properties; fProperties = properties;
fRegistration = getBundleContext().registerService(newClasses, this, properties); fRegistration = getBundleContext().registerService(classes, this, properties);
fRegistration.getReference().getProperty(Constants.OBJECTCLASS); fRegistration.getReference().getProperty(Constants.OBJECTCLASS);
fFilter = generateFilter(fProperties); fFilter = generateFilter(fProperties);
fProperties.put(Constants.OBJECTCLASS, fRegistration.getReference().getProperty(Constants.OBJECTCLASS)); fProperties.put(Constants.OBJECTCLASS, fRegistration.getReference().getProperty(Constants.OBJECTCLASS));