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);
} else {
getElements(
(IViewModelContext)parent.getElement(),
parent.getVMC(),
new GetDataDone<IViewModelContext[]>() { public void run() {
if (!getStatus().isOK()) {
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
* 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
*

View file

@ -175,7 +175,9 @@ public class ViewModelProvider extends AbstractModelProxy
childNode.getElements(
vmc,
doneTracker.add( new GetDataDone<IViewModelContext[]>() { 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();
}

View file

@ -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;
}
}

View file

@ -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

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;
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<BreakpointData> {}
/** Indicates that the state of given breakpoint has changed. */
public interface BreakpointChangedEvent extends IDataModelEvent<IBreakpointDMC> {}
/** 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<IBreakpointDMC[]> done);
/**
* Retrieves all breakpoints for given platform breakpoint object.
*/
void getBreakpoints(IBreakpoint bp, GetDataDone<IBreakpointDMC[]> done);
public interface IBreakpoints extends IDsfService {
public class BreakpointEvent {
public final int fLineNumber;
public BreakpointEvent(int line) {
fLineNumber = line;
}
}
}

View file

@ -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;

View file

@ -61,6 +61,12 @@ public interface INativeProcesses extends IDataModelService {
* @param done Return token with the process context.
*/
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.
@ -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<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 {}
/** 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<IExecutionDMC> {
public interface ISuspendedEvent extends IDataModelEvent<IExecutionDMC> {
StateChangeReason getReason();
}
public interface ResumedEvent extends IDataModelEvent<IExecutionDMC> {
public interface IResumedEvent extends IDataModelEvent<IExecutionDMC> {
StateChangeReason getReason();
}
public interface ContainerSuspendedEvent extends IDataModelEvent<IExecutionDMC> {
public interface IContainerSuspendedEvent extends IDataModelEvent<IExecutionDMC> {
StateChangeReason getReason();
}
public interface ContainerResumedEvent extends IDataModelEvent<IExecutionDMC> {
public interface IContainerResumedEvent extends IDataModelEvent<IExecutionDMC> {
StateChangeReason getReason();
}
public interface IStartedEvent extends IDataModelEvent<IExecutionDMC> {
@ -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);
}

View file

@ -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.
* <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
* 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.
*/
public class AbstractDMC<V extends IDataModelData> extends PlatformObject
implements IDataModelContext
implements IDataModelContext<V>
{
private final String fSessionId;
private final String fServiceFilter;

View file

@ -26,17 +26,19 @@ public class DMCs {
*/
@SuppressWarnings("unchecked")
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()) {
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;
}

View file

@ -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.
*/
<V extends IDataModelData> void getModelData(IDataModelContext<V> dmc, GetDataDone<V> done);
}

View file

@ -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));