mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
[216854] Completed commenting and cleaning up the initial PDA debugger implementation.
This commit is contained in:
parent
0b291f4f12
commit
2d3a869931
91 changed files with 2224 additions and 2280 deletions
Binary file not shown.
Before Width: | Height: | Size: 159 B |
Binary file not shown.
Before Width: | Height: | Size: 361 B |
Binary file not shown.
Before Width: | Height: | Size: 163 B |
Binary file not shown.
Before Width: | Height: | Size: 590 B |
|
@ -27,29 +27,6 @@
|
||||||
</factory>
|
</factory>
|
||||||
</extension>
|
</extension>
|
||||||
|
|
||||||
<!--<extension
|
|
||||||
point="org.eclipse.debug.ui.launchShortcuts">
|
|
||||||
<shortcut
|
|
||||||
label="DSF PDA Application"
|
|
||||||
icon="icons/full/obj16/pda.gif"
|
|
||||||
class="org.eclipse.debug.examples.ui.pda.launcher.PDALaunchShortcut"
|
|
||||||
modes="debug"
|
|
||||||
id="org.eclipse.dd.examples.pda.launchShortcut">
|
|
||||||
<contextualLaunch>
|
|
||||||
<enablement>
|
|
||||||
<with variable="selection">
|
|
||||||
<count value="1"/>
|
|
||||||
<iterate>
|
|
||||||
<instanceof value="org.eclipse.core.resources.IFile"/>
|
|
||||||
<test
|
|
||||||
value="*.pda"
|
|
||||||
property="org.eclipse.debug.ui.matchesPattern"/>
|
|
||||||
</iterate>
|
|
||||||
</with>
|
|
||||||
</enablement>
|
|
||||||
</contextualLaunch>
|
|
||||||
</shortcut>
|
|
||||||
</extension>-->
|
|
||||||
<extension
|
<extension
|
||||||
point="org.eclipse.ui.editors">
|
point="org.eclipse.ui.editors">
|
||||||
<editor
|
<editor
|
||||||
|
@ -133,7 +110,6 @@
|
||||||
class="org.eclipse.dd.examples.pda.ui.breakpoints.PDAEditorAdapterFactory"
|
class="org.eclipse.dd.examples.pda.ui.breakpoints.PDAEditorAdapterFactory"
|
||||||
adaptableType="org.eclipse.dd.examples.pda.ui.editor.PDAEditor">
|
adaptableType="org.eclipse.dd.examples.pda.ui.editor.PDAEditor">
|
||||||
<adapter type="org.eclipse.debug.ui.actions.IToggleBreakpointsTarget"/>
|
<adapter type="org.eclipse.debug.ui.actions.IToggleBreakpointsTarget"/>
|
||||||
<adapter type="org.eclipse.debug.ui.actions.IRunToLineTarget"/>
|
|
||||||
</factory>
|
</factory>
|
||||||
</extension> -->
|
</extension> -->
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
|
@ -26,7 +26,7 @@ import org.eclipse.dd.dsf.debug.ui.sourcelookup.MISourceDisplayAdapter;
|
||||||
import org.eclipse.dd.dsf.service.DsfSession;
|
import org.eclipse.dd.dsf.service.DsfSession;
|
||||||
import org.eclipse.dd.examples.pda.PDAPlugin;
|
import org.eclipse.dd.examples.pda.PDAPlugin;
|
||||||
import org.eclipse.dd.examples.pda.launch.PDALaunch;
|
import org.eclipse.dd.examples.pda.launch.PDALaunch;
|
||||||
import org.eclipse.dd.examples.pda.ui.actions.DsfTerminateCommand;
|
import org.eclipse.dd.examples.pda.ui.actions.PDATerminateCommand;
|
||||||
import org.eclipse.dd.examples.pda.ui.viewmodel.PDAVMAdapter;
|
import org.eclipse.dd.examples.pda.ui.viewmodel.PDAVMAdapter;
|
||||||
import org.eclipse.debug.core.DebugPlugin;
|
import org.eclipse.debug.core.DebugPlugin;
|
||||||
import org.eclipse.debug.core.ILaunch;
|
import org.eclipse.debug.core.ILaunch;
|
||||||
|
@ -45,47 +45,62 @@ import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelProxyFactor
|
||||||
import org.eclipse.debug.ui.sourcelookup.ISourceDisplay;
|
import org.eclipse.debug.ui.sourcelookup.ISourceDisplay;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This implementation of platform adapter factory only retrieves the adapters
|
* The adapter factory is the central point of control of view model and other
|
||||||
* for the launch object. It also manages the creation and destruction
|
* UI adapters of a DSF-based debugger. As new launches are created and
|
||||||
* of the session-based adapters which are returned by the
|
* old ones removed, this factory manages the life cycle of the associated
|
||||||
* IDMContext.getAdapter() methods.
|
* UI adapters.
|
||||||
|
* <p>
|
||||||
|
* As a platform adapter factory, this factory only provides adapters for
|
||||||
|
* the launch object. Adapters for all other objects in the DSF model hierarchy
|
||||||
|
* are registered with the DSF session.
|
||||||
|
* </p>
|
||||||
*/
|
*/
|
||||||
@ThreadSafe
|
@ThreadSafe
|
||||||
@SuppressWarnings({"restriction"})
|
@SuppressWarnings({"restriction"})
|
||||||
public class PDAAdapterFactory implements IAdapterFactory, ILaunchesListener2
|
public class PDAAdapterFactory implements IAdapterFactory, ILaunchesListener2
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Contains the set of adapters that are created for eacy launch instance.
|
||||||
|
*/
|
||||||
@Immutable
|
@Immutable
|
||||||
class LaunchAdapterSet {
|
private static class LaunchAdapterSet {
|
||||||
|
// View Model adapter
|
||||||
final PDAVMAdapter fViewModelAdapter;
|
final PDAVMAdapter fViewModelAdapter;
|
||||||
|
|
||||||
|
// Source lookup and positioning adapter
|
||||||
final MISourceDisplayAdapter fSourceDisplayAdapter;
|
final MISourceDisplayAdapter fSourceDisplayAdapter;
|
||||||
|
|
||||||
|
// Command adapters
|
||||||
final DsfStepIntoCommand fStepIntoCommand;
|
final DsfStepIntoCommand fStepIntoCommand;
|
||||||
final DsfStepOverCommand fStepOverCommand;
|
final DsfStepOverCommand fStepOverCommand;
|
||||||
final DsfStepReturnCommand fStepReturnCommand;
|
final DsfStepReturnCommand fStepReturnCommand;
|
||||||
final DsfSuspendCommand fSuspendCommand;
|
final DsfSuspendCommand fSuspendCommand;
|
||||||
final DsfResumeCommand fResumeCommand;
|
final DsfResumeCommand fResumeCommand;
|
||||||
final DsfTerminateCommand fTerminateCommand;
|
final PDATerminateCommand fTerminateCommand;
|
||||||
|
|
||||||
|
// Adapters for integration with other UI actions
|
||||||
final IDebugModelProvider fDebugModelProvider;
|
final IDebugModelProvider fDebugModelProvider;
|
||||||
final PDALaunch fLaunch;
|
final PDALaunch fLaunch;
|
||||||
|
|
||||||
LaunchAdapterSet(PDALaunch launch) {
|
LaunchAdapterSet(PDALaunch launch) {
|
||||||
|
// Initialize launch and session.
|
||||||
fLaunch = launch;
|
fLaunch = launch;
|
||||||
DsfSession session = launch.getSession();
|
DsfSession session = launch.getSession();
|
||||||
|
|
||||||
|
// Initialize VM
|
||||||
fViewModelAdapter = new PDAVMAdapter(session);
|
fViewModelAdapter = new PDAVMAdapter(session);
|
||||||
|
|
||||||
if (launch.getSourceLocator() instanceof ISourceLookupDirector) {
|
// Initialize source lookup
|
||||||
fSourceDisplayAdapter = new MISourceDisplayAdapter(session, (ISourceLookupDirector)launch.getSourceLocator());
|
fSourceDisplayAdapter = new MISourceDisplayAdapter(session, (ISourceLookupDirector)launch.getSourceLocator());
|
||||||
} else {
|
|
||||||
fSourceDisplayAdapter = null;
|
|
||||||
}
|
|
||||||
session.registerModelAdapter(ISourceDisplay.class, fSourceDisplayAdapter);
|
session.registerModelAdapter(ISourceDisplay.class, fSourceDisplayAdapter);
|
||||||
|
|
||||||
|
// Initialize retargetable command handler.
|
||||||
fStepIntoCommand = new DsfStepIntoCommand(session);
|
fStepIntoCommand = new DsfStepIntoCommand(session);
|
||||||
fStepOverCommand = new DsfStepOverCommand(session);
|
fStepOverCommand = new DsfStepOverCommand(session);
|
||||||
fStepReturnCommand = new DsfStepReturnCommand(session);
|
fStepReturnCommand = new DsfStepReturnCommand(session);
|
||||||
fSuspendCommand = new DsfSuspendCommand(session);
|
fSuspendCommand = new DsfSuspendCommand(session);
|
||||||
fResumeCommand = new DsfResumeCommand(session);
|
fResumeCommand = new DsfResumeCommand(session);
|
||||||
fTerminateCommand = new DsfTerminateCommand(session);
|
fTerminateCommand = new PDATerminateCommand(session);
|
||||||
session.registerModelAdapter(IStepIntoHandler.class, fStepIntoCommand);
|
session.registerModelAdapter(IStepIntoHandler.class, fStepIntoCommand);
|
||||||
session.registerModelAdapter(IStepOverHandler.class, fStepOverCommand);
|
session.registerModelAdapter(IStepOverHandler.class, fStepOverCommand);
|
||||||
session.registerModelAdapter(IStepReturnHandler.class, fStepReturnCommand);
|
session.registerModelAdapter(IStepReturnHandler.class, fStepReturnCommand);
|
||||||
|
@ -93,19 +108,17 @@ public class PDAAdapterFactory implements IAdapterFactory, ILaunchesListener2
|
||||||
session.registerModelAdapter(IResumeHandler.class, fResumeCommand);
|
session.registerModelAdapter(IResumeHandler.class, fResumeCommand);
|
||||||
session.registerModelAdapter(ITerminateHandler.class, fTerminateCommand);
|
session.registerModelAdapter(ITerminateHandler.class, fTerminateCommand);
|
||||||
|
|
||||||
|
// Initialize debug model provider
|
||||||
fDebugModelProvider = new IDebugModelProvider() {
|
fDebugModelProvider = new IDebugModelProvider() {
|
||||||
// @see org.eclipse.debug.core.model.IDebugModelProvider#getModelIdentifiers()
|
|
||||||
public String[] getModelIdentifiers() {
|
public String[] getModelIdentifiers() {
|
||||||
return new String[] { PDAPlugin.ID_PDA_DEBUG_MODEL };
|
return new String[] { PDAPlugin.ID_PDA_DEBUG_MODEL };
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
session.registerModelAdapter(IDebugModelProvider.class, fDebugModelProvider);
|
session.registerModelAdapter(IDebugModelProvider.class, fDebugModelProvider);
|
||||||
|
|
||||||
/*
|
// Register the launch as an adapter This ensures that the launch,
|
||||||
* Registering the launch as an adapter, ensures that this launch,
|
// and debug model ID will be associated with all DMContexts from this
|
||||||
* and debug model ID will be associated with all DMContexts from this
|
// session.
|
||||||
* session.
|
|
||||||
*/
|
|
||||||
session.registerModelAdapter(ILaunch.class, fLaunch);
|
session.registerModelAdapter(ILaunch.class, fLaunch);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,10 +152,8 @@ public class PDAAdapterFactory implements IAdapterFactory, ILaunchesListener2
|
||||||
DebugPlugin.getDefault().getLaunchManager().addLaunchListener(this);
|
DebugPlugin.getDefault().getLaunchManager().addLaunchListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// This IAdapterFactory method returns adapters for the PDA launch object only.
|
||||||
* This method only actually returns adapters for the launch object.
|
@SuppressWarnings("unchecked") // IAdapterFactory is Java 1.3
|
||||||
*/
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public Object getAdapter(Object adaptableObject, Class adapterType) {
|
public Object getAdapter(Object adaptableObject, Class adapterType) {
|
||||||
if (!(adaptableObject instanceof PDALaunch)) return null;
|
if (!(adaptableObject instanceof PDALaunch)) return null;
|
||||||
|
|
||||||
|
@ -167,20 +178,15 @@ public class PDAAdapterFactory implements IAdapterFactory, ILaunchesListener2
|
||||||
else return null;
|
else return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
@SuppressWarnings("unchecked") // IAdapterFactory is Java 1.3
|
||||||
* @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList()
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public Class[] getAdapterList() {
|
public Class[] getAdapterList() {
|
||||||
return new Class[] { IElementContentProvider.class, IModelProxyFactory.class, IColumnPresentationFactory.class };
|
return new Class[] { IElementContentProvider.class, IModelProxyFactory.class, IColumnPresentationFactory.class };
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sessionEnded(DsfSession session) {
|
|
||||||
}
|
|
||||||
|
|
||||||
public void launchesRemoved(ILaunch[] launches) {
|
public void launchesRemoved(ILaunch[] launches) {
|
||||||
// Dispose the set of adapters for a launch only after the launch is
|
// Dispose the set of adapters for a launch only after the launch is
|
||||||
// removed.
|
// removed from the view. If the launch is terminated, the adapters
|
||||||
|
// are still needed to populate the contents of the view.
|
||||||
for (ILaunch launch : launches) {
|
for (ILaunch launch : launches) {
|
||||||
if (launch instanceof PDALaunch) {
|
if (launch instanceof PDALaunch) {
|
||||||
PDALaunch pdaLaunch = (PDALaunch)launch;
|
PDALaunch pdaLaunch = (PDALaunch)launch;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2005, 2007 IBM Corporation and others.
|
* Copyright (c) 2005, 2008 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -8,16 +8,13 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Corporation - initial API and implementation
|
* IBM Corporation - initial API and implementation
|
||||||
* Bjorn Freeman-Benson - initial API and implementation
|
* Bjorn Freeman-Benson - initial API and implementation
|
||||||
|
* Wind River Systems - adopted to use with DSF
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.dd.examples.pda.ui;
|
package org.eclipse.dd.examples.pda.ui;
|
||||||
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.MissingResourceException;
|
|
||||||
import java.util.ResourceBundle;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
|
|
||||||
import org.eclipse.jface.resource.ImageDescriptor;
|
import org.eclipse.jface.resource.ImageDescriptor;
|
||||||
import org.eclipse.jface.resource.ImageRegistry;
|
import org.eclipse.jface.resource.ImageRegistry;
|
||||||
|
@ -32,29 +29,16 @@ import org.osgi.framework.BundleContext;
|
||||||
* The main plugin class to be used in the desktop.
|
* The main plugin class to be used in the desktop.
|
||||||
*/
|
*/
|
||||||
public class PDAUIPlugin extends AbstractUIPlugin {
|
public class PDAUIPlugin extends AbstractUIPlugin {
|
||||||
|
|
||||||
|
public static String PLUGIN_ID = "org.eclipse.dd.examples.pda.ui ";
|
||||||
|
|
||||||
//The shared instance.
|
//The shared instance.
|
||||||
private static PDAUIPlugin plugin;
|
private static PDAUIPlugin plugin;
|
||||||
//Resource bundle.
|
|
||||||
private ResourceBundle resourceBundle;
|
|
||||||
|
|
||||||
private static BundleContext fContext;
|
private static BundleContext fContext;
|
||||||
|
|
||||||
private final static String ICONS_PATH = "icons/full/";//$NON-NLS-1$
|
private final static String ICONS_PATH = "icons/full/";//$NON-NLS-1$
|
||||||
private final static String PATH_OBJECT = ICONS_PATH + "obj16/"; //Model object icons //$NON-NLS-1$
|
private final static String PATH_OBJECT = ICONS_PATH + "obj16/"; //Model object icons //$NON-NLS-1$
|
||||||
private final static String PATH_ELOCALTOOL = ICONS_PATH + "elcl16/"; //Enabled local toolbar icons //$NON-NLS-1$
|
|
||||||
private final static String PATH_DLOCALTOOL = ICONS_PATH + "dlcl16/"; //Disabled local toolbar icons //$NON-NLS-1$
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Toolbar action to pop data stack
|
|
||||||
*/
|
|
||||||
public final static String IMG_ELCL_POP = "IMG_ELCL_POP";
|
|
||||||
public final static String IMG_DLCL_POP = "IMG_DLCL_POP";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Toolbar action to push onto data stack
|
|
||||||
*/
|
|
||||||
public final static String IMG_ELCL_PUSH = "IMG_ELCL_PUSH";
|
|
||||||
public final static String IMG_DLCL_PUSH = "IMG_DLCL_PUSH";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PDA program image
|
* PDA program image
|
||||||
|
@ -70,7 +54,7 @@ public class PDAUIPlugin extends AbstractUIPlugin {
|
||||||
/**
|
/**
|
||||||
* Managed colors
|
* Managed colors
|
||||||
*/
|
*/
|
||||||
private Map fColors = new HashMap();
|
private Map<RGB, Color> fColors = new HashMap<RGB, Color>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The constructor.
|
* The constructor.
|
||||||
|
@ -98,12 +82,9 @@ public class PDAUIPlugin extends AbstractUIPlugin {
|
||||||
public void stop(BundleContext context) throws Exception {
|
public void stop(BundleContext context) throws Exception {
|
||||||
super.stop(context);
|
super.stop(context);
|
||||||
plugin = null;
|
plugin = null;
|
||||||
resourceBundle = null;
|
|
||||||
fContext = null;
|
fContext = null;
|
||||||
Iterator colors = fColors.entrySet().iterator();
|
for (Map.Entry<RGB, Color> entry : fColors.entrySet()) {
|
||||||
while (colors.hasNext()) {
|
entry.getValue().dispose();
|
||||||
Map.Entry entry = (Entry) colors.next();
|
|
||||||
((Color)entry.getValue()).dispose();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,43 +99,8 @@ public class PDAUIPlugin extends AbstractUIPlugin {
|
||||||
return fContext;
|
return fContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the string from the plugin's resource bundle,
|
|
||||||
* or 'key' if not found.
|
|
||||||
*/
|
|
||||||
public static String getResourceString(String key) {
|
|
||||||
ResourceBundle bundle = PDAUIPlugin.getDefault().getResourceBundle();
|
|
||||||
try {
|
|
||||||
return (bundle != null) ? bundle.getString(key) : key;
|
|
||||||
} catch (MissingResourceException e) {
|
|
||||||
return key;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the plugin's resource bundle,
|
|
||||||
*/
|
|
||||||
public ResourceBundle getResourceBundle() {
|
|
||||||
try {
|
|
||||||
if (resourceBundle == null)
|
|
||||||
resourceBundle = ResourceBundle.getBundle("org.eclipse.debug.examples.ui.pda.DebugUIPluginResources");
|
|
||||||
} catch (MissingResourceException x) {
|
|
||||||
resourceBundle = null;
|
|
||||||
}
|
|
||||||
return resourceBundle;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.ui.plugin.AbstractUIPlugin#initializeImageRegistry(org.eclipse.jface.resource.ImageRegistry)
|
|
||||||
*/
|
|
||||||
protected void initializeImageRegistry(ImageRegistry reg) {
|
protected void initializeImageRegistry(ImageRegistry reg) {
|
||||||
declareImage(IMG_OBJ_PDA, PATH_OBJECT + "pda.gif");
|
declareImage(IMG_OBJ_PDA, PATH_OBJECT + "pda.gif");
|
||||||
declareImage(IMG_ELCL_POP, PATH_ELOCALTOOL + "pop.gif");
|
|
||||||
declareImage(IMG_DLCL_POP, PATH_DLOCALTOOL + "pop.gif");
|
|
||||||
declareImage(IMG_ELCL_PUSH, PATH_ELOCALTOOL + "push.gif");
|
|
||||||
declareImage(IMG_DLCL_PUSH, PATH_DLOCALTOOL + "push.gif");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -168,7 +114,7 @@ public class PDAUIPlugin extends AbstractUIPlugin {
|
||||||
* <code>false</code> if this is not a shared image
|
* <code>false</code> if this is not a shared image
|
||||||
*/
|
*/
|
||||||
private void declareImage(String key, String path) {
|
private void declareImage(String key, String path) {
|
||||||
URL url = BundleUtility.find("org.eclipse.debug.examples.ui", path);
|
URL url = BundleUtility.find("org.eclipse.dd.examples.pda.ui", path);
|
||||||
ImageDescriptor desc = ImageDescriptor.createFromURL(url);
|
ImageDescriptor desc = ImageDescriptor.createFromURL(url);
|
||||||
getImageRegistry().put(key, desc);
|
getImageRegistry().put(key, desc);
|
||||||
}
|
}
|
||||||
|
@ -180,7 +126,7 @@ public class PDAUIPlugin extends AbstractUIPlugin {
|
||||||
* @return color
|
* @return color
|
||||||
*/
|
*/
|
||||||
public Color getColor(RGB rgb) {
|
public Color getColor(RGB rgb) {
|
||||||
Color color = (Color) fColors.get(rgb);
|
Color color = fColors.get(rgb);
|
||||||
if (color == null) {
|
if (color == null) {
|
||||||
color= new Color(Display.getCurrent(), rgb);
|
color= new Color(Display.getCurrent(), rgb);
|
||||||
fColors.put(rgb, color);
|
fColors.put(rgb, color);
|
||||||
|
|
|
@ -1,95 +0,0 @@
|
||||||
/*******************************************************************************
|
|
||||||
* 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.examples.pda.ui.actions;
|
|
||||||
|
|
||||||
import org.eclipse.dd.dsf.concurrent.DsfExecutor;
|
|
||||||
import org.eclipse.dd.dsf.concurrent.DsfRunnable;
|
|
||||||
import org.eclipse.dd.dsf.concurrent.RequestMonitor;
|
|
||||||
import org.eclipse.dd.dsf.datamodel.DMContexts;
|
|
||||||
import org.eclipse.dd.dsf.debug.service.IRunControl.IExecutionDMContext;
|
|
||||||
import org.eclipse.dd.dsf.service.DsfServicesTracker;
|
|
||||||
import org.eclipse.dd.dsf.service.DsfSession;
|
|
||||||
import org.eclipse.dd.dsf.ui.viewmodel.datamodel.IDMVMContext;
|
|
||||||
import org.eclipse.dd.examples.pda.service.command.PDACommandControl;
|
|
||||||
import org.eclipse.dd.examples.pda.ui.PDAUIPlugin;
|
|
||||||
import org.eclipse.debug.core.commands.IDebugCommandRequest;
|
|
||||||
import org.eclipse.debug.core.commands.IEnabledStateRequest;
|
|
||||||
import org.eclipse.debug.core.commands.ITerminateHandler;
|
|
||||||
|
|
||||||
public class DsfTerminateCommand implements ITerminateHandler {
|
|
||||||
private final DsfExecutor fExecutor;
|
|
||||||
private final DsfServicesTracker fTracker;
|
|
||||||
|
|
||||||
public DsfTerminateCommand(DsfSession session) {
|
|
||||||
fExecutor = session.getExecutor();
|
|
||||||
fTracker = new DsfServicesTracker(PDAUIPlugin.getBundleContext(), session.getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void dispose() {
|
|
||||||
fTracker.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Run control may not be avilable after a connection is terminated and shut down.
|
|
||||||
public void canExecute(final IEnabledStateRequest request) {
|
|
||||||
if (request.getElements().length != 1 ||
|
|
||||||
!(request.getElements()[0] instanceof IDMVMContext) )
|
|
||||||
{
|
|
||||||
request.setEnabled(false);
|
|
||||||
request.done();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Javac doesn't like the cast to "(AbstractDMVMLayoutNode<?>.DMVMContext)" need to use the
|
|
||||||
// construct below and suppress warnings.
|
|
||||||
IDMVMContext vmc = (IDMVMContext)request.getElements()[0];
|
|
||||||
final IExecutionDMContext dmc = DMContexts.getAncestorOfType(vmc.getDMContext(), IExecutionDMContext.class);
|
|
||||||
if (dmc == null) {
|
|
||||||
request.setEnabled(false);
|
|
||||||
request.done();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
fExecutor.execute(
|
|
||||||
new DsfRunnable() {
|
|
||||||
public void run() {
|
|
||||||
// Get the processes service and the exec context.
|
|
||||||
PDACommandControl commandControl = fTracker.getService(PDACommandControl.class);
|
|
||||||
if (commandControl == null || dmc == null) {
|
|
||||||
// Context or service already invalid.
|
|
||||||
request.setEnabled(false);
|
|
||||||
request.done();
|
|
||||||
} else {
|
|
||||||
// Check the terminate.
|
|
||||||
request.setEnabled(!commandControl.isTerminated());
|
|
||||||
request.done();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean execute(final IDebugCommandRequest request) {
|
|
||||||
if (request.getElements().length != 1) {
|
|
||||||
request.done();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
fExecutor.submit(new DsfRunnable() {
|
|
||||||
public void run() {
|
|
||||||
PDACommandControl commandControl = fTracker.getService(PDACommandControl.class);
|
|
||||||
if (commandControl != null) {
|
|
||||||
commandControl.shutdown(new RequestMonitor(fExecutor, null));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -0,0 +1,130 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2006, 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.examples.pda.ui.actions;
|
||||||
|
|
||||||
|
import java.util.concurrent.RejectedExecutionException;
|
||||||
|
|
||||||
|
import org.eclipse.core.runtime.IStatus;
|
||||||
|
import org.eclipse.core.runtime.Status;
|
||||||
|
import org.eclipse.dd.dsf.concurrent.DsfRunnable;
|
||||||
|
import org.eclipse.dd.dsf.concurrent.ImmediateExecutor;
|
||||||
|
import org.eclipse.dd.dsf.concurrent.RequestMonitor;
|
||||||
|
import org.eclipse.dd.dsf.datamodel.DMContexts;
|
||||||
|
import org.eclipse.dd.dsf.service.DsfServicesTracker;
|
||||||
|
import org.eclipse.dd.dsf.service.DsfSession;
|
||||||
|
import org.eclipse.dd.dsf.ui.viewmodel.datamodel.IDMVMContext;
|
||||||
|
import org.eclipse.dd.examples.pda.service.PDACommandControl;
|
||||||
|
import org.eclipse.dd.examples.pda.service.PDAProgramDMContext;
|
||||||
|
import org.eclipse.dd.examples.pda.ui.PDAUIPlugin;
|
||||||
|
import org.eclipse.debug.core.commands.IDebugCommandRequest;
|
||||||
|
import org.eclipse.debug.core.commands.IEnabledStateRequest;
|
||||||
|
import org.eclipse.debug.core.commands.ITerminateHandler;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The terminate command is specialized for the PDA debugger. Currently there
|
||||||
|
* is no standard interface for terminating a debug session in DSF, because the
|
||||||
|
* details of initiating and shutting down a debug session vary greatly in
|
||||||
|
* different debuggers.
|
||||||
|
*/
|
||||||
|
public class PDATerminateCommand implements ITerminateHandler {
|
||||||
|
// The executor and the services tracker, both initialized from a DSF session.
|
||||||
|
private final DsfSession fSession;
|
||||||
|
private final DsfServicesTracker fTracker;
|
||||||
|
|
||||||
|
public PDATerminateCommand(DsfSession session) {
|
||||||
|
fSession = session;
|
||||||
|
fTracker = new DsfServicesTracker(PDAUIPlugin.getBundleContext(), session.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void dispose() {
|
||||||
|
// DSF services tracker always has to be disposed, because the OSGi services
|
||||||
|
// use reference counting.
|
||||||
|
fTracker.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Run control may not be available after a connection is terminated and shut down.
|
||||||
|
public void canExecute(final IEnabledStateRequest request) {
|
||||||
|
// Terminate can only operate on a single element.
|
||||||
|
if (request.getElements().length != 1 ||
|
||||||
|
!(request.getElements()[0] instanceof IDMVMContext) )
|
||||||
|
{
|
||||||
|
request.setEnabled(false);
|
||||||
|
request.done();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Find the PDA program context in the selected element. If one is not found,
|
||||||
|
// the action should be disabled.
|
||||||
|
IDMVMContext vmc = (IDMVMContext)request.getElements()[0];
|
||||||
|
final PDAProgramDMContext pdaProgramCtx = DMContexts.getAncestorOfType(vmc.getDMContext(), PDAProgramDMContext.class);
|
||||||
|
if (pdaProgramCtx == null) {
|
||||||
|
request.setEnabled(false);
|
||||||
|
request.done();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
fSession.getExecutor().execute(
|
||||||
|
new DsfRunnable() {
|
||||||
|
public void run() {
|
||||||
|
// Get the processes service and the exec context.
|
||||||
|
PDACommandControl commandControl = fTracker.getService(PDACommandControl.class);
|
||||||
|
if (commandControl == null || pdaProgramCtx == null) {
|
||||||
|
// Context or service already invalid.
|
||||||
|
request.setEnabled(false);
|
||||||
|
request.done();
|
||||||
|
} else {
|
||||||
|
// Check whether the control is terminated.
|
||||||
|
request.setEnabled(!commandControl.isTerminated());
|
||||||
|
request.done();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (RejectedExecutionException e) {
|
||||||
|
// The DSF session for this context is no longer active. It's possible to check
|
||||||
|
// for this condition before calling fSession.getExecutor().execute(), but
|
||||||
|
// since this method is executing in a different thread than the session control,
|
||||||
|
// there would still be a chance for a race condition leading to this exception.
|
||||||
|
request.setEnabled(false);
|
||||||
|
request.done();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean execute(final IDebugCommandRequest request) {
|
||||||
|
// Skip the checks and assume that this method is called only if the action
|
||||||
|
// was enabled.
|
||||||
|
|
||||||
|
try {
|
||||||
|
fSession.getExecutor().submit(new DsfRunnable() {
|
||||||
|
public void run() {
|
||||||
|
// If the command control service is available, attempt to terminate the program.
|
||||||
|
PDACommandControl commandControl = fTracker.getService(PDACommandControl.class);
|
||||||
|
if (commandControl != null) {
|
||||||
|
|
||||||
|
commandControl.terminate(
|
||||||
|
new RequestMonitor(ImmediateExecutor.getInstance(), null) {
|
||||||
|
@Override
|
||||||
|
protected void handleCompleted() {
|
||||||
|
request.setStatus(getStatus());
|
||||||
|
request.done();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (RejectedExecutionException e) {
|
||||||
|
request.setStatus(new Status(IStatus.ERROR, PDAUIPlugin.PLUGIN_ID, "PDA debug session is shut down."));
|
||||||
|
request.done();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2005, 2007 IBM Corporation and others.
|
* Copyright (c) 2005, 2008 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -8,6 +8,7 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Corporation - initial API and implementation
|
* IBM Corporation - initial API and implementation
|
||||||
* Bjorn Freeman-Benson - initial API and implementation
|
* Bjorn Freeman-Benson - initial API and implementation
|
||||||
|
* Wind River Systems - adopted to use with DSF
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.dd.examples.pda.ui.breakpoints;
|
package org.eclipse.dd.examples.pda.ui.breakpoints;
|
||||||
|
|
||||||
|
@ -32,6 +33,10 @@ import org.eclipse.ui.texteditor.ITextEditor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adapter to create breakpoints in PDA files.
|
* Adapter to create breakpoints in PDA files.
|
||||||
|
* <p>
|
||||||
|
* This class is identical to the corresponding in PDA debugger implemented in
|
||||||
|
* org.eclipse.debug.examples.ui.
|
||||||
|
* </p>
|
||||||
*/
|
*/
|
||||||
public class PDABreakpointAdapter implements IToggleBreakpointsTargetExtension {
|
public class PDABreakpointAdapter implements IToggleBreakpointsTargetExtension {
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2005, 2007 IBM Corporation and others.
|
* Copyright (c) 2005, 2008 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -8,24 +8,27 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Corporation - initial API and implementation
|
* IBM Corporation - initial API and implementation
|
||||||
* Bjorn Freeman-Benson - initial API and implementation
|
* Bjorn Freeman-Benson - initial API and implementation
|
||||||
|
* Wind River Systems - adopted to use with DSF
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.dd.examples.pda.ui.breakpoints;
|
package org.eclipse.dd.examples.pda.ui.breakpoints;
|
||||||
|
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.runtime.IAdapterFactory;
|
import org.eclipse.core.runtime.IAdapterFactory;
|
||||||
import org.eclipse.dd.examples.pda.ui.editor.PDAEditor;
|
import org.eclipse.dd.examples.pda.ui.editor.PDAEditor;
|
||||||
import org.eclipse.debug.ui.actions.IRunToLineTarget;
|
|
||||||
import org.eclipse.debug.ui.actions.IToggleBreakpointsTarget;
|
import org.eclipse.debug.ui.actions.IToggleBreakpointsTarget;
|
||||||
import org.eclipse.ui.texteditor.ITextEditor;
|
import org.eclipse.ui.texteditor.ITextEditor;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a toggle breakpoint adapter
|
* Creates a toggle breakpoint adapter
|
||||||
|
* <p>
|
||||||
|
* This class is identical to the corresponding in PDA debugger implemented in
|
||||||
|
* org.eclipse.debug.examples.ui.
|
||||||
|
* </p>
|
||||||
*/
|
*/
|
||||||
public class PDAEditorAdapterFactory implements IAdapterFactory {
|
public class PDAEditorAdapterFactory implements IAdapterFactory {
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class)
|
@SuppressWarnings("unchecked") // IAdapterFactory is Java 1.3
|
||||||
*/
|
|
||||||
public Object getAdapter(Object adaptableObject, Class adapterType) {
|
public Object getAdapter(Object adaptableObject, Class adapterType) {
|
||||||
if (adaptableObject instanceof PDAEditor) {
|
if (adaptableObject instanceof PDAEditor) {
|
||||||
ITextEditor editorPart = (ITextEditor) adaptableObject;
|
ITextEditor editorPart = (ITextEditor) adaptableObject;
|
||||||
|
@ -36,21 +39,13 @@ public class PDAEditorAdapterFactory implements IAdapterFactory {
|
||||||
if (adapterType.equals(IToggleBreakpointsTarget.class)) {
|
if (adapterType.equals(IToggleBreakpointsTarget.class)) {
|
||||||
return new PDABreakpointAdapter();
|
return new PDABreakpointAdapter();
|
||||||
}
|
}
|
||||||
//#ifdef ex7
|
|
||||||
//# // TODO: Exercise 7 - create run to line adapter
|
|
||||||
//#else
|
|
||||||
if (adapterType.equals(IRunToLineTarget.class)) {
|
|
||||||
return new PDARunToLineAdapter();
|
|
||||||
}
|
|
||||||
//#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList()
|
@SuppressWarnings("unchecked") // IAdapterFactory is Java 1.3
|
||||||
*/
|
|
||||||
public Class[] getAdapterList() {
|
public Class[] getAdapterList() {
|
||||||
return new Class[]{IToggleBreakpointsTarget.class};
|
return new Class[]{IToggleBreakpointsTarget.class};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,76 +0,0 @@
|
||||||
/*******************************************************************************
|
|
||||||
* Copyright (c) 2005, 2007 IBM Corporation 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:
|
|
||||||
* IBM Corporation - initial API and implementation
|
|
||||||
* Bjorn Freeman-Benson - initial API and implementation
|
|
||||||
*******************************************************************************/
|
|
||||||
package org.eclipse.dd.examples.pda.ui.breakpoints;
|
|
||||||
|
|
||||||
import org.eclipse.core.resources.IFile;
|
|
||||||
import org.eclipse.core.resources.IResource;
|
|
||||||
import org.eclipse.core.runtime.CoreException;
|
|
||||||
import org.eclipse.core.runtime.IAdaptable;
|
|
||||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
|
||||||
import org.eclipse.dd.examples.pda.PDAPlugin;
|
|
||||||
import org.eclipse.dd.examples.pda.breakpoints.PDARunToLineBreakpoint;
|
|
||||||
import org.eclipse.debug.core.model.IBreakpoint;
|
|
||||||
import org.eclipse.debug.core.model.IDebugElement;
|
|
||||||
import org.eclipse.debug.core.model.IDebugTarget;
|
|
||||||
import org.eclipse.debug.core.model.ISuspendResume;
|
|
||||||
import org.eclipse.debug.ui.actions.IRunToLineTarget;
|
|
||||||
import org.eclipse.debug.ui.actions.RunToLineHandler;
|
|
||||||
import org.eclipse.jface.text.ITextSelection;
|
|
||||||
import org.eclipse.jface.viewers.ISelection;
|
|
||||||
import org.eclipse.ui.IEditorPart;
|
|
||||||
import org.eclipse.ui.IWorkbenchPart;
|
|
||||||
import org.eclipse.ui.texteditor.ITextEditor;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Run to line target for the Java debugger
|
|
||||||
*/
|
|
||||||
public class PDARunToLineAdapter implements IRunToLineTarget {
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.debug.ui.actions.IRunToLineTarget#runToLine(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection, org.eclipse.debug.core.model.ISuspendResume)
|
|
||||||
*/
|
|
||||||
public void runToLine(IWorkbenchPart part, ISelection selection, ISuspendResume target) throws CoreException {
|
|
||||||
IEditorPart editorPart = (IEditorPart)part;
|
|
||||||
ITextEditor textEditor = (ITextEditor)editorPart;
|
|
||||||
ITextSelection textSelection = (ITextSelection) selection;
|
|
||||||
int lineNumber = textSelection.getStartLine() + 1;
|
|
||||||
if (lineNumber > 0) {
|
|
||||||
if (target instanceof IAdaptable) {
|
|
||||||
IDebugTarget debugTarget = (IDebugTarget) ((IAdaptable)target).getAdapter(IDebugTarget.class);
|
|
||||||
if (debugTarget != null) {
|
|
||||||
//#ifdef ex7
|
|
||||||
//# // TODO: Exercise 7 - perform the run-to-line with a run-to-line breakpoint and handler
|
|
||||||
//#else
|
|
||||||
IFile resource = (IFile) textEditor.getEditorInput().getAdapter(IResource.class);
|
|
||||||
IBreakpoint breakpoint= new PDARunToLineBreakpoint(resource, lineNumber);
|
|
||||||
RunToLineHandler handler = new RunToLineHandler(debugTarget, target, breakpoint);
|
|
||||||
handler.run(new NullProgressMonitor());
|
|
||||||
//#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.debug.ui.actions.IRunToLineTarget#canRunToLine(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection, org.eclipse.debug.core.model.ISuspendResume)
|
|
||||||
*/
|
|
||||||
public boolean canRunToLine(IWorkbenchPart part, ISelection selection, ISuspendResume target) {
|
|
||||||
//#ifdef ex7
|
|
||||||
//# // TODO: Exercise 7 - ensure the target is a PDA target
|
|
||||||
//# return false;
|
|
||||||
//#else
|
|
||||||
return target instanceof IDebugElement &&
|
|
||||||
((IDebugElement)target).getModelIdentifier().equals(PDAPlugin.ID_PDA_DEBUG_MODEL);
|
|
||||||
//#endif
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2005, 2007 IBM Corporation and others.
|
* Copyright (c) 2005, 2008 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -8,6 +8,7 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Corporation - initial API and implementation
|
* IBM Corporation - initial API and implementation
|
||||||
* Bjorn Freeman-Benson - initial API and implementation
|
* Bjorn Freeman-Benson - initial API and implementation
|
||||||
|
* Wind River Systems - adopted to use with DSF
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.dd.examples.pda.ui.editor;
|
package org.eclipse.dd.examples.pda.ui.editor;
|
||||||
|
|
||||||
|
@ -22,12 +23,16 @@ import org.eclipse.jface.text.source.ISourceViewer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns hover for breakpoints.
|
* Returns hover for breakpoints.
|
||||||
|
* <p>
|
||||||
|
* This class is identical to the corresponding in PDA debugger implemented in
|
||||||
|
* org.eclipse.debug.examples.ui.
|
||||||
|
* </p>
|
||||||
*/
|
*/
|
||||||
public class AnnotationHover implements IAnnotationHover {
|
public class AnnotationHover implements IAnnotationHover {
|
||||||
|
|
||||||
public String getHoverInfo(ISourceViewer sourceViewer, int lineNumber) {
|
public String getHoverInfo(ISourceViewer sourceViewer, int lineNumber) {
|
||||||
IAnnotationModel annotationModel = sourceViewer.getAnnotationModel();
|
IAnnotationModel annotationModel = sourceViewer.getAnnotationModel();
|
||||||
Iterator iterator = annotationModel.getAnnotationIterator();
|
Iterator<?> iterator = annotationModel.getAnnotationIterator();
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
Annotation annotation = (Annotation) iterator.next();
|
Annotation annotation = (Annotation) iterator.next();
|
||||||
Position position = annotationModel.getPosition(annotation);
|
Position position = annotationModel.getPosition(annotation);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2005, 2007 IBM Corporation and others.
|
* Copyright (c) 2005, 2008 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -8,6 +8,7 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Corporation - initial API and implementation
|
* IBM Corporation - initial API and implementation
|
||||||
* Bjorn Freeman-Benson - initial API and implementation
|
* Bjorn Freeman-Benson - initial API and implementation
|
||||||
|
* Wind River Systems - adopted to use with DSF
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.dd.examples.pda.ui.editor;
|
package org.eclipse.dd.examples.pda.ui.editor;
|
||||||
|
|
||||||
|
@ -41,7 +42,7 @@ public class PDAContentAssistProcessor implements IContentAssistProcessor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
List proposals = new ArrayList();
|
List<ICompletionProposal> proposals = new ArrayList<ICompletionProposal>();
|
||||||
String[] keywords = PDAScanner.fgKeywords;
|
String[] keywords = PDAScanner.fgKeywords;
|
||||||
if (prefix.length() > 0) {
|
if (prefix.length() > 0) {
|
||||||
String word = prefix.toString();
|
String word = prefix.toString();
|
||||||
|
@ -59,7 +60,7 @@ public class PDAContentAssistProcessor implements IContentAssistProcessor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!proposals.isEmpty()) {
|
if (!proposals.isEmpty()) {
|
||||||
return (ICompletionProposal[]) proposals.toArray(new ICompletionProposal[proposals.size()]);
|
return proposals.toArray(new ICompletionProposal[proposals.size()]);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2005, 2007 IBM Corporation and others.
|
* Copyright (c) 2005, 2008 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -8,6 +8,7 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Corporation - initial API and implementation
|
* IBM Corporation - initial API and implementation
|
||||||
* Bjorn Freeman-Benson - initial API and implementation
|
* Bjorn Freeman-Benson - initial API and implementation
|
||||||
|
* Wind River Systems - adopted to use with DSF
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.dd.examples.pda.ui.editor;
|
package org.eclipse.dd.examples.pda.ui.editor;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2005, 2007 IBM Corporation and others.
|
* Copyright (c) 2005, 2008 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -8,6 +8,7 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Corporation - initial API and implementation
|
* IBM Corporation - initial API and implementation
|
||||||
* Bjorn Freeman-Benson - initial API and implementation
|
* Bjorn Freeman-Benson - initial API and implementation
|
||||||
|
* Wind River Systems - adopted to use with DSF
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.dd.examples.pda.ui.editor;
|
package org.eclipse.dd.examples.pda.ui.editor;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2005, 2007 IBM Corporation and others.
|
* Copyright (c) 2005, 2008 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -8,6 +8,7 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Corporation - initial API and implementation
|
* IBM Corporation - initial API and implementation
|
||||||
* Bjorn Freeman-Benson - initial API and implementation
|
* Bjorn Freeman-Benson - initial API and implementation
|
||||||
|
* Wind River Systems - adopted to use with DSF
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.dd.examples.pda.ui.editor;
|
package org.eclipse.dd.examples.pda.ui.editor;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2005, 2007 IBM Corporation and others.
|
* Copyright (c) 2005, 2008 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -8,6 +8,7 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Corporation - initial API and implementation
|
* IBM Corporation - initial API and implementation
|
||||||
* Bjorn Freeman-Benson - initial API and implementation
|
* Bjorn Freeman-Benson - initial API and implementation
|
||||||
|
* Wind River Systems - adopted to use with DSF
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.dd.examples.pda.ui.editor;
|
package org.eclipse.dd.examples.pda.ui.editor;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2005, 2007 IBM Corporation and others.
|
* Copyright (c) 2005, 2008 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -8,10 +8,10 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Corporation - initial API and implementation
|
* IBM Corporation - initial API and implementation
|
||||||
* Bjorn Freeman-Benson - initial API and implementation
|
* Bjorn Freeman-Benson - initial API and implementation
|
||||||
|
* Wind River Systems - adopted to use with DSF
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.dd.examples.pda.ui.editor;
|
package org.eclipse.dd.examples.pda.ui.editor;
|
||||||
|
|
||||||
import org.eclipse.debug.core.DebugException;
|
|
||||||
import org.eclipse.jface.action.IAction;
|
import org.eclipse.jface.action.IAction;
|
||||||
import org.eclipse.jface.viewers.ISelection;
|
import org.eclipse.jface.viewers.ISelection;
|
||||||
import org.eclipse.swt.widgets.Event;
|
import org.eclipse.swt.widgets.Event;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2005, 2007 IBM Corporation and others.
|
* Copyright (c) 2005, 2008 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -8,15 +8,10 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Corporation - initial API and implementation
|
* IBM Corporation - initial API and implementation
|
||||||
* Bjorn Freeman-Benson - initial API and implementation
|
* Bjorn Freeman-Benson - initial API and implementation
|
||||||
|
* Wind River Systems - adopted to use with DSF
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.dd.examples.pda.ui.editor;
|
package org.eclipse.dd.examples.pda.ui.editor;
|
||||||
|
|
||||||
import org.eclipse.core.runtime.IAdaptable;
|
|
||||||
import org.eclipse.debug.core.DebugException;
|
|
||||||
import org.eclipse.debug.core.model.IThread;
|
|
||||||
import org.eclipse.debug.core.model.IVariable;
|
|
||||||
import org.eclipse.debug.ui.DebugUITools;
|
|
||||||
import org.eclipse.jface.text.BadLocationException;
|
|
||||||
import org.eclipse.jface.text.IRegion;
|
import org.eclipse.jface.text.IRegion;
|
||||||
import org.eclipse.jface.text.ITextHover;
|
import org.eclipse.jface.text.ITextHover;
|
||||||
import org.eclipse.jface.text.ITextViewer;
|
import org.eclipse.jface.text.ITextViewer;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2005, 2007 IBM Corporation and others.
|
* Copyright (c) 2005, 2008 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -8,6 +8,7 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Corporation - initial API and implementation
|
* IBM Corporation - initial API and implementation
|
||||||
* Bjorn Freeman-Benson - initial API and implementation
|
* Bjorn Freeman-Benson - initial API and implementation
|
||||||
|
* Wind River Systems - adopted to use with DSF
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.dd.examples.pda.ui.editor;
|
package org.eclipse.dd.examples.pda.ui.editor;
|
||||||
|
|
||||||
|
|
|
@ -1,75 +0,0 @@
|
||||||
/*******************************************************************************
|
|
||||||
* Copyright (c) 2005, 2007 IBM Corporation 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:
|
|
||||||
* IBM Corporation - initial API and implementation
|
|
||||||
* Bjorn Freeman-Benson - initial API and implementation
|
|
||||||
*******************************************************************************/
|
|
||||||
package org.eclipse.dd.examples.pda.ui.launcher;
|
|
||||||
|
|
||||||
import org.eclipse.core.resources.IFile;
|
|
||||||
import org.eclipse.core.runtime.CoreException;
|
|
||||||
import org.eclipse.dd.examples.pda.PDAPlugin;
|
|
||||||
import org.eclipse.debug.core.DebugPlugin;
|
|
||||||
import org.eclipse.debug.core.ILaunchConfiguration;
|
|
||||||
import org.eclipse.debug.core.ILaunchConfigurationType;
|
|
||||||
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
|
|
||||||
import org.eclipse.debug.core.ILaunchManager;
|
|
||||||
import org.eclipse.debug.ui.DebugUITools;
|
|
||||||
import org.eclipse.debug.ui.ILaunchShortcut;
|
|
||||||
import org.eclipse.jface.viewers.ISelection;
|
|
||||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
|
||||||
import org.eclipse.ui.IEditorPart;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Launches a PDA file
|
|
||||||
*/
|
|
||||||
public class PDALaunchShortcut implements ILaunchShortcut {
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.debug.ui.ILaunchShortcut#launch(org.eclipse.jface.viewers.ISelection, java.lang.String)
|
|
||||||
*/
|
|
||||||
public void launch(ISelection selection, String mode) {
|
|
||||||
// must be a structured selection with one file selected
|
|
||||||
IFile file = (IFile) ((IStructuredSelection)selection).getFirstElement();
|
|
||||||
|
|
||||||
// check for an existing launch config for the pda file
|
|
||||||
String path = file.getFullPath().toString();
|
|
||||||
ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
|
|
||||||
ILaunchConfigurationType type = launchManager.getLaunchConfigurationType(PDAPlugin.ID_PDA_LAUNCH_CONFIGURATION_TYPE);
|
|
||||||
try {
|
|
||||||
ILaunchConfiguration[] configurations = launchManager.getLaunchConfigurations(type);
|
|
||||||
for (int i = 0; i < configurations.length; i++) {
|
|
||||||
ILaunchConfiguration configuration = configurations[i];
|
|
||||||
String attribute = configuration.getAttribute(PDAPlugin.ATTR_PDA_PROGRAM, (String)null);
|
|
||||||
if (path.equals(attribute)) {
|
|
||||||
DebugUITools.launch(configuration, mode);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (CoreException e) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
// create a new configuration for the pda file
|
|
||||||
ILaunchConfigurationWorkingCopy workingCopy = type.newInstance(null, file.getName());
|
|
||||||
workingCopy.setAttribute(PDAPlugin.ATTR_PDA_PROGRAM, path);
|
|
||||||
ILaunchConfiguration configuration = workingCopy.doSave();
|
|
||||||
DebugUITools.launch(configuration, mode);
|
|
||||||
} catch (CoreException e1) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.debug.ui.ILaunchShortcut#launch(org.eclipse.ui.IEditorPart, java.lang.String)
|
|
||||||
*/
|
|
||||||
public void launch(IEditorPart editor, String mode) {
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2005, 2007 IBM Corporation and others.
|
* Copyright (c) 2005, 2008 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -8,6 +8,7 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Corporation - initial API and implementation
|
* IBM Corporation - initial API and implementation
|
||||||
* Bjorn Freeman-Benson - initial API and implementation
|
* Bjorn Freeman-Benson - initial API and implementation
|
||||||
|
* Wind River Systems - adopted to use with DSF
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.dd.examples.pda.ui.launcher;
|
package org.eclipse.dd.examples.pda.ui.launcher;
|
||||||
|
|
||||||
|
@ -42,6 +43,10 @@ import org.eclipse.ui.dialogs.ResourceListSelectionDialog;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tab to specify the PDA program to run/debug.
|
* Tab to specify the PDA program to run/debug.
|
||||||
|
* <p>
|
||||||
|
* This class is identical to the corresponding in PDA debugger implemented in
|
||||||
|
* org.eclipse.debug.examples.ui.
|
||||||
|
* </p>
|
||||||
*/
|
*/
|
||||||
public class PDAMainTab extends AbstractLaunchConfigurationTab {
|
public class PDAMainTab extends AbstractLaunchConfigurationTab {
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2005, 2007 IBM Corporation and others.
|
* Copyright (c) 2005, 2008 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -8,6 +8,7 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Corporation - initial API and implementation
|
* IBM Corporation - initial API and implementation
|
||||||
* Bjorn Freeman-Benson - initial API and implementation
|
* Bjorn Freeman-Benson - initial API and implementation
|
||||||
|
* Wind River Systems - adopted to use with DSF
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.dd.examples.pda.ui.launcher;
|
package org.eclipse.dd.examples.pda.ui.launcher;
|
||||||
|
|
||||||
|
@ -19,6 +20,10 @@ import org.eclipse.debug.ui.sourcelookup.SourceLookupTab;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tab group for a PDA application
|
* Tab group for a PDA application
|
||||||
|
* <p>
|
||||||
|
* This class is identical to the corresponding in PDA debugger implemented in
|
||||||
|
* org.eclipse.debug.examples.ui.
|
||||||
|
* </p>
|
||||||
*/
|
*/
|
||||||
public class PDATabGroup extends AbstractLaunchConfigurationTabGroup {
|
public class PDATabGroup extends AbstractLaunchConfigurationTabGroup {
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
|
|
@ -32,7 +32,15 @@ import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationCont
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* View Model provider for the Launch (AKA Debug) view. The PDA debugger is
|
||||||
|
* single-threaded, so there is no need for a debug target element to be visible
|
||||||
|
* in the debug view. Therefore the launch VM provider is configured with three nodes:
|
||||||
|
* <ul>
|
||||||
|
* <li> LaunchRootVMNode - This is the root of the PDA view model.</li>
|
||||||
|
* <li> ThreadVMNode - Supplies the PDA program element.</li>
|
||||||
|
* <li> StackFramesVMNode - Supplies the stack frame elements.</li>
|
||||||
|
* <li> StandardProcessVMNode - Supplies elements representing the PDA debugger process.</li>
|
||||||
|
* </ul>
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("restriction")
|
@SuppressWarnings("restriction")
|
||||||
public class LaunchVMProvider extends AbstractDMVMProvider
|
public class LaunchVMProvider extends AbstractDMVMProvider
|
||||||
|
@ -46,15 +54,17 @@ public class LaunchVMProvider extends AbstractDMVMProvider
|
||||||
IRootVMNode launchNode = new LaunchRootVMNode(this);
|
IRootVMNode launchNode = new LaunchRootVMNode(this);
|
||||||
setRootNode(launchNode);
|
setRootNode(launchNode);
|
||||||
|
|
||||||
// Container node to contain all processes and threads
|
// Launch node is a parent to the processes and program nodes.
|
||||||
IVMNode threadsNode = new ThreadVMNode(this, getSession());
|
IVMNode threadsNode = new PDAProgramVMNode(this, getSession());
|
||||||
IVMNode processesNode = new StandardProcessVMNode(this);
|
IVMNode processesNode = new StandardProcessVMNode(this);
|
||||||
addChildNodes(launchNode, new IVMNode[] { threadsNode, processesNode});
|
addChildNodes(launchNode, new IVMNode[] { threadsNode, processesNode});
|
||||||
|
|
||||||
|
// Stack frames node is under the PDA program node.
|
||||||
IVMNode stackFramesNode = new StackFramesVMNode(this, getSession());
|
IVMNode stackFramesNode = new StackFramesVMNode(this, getSession());
|
||||||
addChildNodes(threadsNode, new IVMNode[] { stackFramesNode });
|
addChildNodes(threadsNode, new IVMNode[] { stackFramesNode });
|
||||||
|
|
||||||
|
// Register the LaunchVM provider as a listener to debug and launch
|
||||||
|
// events. These events are used by the launch and processes nodes.
|
||||||
DebugPlugin.getDefault().addDebugEventListener(this);
|
DebugPlugin.getDefault().addDebugEventListener(this);
|
||||||
DebugPlugin.getDefault().getLaunchManager().addLaunchListener(this);
|
DebugPlugin.getDefault().getLaunchManager().addLaunchListener(this);
|
||||||
}
|
}
|
||||||
|
@ -63,8 +73,8 @@ public class LaunchVMProvider extends AbstractDMVMProvider
|
||||||
public void handleDebugEvents(final DebugEvent[] events) {
|
public void handleDebugEvents(final DebugEvent[] events) {
|
||||||
if (isDisposed()) return;
|
if (isDisposed()) return;
|
||||||
|
|
||||||
// We're in session's executor thread. Re-dispach to VM Adapter
|
// This method may be called on any thread. Switch to the
|
||||||
// executor thread and then call root layout node.
|
// view model executor thread before processing.
|
||||||
try {
|
try {
|
||||||
getExecutor().execute(new Runnable() {
|
getExecutor().execute(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -75,7 +85,7 @@ public class LaunchVMProvider extends AbstractDMVMProvider
|
||||||
}
|
}
|
||||||
}});
|
}});
|
||||||
} catch (RejectedExecutionException e) {
|
} catch (RejectedExecutionException e) {
|
||||||
// Ignore. This exception could be thrown if the provider is being
|
// Ignore. This exception could be thrown if the view model is being
|
||||||
// shut down.
|
// shut down.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -106,8 +116,8 @@ public class LaunchVMProvider extends AbstractDMVMProvider
|
||||||
private void handleLaunchesEvent(final LaunchesEvent event) {
|
private void handleLaunchesEvent(final LaunchesEvent event) {
|
||||||
if (isDisposed()) return;
|
if (isDisposed()) return;
|
||||||
|
|
||||||
// We're in session's executor thread. Re-dispach to VM Adapter
|
// This method also may be called on any thread. Switch to the
|
||||||
// executor thread and then call root layout node.
|
// view model executor thread before processing.
|
||||||
try {
|
try {
|
||||||
getExecutor().execute(new Runnable() {
|
getExecutor().execute(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -119,7 +129,7 @@ public class LaunchVMProvider extends AbstractDMVMProvider
|
||||||
}
|
}
|
||||||
}});
|
}});
|
||||||
} catch (RejectedExecutionException e) {
|
} catch (RejectedExecutionException e) {
|
||||||
// Ignore. This exception could be thrown if the provider is being
|
// Ignore. This exception could be thrown if the view model is being
|
||||||
// shut down.
|
// shut down.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,12 +17,10 @@ import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.dd.dsf.concurrent.ConfinedToDsfExecutor;
|
import org.eclipse.dd.dsf.concurrent.ConfinedToDsfExecutor;
|
||||||
import org.eclipse.dd.dsf.concurrent.DataRequestMonitor;
|
import org.eclipse.dd.dsf.concurrent.DataRequestMonitor;
|
||||||
import org.eclipse.dd.dsf.concurrent.DsfRunnable;
|
import org.eclipse.dd.dsf.concurrent.DsfRunnable;
|
||||||
|
import org.eclipse.dd.dsf.concurrent.ImmediateExecutor;
|
||||||
import org.eclipse.dd.dsf.concurrent.RequestMonitor;
|
import org.eclipse.dd.dsf.concurrent.RequestMonitor;
|
||||||
import org.eclipse.dd.dsf.datamodel.IDMContext;
|
|
||||||
import org.eclipse.dd.dsf.datamodel.IDMEvent;
|
import org.eclipse.dd.dsf.datamodel.IDMEvent;
|
||||||
import org.eclipse.dd.dsf.debug.service.IRunControl;
|
import org.eclipse.dd.dsf.debug.service.IRunControl;
|
||||||
import org.eclipse.dd.dsf.debug.service.IRunControl.IContainerResumedDMEvent;
|
|
||||||
import org.eclipse.dd.dsf.debug.service.IRunControl.IContainerSuspendedDMEvent;
|
|
||||||
import org.eclipse.dd.dsf.debug.service.IRunControl.IExecutionDMContext;
|
import org.eclipse.dd.dsf.debug.service.IRunControl.IExecutionDMContext;
|
||||||
import org.eclipse.dd.dsf.debug.service.IRunControl.IExecutionDMData;
|
import org.eclipse.dd.dsf.debug.service.IRunControl.IExecutionDMData;
|
||||||
import org.eclipse.dd.dsf.debug.service.IRunControl.IResumedDMEvent;
|
import org.eclipse.dd.dsf.debug.service.IRunControl.IResumedDMEvent;
|
||||||
|
@ -36,8 +34,9 @@ import org.eclipse.dd.dsf.ui.viewmodel.datamodel.AbstractDMVMNode;
|
||||||
import org.eclipse.dd.dsf.ui.viewmodel.datamodel.AbstractDMVMProvider;
|
import org.eclipse.dd.dsf.ui.viewmodel.datamodel.AbstractDMVMProvider;
|
||||||
import org.eclipse.dd.examples.pda.PDAPlugin;
|
import org.eclipse.dd.examples.pda.PDAPlugin;
|
||||||
import org.eclipse.dd.examples.pda.launch.PDALaunch;
|
import org.eclipse.dd.examples.pda.launch.PDALaunch;
|
||||||
import org.eclipse.dd.examples.pda.service.command.PDACommandControl;
|
import org.eclipse.dd.examples.pda.service.PDACommandControl;
|
||||||
import org.eclipse.dd.examples.pda.service.command.PDAStartedEvent;
|
import org.eclipse.dd.examples.pda.service.PDAProgramDMContext;
|
||||||
|
import org.eclipse.dd.examples.pda.service.PDAStartedEvent;
|
||||||
import org.eclipse.debug.core.ILaunch;
|
import org.eclipse.debug.core.ILaunch;
|
||||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IChildrenCountUpdate;
|
import org.eclipse.debug.internal.ui.viewers.model.provisional.IChildrenCountUpdate;
|
||||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IChildrenUpdate;
|
import org.eclipse.debug.internal.ui.viewers.model.provisional.IChildrenUpdate;
|
||||||
|
@ -50,20 +49,32 @@ import org.eclipse.debug.ui.DebugUITools;
|
||||||
import org.eclipse.debug.ui.IDebugUIConstants;
|
import org.eclipse.debug.ui.IDebugUIConstants;
|
||||||
import org.eclipse.jface.viewers.TreePath;
|
import org.eclipse.jface.viewers.TreePath;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* View Model node representing a PDA program.
|
||||||
|
*/
|
||||||
@SuppressWarnings("restriction")
|
@SuppressWarnings("restriction")
|
||||||
public class ThreadVMNode extends AbstractDMVMNode
|
public class PDAProgramVMNode extends AbstractDMVMNode
|
||||||
implements IElementLabelProvider
|
implements IElementLabelProvider
|
||||||
{
|
{
|
||||||
private class TerminatedThreadVMContext extends AbstractVMContext {
|
// View model context representing a terminated PDA program.
|
||||||
TerminatedThreadVMContext(IVMAdapter adapter, IVMNode node) {
|
// It's purpose is to show a terminated program in the debug view
|
||||||
|
// even after the DSF session is terminated.
|
||||||
|
//
|
||||||
|
// Note: this context does not implement the IDMVMContext
|
||||||
|
// interfaces, as it does not use an IDMContext as its root.
|
||||||
|
//
|
||||||
|
// To implement comparison methods, this contexts uses the
|
||||||
|
// VM node object, such that two terminated program contexts
|
||||||
|
// from the same instance of VM node will be equal.
|
||||||
|
private static class TerminatedProgramVMContext extends AbstractVMContext {
|
||||||
|
TerminatedProgramVMContext(IVMAdapter adapter, IVMNode node) {
|
||||||
super(adapter, node);
|
super(adapter, node);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
if (obj instanceof TerminatedThreadVMContext) {
|
if (obj instanceof TerminatedProgramVMContext) {
|
||||||
TerminatedThreadVMContext context = (TerminatedThreadVMContext)obj;
|
TerminatedProgramVMContext context = (TerminatedProgramVMContext)obj;
|
||||||
return getVMNode().equals(context.getVMNode());
|
return getVMNode().equals(context.getVMNode());
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -75,14 +86,17 @@ public class ThreadVMNode extends AbstractDMVMNode
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ThreadVMNode(AbstractDMVMProvider provider, DsfSession session) {
|
public PDAProgramVMNode(AbstractDMVMProvider provider, DsfSession session) {
|
||||||
super(provider, session, IExecutionDMContext.class);
|
super(provider, session, IExecutionDMContext.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(IHasChildrenUpdate[] updates) {
|
public void update(IHasChildrenUpdate[] updates) {
|
||||||
for (IHasChildrenUpdate update : updates) {
|
for (IHasChildrenUpdate update : updates) {
|
||||||
update.setHasChilren(true);
|
// Check if the launch is initialized. PDA program element should
|
||||||
|
// be shown only if the launch has completed initializing.
|
||||||
|
PDALaunch launch = findLaunchInPath(update.getElementPath());
|
||||||
|
update.setHasChilren(launch != null && launch.isInitialized());
|
||||||
update.done();
|
update.done();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -90,7 +104,14 @@ public class ThreadVMNode extends AbstractDMVMNode
|
||||||
@Override
|
@Override
|
||||||
public void update(IChildrenCountUpdate[] updates) {
|
public void update(IChildrenCountUpdate[] updates) {
|
||||||
for (IChildrenCountUpdate update : updates) {
|
for (IChildrenCountUpdate update : updates) {
|
||||||
|
// Check if the launch is initialized. PDA program element should
|
||||||
|
// be shown only if the launch has completed initializing.
|
||||||
|
PDALaunch launch = findLaunchInPath(update.getElementPath());
|
||||||
|
if (launch != null && launch.isInitialized()) {
|
||||||
update.setChildCount(1);
|
update.setChildCount(1);
|
||||||
|
} else {
|
||||||
|
update.setChildCount(0);
|
||||||
|
}
|
||||||
update.done();
|
update.done();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -100,10 +121,9 @@ public class ThreadVMNode extends AbstractDMVMNode
|
||||||
for (IChildrenUpdate update : updates) {
|
for (IChildrenUpdate update : updates) {
|
||||||
PDALaunch launch = findLaunchInPath(update.getElementPath());
|
PDALaunch launch = findLaunchInPath(update.getElementPath());
|
||||||
if (launch != null && launch.isInitialized() && launch.isShutDown()) {
|
if (launch != null && launch.isInitialized() && launch.isShutDown()) {
|
||||||
// If the debug session has been shut down. We cannot retrieve the
|
// If the debug session has been shut down, add a dummy
|
||||||
// DM context representing the thread. Instead add a dummy
|
// VM context representing the PDA thread.
|
||||||
// "terminated" PDA thread.
|
update.setChild(new TerminatedProgramVMContext(getVMProvider().getVMAdapter(), this), 0);
|
||||||
update.setChild(new TerminatedThreadVMContext(getVMProvider().getVMAdapter(), this), 0);
|
|
||||||
update.done();
|
update.done();
|
||||||
} else {
|
} else {
|
||||||
super.update(new IChildrenUpdate[] { update });
|
super.update(new IChildrenUpdate[] { update });
|
||||||
|
@ -113,24 +133,36 @@ public class ThreadVMNode extends AbstractDMVMNode
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void updateElementsInSessionThread(final IChildrenUpdate update) {
|
protected void updateElementsInSessionThread(final IChildrenUpdate update) {
|
||||||
|
// Check if service is still available. checkService() is a convenience
|
||||||
|
// method that marks the update as failed if the needed service is not
|
||||||
|
// available.
|
||||||
if (!checkService(PDACommandControl.class, null, update)) return;
|
if (!checkService(PDACommandControl.class, null, update)) return;
|
||||||
|
|
||||||
|
// Get the instance of the service. Note that there is no race condition
|
||||||
|
// in getting the service since this method is called only in the
|
||||||
|
// service executor thred.
|
||||||
final PDACommandControl commandControl = getServicesTracker().getService(PDACommandControl.class);
|
final PDACommandControl commandControl = getServicesTracker().getService(PDACommandControl.class);
|
||||||
|
|
||||||
update.setChild(createVMContext(commandControl.getDMContext()), 0);
|
update.setChild(createVMContext(commandControl.getProgramDMContext()), 0);
|
||||||
update.done();
|
update.done();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update(final ILabelUpdate[] updates) {
|
public void update(final ILabelUpdate[] updates) {
|
||||||
for (final ILabelUpdate update : updates) {
|
for (final ILabelUpdate update : updates) {
|
||||||
if (update.getElement() instanceof TerminatedThreadVMContext) {
|
if (update.getElement() instanceof TerminatedProgramVMContext) {
|
||||||
|
// If the element is a terminated program, update the label
|
||||||
|
// in the View Model thread.
|
||||||
updateTerminatedThreadLabel(update);
|
updateTerminatedThreadLabel(update);
|
||||||
} else {
|
} else {
|
||||||
|
// If the element is the PDA Program context, try to switch
|
||||||
|
// to the DSF session thread before updating the label.
|
||||||
try {
|
try {
|
||||||
getSession().getExecutor().execute(new DsfRunnable() {
|
getSession().getExecutor().execute(new DsfRunnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
updateActiveThreadLabelInSessionThread(update);
|
updateProgramLabelInSessionThread(update);
|
||||||
}});
|
}});
|
||||||
} catch (RejectedExecutionException e) {
|
} catch (RejectedExecutionException e) {
|
||||||
|
// Acceptable race condition: DSF session terminated.
|
||||||
handleFailedUpdate(update);
|
handleFailedUpdate(update);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -138,36 +170,45 @@ public class ThreadVMNode extends AbstractDMVMNode
|
||||||
}
|
}
|
||||||
|
|
||||||
@ConfinedToDsfExecutor("getSession().getExecutor()")
|
@ConfinedToDsfExecutor("getSession().getExecutor()")
|
||||||
private void updateActiveThreadLabelInSessionThread(final ILabelUpdate update) {
|
private void updateProgramLabelInSessionThread(final ILabelUpdate update) {
|
||||||
|
// Get a reference to the run control service.
|
||||||
if (!checkService(IRunControl.class, null, update)) return;
|
if (!checkService(IRunControl.class, null, update)) return;
|
||||||
final IRunControl runControl = getServicesTracker().getService(IRunControl.class);
|
final IRunControl runControl = getServicesTracker().getService(IRunControl.class);
|
||||||
|
|
||||||
final IExecutionDMContext dmc = findDmcInPath(update.getViewerInput(), update.getElementPath(), IExecutionDMContext.class);
|
// Find the PDA program context.
|
||||||
|
final PDAProgramDMContext programCtx =
|
||||||
|
findDmcInPath(update.getViewerInput(), update.getElementPath(), PDAProgramDMContext.class);
|
||||||
|
|
||||||
|
// Call service to get current program state
|
||||||
|
final boolean isSuspended = runControl.isSuspended(programCtx);
|
||||||
|
|
||||||
|
// Set the program icon based on the running state of the program.
|
||||||
String imageKey = null;
|
String imageKey = null;
|
||||||
if (getServicesTracker().getService(IRunControl.class).isSuspended(dmc)) {
|
if (isSuspended) {
|
||||||
imageKey = IDebugUIConstants.IMG_OBJS_THREAD_SUSPENDED;
|
imageKey = IDebugUIConstants.IMG_OBJS_THREAD_SUSPENDED;
|
||||||
} else {
|
} else {
|
||||||
imageKey = IDebugUIConstants.IMG_OBJS_THREAD_RUNNING;
|
imageKey = IDebugUIConstants.IMG_OBJS_THREAD_RUNNING;
|
||||||
}
|
}
|
||||||
update.setImageDescriptor(DebugUITools.getImageDescriptor(imageKey), 0);
|
update.setImageDescriptor(DebugUITools.getImageDescriptor(imageKey), 0);
|
||||||
|
|
||||||
final boolean isSuspended = runControl.isSuspended(dmc);
|
// Retrieve the last state chagne reason
|
||||||
|
runControl.getExecutionData(
|
||||||
// Find the Reason for the State
|
programCtx,
|
||||||
runControl.getExecutionData(dmc,
|
new DataRequestMonitor<IExecutionDMData>(ImmediateExecutor.getInstance(), null)
|
||||||
new DataRequestMonitor<IExecutionDMData>(getSession().getExecutor(), null) {
|
{
|
||||||
@Override
|
@Override
|
||||||
public void handleCompleted(){
|
public void handleCompleted(){
|
||||||
|
// If the request failed, fail the udpate.
|
||||||
if (!getStatus().isOK()) {
|
if (!getStatus().isOK()) {
|
||||||
handleFailedUpdate(update);
|
handleFailedUpdate(update);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Compose the thread name string.
|
||||||
final StringBuilder builder = new StringBuilder();
|
final StringBuilder builder = new StringBuilder();
|
||||||
|
|
||||||
builder.append("PDA [");
|
builder.append("PDA [");
|
||||||
builder.append(getProgramName(update));
|
builder.append(programCtx.getProgram());
|
||||||
builder.append("]");
|
builder.append("]");
|
||||||
|
|
||||||
if(isSuspended) {
|
if(isSuspended) {
|
||||||
|
@ -194,6 +235,7 @@ public class ThreadVMNode extends AbstractDMVMNode
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getProgramName(IViewerUpdate update) {
|
private String getProgramName(IViewerUpdate update) {
|
||||||
|
// Retrieve the program name from the launch object in the update path.
|
||||||
String program = "unknown program";
|
String program = "unknown program";
|
||||||
ILaunch launch = findLaunchInPath(update.getElementPath());
|
ILaunch launch = findLaunchInPath(update.getElementPath());
|
||||||
if (launch != null) {
|
if (launch != null) {
|
||||||
|
@ -217,30 +259,26 @@ public class ThreadVMNode extends AbstractDMVMNode
|
||||||
|
|
||||||
public int getDeltaFlags(Object e) {
|
public int getDeltaFlags(Object e) {
|
||||||
if(e instanceof IResumedDMEvent || e instanceof ISuspendedDMEvent) {
|
if(e instanceof IResumedDMEvent || e instanceof ISuspendedDMEvent) {
|
||||||
return IModelDelta.CONTENT;
|
return IModelDelta.STATE;
|
||||||
}
|
}
|
||||||
if (e instanceof PDAStartedEvent) {
|
if (e instanceof PDAStartedEvent) {
|
||||||
return IModelDelta.EXPAND;
|
return IModelDelta.EXPAND | IModelDelta.SELECT;
|
||||||
}
|
}
|
||||||
return IModelDelta.NO_CHANGE;
|
return IModelDelta.NO_CHANGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void buildDelta(Object e, VMDelta parentDelta, int nodeOffset, RequestMonitor rm) {
|
public void buildDelta(Object e, VMDelta parentDelta, int nodeOffset, RequestMonitor rm) {
|
||||||
if(e instanceof IContainerResumedDMEvent) {
|
if(e instanceof IResumedDMEvent || e instanceof ISuspendedDMEvent) {
|
||||||
IDMContext triggeringContext = ((IContainerResumedDMEvent)e).getTriggeringContext();
|
// If a suspended/resumed event is received, just update the
|
||||||
if (triggeringContext != null) {
|
// state of the program. StackFramesVMNode will take care of
|
||||||
parentDelta.addNode(createVMContext(triggeringContext), IModelDelta.CONTENT);
|
// refreshing the stack frames.
|
||||||
}
|
parentDelta.addNode(createVMContext(((IDMEvent<?>)e).getDMContext()), IModelDelta.STATE);
|
||||||
} else if (e instanceof IContainerSuspendedDMEvent) {
|
|
||||||
IDMContext triggeringContext = ((IContainerSuspendedDMEvent)e).getTriggeringContext();
|
|
||||||
if (triggeringContext != null) {
|
|
||||||
parentDelta.addNode(createVMContext(triggeringContext), IModelDelta.CONTENT);
|
|
||||||
}
|
|
||||||
} else if(e instanceof IResumedDMEvent || e instanceof ISuspendedDMEvent) {
|
|
||||||
parentDelta.addNode(createVMContext(((IDMEvent<?>)e).getDMContext()), IModelDelta.CONTENT);
|
|
||||||
}
|
}
|
||||||
if (e instanceof PDAStartedEvent) {
|
if (e instanceof PDAStartedEvent) {
|
||||||
parentDelta.addNode(createVMContext(((PDAStartedEvent)e).getDMContext()), IModelDelta.EXPAND);
|
// When debug session is started expand and select the program.
|
||||||
|
// If the program hits a breakpoint, the top stack frame will then
|
||||||
|
// be selected.
|
||||||
|
parentDelta.addNode(createVMContext(((PDAStartedEvent)e).getDMContext()), IModelDelta.EXPAND | IModelDelta.SELECT);
|
||||||
}
|
}
|
||||||
rm.done();
|
rm.done();
|
||||||
}
|
}
|
|
@ -12,10 +12,11 @@ Require-Bundle: org.eclipse.core.runtime,
|
||||||
org.eclipse.dd.dsf.debug;bundle-version="1.0.0",
|
org.eclipse.dd.dsf.debug;bundle-version="1.0.0",
|
||||||
org.junit4;bundle-version="4.3.1",
|
org.junit4;bundle-version="4.3.1",
|
||||||
org.eclipse.cdt.core;bundle-version="5.0.0"
|
org.eclipse.cdt.core;bundle-version="5.0.0"
|
||||||
Eclipse-LazyStart: true
|
Bundle-ActivationPolicy: lazy
|
||||||
Export-Package: org.eclipse.dd.examples.pda,
|
Export-Package: org.eclipse.dd.examples.pda,
|
||||||
org.eclipse.dd.examples.pda.breakpoints,
|
org.eclipse.dd.examples.pda.breakpoints,
|
||||||
org.eclipse.dd.examples.pda.launch,
|
org.eclipse.dd.examples.pda.launch,
|
||||||
org.eclipse.dd.examples.pda.service.command,
|
org.eclipse.dd.examples.pda.service,
|
||||||
org.eclipse.debug.examples.core.pda.sourcelookup
|
org.eclipse.dd.examples.pda.service.commands,
|
||||||
|
org.eclipse.dd.examples.pda.sourcelookup
|
||||||
Bundle-RequiredExecutionEnvironment: J2SE-1.5
|
Bundle-RequiredExecutionEnvironment: J2SE-1.5
|
||||||
|
|
|
@ -121,7 +121,7 @@ Sets a data value in the data stack at the given location
|
||||||
Sets a variable value
|
Sets a variable value
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
C: setvar {variable} {value}
|
C: setvar {frame_number} {variable} {value}
|
||||||
R: ok
|
R: ok
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
|
|
|
@ -21,14 +21,14 @@
|
||||||
<extension
|
<extension
|
||||||
point="org.eclipse.debug.core.sourceLocators">
|
point="org.eclipse.debug.core.sourceLocators">
|
||||||
<sourceLocator
|
<sourceLocator
|
||||||
class="org.eclipse.debug.examples.core.pda.sourcelookup.PDASourceLookupDirector"
|
class="org.eclipse.dd.examples.pda.sourcelookup.PDASourceLookupDirector"
|
||||||
name="DSF PDA Source Locator"
|
name="DSF PDA Source Locator"
|
||||||
id="org.eclipse.dd.examples.pda.sourceLocator"/>
|
id="org.eclipse.dd.examples.pda.sourceLocator"/>
|
||||||
</extension>
|
</extension>
|
||||||
<extension
|
<extension
|
||||||
point="org.eclipse.debug.core.sourcePathComputers">
|
point="org.eclipse.debug.core.sourcePathComputers">
|
||||||
<sourcePathComputer
|
<sourcePathComputer
|
||||||
class="org.eclipse.debug.examples.core.pda.sourcelookup.PDASourcePathComputerDelegate"
|
class="org.eclipse.dd.examples.pda.sourcelookup.PDASourcePathComputerDelegate"
|
||||||
id="org.eclipse.dd.examples.pda.sourcePathComputer"/>
|
id="org.eclipse.dd.examples.pda.sourcePathComputer"/>
|
||||||
</extension>
|
</extension>
|
||||||
<extension
|
<extension
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2005, 2007 IBM Corporation and others.
|
* Copyright (c) 2005, 2008 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -8,6 +8,7 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Corporation - initial API and implementation
|
* IBM Corporation - initial API and implementation
|
||||||
* Bjorn Freeman-Benson - initial API and implementation
|
* Bjorn Freeman-Benson - initial API and implementation
|
||||||
|
* Wind River Systems - adopted to use with DSF
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.dd.examples.pda;
|
package org.eclipse.dd.examples.pda;
|
||||||
|
|
||||||
|
@ -44,9 +45,11 @@ public class PDAPlugin extends Plugin {
|
||||||
|
|
||||||
//The shared instance.
|
//The shared instance.
|
||||||
private static PDAPlugin plugin;
|
private static PDAPlugin plugin;
|
||||||
|
|
||||||
//Resource bundle.
|
//Resource bundle.
|
||||||
private ResourceBundle resourceBundle;
|
private ResourceBundle resourceBundle;
|
||||||
|
|
||||||
|
// Bundle context used in registering and retrieving DSF (OSGi) services.
|
||||||
private static BundleContext fContext;
|
private static BundleContext fContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -60,6 +63,7 @@ public class PDAPlugin extends Plugin {
|
||||||
* location of a local Perl executable (value <code>perlExecutable</code>).
|
* location of a local Perl executable (value <code>perlExecutable</code>).
|
||||||
*/
|
*/
|
||||||
public static final String VARIALBE_PERL_EXECUTABLE = "dsfPerlExecutable";
|
public static final String VARIALBE_PERL_EXECUTABLE = "dsfPerlExecutable";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Launch configuration attribute key. Value is a path to a perl
|
* Launch configuration attribute key. Value is a path to a perl
|
||||||
* program. The path is a string representing a full path
|
* program. The path is a string representing a full path
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2005, 2007 IBM Corporation and others.
|
* Copyright (c) 2005, 2008 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -8,6 +8,7 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Corporation - initial API and implementation
|
* IBM Corporation - initial API and implementation
|
||||||
* Bjorn Freeman-Benson - initial API and implementation
|
* Bjorn Freeman-Benson - initial API and implementation
|
||||||
|
* Wind River Systems - adopted to use with DSF
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.dd.examples.pda.breakpoints;
|
package org.eclipse.dd.examples.pda.breakpoints;
|
||||||
|
|
||||||
|
@ -23,6 +24,10 @@ import org.eclipse.debug.core.model.LineBreakpoint;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PDA line breakpoint
|
* PDA line breakpoint
|
||||||
|
* <p>
|
||||||
|
* This class is identical to the corresponding in PDA debugger implemented in
|
||||||
|
* org.eclipse.debug.examples.
|
||||||
|
* </p>
|
||||||
*/
|
*/
|
||||||
public class PDALineBreakpoint extends LineBreakpoint {
|
public class PDALineBreakpoint extends LineBreakpoint {
|
||||||
|
|
||||||
|
|
|
@ -1,70 +0,0 @@
|
||||||
/*******************************************************************************
|
|
||||||
* Copyright (c) 2005, 2007 IBM Corporation 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:
|
|
||||||
* IBM Corporation - initial API and implementation
|
|
||||||
* Bjorn Freeman-Benson - initial API and implementation
|
|
||||||
*******************************************************************************/
|
|
||||||
package org.eclipse.dd.examples.pda.breakpoints;
|
|
||||||
|
|
||||||
import org.eclipse.core.resources.IFile;
|
|
||||||
import org.eclipse.core.resources.IMarker;
|
|
||||||
import org.eclipse.core.resources.IWorkspaceRunnable;
|
|
||||||
import org.eclipse.core.resources.ResourcesPlugin;
|
|
||||||
import org.eclipse.core.runtime.CoreException;
|
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
|
||||||
import org.eclipse.debug.core.DebugException;
|
|
||||||
import org.eclipse.debug.core.model.IBreakpoint;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A run to line breakpoint.
|
|
||||||
*/
|
|
||||||
public class PDARunToLineBreakpoint extends PDALineBreakpoint {
|
|
||||||
|
|
||||||
private IFile fSourceFile;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructs a run-to-line breakpoint in the given PDA program.
|
|
||||||
*
|
|
||||||
* @param resource PDA source file
|
|
||||||
* @param lineNumber line to run to
|
|
||||||
* @exception DebugException if unable to create the breakpoint
|
|
||||||
*/
|
|
||||||
public PDARunToLineBreakpoint(final IFile resource, final int lineNumber) throws DebugException {
|
|
||||||
IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
|
|
||||||
public void run(IProgressMonitor monitor) throws CoreException {
|
|
||||||
// associate with workspace root to avoid drawing in editor ruler
|
|
||||||
IMarker marker = ResourcesPlugin.getWorkspace().getRoot().createMarker("org.eclipse.debug.examples.core.pda.markerType.lineBreakpoint");
|
|
||||||
setMarker(marker);
|
|
||||||
marker.setAttribute(IBreakpoint.ENABLED, Boolean.TRUE);
|
|
||||||
marker.setAttribute(IMarker.LINE_NUMBER, lineNumber);
|
|
||||||
marker.setAttribute(IBreakpoint.ID, getModelIdentifier());
|
|
||||||
setRegistered(false);
|
|
||||||
fSourceFile = resource;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
run(getMarkerRule(resource), runnable);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns whether this breakpoint is a run-to-line breakpoint
|
|
||||||
*
|
|
||||||
* @return whether this breakpoint is a run-to-line breakpoint
|
|
||||||
*/
|
|
||||||
public boolean isRunToLineBreakpoint() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the source file this breakpoint is contained in.
|
|
||||||
*
|
|
||||||
* @return the source file this breakpoint is contained in
|
|
||||||
*/
|
|
||||||
public IFile getSourceFile() {
|
|
||||||
return fSourceFile;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2005, 2007 IBM Corporation and others.
|
* Copyright (c) 2005, 2008 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -8,6 +8,7 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Corporation - initial API and implementation
|
* IBM Corporation - initial API and implementation
|
||||||
* Bjorn Freeman-Benson - initial API and implementation
|
* Bjorn Freeman-Benson - initial API and implementation
|
||||||
|
* Wind River Systems - adopted to use with DSF
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.dd.examples.pda.breakpoints;
|
package org.eclipse.dd.examples.pda.breakpoints;
|
||||||
|
|
||||||
|
@ -22,6 +23,10 @@ import org.eclipse.debug.core.model.IWatchpoint;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A watchpoint.
|
* A watchpoint.
|
||||||
|
* <p>
|
||||||
|
* This class is identical to the corresponding in PDA debugger implemented in
|
||||||
|
* org.eclipse.debug.examples.
|
||||||
|
* </p>
|
||||||
*/
|
*/
|
||||||
public class PDAWatchpoint extends PDALineBreakpoint implements IWatchpoint {
|
public class PDAWatchpoint extends PDALineBreakpoint implements IWatchpoint {
|
||||||
|
|
||||||
|
|
|
@ -15,16 +15,14 @@ import org.eclipse.core.runtime.MultiStatus;
|
||||||
import org.eclipse.core.runtime.Platform;
|
import org.eclipse.core.runtime.Platform;
|
||||||
import org.eclipse.dd.dsf.concurrent.ConfinedToDsfExecutor;
|
import org.eclipse.dd.dsf.concurrent.ConfinedToDsfExecutor;
|
||||||
import org.eclipse.dd.dsf.concurrent.DefaultDsfExecutor;
|
import org.eclipse.dd.dsf.concurrent.DefaultDsfExecutor;
|
||||||
import org.eclipse.dd.dsf.concurrent.DsfExecutor;
|
|
||||||
import org.eclipse.dd.dsf.concurrent.ImmediateExecutor;
|
import org.eclipse.dd.dsf.concurrent.ImmediateExecutor;
|
||||||
import org.eclipse.dd.dsf.concurrent.RequestMonitor;
|
import org.eclipse.dd.dsf.concurrent.RequestMonitor;
|
||||||
import org.eclipse.dd.dsf.concurrent.Sequence;
|
import org.eclipse.dd.dsf.concurrent.Sequence;
|
||||||
import org.eclipse.dd.dsf.concurrent.ThreadSafe;
|
import org.eclipse.dd.dsf.concurrent.ThreadSafe;
|
||||||
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.DsfSession;
|
import org.eclipse.dd.dsf.service.DsfSession;
|
||||||
import org.eclipse.dd.examples.pda.PDAPlugin;
|
import org.eclipse.dd.examples.pda.PDAPlugin;
|
||||||
import org.eclipse.dd.examples.pda.service.command.PDATerminatedEvent;
|
import org.eclipse.dd.examples.pda.service.PDATerminatedEvent;
|
||||||
import org.eclipse.debug.core.DebugException;
|
import org.eclipse.debug.core.DebugException;
|
||||||
import org.eclipse.debug.core.ILaunchConfiguration;
|
import org.eclipse.debug.core.ILaunchConfiguration;
|
||||||
import org.eclipse.debug.core.Launch;
|
import org.eclipse.debug.core.Launch;
|
||||||
|
@ -32,23 +30,38 @@ import org.eclipse.debug.core.model.ISourceLocator;
|
||||||
import org.eclipse.debug.core.model.ITerminate;
|
import org.eclipse.debug.core.model.ITerminate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A DSF-based debugger has to override the base launch class in order to
|
* The PDA launch object. In general, a DSF-based debugger has to override
|
||||||
* supply its own content providers for the debug view.
|
* the base launch class in order to supply its own content providers for the
|
||||||
|
* debug view. Additionally, the PDA launch is used to monitor the state of the
|
||||||
|
* PDA debugger and to shutdown the DSF services and session belonging to the
|
||||||
|
* launch.
|
||||||
|
* <p>
|
||||||
|
* The PDA launch class mostly contains methods and fields that can be accessed
|
||||||
|
* on any thread. However, some fields and methods used for managing the DSF
|
||||||
|
* session need to be synchronized using the DSF executor.
|
||||||
|
* </p>
|
||||||
*/
|
*/
|
||||||
@ThreadSafe
|
@ThreadSafe
|
||||||
public class PDALaunch extends Launch
|
public class PDALaunch extends Launch
|
||||||
implements ITerminate
|
implements ITerminate
|
||||||
{
|
{
|
||||||
|
// DSF executor and session. Both are created and shutdown by the launch.
|
||||||
private final DefaultDsfExecutor fExecutor;
|
private final DefaultDsfExecutor fExecutor;
|
||||||
private final DsfSession fSession;
|
private final DsfSession fSession;
|
||||||
|
|
||||||
@ConfinedToDsfExecutor("getSession().getExecutor()")
|
// Objects used to track the status of the DSF session.
|
||||||
private DsfServicesTracker fTracker;
|
|
||||||
|
|
||||||
private Sequence fInitializationSequence = null;
|
private Sequence fInitializationSequence = null;
|
||||||
private boolean fInitialized = false;
|
private boolean fInitialized = false;
|
||||||
private boolean fShutDown = false;
|
private boolean fShutDown = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Launch constructor creates the launch for given parameters. The
|
||||||
|
* constructor also creates a DSF session and an executor, so that
|
||||||
|
* {@link #getSession()} returns a valid value, however no services
|
||||||
|
* are initialized yet.
|
||||||
|
*
|
||||||
|
* @see Launch
|
||||||
|
*/
|
||||||
public PDALaunch(ILaunchConfiguration launchConfiguration, String mode, ISourceLocator locator) {
|
public PDALaunch(ILaunchConfiguration launchConfiguration, String mode, ISourceLocator locator) {
|
||||||
super(launchConfiguration, mode, locator);
|
super(launchConfiguration, mode, locator);
|
||||||
|
|
||||||
|
@ -60,34 +73,68 @@ public class PDALaunch extends Launch
|
||||||
fSession = DsfSession.startSession(fExecutor, PDAPlugin.ID_PDA_DEBUG_MODEL);
|
fSession = DsfSession.startSession(fExecutor, PDAPlugin.ID_PDA_DEBUG_MODEL);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DsfExecutor getDsfExecutor() { return fExecutor; }
|
/**
|
||||||
|
* Returns the DSF services session that belongs to this launch. This
|
||||||
|
* method will always return a DsfSession object, however if the debugger
|
||||||
|
* is shut down, the session will no longer active.
|
||||||
|
*/
|
||||||
public DsfSession getSession() { return fSession; }
|
public DsfSession getSession() { return fSession; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the DSF services using the specified parameters. This
|
||||||
|
* method has to be called on the executor thread in order to avoid
|
||||||
|
* synchronization issues.
|
||||||
|
*/
|
||||||
@ConfinedToDsfExecutor("getSession().getExecutor()")
|
@ConfinedToDsfExecutor("getSession().getExecutor()")
|
||||||
public void initializeServices(String program, int requestPort, int eventPort, final RequestMonitor rm)
|
public void initializeServices(String program, int requestPort, int eventPort, final RequestMonitor rm)
|
||||||
{
|
{
|
||||||
fTracker = new DsfServicesTracker(PDAPlugin.getBundleContext(), fSession.getId());
|
// Double-check that we're being called in the correct thread.
|
||||||
|
assert fExecutor.isInExecutorThread();
|
||||||
|
|
||||||
|
// Check if shutdownServices() was called already, which would be
|
||||||
|
// highly unusual, but if so we don't need to do anything except set
|
||||||
|
// the initialized flag.
|
||||||
|
synchronized(this) {
|
||||||
|
if (fShutDown) {
|
||||||
|
fInitialized = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Register the launch as listener for services events.
|
||||||
fSession.addServiceEventListener(PDALaunch.this, null);
|
fSession.addServiceEventListener(PDALaunch.this, null);
|
||||||
|
|
||||||
|
// Initialize the fInitializationSequence attribute in a synchronized
|
||||||
|
// block, because it may be accessed in another thread by shutdown().
|
||||||
|
// The initialization sequence is stored in a field to allow it to be
|
||||||
|
// canceled if shutdownServices() is called before the sequence
|
||||||
|
// completes.
|
||||||
synchronized(this) {
|
synchronized(this) {
|
||||||
fInitializationSequence = new PDAServicesInitSequence(
|
fInitializationSequence = new PDAServicesInitSequence(
|
||||||
getSession(), this, program, requestPort, eventPort,
|
getSession(), program, requestPort, eventPort,
|
||||||
new RequestMonitor(ImmediateExecutor.getInstance(), rm) {
|
new RequestMonitor(ImmediateExecutor.getInstance(), rm) {
|
||||||
@Override
|
@Override
|
||||||
protected void handleCompleted() {
|
protected void handleCompleted() {
|
||||||
|
// Set the initialized flag and check whether the
|
||||||
|
// shutdown flag is set. Access the flags in a
|
||||||
|
// synchronized section as these flags can be accessed
|
||||||
|
// on any thread.
|
||||||
boolean doShutdown = false;
|
boolean doShutdown = false;
|
||||||
synchronized (this)
|
synchronized (this) {
|
||||||
{
|
|
||||||
fInitialized = true;
|
fInitialized = true;
|
||||||
fInitializationSequence = null;
|
fInitializationSequence = null;
|
||||||
if (fShutDown) {
|
if (fShutDown) {
|
||||||
doShutdown = true;
|
doShutdown = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (doShutdown) {
|
if (doShutdown) {
|
||||||
|
// If shutdownServices() was already called, start the
|
||||||
|
// shutdown sequence now.
|
||||||
doShutdown(rm);
|
doShutdown(rm);
|
||||||
} else {
|
} else {
|
||||||
|
// If there was an error in the startup sequence,
|
||||||
|
// report the error to the client.
|
||||||
if (getStatus().getSeverity() == IStatus.ERROR) {
|
if (getStatus().getSeverity() == IStatus.ERROR) {
|
||||||
rm.setStatus(getStatus());
|
rm.setStatus(getStatus());
|
||||||
}
|
}
|
||||||
|
@ -97,18 +144,30 @@ public class PDALaunch extends Launch
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Finally, execute the sequence.
|
||||||
getSession().getExecutor().execute(fInitializationSequence);
|
getSession().getExecutor().execute(fInitializationSequence);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event handler for a debugger terminated event.
|
||||||
|
*/
|
||||||
@DsfServiceEventHandler
|
@DsfServiceEventHandler
|
||||||
public void eventDispatched(PDATerminatedEvent event) {
|
public void eventDispatched(PDATerminatedEvent event) {
|
||||||
shutdownServices(new RequestMonitor(ImmediateExecutor.getInstance(), null));
|
shutdownServices(new RequestMonitor(ImmediateExecutor.getInstance(), null));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether the DSF service initialization sequence has completed yet.
|
||||||
|
*/
|
||||||
public synchronized boolean isInitialized() {
|
public synchronized boolean isInitialized() {
|
||||||
return fInitialized;
|
return fInitialized;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether the DSF services have been set to shut down.
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public synchronized boolean isShutDown() {
|
public synchronized boolean isShutDown() {
|
||||||
return fShutDown;
|
return fShutDown;
|
||||||
}
|
}
|
||||||
|
@ -144,9 +203,13 @@ public class PDALaunch extends Launch
|
||||||
*/
|
*/
|
||||||
@ConfinedToDsfExecutor("getSession().getExecutor()")
|
@ConfinedToDsfExecutor("getSession().getExecutor()")
|
||||||
public void shutdownServices(final RequestMonitor rm) {
|
public void shutdownServices(final RequestMonitor rm) {
|
||||||
|
// Check initialize and shutdown flags to determine if the shutdown
|
||||||
|
// sequence can be called yet.
|
||||||
boolean doShutdown = false;
|
boolean doShutdown = false;
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
if (!fInitialized && fInitializationSequence != null) {
|
if (!fInitialized && fInitializationSequence != null) {
|
||||||
|
// Launch has not yet initialized, try to cancel the
|
||||||
|
// shutdown sequence.
|
||||||
fInitializationSequence.cancel(false);
|
fInitializationSequence.cancel(false);
|
||||||
} else {
|
} else {
|
||||||
doShutdown = !fShutDown && fInitialized;
|
doShutdown = !fShutDown && fInitialized;
|
||||||
|
@ -164,7 +227,7 @@ public class PDALaunch extends Launch
|
||||||
@ConfinedToDsfExecutor("getSession().getExecutor()")
|
@ConfinedToDsfExecutor("getSession().getExecutor()")
|
||||||
private void doShutdown(final RequestMonitor rm) {
|
private void doShutdown(final RequestMonitor rm) {
|
||||||
fExecutor.execute( new PDAServicesShutdownSequence(
|
fExecutor.execute( new PDAServicesShutdownSequence(
|
||||||
getDsfExecutor(), fSession.getId(),
|
fExecutor, fSession.getId(),
|
||||||
new RequestMonitor(fSession.getExecutor(), rm) {
|
new RequestMonitor(fSession.getExecutor(), rm) {
|
||||||
@Override
|
@Override
|
||||||
public void handleCompleted() {
|
public void handleCompleted() {
|
||||||
|
@ -174,8 +237,6 @@ public class PDALaunch extends Launch
|
||||||
PDAPlugin.PLUGIN_ID, -1, new IStatus[]{getStatus()}, "Session shutdown failed", null)); //$NON-NLS-1$
|
PDAPlugin.PLUGIN_ID, -1, new IStatus[]{getStatus()}, "Session shutdown failed", null)); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
// Last order of business, shutdown the dispatch queue.
|
// Last order of business, shutdown the dispatch queue.
|
||||||
fTracker.dispose();
|
|
||||||
fTracker = null;
|
|
||||||
DsfSession.endSession(fSession);
|
DsfSession.endSession(fSession);
|
||||||
// endSession takes a full dispatch to distribute the
|
// endSession takes a full dispatch to distribute the
|
||||||
// session-ended event, finish step only after the dispatch.
|
// session-ended event, finish step only after the dispatch.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2005, 2007 IBM Corporation and others.
|
* Copyright (c) 2005, 2008 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -8,6 +8,7 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Corporation - initial API and implementation
|
* IBM Corporation - initial API and implementation
|
||||||
* Bjorn Freeman-Benson - initial API and implementation
|
* Bjorn Freeman-Benson - initial API and implementation
|
||||||
|
* Wind River Systems - adopted to use with DSF
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.dd.examples.pda.launch;
|
package org.eclipse.dd.examples.pda.launch;
|
||||||
|
|
||||||
|
@ -59,9 +60,13 @@ public class PDALaunchDelegate extends LaunchConfigurationDelegate {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean buildForLaunch(ILaunchConfiguration configuration, String mode, IProgressMonitor monitor) throws CoreException {
|
public boolean buildForLaunch(ILaunchConfiguration configuration, String mode, IProgressMonitor monitor) throws CoreException {
|
||||||
|
// PDA programs do not require building.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a source locator created based on the attributes in the launch configuration.
|
||||||
|
*/
|
||||||
private ISourceLocator getSourceLocator(ILaunchConfiguration configuration) throws CoreException {
|
private ISourceLocator getSourceLocator(ILaunchConfiguration configuration) throws CoreException {
|
||||||
String type = configuration.getAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_ID, (String)null);
|
String type = configuration.getAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_ID, (String)null);
|
||||||
if (type == null) {
|
if (type == null) {
|
||||||
|
@ -83,12 +88,7 @@ public class PDALaunchDelegate extends LaunchConfigurationDelegate {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.debug.core.model.ILaunchConfigurationDelegate#launch(org.eclipse.debug.core.ILaunchConfiguration, java.lang.String, org.eclipse.debug.core.ILaunch, org.eclipse.core.runtime.IProgressMonitor)
|
|
||||||
*/
|
|
||||||
public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
|
public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
|
||||||
|
|
||||||
String program = configuration.getAttribute(PDAPlugin.ATTR_PDA_PROGRAM, (String)null);
|
String program = configuration.getAttribute(PDAPlugin.ATTR_PDA_PROGRAM, (String)null);
|
||||||
if (program == null) {
|
if (program == null) {
|
||||||
abort("Perl program unspecified.", null);
|
abort("Perl program unspecified.", null);
|
||||||
|
@ -105,10 +105,20 @@ public class PDALaunchDelegate extends LaunchConfigurationDelegate {
|
||||||
initServices(pdaLaunch, program, requestPort, eventPort);
|
initServices(pdaLaunch, program, requestPort, eventPort);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Launches PDA interpreter with the given program.
|
||||||
|
*
|
||||||
|
* @param launch Launch that will contain the new process.
|
||||||
|
* @param program PDA program to use in the interpreter.
|
||||||
|
* @param requestPort The port number for connecting the request socket.
|
||||||
|
* @param eventPort The port number for connecting the events socket.
|
||||||
|
*
|
||||||
|
* @throws CoreException
|
||||||
|
*/
|
||||||
private void launchProcess(ILaunch launch, String program, int requestPort, int eventPort) throws CoreException {
|
private void launchProcess(ILaunch launch, String program, int requestPort, int eventPort) throws CoreException {
|
||||||
List<String> commandList = new ArrayList<String>();
|
List<String> commandList = new ArrayList<String>();
|
||||||
|
|
||||||
// Perl executable
|
// Find Perl executable
|
||||||
IValueVariable perl = VariablesPlugin.getDefault().getStringVariableManager().getValueVariable(PDAPlugin.VARIALBE_PERL_EXECUTABLE);
|
IValueVariable perl = VariablesPlugin.getDefault().getStringVariableManager().getValueVariable(PDAPlugin.VARIALBE_PERL_EXECUTABLE);
|
||||||
if (perl == null) {
|
if (perl == null) {
|
||||||
abort("Perl executable location undefined. Check value of ${dsfPerlExecutable}.", null);
|
abort("Perl executable location undefined. Check value of ${dsfPerlExecutable}.", null);
|
||||||
|
@ -130,6 +140,7 @@ public class PDALaunchDelegate extends LaunchConfigurationDelegate {
|
||||||
}
|
}
|
||||||
commandList.add(vm.getAbsolutePath());
|
commandList.add(vm.getAbsolutePath());
|
||||||
|
|
||||||
|
// Add PDA program
|
||||||
IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(program));
|
IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(program));
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
abort(MessageFormat.format("Perl program {0} does not exist.", new Object[] {file.getFullPath().toString()}), null);
|
abort(MessageFormat.format("Perl program {0} does not exist.", new Object[] {file.getFullPath().toString()}), null);
|
||||||
|
@ -137,19 +148,26 @@ public class PDALaunchDelegate extends LaunchConfigurationDelegate {
|
||||||
|
|
||||||
commandList.add(file.getLocation().toOSString());
|
commandList.add(file.getLocation().toOSString());
|
||||||
|
|
||||||
// add debug arguments - i.e. '-debug requestPort eventPort'
|
// Add debug arguments - i.e. '-debug requestPort eventPort'
|
||||||
commandList.add("-debug");
|
commandList.add("-debug");
|
||||||
commandList.add("" + requestPort);
|
commandList.add("" + requestPort);
|
||||||
commandList.add("" + eventPort);
|
commandList.add("" + eventPort);
|
||||||
|
|
||||||
|
// Launch the perl process.
|
||||||
String[] commandLine = commandList.toArray(new String[commandList.size()]);
|
String[] commandLine = commandList.toArray(new String[commandList.size()]);
|
||||||
Process process = DebugPlugin.exec(commandLine, null);
|
Process process = DebugPlugin.exec(commandLine, null);
|
||||||
|
|
||||||
|
// Create a debug platform process object and add it to the launch.
|
||||||
DebugPlugin.newProcess(launch, process, path);
|
DebugPlugin.newProcess(launch, process, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calls the launch to initialize DSF services for this launch.
|
||||||
|
*/
|
||||||
private void initServices(final PDALaunch pdaLaunch, final String program, final int requestPort, final int eventPort)
|
private void initServices(final PDALaunch pdaLaunch, final String program, final int requestPort, final int eventPort)
|
||||||
throws CoreException
|
throws CoreException
|
||||||
{
|
{
|
||||||
|
// Synchronization object to use when waiting for the services initialization.
|
||||||
Query<Object> initQuery = new Query<Object>() {
|
Query<Object> initQuery = new Query<Object>() {
|
||||||
@Override
|
@Override
|
||||||
protected void execute(DataRequestMonitor<Object> rm) {
|
protected void execute(DataRequestMonitor<Object> rm) {
|
||||||
|
@ -157,8 +175,10 @@ public class PDALaunchDelegate extends LaunchConfigurationDelegate {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Submit the query to the executor.
|
||||||
pdaLaunch.getSession().getExecutor().execute(initQuery);
|
pdaLaunch.getSession().getExecutor().execute(initQuery);
|
||||||
try {
|
try {
|
||||||
|
// Block waiting for query results.
|
||||||
initQuery.get();
|
initQuery.get();
|
||||||
} catch (InterruptedException e1) {
|
} catch (InterruptedException e1) {
|
||||||
throw new DebugException(new Status(IStatus.ERROR, PDAPlugin.PLUGIN_ID, DebugException.INTERNAL_ERROR, "Interrupted Exception in dispatch thread", e1)); //$NON-NLS-1$
|
throw new DebugException(new Status(IStatus.ERROR, PDAPlugin.PLUGIN_ID, DebugException.INTERNAL_ERROR, "Interrupted Exception in dispatch thread", e1)); //$NON-NLS-1$
|
||||||
|
@ -181,8 +201,6 @@ public class PDALaunchDelegate extends LaunchConfigurationDelegate {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a free port number on localhost, or -1 if unable to find a free port.
|
* Returns a free port number on localhost, or -1 if unable to find a free port.
|
||||||
*
|
|
||||||
* @return a free port number on localhost, or -1 if unable to find a free port
|
|
||||||
*/
|
*/
|
||||||
public static int findFreePort() {
|
public static int findFreePort() {
|
||||||
ServerSocket socket= null;
|
ServerSocket socket= null;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2006 Wind River Systems and others.
|
* Copyright (c) 2008 Wind River Systems and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -15,29 +15,46 @@ import org.eclipse.dd.dsf.concurrent.Sequence;
|
||||||
import org.eclipse.dd.dsf.debug.service.BreakpointsMediator;
|
import org.eclipse.dd.dsf.debug.service.BreakpointsMediator;
|
||||||
import org.eclipse.dd.dsf.debug.service.StepQueueManager;
|
import org.eclipse.dd.dsf.debug.service.StepQueueManager;
|
||||||
import org.eclipse.dd.dsf.service.DsfSession;
|
import org.eclipse.dd.dsf.service.DsfSession;
|
||||||
import org.eclipse.dd.examples.pda.service.breakpoints.PDABreakpointAttributeTranslator;
|
import org.eclipse.dd.examples.pda.service.PDABreakpointAttributeTranslator;
|
||||||
import org.eclipse.dd.examples.pda.service.breakpoints.PDABreakpoints;
|
import org.eclipse.dd.examples.pda.service.PDABreakpoints;
|
||||||
import org.eclipse.dd.examples.pda.service.command.PDACommandControl;
|
import org.eclipse.dd.examples.pda.service.PDACommandControl;
|
||||||
import org.eclipse.dd.examples.pda.service.expressions.PDAExpressions;
|
import org.eclipse.dd.examples.pda.service.PDAExpressions;
|
||||||
import org.eclipse.dd.examples.pda.service.runcontrol.PDARunControl;
|
import org.eclipse.dd.examples.pda.service.PDARunControl;
|
||||||
import org.eclipse.dd.examples.pda.service.stack.PDAStack;
|
import org.eclipse.dd.examples.pda.service.PDAStack;
|
||||||
import org.eclipse.debug.examples.core.pda.sourcelookup.PDASourceLookupDirector;
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The initialization sequence for PDA debugger services. This sequence contains
|
||||||
|
* the series of steps that are executed to properly initialize the PDA-DSF debug
|
||||||
|
* session. If any of the individual steps fail, the initialization will abort.
|
||||||
|
* <p>
|
||||||
|
* The order in which services are initialized is important. Some services depend
|
||||||
|
* on other services and they assume that they will be initialized only if those
|
||||||
|
* services are active. Also the service events are prioritized and their priority
|
||||||
|
* depends on the order in which the services were initialized.
|
||||||
|
* </p>
|
||||||
|
*/
|
||||||
public class PDAServicesInitSequence extends Sequence {
|
public class PDAServicesInitSequence extends Sequence {
|
||||||
|
|
||||||
Step[] fSteps = new Step[] {
|
Step[] fSteps = new Step[] {
|
||||||
// Create and initialize the Connection service.
|
new Step()
|
||||||
new Step() {
|
{
|
||||||
@Override
|
@Override
|
||||||
public void execute(RequestMonitor requestMonitor) {
|
public void execute(RequestMonitor requestMonitor) {
|
||||||
// Create the connection.
|
// Create the connection to PDA debugger.
|
||||||
fCommandControl = new PDACommandControl(fSession, fRequestPort, fEventPort);
|
fCommandControl = new PDACommandControl(fSession, fProgram, fRequestPort, fEventPort);
|
||||||
fCommandControl.initialize(requestMonitor);
|
fCommandControl.initialize(requestMonitor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void rollBack(RequestMonitor rm) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
super.rollBack(rm);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
new Step() {
|
new Step() {
|
||||||
@Override
|
@Override
|
||||||
public void execute(RequestMonitor requestMonitor) {
|
public void execute(RequestMonitor requestMonitor) {
|
||||||
|
// Start the run control service.
|
||||||
fRunControl = new PDARunControl(fSession);
|
fRunControl = new PDARunControl(fSession);
|
||||||
fRunControl.initialize(requestMonitor);
|
fRunControl.initialize(requestMonitor);
|
||||||
}
|
}
|
||||||
|
@ -45,62 +62,65 @@ public class PDAServicesInitSequence extends Sequence {
|
||||||
new Step() {
|
new Step() {
|
||||||
@Override
|
@Override
|
||||||
public void execute(RequestMonitor requestMonitor) {
|
public void execute(RequestMonitor requestMonitor) {
|
||||||
|
// Start the service to manage step actions.
|
||||||
new StepQueueManager(fSession).initialize(requestMonitor);
|
new StepQueueManager(fSession).initialize(requestMonitor);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
new Step() {
|
new Step() {
|
||||||
@Override
|
@Override
|
||||||
public void execute(final RequestMonitor requestMonitor) {
|
public void execute(final RequestMonitor requestMonitor) {
|
||||||
// Create the low-level breakpoint service
|
// Start the low-level breakpoint service
|
||||||
new PDABreakpoints(fSession, fProgram).initialize(new RequestMonitor(getExecutor(), requestMonitor));
|
new PDABreakpoints(fSession).initialize(new RequestMonitor(getExecutor(), requestMonitor));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
new Step() {
|
new Step() {
|
||||||
@Override
|
@Override
|
||||||
public void execute(final RequestMonitor requestMonitor) {
|
public void execute(final RequestMonitor requestMonitor) {
|
||||||
|
// Create the breakpoint mediator and start tracking PDA breakpoints.
|
||||||
|
|
||||||
final BreakpointsMediator bpmService = new BreakpointsMediator(
|
final BreakpointsMediator bpmService = new BreakpointsMediator(
|
||||||
fSession, new PDABreakpointAttributeTranslator());
|
fSession, new PDABreakpointAttributeTranslator());
|
||||||
bpmService.initialize(new RequestMonitor(getExecutor(), requestMonitor) {
|
bpmService.initialize(new RequestMonitor(getExecutor(), requestMonitor) {
|
||||||
@Override
|
@Override
|
||||||
protected void handleOK() {
|
protected void handleOK() {
|
||||||
bpmService.startTrackingBreakpoints(fCommandControl.getDMContext(), requestMonitor);
|
bpmService.startTrackingBreakpoints(fCommandControl.getProgramDMContext(), requestMonitor);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
new Step() { @Override
|
new Step() { @Override
|
||||||
public void execute(RequestMonitor requestMonitor) {
|
public void execute(RequestMonitor requestMonitor) {
|
||||||
|
// Start the stack service.
|
||||||
new PDAStack(fSession).initialize(requestMonitor);
|
new PDAStack(fSession).initialize(requestMonitor);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
new Step() { @Override
|
new Step() { @Override
|
||||||
public void execute(RequestMonitor requestMonitor) {
|
public void execute(RequestMonitor requestMonitor) {
|
||||||
|
// Start the service to track expressions.
|
||||||
new PDAExpressions(fSession).initialize(requestMonitor);
|
new PDAExpressions(fSession).initialize(requestMonitor);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
new Step() { @Override
|
new Step() { @Override
|
||||||
public void execute(RequestMonitor requestMonitor) {
|
public void execute(RequestMonitor requestMonitor) {
|
||||||
fRunControl.resume(fCommandControl.getDMContext(), requestMonitor);
|
fRunControl.resume(fCommandControl.getProgramDMContext(), requestMonitor);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Sequence input parameters, used in initializing services.
|
||||||
private DsfSession fSession;
|
private DsfSession fSession;
|
||||||
private PDALaunch fLaunch;
|
|
||||||
private String fProgram;
|
private String fProgram;
|
||||||
private int fRequestPort;
|
private int fRequestPort;
|
||||||
private int fEventPort;
|
private int fEventPort;
|
||||||
|
|
||||||
PDACommandControl fCommandControl;
|
// Service references, initialized when created and used in initializing other services.
|
||||||
PDARunControl fRunControl;
|
private PDACommandControl fCommandControl;
|
||||||
PDASourceLookupDirector fSourceLookup;
|
private PDARunControl fRunControl;
|
||||||
|
|
||||||
public PDAServicesInitSequence(DsfSession session, PDALaunch launch, String program, int requestPort,
|
public PDAServicesInitSequence(DsfSession session, String program, int requestPort, int eventPort, RequestMonitor rm)
|
||||||
int eventPort, RequestMonitor rm)
|
|
||||||
{
|
{
|
||||||
super(session.getExecutor(), rm);
|
super(session.getExecutor(), rm);
|
||||||
fSession = session;
|
fSession = session;
|
||||||
fLaunch = launch;
|
|
||||||
fProgram = program;
|
fProgram = program;
|
||||||
fRequestPort = requestPort;
|
fRequestPort = requestPort;
|
||||||
fEventPort = eventPort;
|
fEventPort = eventPort;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2006 Wind River Systems and others.
|
* Copyright (c) 2008 Wind River Systems and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -20,30 +20,27 @@ import org.eclipse.dd.dsf.debug.service.StepQueueManager;
|
||||||
import org.eclipse.dd.dsf.service.DsfServicesTracker;
|
import org.eclipse.dd.dsf.service.DsfServicesTracker;
|
||||||
import org.eclipse.dd.dsf.service.IDsfService;
|
import org.eclipse.dd.dsf.service.IDsfService;
|
||||||
import org.eclipse.dd.examples.pda.PDAPlugin;
|
import org.eclipse.dd.examples.pda.PDAPlugin;
|
||||||
import org.eclipse.dd.examples.pda.service.breakpoints.PDABreakpoints;
|
import org.eclipse.dd.examples.pda.service.PDABreakpoints;
|
||||||
import org.eclipse.dd.examples.pda.service.command.PDACommandControl;
|
import org.eclipse.dd.examples.pda.service.PDACommandControl;
|
||||||
import org.eclipse.dd.examples.pda.service.expressions.PDAExpressions;
|
import org.eclipse.dd.examples.pda.service.PDAExpressions;
|
||||||
import org.eclipse.dd.examples.pda.service.runcontrol.PDARunControl;
|
import org.eclipse.dd.examples.pda.service.PDARunControl;
|
||||||
import org.eclipse.dd.examples.pda.service.stack.PDAStack;
|
import org.eclipse.dd.examples.pda.service.PDAStack;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The shutdown sequence for PDA debugger services. This sequence contains
|
||||||
|
* the series of steps that are executed to properly shutdown the PDA-DSF debug
|
||||||
|
* session. If any of the individual steps fail, the shutdown will abort.
|
||||||
|
* <p>
|
||||||
|
* Services are shut down in the reverse order of initialization.
|
||||||
|
* </p>
|
||||||
|
*/
|
||||||
public class PDAServicesShutdownSequence extends Sequence {
|
public class PDAServicesShutdownSequence extends Sequence {
|
||||||
|
|
||||||
String fSessionId;
|
private final Step[] fSteps = new Step[] {
|
||||||
DsfServicesTracker fTracker;
|
new Step() {
|
||||||
|
|
||||||
public PDAServicesShutdownSequence(DsfExecutor executor, String sessionId, RequestMonitor requestMonitor) {
|
|
||||||
super(executor, requestMonitor);
|
|
||||||
fSessionId = sessionId;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Step[] getSteps() {
|
|
||||||
return fSteps;
|
|
||||||
}
|
|
||||||
|
|
||||||
private final Step[] fSteps = new Step[] { new Step() {
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(RequestMonitor requestMonitor) {
|
public void execute(RequestMonitor requestMonitor) {
|
||||||
|
// Initialize services tracker.
|
||||||
assert PDAPlugin.getBundleContext() != null;
|
assert PDAPlugin.getBundleContext() != null;
|
||||||
fTracker = new DsfServicesTracker(PDAPlugin.getBundleContext(), fSessionId);
|
fTracker = new DsfServicesTracker(PDAPlugin.getBundleContext(), fSessionId);
|
||||||
requestMonitor.done();
|
requestMonitor.done();
|
||||||
|
@ -51,32 +48,13 @@ public class PDAServicesShutdownSequence extends Sequence {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void rollBack(RequestMonitor requestMonitor) {
|
public void rollBack(RequestMonitor requestMonitor) {
|
||||||
|
// In case the shutdown sequence aborts, ensure that the
|
||||||
|
// tracker is properly disposed.
|
||||||
fTracker.dispose();
|
fTracker.dispose();
|
||||||
fTracker = null;
|
fTracker = null;
|
||||||
requestMonitor.done();
|
requestMonitor.done();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
/* new Step() {
|
|
||||||
@Override
|
|
||||||
public void execute(RequestMonitor requestMonitor) {
|
|
||||||
shutdownService(MIRegisters.class, requestMonitor);
|
|
||||||
}
|
|
||||||
}, new Step() {
|
|
||||||
@Override
|
|
||||||
public void execute(RequestMonitor requestMonitor) {
|
|
||||||
shutdownService(MIBreakpointsManager.class, requestMonitor);
|
|
||||||
}
|
|
||||||
}, new Step() {
|
|
||||||
@Override
|
|
||||||
public void execute(RequestMonitor requestMonitor) {
|
|
||||||
shutdownService(MIBreakpoints.class, requestMonitor);
|
|
||||||
}
|
|
||||||
}, new Step() {
|
|
||||||
@Override
|
|
||||||
public void execute(RequestMonitor requestMonitor) {
|
|
||||||
shutdownService(CSourceLookup.class, requestMonitor);
|
|
||||||
}
|
|
||||||
},*/
|
|
||||||
new Step() {
|
new Step() {
|
||||||
@Override
|
@Override
|
||||||
public void execute(RequestMonitor requestMonitor) {
|
public void execute(RequestMonitor requestMonitor) {
|
||||||
|
@ -125,7 +103,21 @@ public class PDAServicesShutdownSequence extends Sequence {
|
||||||
fTracker = null;
|
fTracker = null;
|
||||||
requestMonitor.done();
|
requestMonitor.done();
|
||||||
}
|
}
|
||||||
} };
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
private String fSessionId;
|
||||||
|
private DsfServicesTracker fTracker;
|
||||||
|
|
||||||
|
public PDAServicesShutdownSequence(DsfExecutor executor, String sessionId, RequestMonitor requestMonitor) {
|
||||||
|
super(executor, requestMonitor);
|
||||||
|
fSessionId = sessionId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Step[] getSteps() {
|
||||||
|
return fSteps;
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private void shutdownService(Class clazz, final RequestMonitor requestMonitor) {
|
private void shutdownService(Class clazz, final RequestMonitor requestMonitor) {
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Wind River Systems - initial API and implementation
|
* Wind River Systems - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.dd.examples.pda.service.breakpoints;
|
package org.eclipse.dd.examples.pda.service;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -29,22 +29,33 @@ import org.eclipse.debug.core.DebugException;
|
||||||
import org.eclipse.debug.core.model.IBreakpoint;
|
import org.eclipse.debug.core.model.IBreakpoint;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Translator between {@link PDALineBreakpoint} object attributes and
|
||||||
|
* attributes used by the {@link PDABreakpoints} service.
|
||||||
|
* <p>
|
||||||
|
* The attribute translator is used by the standard {@link BreakpointsMediator}
|
||||||
|
* service to map between platform breakpoint attributes and target-side DSF
|
||||||
|
* breakpoint attributes. Thus, this object encapsulates the model-specific
|
||||||
|
* functionality of synchronizing target side and IDE-side breakpoint objects.
|
||||||
|
* </p>
|
||||||
*/
|
*/
|
||||||
public class PDABreakpointAttributeTranslator implements IBreakpointAttributeTranslator {
|
public class PDABreakpointAttributeTranslator implements IBreakpointAttributeTranslator {
|
||||||
|
|
||||||
|
// Arrays of common attributes between the two breakpoint types. These
|
||||||
|
// attributes can be copied directly without translation.
|
||||||
private static final String[] fgPDALineBreakpointAttributes = {
|
private static final String[] fgPDALineBreakpointAttributes = {
|
||||||
|
IBreakpoint.ENABLED,
|
||||||
IMarker.LINE_NUMBER,
|
IMarker.LINE_NUMBER,
|
||||||
};
|
};
|
||||||
|
|
||||||
private static final String[] fgPDAWatchpointAttributes = {
|
private static final String[] fgPDAWatchpointAttributes = {
|
||||||
|
IBreakpoint.ENABLED,
|
||||||
PDAWatchpoint.FUNCTION_NAME,
|
PDAWatchpoint.FUNCTION_NAME,
|
||||||
PDAWatchpoint.VAR_NAME,
|
PDAWatchpoint.VAR_NAME,
|
||||||
PDAWatchpoint.ACCESS,
|
PDAWatchpoint.ACCESS,
|
||||||
PDAWatchpoint.MODIFICATION
|
PDAWatchpoint.MODIFICATION
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// PDA breakpoints translator doesn't keep any state and it doesn't
|
||||||
|
// need to initialize or clean up.
|
||||||
public void initialize(BreakpointsMediator mediator) {
|
public void initialize(BreakpointsMediator mediator) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,15 +67,19 @@ public class PDABreakpointAttributeTranslator implements IBreakpointAttributeTra
|
||||||
{
|
{
|
||||||
Map<String, Object> attrs = new HashMap<String, Object>();
|
Map<String, Object> attrs = new HashMap<String, Object>();
|
||||||
|
|
||||||
|
// Check that the marker exists and retrieve its attributes.
|
||||||
|
// Due to accepted race conditions, the breakpiont marker may become null
|
||||||
|
// while this method is being invoked. In this case throw an exception
|
||||||
|
// and let the caller handle it.
|
||||||
IMarker marker = bp.getMarker();
|
IMarker marker = bp.getMarker();
|
||||||
if (marker == null || !marker.exists()) {
|
if (marker == null || !marker.exists()) {
|
||||||
throw new DebugException(new Status(IStatus.ERROR, PDAPlugin.PLUGIN_ID, DebugException.REQUEST_FAILED, "Breakpoint marker does not exist", null));
|
throw new DebugException(new Status(IStatus.ERROR, PDAPlugin.PLUGIN_ID, DebugException.REQUEST_FAILED, "Breakpoint marker does not exist", null));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Suppress cast warning: platform is still on Java 1.3
|
// Suppress cast warning: platform is still on Java 1.3
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
Map<String, Object> platformBpAttrs = marker.getAttributes();
|
Map<String, Object> platformBpAttrs = marker.getAttributes();
|
||||||
|
|
||||||
|
// Copy breakpoint attributes.
|
||||||
if (bp instanceof PDAWatchpoint) {
|
if (bp instanceof PDAWatchpoint) {
|
||||||
attrs.put(PDABreakpoints.ATTR_BREAKPOINT_TYPE, PDABreakpoints.PDA_WATCHPOINT);
|
attrs.put(PDABreakpoints.ATTR_BREAKPOINT_TYPE, PDABreakpoints.PDA_WATCHPOINT);
|
||||||
|
|
||||||
|
@ -81,6 +96,9 @@ public class PDABreakpointAttributeTranslator implements IBreakpointAttributeTra
|
||||||
attrs.put(IBreakpoint.ENABLED, false);
|
attrs.put(IBreakpoint.ENABLED, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The breakpoint mediator allows for multiple target-side breakpoints
|
||||||
|
// to be created for each IDE breakpoint. Although in case of PDA this
|
||||||
|
// feature is never used, we still have to return a list of attributes.
|
||||||
List<Map<String, Object>> retVal = new ArrayList<Map<String, Object>>(1);
|
List<Map<String, Object>> retVal = new ArrayList<Map<String, Object>>(1);
|
||||||
retVal.add(attrs);
|
retVal.add(attrs);
|
||||||
return retVal;
|
return retVal;
|
||||||
|
@ -96,7 +114,7 @@ public class PDABreakpointAttributeTranslator implements IBreakpointAttributeTra
|
||||||
|
|
||||||
public boolean canUpdateAttributes(IBreakpointDMContext bp, Map<String, Object> delta) {
|
public boolean canUpdateAttributes(IBreakpointDMContext bp, Map<String, Object> delta) {
|
||||||
// PDA debugger only allows updating of the action property of the watchpoint.
|
// PDA debugger only allows updating of the action property of the watchpoint.
|
||||||
// All other breakpoint updates will require a reinstallation.
|
// All other breakpoint updates will require a re-installation.
|
||||||
if (bp instanceof PDAWatchpoint) {
|
if (bp instanceof PDAWatchpoint) {
|
||||||
Map<String, Object> deltaCopy = new HashMap<String, Object>(delta);
|
Map<String, Object> deltaCopy = new HashMap<String, Object>(delta);
|
||||||
deltaCopy.remove(PDAWatchpoint.ACCESS);
|
deltaCopy.remove(PDAWatchpoint.ACCESS);
|
|
@ -0,0 +1,395 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2007 Ericsson 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:
|
||||||
|
* Ericsson - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
package org.eclipse.dd.examples.pda.service;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Hashtable;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.eclipse.core.resources.IMarker;
|
||||||
|
import org.eclipse.dd.dsf.concurrent.DataRequestMonitor;
|
||||||
|
import org.eclipse.dd.dsf.concurrent.Immutable;
|
||||||
|
import org.eclipse.dd.dsf.concurrent.RequestMonitor;
|
||||||
|
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.IBreakpoints;
|
||||||
|
import org.eclipse.dd.dsf.service.AbstractDsfService;
|
||||||
|
import org.eclipse.dd.dsf.service.DsfSession;
|
||||||
|
import org.eclipse.dd.examples.pda.PDAPlugin;
|
||||||
|
import org.eclipse.dd.examples.pda.breakpoints.PDAWatchpoint;
|
||||||
|
import org.eclipse.dd.examples.pda.service.commands.PDAClearBreakpointCommand;
|
||||||
|
import org.eclipse.dd.examples.pda.service.commands.PDACommandResult;
|
||||||
|
import org.eclipse.dd.examples.pda.service.commands.PDASetBreakpointCommand;
|
||||||
|
import org.eclipse.dd.examples.pda.service.commands.PDAWatchCommand;
|
||||||
|
import org.eclipse.debug.core.model.IBreakpoint;
|
||||||
|
import org.osgi.framework.BundleContext;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initial breakpoint service implementation.
|
||||||
|
* Implements the IBreakpoints interface.
|
||||||
|
*/
|
||||||
|
public class PDABreakpoints extends AbstractDsfService implements IBreakpoints
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Context representing a PDA line breakpoint. In PDA debugger, since there is only
|
||||||
|
* one file being debugged at a time, a breakpoint is uniquely identified using the
|
||||||
|
* line number only.
|
||||||
|
*/
|
||||||
|
@Immutable
|
||||||
|
private static class BreakpointDMContext extends AbstractDMContext implements IBreakpointDMContext {
|
||||||
|
|
||||||
|
final Integer fLine;
|
||||||
|
|
||||||
|
public BreakpointDMContext(String sessionId, PDAProgramDMContext commandControlCtx, Integer line) {
|
||||||
|
super(sessionId, new IDMContext[] { commandControlCtx });
|
||||||
|
fLine = line;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
return baseEquals(obj) && (fLine.equals(((BreakpointDMContext) obj).fLine));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return baseHashCode() + fLine.hashCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return baseToString() + ".breakpoint(" + fLine + ")"; //$NON-NLS-1$//$NON-NLS-2$*/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Context representing a watch point. In PDA debugger, a watchpoint is
|
||||||
|
* uniquely identified using the function and variable.
|
||||||
|
*/
|
||||||
|
@Immutable
|
||||||
|
private static class WatchpointDMContext extends AbstractDMContext implements IBreakpointDMContext {
|
||||||
|
final String fFunction;
|
||||||
|
final String fVariable;
|
||||||
|
|
||||||
|
public WatchpointDMContext(String sessionId, PDAProgramDMContext commandControlCtx, String function,
|
||||||
|
String variable)
|
||||||
|
{
|
||||||
|
super(sessionId, new IDMContext[] { commandControlCtx });
|
||||||
|
fFunction = function;
|
||||||
|
fVariable = variable;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (baseEquals(obj)) {
|
||||||
|
WatchpointDMContext watchpointCtx = (WatchpointDMContext)obj;
|
||||||
|
return fFunction.equals(watchpointCtx.fFunction) && fVariable.equals(watchpointCtx.fVariable);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return baseHashCode() + fFunction.hashCode() + fVariable.hashCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return baseToString() + ".watchpoint(" + fFunction + "::" + fVariable + ")";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Attribute names
|
||||||
|
public static final String ATTR_BREAKPOINT_TYPE = PDAPlugin.PLUGIN_ID + ".pdaBreakpointType"; //$NON-NLS-1$
|
||||||
|
public static final String PDA_LINE_BREAKPOINT = "breakpoint"; //$NON-NLS-1$
|
||||||
|
public static final String PDA_WATCHPOINT = "watchpoint"; //$NON-NLS-1$
|
||||||
|
public static final String ATTR_PROGRAM_PATH = PDAPlugin.PLUGIN_ID + ".pdaProgramPath"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
// Services
|
||||||
|
private PDACommandControl fCommandControl;
|
||||||
|
|
||||||
|
// Breakpoints currently installed
|
||||||
|
private Set<IBreakpointDMContext> fBreakpoints = new HashSet<IBreakpointDMContext>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The service constructor
|
||||||
|
*
|
||||||
|
* @param session The debugging session this service belongs to.
|
||||||
|
*/
|
||||||
|
public PDABreakpoints(DsfSession session) {
|
||||||
|
super(session);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initialize(final RequestMonitor rm) {
|
||||||
|
super.initialize(new RequestMonitor(getExecutor(), rm) {
|
||||||
|
@Override
|
||||||
|
protected void handleOK() {
|
||||||
|
doInitialize(rm);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void doInitialize(final RequestMonitor rm) {
|
||||||
|
// Get the services references
|
||||||
|
fCommandControl = getServicesTracker().getService(PDACommandControl.class);
|
||||||
|
|
||||||
|
// Register this service
|
||||||
|
register(new String[] { IBreakpoints.class.getName(), PDABreakpoints.class.getName() },
|
||||||
|
new Hashtable<String, String>());
|
||||||
|
|
||||||
|
rm.done();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void shutdown(final RequestMonitor rm) {
|
||||||
|
unregister();
|
||||||
|
rm.done();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected BundleContext getBundleContext() {
|
||||||
|
return PDAPlugin.getBundleContext();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void getBreakpoints(final IBreakpointsTargetDMContext context, final DataRequestMonitor<IBreakpointDMContext[]> rm) {
|
||||||
|
// Validate the context
|
||||||
|
if (!fCommandControl.getProgramDMContext().equals(context)) {
|
||||||
|
PDAPlugin.failRequest(rm, INVALID_HANDLE, "Invalid breakpoints target context");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
rm.setData(fBreakpoints.toArray(new IBreakpointDMContext[fBreakpoints.size()]));
|
||||||
|
rm.done();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void getBreakpointDMData(IBreakpointDMContext dmc, DataRequestMonitor<IBreakpointDMData> rm) {
|
||||||
|
PDAPlugin.failRequest(rm, NOT_SUPPORTED, "Retrieving breakpoint data is not supported");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void insertBreakpoint(IBreakpointsTargetDMContext context, Map<String, Object> attributes,
|
||||||
|
DataRequestMonitor<IBreakpointDMContext> rm)
|
||||||
|
{
|
||||||
|
Boolean enabled = (Boolean)attributes.get(IBreakpoint.ENABLED);
|
||||||
|
if (enabled != null && !enabled.booleanValue()) {
|
||||||
|
// If the breakpoint is disabled, just fail the request.
|
||||||
|
PDAPlugin.failRequest(rm, REQUEST_FAILED, "Breakpoint is disabled");
|
||||||
|
} else {
|
||||||
|
String type = (String) attributes.get(ATTR_BREAKPOINT_TYPE);
|
||||||
|
|
||||||
|
if (PDA_LINE_BREAKPOINT.equals(type)) {
|
||||||
|
// Retrieve the PDA program context from the context given in the
|
||||||
|
// argument. This service is typically only called by the
|
||||||
|
// breakpoints mediator, which was called with the program context
|
||||||
|
// in the services initialization sequence. So checking if
|
||||||
|
// programCtx != null is mostly a formality.
|
||||||
|
PDAProgramDMContext programCtx = DMContexts.getAncestorOfType(context, PDAProgramDMContext.class);
|
||||||
|
if (programCtx != null) {
|
||||||
|
doInsertBreakpoint(programCtx, attributes, rm);
|
||||||
|
} else {
|
||||||
|
PDAPlugin.failRequest(rm, INVALID_HANDLE, "Unknown breakpoint type");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (PDA_WATCHPOINT.equals(type)) {
|
||||||
|
doInsertWatchpoint(attributes, rm);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
PDAPlugin.failRequest(rm, REQUEST_FAILED, "Unknown breakpoint type");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void doInsertBreakpoint(PDAProgramDMContext programCtx, final Map<String, Object> attributes, final DataRequestMonitor<IBreakpointDMContext> rm)
|
||||||
|
{
|
||||||
|
// Compare the program path in the breakpoint with the path in the PDA
|
||||||
|
// program context. Only insert the breakpoint if the program matches.
|
||||||
|
String program = (String)attributes.get(ATTR_PROGRAM_PATH);
|
||||||
|
if (!programCtx.getProgram().equals(program)) {
|
||||||
|
PDAPlugin.failRequest(rm, REQUEST_FAILED, "Invalid file name");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Retrieve the line.
|
||||||
|
Integer line = (Integer)attributes.get(IMarker.LINE_NUMBER);
|
||||||
|
if (line == null) {
|
||||||
|
PDAPlugin.failRequest(rm, REQUEST_FAILED, "No breakpoint line specified");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create a new breakpoint context object and check that it's not
|
||||||
|
// installed already. PDA can only track a single breakpoint at a
|
||||||
|
// given line, attempting to set the second breakpoint should fail.
|
||||||
|
final BreakpointDMContext breakpointCtx =
|
||||||
|
new BreakpointDMContext(getSession().getId(), fCommandControl.getProgramDMContext(), line);
|
||||||
|
if (fBreakpoints.contains(breakpointCtx)) {
|
||||||
|
PDAPlugin.failRequest(rm, REQUEST_FAILED, "Breakpoint already set");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add the new breakpoint context to the list of known breakpoints.
|
||||||
|
// Adding it here, before the set command is completed will prevent
|
||||||
|
// a possibility of a second breakpoint being installed in the same
|
||||||
|
// location while this breakpoint is being processed. It will also
|
||||||
|
// allow the breakpoint to be removed or updated even while it is
|
||||||
|
// still being processed here.
|
||||||
|
fBreakpoints.add(breakpointCtx);
|
||||||
|
fCommandControl.queueCommand(
|
||||||
|
new PDASetBreakpointCommand(fCommandControl.getProgramDMContext(), line),
|
||||||
|
new DataRequestMonitor<PDACommandResult>(getExecutor(), rm) {
|
||||||
|
@Override
|
||||||
|
protected void handleOK() {
|
||||||
|
rm.setData(breakpointCtx);
|
||||||
|
rm.done();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void handleErrorOrCancel() {
|
||||||
|
// If inserting of the breakpoint failed, remove it from
|
||||||
|
// the set of installed breakpoints.
|
||||||
|
fBreakpoints.remove(breakpointCtx);
|
||||||
|
super.handleErrorOrCancel();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void doInsertWatchpoint(final Map<String, Object> attributes, final DataRequestMonitor<IBreakpointDMContext> rm)
|
||||||
|
{
|
||||||
|
String function = (String)attributes.get(PDAWatchpoint.FUNCTION_NAME);
|
||||||
|
if (function == null) {
|
||||||
|
PDAPlugin.failRequest(rm, REQUEST_FAILED, "No function specified");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String variable = (String)attributes.get(PDAWatchpoint.VAR_NAME);
|
||||||
|
if (variable == null) {
|
||||||
|
PDAPlugin.failRequest(rm, REQUEST_FAILED, "No variable specified");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Boolean isAccess = (Boolean)attributes.get(PDAWatchpoint.ACCESS);
|
||||||
|
isAccess = isAccess != null ? isAccess : Boolean.FALSE;
|
||||||
|
|
||||||
|
Boolean isModification = (Boolean)attributes.get(PDAWatchpoint.MODIFICATION);
|
||||||
|
isModification = isModification != null ? isModification : Boolean.FALSE;
|
||||||
|
|
||||||
|
// Create a new watchpoint context object and check that it's not
|
||||||
|
// installed already. PDA can only track a single watchpoint for a given
|
||||||
|
// function::variable, attempting to set the second breakpoint should fail.
|
||||||
|
final WatchpointDMContext watchpointCtx =
|
||||||
|
new WatchpointDMContext(getSession().getId(), fCommandControl.getProgramDMContext(), function, variable);
|
||||||
|
if (fBreakpoints.contains(watchpointCtx)) {
|
||||||
|
PDAPlugin.failRequest(rm, REQUEST_FAILED, "Watchpoint already set");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Determine the watch operation to perform.
|
||||||
|
PDAWatchCommand.WatchOperation watchOperation = PDAWatchCommand.WatchOperation.NONE;
|
||||||
|
if (isAccess && isModification) {
|
||||||
|
watchOperation = PDAWatchCommand.WatchOperation.BOTH;
|
||||||
|
} else if (isAccess) {
|
||||||
|
watchOperation = PDAWatchCommand.WatchOperation.READ;
|
||||||
|
} else if (isModification) {
|
||||||
|
watchOperation = PDAWatchCommand.WatchOperation.WRITE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add the new breakpoint context to the list of known breakpoints.
|
||||||
|
// Adding it here, before the set command is completed will prevent
|
||||||
|
// a possibility of a second breakpoint being installed in the same
|
||||||
|
// location while this breakpoint is being processed. It will also
|
||||||
|
// allow the breakpoint to be removed or updated even while it is
|
||||||
|
// still being processed here.
|
||||||
|
fBreakpoints.add(watchpointCtx);
|
||||||
|
fCommandControl.queueCommand(
|
||||||
|
new PDAWatchCommand(fCommandControl.getProgramDMContext(), function, variable, watchOperation),
|
||||||
|
new DataRequestMonitor<PDACommandResult>(getExecutor(), rm) {
|
||||||
|
@Override
|
||||||
|
protected void handleOK() {
|
||||||
|
rm.setData(watchpointCtx);
|
||||||
|
rm.done();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void handleErrorOrCancel() {
|
||||||
|
// Since the command failed, we need to remove the breakpoint from
|
||||||
|
// the existing breakpoint set.
|
||||||
|
fBreakpoints.remove(watchpointCtx);
|
||||||
|
super.handleErrorOrCancel();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeBreakpoint(IBreakpointDMContext bpCtx, RequestMonitor rm) {
|
||||||
|
if (!fBreakpoints.contains(bpCtx)) {
|
||||||
|
PDAPlugin.failRequest(rm, REQUEST_FAILED, "Breakpoint already removed");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bpCtx instanceof BreakpointDMContext) {
|
||||||
|
doRemoveBreakpoint((BreakpointDMContext)bpCtx, rm);
|
||||||
|
} else if (bpCtx instanceof WatchpointDMContext) {
|
||||||
|
doRemoveWatchpoint((WatchpointDMContext)bpCtx, rm);
|
||||||
|
} else {
|
||||||
|
PDAPlugin.failRequest(rm, INVALID_HANDLE, "Invalid breakpoint");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void doRemoveBreakpoint(BreakpointDMContext bpCtx, RequestMonitor rm) {
|
||||||
|
// Remove the breakpoint from the table right away, so that even when
|
||||||
|
// the remove is being processed, a new breakpoint can be created at the same
|
||||||
|
// location.
|
||||||
|
fBreakpoints.remove(bpCtx);
|
||||||
|
|
||||||
|
fCommandControl.queueCommand(
|
||||||
|
new PDAClearBreakpointCommand(fCommandControl.getProgramDMContext(), bpCtx.fLine),
|
||||||
|
new DataRequestMonitor<PDACommandResult>(getExecutor(), rm));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void doRemoveWatchpoint(WatchpointDMContext bpCtx, RequestMonitor rm) {
|
||||||
|
fBreakpoints.remove(bpCtx);
|
||||||
|
|
||||||
|
// Watchpoints are cleared using the same command, but with a "no watch" operation
|
||||||
|
fCommandControl.queueCommand(
|
||||||
|
new PDAWatchCommand(
|
||||||
|
fCommandControl.getProgramDMContext(), bpCtx.fFunction, bpCtx.fVariable, PDAWatchCommand.WatchOperation.NONE),
|
||||||
|
new DataRequestMonitor<PDACommandResult>(getExecutor(), rm));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateBreakpoint(final IBreakpointDMContext bpCtx, Map<String, Object> attributes, final RequestMonitor rm) {
|
||||||
|
if (!fBreakpoints.contains(bpCtx)) {
|
||||||
|
PDAPlugin.failRequest(rm, REQUEST_FAILED, "Breakpoint not installed");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bpCtx instanceof BreakpointDMContext) {
|
||||||
|
PDAPlugin.failRequest(rm, NOT_SUPPORTED, "Modifying PDA breakpoints is not supported");
|
||||||
|
} else if (bpCtx instanceof WatchpointDMContext) {
|
||||||
|
// PDA debugger can only track one watchpoint in the same location,
|
||||||
|
// so we can simply remove the existing context from the set and
|
||||||
|
// call insert again.
|
||||||
|
fBreakpoints.remove(bpCtx);
|
||||||
|
doInsertWatchpoint(
|
||||||
|
attributes,
|
||||||
|
new DataRequestMonitor<IBreakpointDMContext>(getExecutor(), rm) {
|
||||||
|
@Override
|
||||||
|
protected void handleOK() {
|
||||||
|
// The inserted watchpoint context will equal the
|
||||||
|
// current context.
|
||||||
|
assert bpCtx.equals(getData());
|
||||||
|
rm.done();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
PDAPlugin.failRequest(rm, INVALID_HANDLE, "Invalid breakpoint");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package org.eclipse.dd.examples.pda.service.command;
|
package org.eclipse.dd.examples.pda.service;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -30,10 +30,10 @@ 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.AbstractDsfService;
|
||||||
import org.eclipse.dd.dsf.service.DsfSession;
|
import org.eclipse.dd.dsf.service.DsfSession;
|
||||||
import org.eclipse.dd.dsf.service.IDsfService;
|
|
||||||
import org.eclipse.dd.examples.pda.PDAPlugin;
|
import org.eclipse.dd.examples.pda.PDAPlugin;
|
||||||
import org.eclipse.dd.examples.pda.service.command.commands.AbstractPDACommand;
|
import org.eclipse.dd.examples.pda.service.commands.AbstractPDACommand;
|
||||||
import org.eclipse.dd.examples.pda.service.command.commands.PDAExitCommand;
|
import org.eclipse.dd.examples.pda.service.commands.PDACommandResult;
|
||||||
|
import org.eclipse.dd.examples.pda.service.commands.PDAExitCommand;
|
||||||
import org.osgi.framework.BundleContext;
|
import org.osgi.framework.BundleContext;
|
||||||
|
|
||||||
|
|
||||||
|
@ -53,6 +53,11 @@ public class PDACommandControl extends AbstractDsfService implements ICommandCon
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Parameters that the command control is created with.
|
||||||
|
final private String fProgram;
|
||||||
|
final private int fRequestPort;
|
||||||
|
final private int fEventPort;
|
||||||
|
|
||||||
// Queue of commands waiting to be sent to the debugger. As long as commands
|
// Queue of commands waiting to be sent to the debugger. As long as commands
|
||||||
// are in this queue, they can still be removed by clients.
|
// are in this queue, they can still be removed by clients.
|
||||||
private final List<CommandHandle> fCommandQueue = new LinkedList<CommandHandle>();
|
private final List<CommandHandle> fCommandQueue = new LinkedList<CommandHandle>();
|
||||||
|
@ -71,15 +76,13 @@ public class PDACommandControl extends AbstractDsfService implements ICommandCon
|
||||||
private boolean fTerminated = false;
|
private boolean fTerminated = false;
|
||||||
|
|
||||||
// Data Model context of this command control.
|
// Data Model context of this command control.
|
||||||
private PDACommandControlDMContext fDMContext;
|
private PDAProgramDMContext fDMContext;
|
||||||
|
|
||||||
// Synchronous listeners for commands and events.
|
// Synchronous listeners for commands and events.
|
||||||
private final List<ICommandListener> fCommandListeners = new ArrayList<ICommandListener>();
|
private final List<ICommandListener> fCommandListeners = new ArrayList<ICommandListener>();
|
||||||
private final List<IEventListener> fEventListeners = new ArrayList<IEventListener>();
|
private final List<IEventListener> fEventListeners = new ArrayList<IEventListener>();
|
||||||
|
|
||||||
// Sockets for communicating with PDA debugger
|
// Sockets for communicating with PDA debugger
|
||||||
final private int fRequestPort;
|
|
||||||
final private int fEventPort;
|
|
||||||
private Socket fRequestSocket;
|
private Socket fRequestSocket;
|
||||||
private PrintWriter fRequestWriter;
|
private PrintWriter fRequestWriter;
|
||||||
private BufferedReader fRequestReader;
|
private BufferedReader fRequestReader;
|
||||||
|
@ -96,14 +99,16 @@ public class PDACommandControl extends AbstractDsfService implements ICommandCon
|
||||||
* @param requestPort Port number for sending PDA commands.
|
* @param requestPort Port number for sending PDA commands.
|
||||||
* @param eventPort Port for listening to PDA events.
|
* @param eventPort Port for listening to PDA events.
|
||||||
*/
|
*/
|
||||||
public PDACommandControl(DsfSession session, int requestPort, int eventPort) {
|
public PDACommandControl(DsfSession session, String program, int requestPort, int eventPort) {
|
||||||
super(session);
|
super(session);
|
||||||
|
fProgram = program;
|
||||||
fRequestPort = requestPort;
|
fRequestPort = requestPort;
|
||||||
fEventPort = eventPort;
|
fEventPort = eventPort;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initialize(final RequestMonitor rm) {
|
public void initialize(final RequestMonitor rm) {
|
||||||
|
// Call the super-class to perform initialization first.
|
||||||
super.initialize( new RequestMonitor(getExecutor(), rm) {
|
super.initialize( new RequestMonitor(getExecutor(), rm) {
|
||||||
@Override
|
@Override
|
||||||
protected void handleOK() {
|
protected void handleOK() {
|
||||||
|
@ -112,10 +117,11 @@ public class PDACommandControl extends AbstractDsfService implements ICommandCon
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void doInitialize(final RequestMonitor rm) {
|
private void doInitialize(final RequestMonitor rm) {
|
||||||
// Create the control's data model context.
|
// Create the control's data model context.
|
||||||
fDMContext = new PDACommandControlDMContext(getSession().getId());
|
fDMContext = new PDAProgramDMContext(getSession().getId(), fProgram);
|
||||||
|
|
||||||
|
// Add a listener for PDA events to track the started/terminated state.
|
||||||
addEventListener(new IEventListener() {
|
addEventListener(new IEventListener() {
|
||||||
public void eventReceived(Object output) {
|
public void eventReceived(Object output) {
|
||||||
if ("started".equals(output)) {
|
if ("started".equals(output)) {
|
||||||
|
@ -170,11 +176,11 @@ public class PDACommandControl extends AbstractDsfService implements ICommandCon
|
||||||
socketsInitializeRm.done();
|
socketsInitializeRm.done();
|
||||||
} catch (UnknownHostException e) {
|
} catch (UnknownHostException e) {
|
||||||
socketsInitializeRm.setStatus(new Status(
|
socketsInitializeRm.setStatus(new Status(
|
||||||
IStatus.ERROR, PDAPlugin.PLUGIN_ID, IDsfService.REQUEST_FAILED, "Unable to connect to PDA VM", e));
|
IStatus.ERROR, PDAPlugin.PLUGIN_ID, REQUEST_FAILED, "Unable to connect to PDA VM", e));
|
||||||
socketsInitializeRm.done();
|
socketsInitializeRm.done();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
socketsInitializeRm.setStatus(new Status(
|
socketsInitializeRm.setStatus(new Status(
|
||||||
IStatus.ERROR, PDAPlugin.PLUGIN_ID, IDsfService.REQUEST_FAILED, "Unable to connect to PDA VM", e));
|
IStatus.ERROR, PDAPlugin.PLUGIN_ID, REQUEST_FAILED, "Unable to connect to PDA VM", e));
|
||||||
socketsInitializeRm.done();
|
socketsInitializeRm.done();
|
||||||
}
|
}
|
||||||
return Status.OK_STATUS;
|
return Status.OK_STATUS;
|
||||||
|
@ -211,8 +217,11 @@ public class PDACommandControl extends AbstractDsfService implements ICommandCon
|
||||||
return PDAPlugin.getBundleContext();
|
return PDAPlugin.getBundleContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
class CommandSendJob extends Job {
|
/**
|
||||||
public CommandSendJob() {
|
* Job that services the send command queue.
|
||||||
|
*/
|
||||||
|
private class CommandSendJob extends Job {
|
||||||
|
CommandSendJob() {
|
||||||
super("PDA Command Send");
|
super("PDA Command Send");
|
||||||
setSystem(true);
|
setSystem(true);
|
||||||
}
|
}
|
||||||
|
@ -222,26 +231,45 @@ public class PDACommandControl extends AbstractDsfService implements ICommandCon
|
||||||
while (!isTerminated()) {
|
while (!isTerminated()) {
|
||||||
synchronized(fTxCommands) {
|
synchronized(fTxCommands) {
|
||||||
try {
|
try {
|
||||||
|
// Remove comamnd from send queue.
|
||||||
final CommandHandle commandHandle = fTxCommands.take();
|
final CommandHandle commandHandle = fTxCommands.take();
|
||||||
|
|
||||||
|
// Send the request to PDA
|
||||||
fRequestWriter.println(commandHandle.fCommand.getRequest());
|
fRequestWriter.println(commandHandle.fCommand.getRequest());
|
||||||
fRequestWriter.flush();
|
fRequestWriter.flush();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// wait for reply
|
// wait for reply
|
||||||
final String response = fRequestReader.readLine();
|
final String response = fRequestReader.readLine();
|
||||||
|
|
||||||
|
// Process the reply in the executor thread.
|
||||||
|
try {
|
||||||
getExecutor().execute(new DsfRunnable() {
|
getExecutor().execute(new DsfRunnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
processCommandDone(commandHandle, response);
|
processCommandDone(commandHandle, response);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
} catch (RejectedExecutionException e) {
|
||||||
|
// Acceptable race condition may see the session shut down
|
||||||
|
// while we're waiting for command response. Still complete
|
||||||
|
// the request monitor.
|
||||||
|
assert isTerminated();
|
||||||
|
assert isTerminated();
|
||||||
|
PDAPlugin.failRequest(commandHandle.fRequestMonitor, REQUEST_FAILED, "Command control shut down.");
|
||||||
|
}
|
||||||
} catch (final IOException e) {
|
} catch (final IOException e) {
|
||||||
|
// Process error it in the executor thread
|
||||||
|
try {
|
||||||
getExecutor().execute(new DsfRunnable() {
|
getExecutor().execute(new DsfRunnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
processCommandException(commandHandle, e);
|
processCommandException(commandHandle, e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
} catch (RejectedExecutionException re) {
|
||||||
|
// Acceptable race condition... see above
|
||||||
|
assert isTerminated();
|
||||||
|
PDAPlugin.failRequest(commandHandle.fRequestMonitor, REQUEST_FAILED, "Command control shut down.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
break; // Shutting down.
|
break; // Shutting down.
|
||||||
|
@ -254,13 +282,12 @@ public class PDACommandControl extends AbstractDsfService implements ICommandCon
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Listens to events from the PDA VM and fires corresponding
|
* Job that services the PDA event socket.
|
||||||
* debug events.
|
|
||||||
*/
|
*/
|
||||||
class EventDispatchJob extends Job {
|
class EventDispatchJob extends Job {
|
||||||
|
|
||||||
public EventDispatchJob() {
|
public EventDispatchJob() {
|
||||||
super("PDA Event Dispatch");
|
super("PDA Event Listner");
|
||||||
setSystem(true);
|
setSystem(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -268,9 +295,11 @@ public class PDACommandControl extends AbstractDsfService implements ICommandCon
|
||||||
protected IStatus run(IProgressMonitor monitor) {
|
protected IStatus run(IProgressMonitor monitor) {
|
||||||
while (!isTerminated()) {
|
while (!isTerminated()) {
|
||||||
try {
|
try {
|
||||||
|
// Wait for an event.
|
||||||
final String event = fEventReader.readLine();
|
final String event = fEventReader.readLine();
|
||||||
if (event != null) {
|
if (event != null) {
|
||||||
try {
|
try {
|
||||||
|
// Process the event in executor thread.
|
||||||
getExecutor().execute(new DsfRunnable() {
|
getExecutor().execute(new DsfRunnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
processEventReceived(event);
|
processEventReceived(event);
|
||||||
|
@ -285,6 +314,8 @@ public class PDACommandControl extends AbstractDsfService implements ICommandCon
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!isTerminated()) {
|
if (!isTerminated()) {
|
||||||
|
// Exception from the event socket is an indicator that the PDA debugger
|
||||||
|
// has exited. Call setTerminated() in executor thread.
|
||||||
try {
|
try {
|
||||||
getExecutor().execute(new DsfRunnable() {
|
getExecutor().execute(new DsfRunnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -309,11 +340,14 @@ public class PDACommandControl extends AbstractDsfService implements ICommandCon
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
DataRequestMonitor<PDACommandResult> pdaRM = (DataRequestMonitor<PDACommandResult>)rm;
|
DataRequestMonitor<PDACommandResult> pdaRM = (DataRequestMonitor<PDACommandResult>)rm;
|
||||||
|
|
||||||
|
// Add the command to the queue and notify command listeners.
|
||||||
fCommandQueue.add( new CommandHandle(pdaCommand, pdaRM) );
|
fCommandQueue.add( new CommandHandle(pdaCommand, pdaRM) );
|
||||||
for (ICommandListener listener : fCommandListeners) {
|
for (ICommandListener listener : fCommandListeners) {
|
||||||
listener.commandQueued(command);
|
listener.commandQueued(command);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// In a separate dispatch cycle. This allows command listeners to repond to the
|
||||||
|
// command queued event.
|
||||||
getExecutor().execute(new DsfRunnable() {
|
getExecutor().execute(new DsfRunnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
processQueues();
|
processQueues();
|
||||||
|
@ -321,9 +355,7 @@ public class PDACommandControl extends AbstractDsfService implements ICommandCon
|
||||||
});
|
});
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
rm.setStatus(new Status(
|
PDAPlugin.failRequest(rm, INTERNAL_ERROR, "Unrecognized command: " + command);
|
||||||
IStatus.ERROR, PDAPlugin.PLUGIN_ID, IDsfService.INTERNAL_ERROR, "Unrecognized command: " + command, null));
|
|
||||||
rm.done();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -333,6 +365,7 @@ public class PDACommandControl extends AbstractDsfService implements ICommandCon
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeCommand(ICommand<? extends ICommandResult> command) {
|
public void removeCommand(ICommand<? extends ICommandResult> command) {
|
||||||
|
// Removes given command from the queue and notify the listeners
|
||||||
for (Iterator<CommandHandle> itr = fCommandQueue.iterator(); itr.hasNext();) {
|
for (Iterator<CommandHandle> itr = fCommandQueue.iterator(); itr.hasNext();) {
|
||||||
CommandHandle handle = itr.next();
|
CommandHandle handle = itr.next();
|
||||||
if (command.equals(handle.fCommand)) {
|
if (command.equals(handle.fCommand)) {
|
||||||
|
@ -361,29 +394,44 @@ public class PDACommandControl extends AbstractDsfService implements ICommandCon
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processCommandDone(CommandHandle handle, String response) {
|
private void processCommandDone(CommandHandle handle, String response) {
|
||||||
|
// Trace to debug output.
|
||||||
PDAPlugin.debug("R: " + response);
|
PDAPlugin.debug("R: " + response);
|
||||||
|
|
||||||
|
// Given the PDA response string, create the result using the command
|
||||||
|
// that was sent.
|
||||||
PDACommandResult result = handle.fCommand.createResult(response);
|
PDACommandResult result = handle.fCommand.createResult(response);
|
||||||
|
|
||||||
|
// Set the result to the request monitor and return to sender.
|
||||||
|
// Note: as long as PDA sends some response, a PDA command will never
|
||||||
|
// return an error.
|
||||||
handle.fRequestMonitor.setData(result);
|
handle.fRequestMonitor.setData(result);
|
||||||
handle.fRequestMonitor.done();
|
handle.fRequestMonitor.done();
|
||||||
|
|
||||||
|
// Notify listeners of the response
|
||||||
for (ICommandListener listener : fCommandListeners) {
|
for (ICommandListener listener : fCommandListeners) {
|
||||||
listener.commandDone(handle.fCommand, result);
|
listener.commandDone(handle.fCommand, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Process next command in queue.
|
||||||
processQueues();
|
processQueues();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void processCommandException(CommandHandle handle, Throwable exception) {
|
private void processCommandException(CommandHandle handle, Throwable exception) {
|
||||||
|
|
||||||
|
// If sending a command resulted in an exception, notify the client.
|
||||||
handle.fRequestMonitor.setStatus(new Status(
|
handle.fRequestMonitor.setStatus(new Status(
|
||||||
IStatus.ERROR, PDAPlugin.PLUGIN_ID, IDsfService.REQUEST_FAILED, "Exception reading request response", exception));
|
IStatus.ERROR, PDAPlugin.PLUGIN_ID, REQUEST_FAILED, "Exception reading request response", exception));
|
||||||
handle.fRequestMonitor.done();
|
handle.fRequestMonitor.done();
|
||||||
|
|
||||||
|
// Notify listeners also.
|
||||||
for (ICommandListener listener : fCommandListeners) {
|
for (ICommandListener listener : fCommandListeners) {
|
||||||
listener.commandDone(handle.fCommand, null);
|
listener.commandDone(handle.fCommand, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processEventReceived(String event) {
|
private void processEventReceived(String event) {
|
||||||
|
// Notify the listeners only.
|
||||||
PDAPlugin.debug("E: " + event);
|
PDAPlugin.debug("E: " + event);
|
||||||
for (IEventListener listener : fEventListeners) {
|
for (IEventListener listener : fEventListeners) {
|
||||||
listener.eventReceived(event);
|
listener.eventReceived(event);
|
||||||
|
@ -396,7 +444,7 @@ public class PDACommandControl extends AbstractDsfService implements ICommandCon
|
||||||
// with an error.
|
// with an error.
|
||||||
for (CommandHandle handle : fCommandQueue) {
|
for (CommandHandle handle : fCommandQueue) {
|
||||||
handle.fRequestMonitor.setStatus(new Status(
|
handle.fRequestMonitor.setStatus(new Status(
|
||||||
IStatus.ERROR, PDAPlugin.PLUGIN_ID, IDsfService.INVALID_STATE, "Command control is terminated", null));
|
IStatus.ERROR, PDAPlugin.PLUGIN_ID, INVALID_STATE, "Command control is terminated", null));
|
||||||
handle.fRequestMonitor.done();
|
handle.fRequestMonitor.done();
|
||||||
}
|
}
|
||||||
fCommandQueue.clear();
|
fCommandQueue.clear();
|
||||||
|
@ -414,19 +462,24 @@ public class PDACommandControl extends AbstractDsfService implements ICommandCon
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the PDA Debugger top-level Data Model context.
|
||||||
|
* @see PDAProgramDMContext
|
||||||
|
*/
|
||||||
@ThreadSafe
|
@ThreadSafe
|
||||||
public PDACommandControlDMContext getDMContext() {
|
public PDAProgramDMContext getProgramDMContext() {
|
||||||
return fDMContext;
|
return fDMContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setStarted() {
|
private void setStarted() {
|
||||||
|
// Mark the command control as started and ready to process commands.
|
||||||
fStarted = true;
|
fStarted = true;
|
||||||
|
|
||||||
// Process any waiting commands.
|
// Process any commands which may have been queued before the
|
||||||
processQueues();
|
processQueues();
|
||||||
|
|
||||||
// Issue a data model event.
|
// Issue a data model event.
|
||||||
getSession().dispatchEvent(new PDAStartedEvent(getDMContext()), getProperties());
|
getSession().dispatchEvent(new PDAStartedEvent(getProgramDMContext()), getProperties());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -448,7 +501,7 @@ public class PDACommandControl extends AbstractDsfService implements ICommandCon
|
||||||
processQueues();
|
processQueues();
|
||||||
|
|
||||||
// Issue a data model event.
|
// Issue a data model event.
|
||||||
getSession().dispatchEvent(new PDATerminatedEvent(getDMContext()), getProperties());
|
getSession().dispatchEvent(new PDATerminatedEvent(getProgramDMContext()), getProperties());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,373 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* 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.examples.pda.service;
|
||||||
|
|
||||||
|
import java.util.Hashtable;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.eclipse.dd.dsf.concurrent.DataRequestMonitor;
|
||||||
|
import org.eclipse.dd.dsf.concurrent.Immutable;
|
||||||
|
import org.eclipse.dd.dsf.concurrent.RequestMonitor;
|
||||||
|
import org.eclipse.dd.dsf.datamodel.AbstractDMContext;
|
||||||
|
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.IExpressions;
|
||||||
|
import org.eclipse.dd.dsf.debug.service.IStack;
|
||||||
|
import org.eclipse.dd.dsf.debug.service.IRegisters.IRegisterDMContext;
|
||||||
|
import org.eclipse.dd.dsf.debug.service.IRunControl.IResumedDMEvent;
|
||||||
|
import org.eclipse.dd.dsf.debug.service.IRunControl.ISuspendedDMEvent;
|
||||||
|
import org.eclipse.dd.dsf.debug.service.IRunControl.StateChangeReason;
|
||||||
|
import org.eclipse.dd.dsf.debug.service.IStack.IFrameDMContext;
|
||||||
|
import org.eclipse.dd.dsf.debug.service.command.CommandCache;
|
||||||
|
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.examples.pda.PDAPlugin;
|
||||||
|
import org.eclipse.dd.examples.pda.service.commands.PDACommandResult;
|
||||||
|
import org.eclipse.dd.examples.pda.service.commands.PDASetVarCommand;
|
||||||
|
import org.eclipse.dd.examples.pda.service.commands.PDAVarCommand;
|
||||||
|
import org.osgi.framework.BundleContext;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class PDAExpressions extends AbstractDsfService implements IExpressions {
|
||||||
|
|
||||||
|
@Immutable
|
||||||
|
private static class ExpressionDMContext extends AbstractDMContext implements IExpressionDMContext {
|
||||||
|
|
||||||
|
final private String fExpression;
|
||||||
|
|
||||||
|
ExpressionDMContext(String sessionId, IFrameDMContext frameDmc, String expressin) {
|
||||||
|
super(sessionId, new IDMContext[] { frameDmc });
|
||||||
|
fExpression = expressin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getExpression() {
|
||||||
|
return fExpression;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object other) {
|
||||||
|
return super.baseEquals(other) && ((ExpressionDMContext)other).fExpression.equals(fExpression);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return super.baseHashCode() + fExpression.hashCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return baseToString() + ".expression(" + fExpression + ")";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PDA expressions are simply variables. Only the variable name
|
||||||
|
* is relevant for its data.
|
||||||
|
*/
|
||||||
|
@Immutable
|
||||||
|
private static class ExpressionDMData implements IExpressionDMData {
|
||||||
|
|
||||||
|
final private String fExpression;
|
||||||
|
|
||||||
|
public ExpressionDMData(String expression) {
|
||||||
|
fExpression = expression;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BasicType getBasicType() {
|
||||||
|
return BasicType.basic;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEncoding() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, Integer> getEnumerations() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return fExpression;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IRegisterDMContext getRegister() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getStringValue() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTypeId() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTypeName() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// @see #createExpression()
|
||||||
|
@Immutable
|
||||||
|
private static class InvalidExpressionDMContext extends AbstractDMContext implements IExpressionDMContext {
|
||||||
|
final private String fExpression;
|
||||||
|
|
||||||
|
public InvalidExpressionDMContext(String sessionId, IDMContext parent, String expr) {
|
||||||
|
super(sessionId, new IDMContext[] { parent });
|
||||||
|
fExpression = expr;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object other) {
|
||||||
|
return super.baseEquals(other) &&
|
||||||
|
fExpression == null
|
||||||
|
? ((InvalidExpressionDMContext) other).getExpression() == null
|
||||||
|
: fExpression.equals(((InvalidExpressionDMContext) other).getExpression());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return fExpression == null ? super.baseHashCode() : super.baseHashCode() ^ fExpression.hashCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return baseToString() + ".invalid_expr[" + fExpression + "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getExpression() {
|
||||||
|
return fExpression;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Immutable
|
||||||
|
private static class ExpressionChangedDMEvent extends AbstractDMEvent<IExpressionDMContext>
|
||||||
|
implements IExpressionChangedDMEvent
|
||||||
|
{
|
||||||
|
ExpressionChangedDMEvent(IExpressionDMContext expression) {
|
||||||
|
super(expression);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private PDACommandControl fCommandControl;
|
||||||
|
private IStack fStack;
|
||||||
|
|
||||||
|
private CommandCache fCommandCache;
|
||||||
|
|
||||||
|
public PDAExpressions(DsfSession session) {
|
||||||
|
super(session);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected BundleContext getBundleContext() {
|
||||||
|
return PDAPlugin.getBundleContext();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initialize(final RequestMonitor rm) {
|
||||||
|
super.initialize(
|
||||||
|
new RequestMonitor(getExecutor(), rm) {
|
||||||
|
@Override
|
||||||
|
protected void handleOK() {
|
||||||
|
doInitialize(rm);
|
||||||
|
}});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void doInitialize(final RequestMonitor rm) {
|
||||||
|
fCommandControl = getServicesTracker().getService(PDACommandControl.class);
|
||||||
|
fStack = getServicesTracker().getService(IStack.class);
|
||||||
|
fCommandCache = new CommandCache(fCommandControl);
|
||||||
|
|
||||||
|
getSession().addServiceEventListener(this, null);
|
||||||
|
|
||||||
|
register(new String[]{IExpressions.class.getName(), PDAExpressions.class.getName()}, new Hashtable<String,String>());
|
||||||
|
|
||||||
|
rm.done();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void shutdown(final RequestMonitor rm) {
|
||||||
|
getSession().removeServiceEventListener(this);
|
||||||
|
fCommandCache.reset();
|
||||||
|
super.shutdown(rm);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void canWriteExpression(IExpressionDMContext expressionContext, DataRequestMonitor<Boolean> rm) {
|
||||||
|
rm.setData(true);
|
||||||
|
rm.done();
|
||||||
|
}
|
||||||
|
|
||||||
|
public IExpressionDMContext createExpression(IDMContext ctx, String expression) {
|
||||||
|
// Create an expression based on the given context and string expression.
|
||||||
|
// The PDA debugger can only evaluate variables as expressions and only
|
||||||
|
// in context of a frame.
|
||||||
|
IFrameDMContext frameCtx = DMContexts.getAncestorOfType(ctx, IFrameDMContext.class);
|
||||||
|
if (frameCtx != null) {
|
||||||
|
return new ExpressionDMContext(getSession().getId(), frameCtx, expression);
|
||||||
|
} else {
|
||||||
|
// If a frame cannot be found in context, return an "invalid"
|
||||||
|
// expression context, because a null return value is not allowed.
|
||||||
|
// Evaluating an invalid expression context will always yield an
|
||||||
|
// error.
|
||||||
|
return new InvalidExpressionDMContext(getSession().getId(), ctx, expression);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void getBaseExpressions(IExpressionDMContext exprContext, DataRequestMonitor<IExpressionDMContext[]> rm) {
|
||||||
|
PDAPlugin.failRequest(rm, NOT_SUPPORTED, "Not supported");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void getExpressionAddressData(IExpressionDMContext dmc, DataRequestMonitor<IExpressionDMAddress> rm) {
|
||||||
|
PDAPlugin.failRequest(rm, NOT_SUPPORTED, "Not supported");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void getExpressionData(final IExpressionDMContext exprCtx, final DataRequestMonitor<IExpressionDMData> rm) {
|
||||||
|
// Since expression data doesn't contain any more information than the
|
||||||
|
// context, it doesn't require any debugger commmands.
|
||||||
|
if (exprCtx instanceof ExpressionDMContext) {
|
||||||
|
rm.setData(new ExpressionDMData(exprCtx.getExpression()));
|
||||||
|
rm.done();
|
||||||
|
} else {
|
||||||
|
PDAPlugin.failRequest(rm, INVALID_HANDLE, "Invalid expression context " + exprCtx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void getSubExpressionCount(IExpressionDMContext exprCtx, DataRequestMonitor<Integer> rm) {
|
||||||
|
PDAPlugin.failRequest(rm, NOT_SUPPORTED, "Not supported");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void getSubExpressions(IExpressionDMContext exprCtx, DataRequestMonitor<IExpressionDMContext[]> rm) {
|
||||||
|
PDAPlugin.failRequest(rm, NOT_SUPPORTED, "Not supported");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void getSubExpressions(IExpressionDMContext exprCtx, int startIndex, int length,
|
||||||
|
DataRequestMonitor<IExpressionDMContext[]> rm)
|
||||||
|
{
|
||||||
|
PDAPlugin.failRequest(rm, NOT_SUPPORTED, "Not supported");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void getAvailableFormats(IFormattedDataDMContext dmc, DataRequestMonitor<String[]> rm) {
|
||||||
|
// PDA debugger doesn't support formatting the expression. Natural
|
||||||
|
// formatting is the only available option.
|
||||||
|
rm.setData(new String[] { NATURAL_FORMAT });
|
||||||
|
rm.done();
|
||||||
|
}
|
||||||
|
|
||||||
|
public FormattedValueDMContext getFormattedValueContext(IFormattedDataDMContext exprCtx, String formatId) {
|
||||||
|
// Creates a context that can be used to retrieve a formatted value.
|
||||||
|
return new FormattedValueDMContext(this, exprCtx, formatId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void getFormattedExpressionValue(FormattedValueDMContext formattedCtx,
|
||||||
|
final DataRequestMonitor<FormattedValueDMData> rm)
|
||||||
|
{
|
||||||
|
final ExpressionDMContext exprCtx = DMContexts.getAncestorOfType(formattedCtx, ExpressionDMContext.class);
|
||||||
|
if (exprCtx != null) {
|
||||||
|
final IFrameDMContext frameCtx = DMContexts.getAncestorOfType(exprCtx, IFrameDMContext.class);
|
||||||
|
|
||||||
|
// First retrieve the stack depth, needed to properly calculate
|
||||||
|
// the frame index that is used by the PDAVarCommand.
|
||||||
|
fStack.getStackDepth(
|
||||||
|
frameCtx, 0,
|
||||||
|
new DataRequestMonitor<Integer>(getExecutor(), rm) {
|
||||||
|
@Override
|
||||||
|
protected void handleOK() {
|
||||||
|
// Calculate the frame index.
|
||||||
|
int frameId = getData() - frameCtx.getLevel() - 1;
|
||||||
|
|
||||||
|
// Send the command to evaluate the variable.
|
||||||
|
fCommandCache.execute(
|
||||||
|
new PDAVarCommand(fCommandControl.getProgramDMContext(), frameId, exprCtx.getExpression()),
|
||||||
|
new DataRequestMonitor<PDACommandResult>(getExecutor(), rm) {
|
||||||
|
@Override
|
||||||
|
protected void handleOK() {
|
||||||
|
rm.setData(new FormattedValueDMData(getData().fResponseText));
|
||||||
|
rm.done();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
PDAPlugin.failRequest(rm, INVALID_HANDLE, "Invalid expression context " + formattedCtx);
|
||||||
|
rm.done();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void writeExpression(final IExpressionDMContext exprCtx, final String exprValue, String formatId,
|
||||||
|
final RequestMonitor rm)
|
||||||
|
{
|
||||||
|
if (exprCtx instanceof ExpressionDMContext) {
|
||||||
|
final IFrameDMContext frameCtx = DMContexts.getAncestorOfType(exprCtx, IFrameDMContext.class);
|
||||||
|
|
||||||
|
// Similarly to retrieving the variable, retrieve the
|
||||||
|
// stack depth first.
|
||||||
|
fStack.getStackDepth(
|
||||||
|
frameCtx, 0,
|
||||||
|
new DataRequestMonitor<Integer>(getExecutor(), rm) {
|
||||||
|
@Override
|
||||||
|
protected void handleOK() {
|
||||||
|
// Calculate the frame index.
|
||||||
|
int frameId = getData() - frameCtx.getLevel() - 1;
|
||||||
|
|
||||||
|
// Send the "write" command to PDA debugger
|
||||||
|
fCommandCache.execute(
|
||||||
|
new PDASetVarCommand(fCommandControl.getProgramDMContext(), frameId, exprCtx.getExpression(), exprValue),
|
||||||
|
new DataRequestMonitor<PDACommandResult>(getExecutor(), rm) {
|
||||||
|
@Override
|
||||||
|
protected void handleOK() {
|
||||||
|
getSession().dispatchEvent(new ExpressionChangedDMEvent(exprCtx), getProperties());
|
||||||
|
rm.done();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
PDAPlugin.failRequest(rm, INVALID_HANDLE, "Invalid expression context " + exprCtx);
|
||||||
|
rm.done();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Deprecated
|
||||||
|
public void getModelData(IDMContext dmc, DataRequestMonitor<?> rm) {
|
||||||
|
if (dmc instanceof IExpressionDMContext) {
|
||||||
|
getExpressionData((IExpressionDMContext) dmc, (DataRequestMonitor<IExpressionDMData>) rm);
|
||||||
|
} else if (dmc instanceof FormattedValueDMContext) {
|
||||||
|
getFormattedExpressionValue((FormattedValueDMContext) dmc, (DataRequestMonitor<FormattedValueDMData>) rm);
|
||||||
|
} else {
|
||||||
|
PDAPlugin.failRequest(rm, INVALID_HANDLE, "Unknown DMC type");
|
||||||
|
rm.done();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@DsfServiceEventHandler
|
||||||
|
public void eventDispatched(IResumedDMEvent e) {
|
||||||
|
// Mark the cache as not available, so that data retrieval commands
|
||||||
|
// will fail. Also reset the cache unless it was a step command.
|
||||||
|
fCommandCache.setTargetAvailable(false);
|
||||||
|
if (!e.getReason().equals(StateChangeReason.STEP)) {
|
||||||
|
fCommandCache.reset();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@DsfServiceEventHandler
|
||||||
|
public void eventDispatched(ISuspendedDMEvent e) {
|
||||||
|
// Enable sending commands to target and clear the cache.
|
||||||
|
fCommandCache.setTargetAvailable(true);
|
||||||
|
fCommandCache.reset();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,87 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2007 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.examples.pda.service;
|
||||||
|
|
||||||
|
import org.eclipse.core.runtime.PlatformObject;
|
||||||
|
import org.eclipse.dd.dsf.datamodel.AbstractDMContext;
|
||||||
|
import org.eclipse.dd.dsf.datamodel.IDMContext;
|
||||||
|
import org.eclipse.dd.dsf.debug.service.IBreakpoints.IBreakpointsTargetDMContext;
|
||||||
|
import org.eclipse.dd.dsf.debug.service.IRunControl.IExecutionDMContext;
|
||||||
|
import org.eclipse.dd.dsf.service.DsfSession;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Top-level Data Model context for the PDA debugger representing the PDA
|
||||||
|
* program.
|
||||||
|
* <p>
|
||||||
|
* The PDA debugger is a single-threaded application. Therefore this
|
||||||
|
* top level context implements IExecutionDMContext directly, hence this
|
||||||
|
* context can be used to call the IRunControl service to perform run
|
||||||
|
* control opreations.
|
||||||
|
* </p>
|
||||||
|
* <p>
|
||||||
|
* Also, the PDA debugger allows setting breakpoints in scope of the
|
||||||
|
* whole program only, so this context can be used with the breakpoints
|
||||||
|
* service to install/remove breakpoints.
|
||||||
|
* </p>
|
||||||
|
* <p>
|
||||||
|
* Note: There should only be one instance of PDACommandControlDMContext created
|
||||||
|
* by each PDA command control, so its equals method defaults to using
|
||||||
|
* instance comparison.
|
||||||
|
* </p>
|
||||||
|
*/
|
||||||
|
public class PDAProgramDMContext extends PlatformObject
|
||||||
|
implements IExecutionDMContext, IBreakpointsTargetDMContext
|
||||||
|
{
|
||||||
|
final static IDMContext[] EMPTY_PARENTS_ARRAY = new IDMContext[0];
|
||||||
|
|
||||||
|
final private String fSessionId;
|
||||||
|
final private String fProgram;
|
||||||
|
|
||||||
|
public PDAProgramDMContext(String sessionId, String program) {
|
||||||
|
fSessionId = sessionId;
|
||||||
|
fProgram = program;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSessionId() {
|
||||||
|
return fSessionId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getProgram() {
|
||||||
|
return fProgram;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IDMContext[] getParents() {
|
||||||
|
return EMPTY_PARENTS_ARRAY;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "PDA(" + getSessionId() + ")";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see AbstractDMContext#getAdapter(Class)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public Object getAdapter(Class adapterType) {
|
||||||
|
Object retVal = null;
|
||||||
|
DsfSession session = DsfSession.getSession(fSessionId);
|
||||||
|
if (session != null) {
|
||||||
|
retVal = session.getModelAdapter(adapterType);
|
||||||
|
}
|
||||||
|
if (retVal == null) {
|
||||||
|
retVal = super.getAdapter(adapterType);
|
||||||
|
}
|
||||||
|
return retVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,317 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* 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
|
||||||
|
* Ericsson AB - Modified for handling of multiple threads
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.dd.examples.pda.service;
|
||||||
|
|
||||||
|
import java.util.Hashtable;
|
||||||
|
|
||||||
|
import org.eclipse.dd.dsf.concurrent.DataRequestMonitor;
|
||||||
|
import org.eclipse.dd.dsf.concurrent.Immutable;
|
||||||
|
import org.eclipse.dd.dsf.concurrent.RequestMonitor;
|
||||||
|
import org.eclipse.dd.dsf.datamodel.AbstractDMEvent;
|
||||||
|
import org.eclipse.dd.dsf.datamodel.IDMContext;
|
||||||
|
import org.eclipse.dd.dsf.datamodel.IDMEvent;
|
||||||
|
import org.eclipse.dd.dsf.debug.service.IRunControl;
|
||||||
|
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.DsfSession;
|
||||||
|
import org.eclipse.dd.dsf.service.IDsfService;
|
||||||
|
import org.eclipse.dd.examples.pda.PDAPlugin;
|
||||||
|
import org.eclipse.dd.examples.pda.service.commands.PDACommandResult;
|
||||||
|
import org.eclipse.dd.examples.pda.service.commands.PDAResumeCommand;
|
||||||
|
import org.eclipse.dd.examples.pda.service.commands.PDAStepCommand;
|
||||||
|
import org.eclipse.dd.examples.pda.service.commands.PDASuspendCommand;
|
||||||
|
import org.osgi.framework.BundleContext;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Service for monitoring and controlling execution state of the DPA
|
||||||
|
* program.
|
||||||
|
* <p>
|
||||||
|
* This service depends on the {@link PDACommandControl} service.
|
||||||
|
* It must be initialized before this service is initialized.
|
||||||
|
* </p>
|
||||||
|
*/
|
||||||
|
public class PDARunControl extends AbstractDsfService
|
||||||
|
implements IRunControl, IEventListener
|
||||||
|
{
|
||||||
|
// Implementation note about tracking execution state:
|
||||||
|
// This class implements event handlers for the events that are generated by
|
||||||
|
// this service itself. When the event is dispatched, these handlers will
|
||||||
|
// be called first, before any of the clients. These handlers update the
|
||||||
|
// service's internal state information to make them consistent with the
|
||||||
|
// events being issued. Doing this in the handlers as opposed to when
|
||||||
|
// the events are generated, guarantees that the state of the service will
|
||||||
|
// always be consistent with the events.
|
||||||
|
// The purpose of this pattern is to allow clients that listen to service
|
||||||
|
// events and track service state, to be perfectly in sync with the service
|
||||||
|
// state.
|
||||||
|
|
||||||
|
@Immutable
|
||||||
|
private static class ExecutionDMData implements IExecutionDMData {
|
||||||
|
private final StateChangeReason fReason;
|
||||||
|
ExecutionDMData(StateChangeReason reason) {
|
||||||
|
fReason = reason;
|
||||||
|
}
|
||||||
|
public StateChangeReason getStateChangeReason() { return fReason; }
|
||||||
|
}
|
||||||
|
|
||||||
|
@Immutable
|
||||||
|
private static class ResumedEvent extends AbstractDMEvent<IExecutionDMContext>
|
||||||
|
implements IResumedDMEvent
|
||||||
|
{
|
||||||
|
private final String fPDAEvent;
|
||||||
|
|
||||||
|
ResumedEvent(IExecutionDMContext ctx, String pdaEvent) {
|
||||||
|
super(ctx);
|
||||||
|
fPDAEvent = pdaEvent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StateChangeReason getReason() {
|
||||||
|
if (fPDAEvent.startsWith("resumed breakpoint") || fPDAEvent.startsWith("suspended watch")) {
|
||||||
|
return StateChangeReason.BREAKPOINT;
|
||||||
|
} else if (fPDAEvent.equals("resumed step") || fPDAEvent.equals("resumed drop")) {
|
||||||
|
return StateChangeReason.STEP;
|
||||||
|
} else if (fPDAEvent.equals("resumed client")) {
|
||||||
|
return StateChangeReason.USER_REQUEST;
|
||||||
|
} else {
|
||||||
|
return StateChangeReason.UNKNOWN;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Immutable
|
||||||
|
private static class SuspendedEvent extends AbstractDMEvent<IExecutionDMContext>
|
||||||
|
implements ISuspendedDMEvent
|
||||||
|
{
|
||||||
|
private final String fPDAEvent;
|
||||||
|
|
||||||
|
SuspendedEvent(IExecutionDMContext ctx, String pdaEvent) {
|
||||||
|
super(ctx);
|
||||||
|
fPDAEvent = pdaEvent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StateChangeReason getReason() {
|
||||||
|
if (fPDAEvent.startsWith("suspended breakpoint") || fPDAEvent.startsWith("suspended watch")) {
|
||||||
|
return StateChangeReason.BREAKPOINT;
|
||||||
|
} else if (fPDAEvent.equals("suspended step") || fPDAEvent.equals("suspended drop")) {
|
||||||
|
return StateChangeReason.STEP;
|
||||||
|
} else if (fPDAEvent.equals("suspended client")) {
|
||||||
|
return StateChangeReason.USER_REQUEST;
|
||||||
|
} else {
|
||||||
|
return StateChangeReason.UNKNOWN;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Services
|
||||||
|
private PDACommandControl fCommandControl;
|
||||||
|
|
||||||
|
// State flags
|
||||||
|
private boolean fSuspended = true;
|
||||||
|
private boolean fResumePending = false;
|
||||||
|
private boolean fStepping = false;
|
||||||
|
private StateChangeReason fStateChangeReason;
|
||||||
|
|
||||||
|
public PDARunControl(DsfSession session) {
|
||||||
|
super(session);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected BundleContext getBundleContext() {
|
||||||
|
return PDAPlugin.getBundleContext();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initialize(final RequestMonitor rm) {
|
||||||
|
super.initialize(
|
||||||
|
new RequestMonitor(getExecutor(), rm) {
|
||||||
|
@Override
|
||||||
|
protected void handleOK() {
|
||||||
|
doInitialize(rm);
|
||||||
|
}});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void doInitialize(final RequestMonitor rm) {
|
||||||
|
fCommandControl = getServicesTracker().getService(PDACommandControl.class);
|
||||||
|
|
||||||
|
// Add ourselves as a listener to PDA events, to catch suspended/resumed
|
||||||
|
// events.
|
||||||
|
fCommandControl.addEventListener(this);
|
||||||
|
|
||||||
|
// Add ourselves as a listener to service events, in order to process
|
||||||
|
// our own suspended/resumed events.
|
||||||
|
getSession().addServiceEventListener(this, null);
|
||||||
|
|
||||||
|
// Register the service with OSGi
|
||||||
|
register(new String[]{IRunControl.class.getName(), PDARunControl.class.getName()}, new Hashtable<String,String>());
|
||||||
|
|
||||||
|
rm.done();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void shutdown(final RequestMonitor rm) {
|
||||||
|
fCommandControl.removeEventListener(this);
|
||||||
|
getSession().removeServiceEventListener(this);
|
||||||
|
super.shutdown(rm);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public void getModelData(IDMContext dmc, DataRequestMonitor<?> rm) {
|
||||||
|
// The getModelData() is deprecated and clients are expected to switch
|
||||||
|
// to getExecutionData() and other data retrieve methods directly.
|
||||||
|
// However the UI cache still uses it for now.
|
||||||
|
if (dmc instanceof IExecutionDMContext) {
|
||||||
|
getExecutionData((IExecutionDMContext)dmc, (DataRequestMonitor<IExecutionDMData>)rm);
|
||||||
|
} else {
|
||||||
|
PDAPlugin.failRequest(rm, INVALID_HANDLE, "Unknown DMC type");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void eventReceived(Object output) {
|
||||||
|
if (!(output instanceof String)) return;
|
||||||
|
String event = (String)output;
|
||||||
|
|
||||||
|
// Handle PDA debugger suspende/resumed events and issue the
|
||||||
|
// corresponding Data Model events. Do not update the state
|
||||||
|
// information until we start dispatching the service events.
|
||||||
|
if (event.startsWith("suspended")) {
|
||||||
|
IDMEvent<?> dmEvent = new SuspendedEvent(fCommandControl.getProgramDMContext(), event);
|
||||||
|
getSession().dispatchEvent(dmEvent, getProperties());
|
||||||
|
} else if (event.startsWith("resumed")) {
|
||||||
|
IDMEvent<?> dmEvent = new ResumedEvent(fCommandControl.getProgramDMContext(), event);
|
||||||
|
getSession().dispatchEvent(dmEvent, getProperties());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@DsfServiceEventHandler
|
||||||
|
public void eventDispatched(ResumedEvent e) {
|
||||||
|
// This service should be the first to receive the ResumedEvent,
|
||||||
|
// (before any other listeners are called). Here, update the
|
||||||
|
// service state information based on the the resumed event.
|
||||||
|
fSuspended = false;
|
||||||
|
fResumePending = false;
|
||||||
|
fStateChangeReason = e.getReason();
|
||||||
|
fStepping = e.getReason().equals(StateChangeReason.STEP);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@DsfServiceEventHandler
|
||||||
|
public void eventDispatched(SuspendedEvent e) {
|
||||||
|
// This service should be the first to receive the SuspendedEvent also,
|
||||||
|
// (before any other listeners are called). Here, update the
|
||||||
|
// service state information based on the the suspended event.
|
||||||
|
fStateChangeReason = e.getReason();
|
||||||
|
fResumePending = false;
|
||||||
|
fSuspended = true;
|
||||||
|
fStepping = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public boolean canResume(IExecutionDMContext context) {
|
||||||
|
return isSuspended(context) && !fResumePending;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canSuspend(IExecutionDMContext context) {
|
||||||
|
return !isSuspended(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSuspended(IExecutionDMContext context) {
|
||||||
|
return fSuspended;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isStepping(IExecutionDMContext context) {
|
||||||
|
return !isSuspended(context) && fStepping;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void resume(IExecutionDMContext context, final RequestMonitor rm) {
|
||||||
|
assert context != null;
|
||||||
|
|
||||||
|
if (canResume(context)) {
|
||||||
|
fResumePending = true;
|
||||||
|
fCommandControl.queueCommand(
|
||||||
|
new PDAResumeCommand(fCommandControl.getProgramDMContext()),
|
||||||
|
new DataRequestMonitor<PDACommandResult>(getExecutor(), rm) {
|
||||||
|
@Override
|
||||||
|
protected void handleErrorOrCancel() {
|
||||||
|
// If the resume command failed, we no longer
|
||||||
|
// expect to receive a resumed event.
|
||||||
|
fResumePending = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}else {
|
||||||
|
PDAPlugin.failRequest(rm, INVALID_STATE, "Given context: " + context + ", is already running.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void suspend(IExecutionDMContext context, final RequestMonitor rm){
|
||||||
|
assert context != null;
|
||||||
|
|
||||||
|
if (canSuspend(context)) {
|
||||||
|
fCommandControl.queueCommand(
|
||||||
|
new PDASuspendCommand(fCommandControl.getProgramDMContext()),
|
||||||
|
new DataRequestMonitor<PDACommandResult>(getExecutor(), rm));
|
||||||
|
|
||||||
|
} else {
|
||||||
|
PDAPlugin.failRequest(rm, IDsfService.INVALID_STATE, "Given context: " + context + ", is already suspended.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canStep(IExecutionDMContext context) {
|
||||||
|
return canResume(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void step(IExecutionDMContext context, StepType stepType, final RequestMonitor rm) {
|
||||||
|
assert context != null;
|
||||||
|
|
||||||
|
if (canResume(context)) {
|
||||||
|
fResumePending = true;
|
||||||
|
fStepping = true;
|
||||||
|
|
||||||
|
fCommandControl.queueCommand(
|
||||||
|
new PDAStepCommand(fCommandControl.getProgramDMContext()),
|
||||||
|
new DataRequestMonitor<PDACommandResult>(getExecutor(), rm) {
|
||||||
|
@Override
|
||||||
|
protected void handleErrorOrCancel() {
|
||||||
|
// If the step command failed, we no longer
|
||||||
|
// expect to receive a resumed event.
|
||||||
|
fResumePending = false;
|
||||||
|
fStepping = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
} else {
|
||||||
|
PDAPlugin.failRequest(rm, INVALID_STATE, "Cannot resume context");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canInstructionStep(IExecutionDMContext context) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void instructionStep(IExecutionDMContext context, StepType stepType, RequestMonitor rm) {
|
||||||
|
PDAPlugin.failRequest(rm, NOT_SUPPORTED, "Operation not implemented");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void getExecutionContexts(final IContainerDMContext containerDmc, final DataRequestMonitor<IExecutionDMContext[]> rm) {
|
||||||
|
PDAPlugin.failRequest(rm, NOT_SUPPORTED, "Operation not implemented");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void getExecutionData(IExecutionDMContext dmc, DataRequestMonitor<IExecutionDMData> rm){
|
||||||
|
rm.setData( new ExecutionDMData(fStateChangeReason) );
|
||||||
|
rm.done();
|
||||||
|
}
|
||||||
|
}
|
|
@ -8,14 +8,15 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Wind River Systems - initial API and implementation
|
* Wind River Systems - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.dd.examples.pda.service.stack;
|
package org.eclipse.dd.examples.pda.service;
|
||||||
|
|
||||||
import java.util.Hashtable;
|
import java.util.Hashtable;
|
||||||
|
|
||||||
import org.eclipse.core.runtime.IStatus;
|
import org.eclipse.cdt.core.IAddress;
|
||||||
import org.eclipse.core.runtime.Status;
|
|
||||||
import org.eclipse.dd.dsf.concurrent.DataRequestMonitor;
|
import org.eclipse.dd.dsf.concurrent.DataRequestMonitor;
|
||||||
|
import org.eclipse.dd.dsf.concurrent.Immutable;
|
||||||
import org.eclipse.dd.dsf.concurrent.RequestMonitor;
|
import org.eclipse.dd.dsf.concurrent.RequestMonitor;
|
||||||
|
import org.eclipse.dd.dsf.datamodel.AbstractDMContext;
|
||||||
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.service.IRunControl;
|
import org.eclipse.dd.dsf.debug.service.IRunControl;
|
||||||
|
@ -30,20 +31,143 @@ import org.eclipse.dd.dsf.service.DsfServiceEventHandler;
|
||||||
import org.eclipse.dd.dsf.service.DsfSession;
|
import org.eclipse.dd.dsf.service.DsfSession;
|
||||||
import org.eclipse.dd.dsf.service.IDsfService;
|
import org.eclipse.dd.dsf.service.IDsfService;
|
||||||
import org.eclipse.dd.examples.pda.PDAPlugin;
|
import org.eclipse.dd.examples.pda.PDAPlugin;
|
||||||
import org.eclipse.dd.examples.pda.service.command.PDACommandControl;
|
import org.eclipse.dd.examples.pda.service.commands.PDAFrame;
|
||||||
import org.eclipse.dd.examples.pda.service.command.commands.PDAFrame;
|
import org.eclipse.dd.examples.pda.service.commands.PDAStackCommand;
|
||||||
import org.eclipse.dd.examples.pda.service.command.commands.PDAStackCommand;
|
import org.eclipse.dd.examples.pda.service.commands.PDAStackCommandResult;
|
||||||
import org.eclipse.dd.examples.pda.service.command.commands.PDAStackCommandResult;
|
|
||||||
import org.osgi.framework.BundleContext;
|
import org.osgi.framework.BundleContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Service for retrieving PDA debugger stack data.
|
||||||
|
* <p>
|
||||||
|
* This service depends on the {@link PDACommandControl} service and the
|
||||||
|
* {@link IRunControl} service. These services must be initialized before
|
||||||
|
* this service is initialized.
|
||||||
|
* </p>
|
||||||
*/
|
*/
|
||||||
public class PDAStack extends AbstractDsfService implements IStack {
|
public class PDAStack extends AbstractDsfService implements IStack {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PDA stack frame contains only the stack frame level. It is only
|
||||||
|
* used as an index into the frame data returned by the PDA debugger.
|
||||||
|
*/
|
||||||
|
@Immutable
|
||||||
|
private static class FrameDMContext extends AbstractDMContext implements IFrameDMContext {
|
||||||
|
|
||||||
|
final private int fLevel;
|
||||||
|
|
||||||
|
FrameDMContext(String sessionId, IExecutionDMContext execDmc, int level) {
|
||||||
|
super(sessionId, new IDMContext[] { execDmc });
|
||||||
|
fLevel = level;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getLevel() { return fLevel; }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object other) {
|
||||||
|
return super.baseEquals(other) && ((FrameDMContext)other).fLevel == fLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return super.baseHashCode() ^ fLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return baseToString() + ".frame[" + fLevel + "]"; //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Frame data based on the PDAFrame object returned by the PDA debugger.
|
||||||
|
*/
|
||||||
|
@Immutable
|
||||||
|
private static class FrameDMData implements IFrameDMData {
|
||||||
|
|
||||||
|
final private PDAFrame fFrame;
|
||||||
|
|
||||||
|
FrameDMData(PDAFrame frame) {
|
||||||
|
fFrame = frame;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFile() {
|
||||||
|
return fFrame.fFilePath.lastSegment();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFunction() {
|
||||||
|
return fFrame.fFunction;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getLine() {
|
||||||
|
return fFrame.fLine + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getColumn() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IAddress getAddress() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Context representing a variable in a given stack frame.
|
||||||
|
*/
|
||||||
|
@Immutable
|
||||||
|
private static class VariableDMContext extends AbstractDMContext implements IVariableDMContext {
|
||||||
|
|
||||||
|
final private String fVariable;
|
||||||
|
|
||||||
|
VariableDMContext(String sessionId, IFrameDMContext frameCtx, String variable) {
|
||||||
|
super(sessionId, new IDMContext[] { frameCtx });
|
||||||
|
fVariable = variable;
|
||||||
|
}
|
||||||
|
|
||||||
|
String getVariable() { return fVariable; }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object other) {
|
||||||
|
return super.baseEquals(other) && ((VariableDMContext)other).fVariable.equals(fVariable);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return super.baseHashCode() + fVariable.hashCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return baseToString() + ".variable(" + fVariable + ")"; //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PDA variable data, only supports returning the variable name.
|
||||||
|
*/
|
||||||
|
@Immutable
|
||||||
|
private static class VariableDMData implements IVariableDMData {
|
||||||
|
|
||||||
|
final private String fVariable;
|
||||||
|
|
||||||
|
VariableDMData(String variable) {
|
||||||
|
fVariable = variable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return fVariable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getValue() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Services that this service depends on.
|
||||||
private PDACommandControl fCommandControl;
|
private PDACommandControl fCommandControl;
|
||||||
private IRunControl fRunControl;
|
private IRunControl fRunControl;
|
||||||
|
|
||||||
|
// Command cache
|
||||||
private CommandCache fCommandCache;
|
private CommandCache fCommandCache;
|
||||||
|
|
||||||
public PDAStack(DsfSession session) {
|
public PDAStack(DsfSession session) {
|
||||||
|
@ -66,12 +190,17 @@ public class PDAStack extends AbstractDsfService implements IStack {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doInitialize(final RequestMonitor rm) {
|
private void doInitialize(final RequestMonitor rm) {
|
||||||
|
// Initialize service references that stack service depends on
|
||||||
fCommandControl = getServicesTracker().getService(PDACommandControl.class);
|
fCommandControl = getServicesTracker().getService(PDACommandControl.class);
|
||||||
fRunControl = getServicesTracker().getService(IRunControl.class);
|
fRunControl = getServicesTracker().getService(IRunControl.class);
|
||||||
|
|
||||||
|
// Create the commands cache
|
||||||
fCommandCache = new CommandCache(fCommandControl);
|
fCommandCache = new CommandCache(fCommandControl);
|
||||||
|
|
||||||
|
// Register to listen for run control events, to clear cache accordingly.
|
||||||
getSession().addServiceEventListener(this, null);
|
getSession().addServiceEventListener(this, null);
|
||||||
|
|
||||||
|
// Register stack service with OSGi
|
||||||
register(new String[]{IStack.class.getName(), PDAStack.class.getName()}, new Hashtable<String,String>());
|
register(new String[]{IStack.class.getName(), PDAStack.class.getName()}, new Hashtable<String,String>());
|
||||||
|
|
||||||
rm.done();
|
rm.done();
|
||||||
|
@ -84,46 +213,48 @@ public class PDAStack extends AbstractDsfService implements IStack {
|
||||||
super.shutdown(rm);
|
super.shutdown(rm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void getArguments(IFrameDMContext frameCtx, DataRequestMonitor<IVariableDMContext[]> rm) {
|
public void getArguments(IFrameDMContext frameCtx, DataRequestMonitor<IVariableDMContext[]> rm) {
|
||||||
rm.setStatus(new Status(IStatus.ERROR, PDAPlugin.PLUGIN_ID, IDsfService.NOT_SUPPORTED, "PDA debugger does not support function arguments.", null)); //$NON-NLS-1$
|
PDAPlugin.failRequest(rm, IDsfService.NOT_SUPPORTED, "PDA debugger does not support function arguments.");
|
||||||
rm.done();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getFrameData(final IFrameDMContext frameCtx, final DataRequestMonitor<IFrameDMData> rm) {
|
public void getFrameData(final IFrameDMContext frameCtx, final DataRequestMonitor<IFrameDMData> rm) {
|
||||||
if ( !(frameCtx instanceof FrameDMContext) ) {
|
// Execute the PDA stack command, or retrieve the result from cache if already available.
|
||||||
rm.setStatus(new Status(IStatus.ERROR, PDAPlugin.PLUGIN_ID, IDsfService.INVALID_HANDLE, "Invalid context " + frameCtx, null)); //$NON-NLS-1$
|
|
||||||
rm.done();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
fCommandCache.execute(
|
fCommandCache.execute(
|
||||||
new PDAStackCommand(fCommandControl.getDMContext()),
|
new PDAStackCommand(fCommandControl.getProgramDMContext()),
|
||||||
new DataRequestMonitor<PDAStackCommandResult>(getExecutor(), rm) {
|
new DataRequestMonitor<PDAStackCommandResult>(getExecutor(), rm) {
|
||||||
@Override
|
@Override
|
||||||
protected void handleOK() {
|
protected void handleOK() {
|
||||||
|
// PDAFrame array is ordered highest to lowest. We need to
|
||||||
|
// calculate the index based on frame level.
|
||||||
int frameId = getData().fFrames.length - frameCtx.getLevel() - 1;
|
int frameId = getData().fFrames.length - frameCtx.getLevel() - 1;
|
||||||
if (frameId < 0) {
|
if (frameId < 0) {
|
||||||
rm.setStatus(new Status(IStatus.ERROR, PDAPlugin.PLUGIN_ID, IDsfService.INVALID_HANDLE, "Invalid frame level " + frameCtx, null)); //$NON-NLS-1$
|
PDAPlugin.failRequest(rm, IDsfService.INVALID_HANDLE, "Invalid frame level " + frameCtx);
|
||||||
rm.done();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Create the frame data object based on the corresponding PDAFrame
|
||||||
rm.setData(new FrameDMData(getData().fFrames[frameId]));
|
rm.setData(new FrameDMData(getData().fFrames[frameId]));
|
||||||
rm.done();
|
rm.done();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void getFrames(IDMContext context, final DataRequestMonitor<IFrameDMContext[]> rm) {
|
public void getFrames(IDMContext context, final DataRequestMonitor<IFrameDMContext[]> rm) {
|
||||||
|
// Can only create stack frames for an execution context as a parent,
|
||||||
|
// however the argument context is a generic context type, so it could
|
||||||
|
// be an execution context, a frame, a variable, etc. Search the
|
||||||
|
// hierarchy of the argument context to find the execution one.
|
||||||
final IExecutionDMContext execCtx = DMContexts.getAncestorOfType(context, IExecutionDMContext.class);
|
final IExecutionDMContext execCtx = DMContexts.getAncestorOfType(context, IExecutionDMContext.class);
|
||||||
if (execCtx == null) {
|
if (execCtx == null) {
|
||||||
rm.setStatus(new Status(IStatus.ERROR, PDAPlugin.PLUGIN_ID, IDsfService.INVALID_HANDLE, "Invalid context " + context, null)); //$NON-NLS-1$
|
PDAPlugin.failRequest(rm, IDsfService.INVALID_HANDLE, "Invalid context " + context);
|
||||||
rm.done();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Execute the stack command and create the corresponding frame contexts.
|
||||||
fCommandCache.execute(
|
fCommandCache.execute(
|
||||||
new PDAStackCommand(fCommandControl.getDMContext()),
|
new PDAStackCommand(fCommandControl.getProgramDMContext()),
|
||||||
new DataRequestMonitor<PDAStackCommandResult>(getExecutor(), rm) {
|
new DataRequestMonitor<PDAStackCommandResult>(getExecutor(), rm) {
|
||||||
@Override
|
@Override
|
||||||
protected void handleOK() {
|
protected void handleOK() {
|
||||||
|
@ -138,26 +269,21 @@ public class PDAStack extends AbstractDsfService implements IStack {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getLocals(final IFrameDMContext frameCtx, final DataRequestMonitor<IVariableDMContext[]> rm) {
|
public void getLocals(final IFrameDMContext frameCtx, final DataRequestMonitor<IVariableDMContext[]> rm) {
|
||||||
if ( !(frameCtx instanceof FrameDMContext) ) {
|
// Execute the stack command again.
|
||||||
rm.setStatus(new Status(IStatus.ERROR, PDAPlugin.PLUGIN_ID, IDsfService.INVALID_HANDLE, "Invalid context " + frameCtx, null)); //$NON-NLS-1$
|
|
||||||
rm.done();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
fCommandCache.execute(
|
fCommandCache.execute(
|
||||||
new PDAStackCommand(fCommandControl.getDMContext()),
|
new PDAStackCommand(fCommandControl.getProgramDMContext()),
|
||||||
new DataRequestMonitor<PDAStackCommandResult>(getExecutor(), rm) {
|
new DataRequestMonitor<PDAStackCommandResult>(getExecutor(), rm) {
|
||||||
@Override
|
@Override
|
||||||
protected void handleOK() {
|
protected void handleOK() {
|
||||||
|
// Find the correct PDAFrame
|
||||||
int frameId = getData().fFrames.length - frameCtx.getLevel() - 1;
|
int frameId = getData().fFrames.length - frameCtx.getLevel() - 1;
|
||||||
if (frameId < 0) {
|
if (frameId < 0) {
|
||||||
rm.setStatus(new Status(IStatus.ERROR, PDAPlugin.PLUGIN_ID, IDsfService.INVALID_HANDLE, "Invalid frame level " + frameCtx, null)); //$NON-NLS-1$
|
PDAPlugin.failRequest(rm, IDsfService.INVALID_HANDLE, "Invalid frame level " + frameCtx);
|
||||||
rm.done();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PDAFrame pdaFrame = getData().fFrames[frameId];
|
PDAFrame pdaFrame = getData().fFrames[frameId];
|
||||||
|
|
||||||
|
// Create variable contexts for all variables in frame.
|
||||||
IVariableDMContext[] variableCtxs = new IVariableDMContext[pdaFrame.fVariables.length];
|
IVariableDMContext[] variableCtxs = new IVariableDMContext[pdaFrame.fVariables.length];
|
||||||
for (int i = 0; i < pdaFrame.fVariables.length; i++) {
|
for (int i = 0; i < pdaFrame.fVariables.length; i++) {
|
||||||
variableCtxs[i] = new VariableDMContext(getSession().getId(), frameCtx, pdaFrame.fVariables[i]);
|
variableCtxs[i] = new VariableDMContext(getSession().getId(), frameCtx, pdaFrame.fVariables[i]);
|
||||||
|
@ -170,8 +296,9 @@ public class PDAStack extends AbstractDsfService implements IStack {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getStackDepth(IDMContext context, int maxDepth, final DataRequestMonitor<Integer> rm) {
|
public void getStackDepth(IDMContext context, int maxDepth, final DataRequestMonitor<Integer> rm) {
|
||||||
|
// Execute stack command and return the data's size.
|
||||||
fCommandCache.execute(
|
fCommandCache.execute(
|
||||||
new PDAStackCommand(fCommandControl.getDMContext()),
|
new PDAStackCommand(fCommandControl.getProgramDMContext()),
|
||||||
new DataRequestMonitor<PDAStackCommandResult>(getExecutor(), rm) {
|
new DataRequestMonitor<PDAStackCommandResult>(getExecutor(), rm) {
|
||||||
@Override
|
@Override
|
||||||
protected void handleOK() {
|
protected void handleOK() {
|
||||||
|
@ -182,23 +309,30 @@ public class PDAStack extends AbstractDsfService implements IStack {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getTopFrame(IDMContext context, final DataRequestMonitor<IFrameDMContext> rm) {
|
public void getTopFrame(IDMContext context, final DataRequestMonitor<IFrameDMContext> rm) {
|
||||||
|
// Can only create stack frames for an execution context as a parent,
|
||||||
|
// however the argument context is a generic context type, so it could
|
||||||
|
// be an execution context, a frame, a variable, etc. Search the
|
||||||
|
// hierarchy of the argument context to find the execution one.
|
||||||
final IExecutionDMContext execCtx = DMContexts.getAncestorOfType(context, IExecutionDMContext.class);
|
final IExecutionDMContext execCtx = DMContexts.getAncestorOfType(context, IExecutionDMContext.class);
|
||||||
if (execCtx == null) {
|
if (execCtx == null) {
|
||||||
rm.setStatus(new Status(IStatus.ERROR, PDAPlugin.PLUGIN_ID, IDsfService.INVALID_HANDLE, "Invalid context " + context, null)); //$NON-NLS-1$
|
PDAPlugin.failRequest(rm, IDsfService.INVALID_HANDLE, "Invalid context " + context);
|
||||||
rm.done();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Since the frame context only contain the level, there's no need to
|
||||||
|
// call the PDA debugger. Simply create a context for level 0.
|
||||||
rm.setData(new FrameDMContext(getSession().getId(), execCtx, 0));
|
rm.setData(new FrameDMContext(getSession().getId(), execCtx, 0));
|
||||||
rm.done();
|
rm.done();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getVariableData(IVariableDMContext variableCtx, DataRequestMonitor<IVariableDMData> rm) {
|
public void getVariableData(IVariableDMContext variableCtx, DataRequestMonitor<IVariableDMData> rm) {
|
||||||
if ( !(variableCtx instanceof VariableDMContext) ) {
|
if ( !(variableCtx instanceof VariableDMContext) ) {
|
||||||
rm.setStatus(new Status(IStatus.ERROR, PDAPlugin.PLUGIN_ID, IDsfService.INVALID_HANDLE, "Invalid context " + variableCtx, null)); //$NON-NLS-1$
|
PDAPlugin.failRequest(rm, IDsfService.INVALID_HANDLE, "Invalid context " + variableCtx);
|
||||||
rm.done();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The variable data doen't contain a value. So there's no need to
|
||||||
|
// go to the back end to retrieve it.
|
||||||
String variable = ((VariableDMContext)variableCtx).getVariable();
|
String variable = ((VariableDMContext)variableCtx).getVariable();
|
||||||
|
|
||||||
rm.setData(new VariableDMData(variable));
|
rm.setData(new VariableDMData(variable));
|
||||||
|
@ -206,26 +340,30 @@ public class PDAStack extends AbstractDsfService implements IStack {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isStackAvailable(IDMContext context) {
|
public boolean isStackAvailable(IDMContext context) {
|
||||||
|
// Stack is available if the program is suspended or stepping.
|
||||||
IExecutionDMContext execCtx = DMContexts.getAncestorOfType(context, IExecutionDMContext.class);
|
IExecutionDMContext execCtx = DMContexts.getAncestorOfType(context, IExecutionDMContext.class);
|
||||||
return execCtx != null && (fRunControl.isSuspended(execCtx) || (fRunControl.isStepping(execCtx)));
|
return execCtx != null && (fRunControl.isSuspended(execCtx) || (fRunControl.isStepping(execCtx)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void getModelData(IDMContext dmc, DataRequestMonitor<?> rm) {
|
public void getModelData(IDMContext dmc, DataRequestMonitor<?> rm) {
|
||||||
|
// The getModelData() is deprecated and clients are expected to switch
|
||||||
|
// to getExecutionData() and other data retrieve methods directly.
|
||||||
|
// However the UI cache still uses it for now.
|
||||||
if (dmc instanceof IFrameDMContext) {
|
if (dmc instanceof IFrameDMContext) {
|
||||||
getFrameData((IFrameDMContext)dmc, (DataRequestMonitor<IFrameDMData>)rm);
|
getFrameData((IFrameDMContext)dmc, (DataRequestMonitor<IFrameDMData>)rm);
|
||||||
// getFrameData invokes rm
|
|
||||||
} else if (dmc instanceof IVariableDMContext) {
|
} else if (dmc instanceof IVariableDMContext) {
|
||||||
getVariableData((IVariableDMContext)dmc, (DataRequestMonitor<IVariableDMData>)rm);
|
getVariableData((IVariableDMContext)dmc, (DataRequestMonitor<IVariableDMData>)rm);
|
||||||
// getVariablesData invokes rm
|
|
||||||
} else {
|
} else {
|
||||||
rm.setStatus(new Status(IStatus.ERROR, PDAPlugin.PLUGIN_ID, IDsfService.INVALID_HANDLE, "Unknown context type", null)); //$NON-NLS-1$
|
PDAPlugin.failRequest(rm, IDsfService.INVALID_HANDLE, "Unknown context type");
|
||||||
rm.done();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@DsfServiceEventHandler
|
@DsfServiceEventHandler
|
||||||
public void eventDispatched(IResumedDMEvent e) {
|
public void eventDispatched(IResumedDMEvent e) {
|
||||||
|
// Mark the cache as not available, so that stack commands will
|
||||||
|
// fail. Also reset the cache unless it was a step command.
|
||||||
fCommandCache.setTargetAvailable(false);
|
fCommandCache.setTargetAvailable(false);
|
||||||
if (!e.getReason().equals(StateChangeReason.STEP)) {
|
if (!e.getReason().equals(StateChangeReason.STEP)) {
|
||||||
fCommandCache.reset();
|
fCommandCache.reset();
|
||||||
|
@ -235,6 +373,7 @@ public class PDAStack extends AbstractDsfService implements IStack {
|
||||||
|
|
||||||
@DsfServiceEventHandler
|
@DsfServiceEventHandler
|
||||||
public void eventDispatched(ISuspendedDMEvent e) {
|
public void eventDispatched(ISuspendedDMEvent e) {
|
||||||
|
// Enable sending commands to target and clear the cache.
|
||||||
fCommandCache.setTargetAvailable(true);
|
fCommandCache.setTargetAvailable(true);
|
||||||
fCommandCache.reset();
|
fCommandCache.reset();
|
||||||
}
|
}
|
|
@ -8,15 +8,15 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Wind River Systems - initial API and implementation
|
* Wind River Systems - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.dd.examples.pda.service.command;
|
package org.eclipse.dd.examples.pda.service;
|
||||||
|
|
||||||
import org.eclipse.dd.dsf.datamodel.AbstractDMEvent;
|
import org.eclipse.dd.dsf.datamodel.AbstractDMEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Event issued when the PDA debugger is started.
|
||||||
*/
|
*/
|
||||||
public class PDAStartedEvent extends AbstractDMEvent<PDACommandControlDMContext> {
|
public class PDAStartedEvent extends AbstractDMEvent<PDAProgramDMContext> {
|
||||||
PDAStartedEvent(PDACommandControlDMContext context) {
|
PDAStartedEvent(PDAProgramDMContext context) {
|
||||||
super(context);
|
super(context);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -8,15 +8,15 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Wind River Systems - initial API and implementation
|
* Wind River Systems - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.dd.examples.pda.service.command;
|
package org.eclipse.dd.examples.pda.service;
|
||||||
|
|
||||||
import org.eclipse.dd.dsf.datamodel.AbstractDMEvent;
|
import org.eclipse.dd.dsf.datamodel.AbstractDMEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Event issued when the PDA debugger exits.
|
||||||
*/
|
*/
|
||||||
public class PDATerminatedEvent extends AbstractDMEvent<PDACommandControlDMContext> {
|
public class PDATerminatedEvent extends AbstractDMEvent<PDAProgramDMContext> {
|
||||||
PDATerminatedEvent(PDACommandControlDMContext context) {
|
PDATerminatedEvent(PDAProgramDMContext context) {
|
||||||
super(context);
|
super(context);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,48 +0,0 @@
|
||||||
/*******************************************************************************
|
|
||||||
* 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.examples.pda.service.breakpoints;
|
|
||||||
|
|
||||||
import org.eclipse.dd.dsf.concurrent.Immutable;
|
|
||||||
import org.eclipse.dd.dsf.datamodel.AbstractDMContext;
|
|
||||||
import org.eclipse.dd.dsf.datamodel.IDMContext;
|
|
||||||
import org.eclipse.dd.dsf.debug.service.IBreakpoints.IBreakpointDMContext;
|
|
||||||
import org.eclipse.dd.examples.pda.service.command.PDACommandControlDMContext;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Context representing a PDA line breakpoint. In PDA debugger, since there is only
|
|
||||||
* one file being debugged at a time, a breakpoint is uniquely identified using the
|
|
||||||
* line number only.
|
|
||||||
*/
|
|
||||||
@Immutable
|
|
||||||
class BreakpointDMContext extends AbstractDMContext implements IBreakpointDMContext {
|
|
||||||
|
|
||||||
final Integer fLine;
|
|
||||||
|
|
||||||
public BreakpointDMContext(String sessionId, PDACommandControlDMContext commandControlCtx, Integer line) {
|
|
||||||
super(sessionId, new IDMContext[] { commandControlCtx });
|
|
||||||
fLine = line;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object obj) {
|
|
||||||
return baseEquals(obj) && (fLine.equals(((BreakpointDMContext) obj).fLine));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return baseHashCode() + fLine.hashCode();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return baseToString() + ".breakpoint(" + fLine + ")"; //$NON-NLS-1$//$NON-NLS-2$*/
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,264 +0,0 @@
|
||||||
/*******************************************************************************
|
|
||||||
* Copyright (c) 2007 Ericsson 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:
|
|
||||||
* Ericsson - Initial API and implementation
|
|
||||||
*******************************************************************************/
|
|
||||||
|
|
||||||
package org.eclipse.dd.examples.pda.service.breakpoints;
|
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Hashtable;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import org.eclipse.core.resources.IMarker;
|
|
||||||
import org.eclipse.dd.dsf.concurrent.DataRequestMonitor;
|
|
||||||
import org.eclipse.dd.dsf.concurrent.RequestMonitor;
|
|
||||||
import org.eclipse.dd.dsf.debug.service.IBreakpoints;
|
|
||||||
import org.eclipse.dd.dsf.service.AbstractDsfService;
|
|
||||||
import org.eclipse.dd.dsf.service.DsfSession;
|
|
||||||
import org.eclipse.dd.dsf.service.IDsfService;
|
|
||||||
import org.eclipse.dd.examples.pda.PDAPlugin;
|
|
||||||
import org.eclipse.dd.examples.pda.breakpoints.PDAWatchpoint;
|
|
||||||
import org.eclipse.dd.examples.pda.service.command.PDACommandControl;
|
|
||||||
import org.eclipse.dd.examples.pda.service.command.PDACommandResult;
|
|
||||||
import org.eclipse.dd.examples.pda.service.command.commands.PDAClearBreakpointCommand;
|
|
||||||
import org.eclipse.dd.examples.pda.service.command.commands.PDASetBreakpointCommand;
|
|
||||||
import org.eclipse.dd.examples.pda.service.command.commands.PDAWatchCommand;
|
|
||||||
import org.osgi.framework.BundleContext;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initial breakpoint service implementation.
|
|
||||||
* Implements the IBreakpoints interface.
|
|
||||||
*/
|
|
||||||
public class PDABreakpoints extends AbstractDsfService implements IBreakpoints
|
|
||||||
{
|
|
||||||
public static final String ATTR_BREAKPOINT_TYPE = PDAPlugin.PLUGIN_ID + ".pdaBreakpointType"; //$NON-NLS-1$
|
|
||||||
public static final String PDA_LINE_BREAKPOINT = "breakpoint"; //$NON-NLS-1$
|
|
||||||
public static final String PDA_WATCHPOINT = "watchpoint"; //$NON-NLS-1$
|
|
||||||
public static final String ATTR_PROGRAM_PATH = PDAPlugin.PLUGIN_ID + ".pdaProgramPath"; //$NON-NLS-1$
|
|
||||||
|
|
||||||
private final String fProgram;
|
|
||||||
|
|
||||||
// Services
|
|
||||||
private PDACommandControl fCommandControl;
|
|
||||||
|
|
||||||
// Service breakpoints tracking
|
|
||||||
// The breakpoints are stored per context and keyed on the back-end breakpoint reference
|
|
||||||
private Set<IBreakpointDMContext> fBreakpoints = new HashSet<IBreakpointDMContext>();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The service constructor
|
|
||||||
*
|
|
||||||
* @param session The debugging session this service belongs to.
|
|
||||||
* @param program The name of the program of this PDA debugger.
|
|
||||||
*/
|
|
||||||
public PDABreakpoints(DsfSession session, String program) {
|
|
||||||
super(session);
|
|
||||||
fProgram = program;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void initialize(final RequestMonitor rm) {
|
|
||||||
super.initialize(new RequestMonitor(getExecutor(), rm) {
|
|
||||||
@Override
|
|
||||||
protected void handleOK() {
|
|
||||||
doInitialize(rm);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void doInitialize(final RequestMonitor rm) {
|
|
||||||
|
|
||||||
// Get the services references
|
|
||||||
fCommandControl = getServicesTracker().getService(PDACommandControl.class);
|
|
||||||
|
|
||||||
// Register this service
|
|
||||||
register(new String[] { IBreakpoints.class.getName(), PDABreakpoints.class.getName() },
|
|
||||||
new Hashtable<String, String>());
|
|
||||||
|
|
||||||
rm.done();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void shutdown(final RequestMonitor rm) {
|
|
||||||
unregister();
|
|
||||||
rm.done();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected BundleContext getBundleContext() {
|
|
||||||
return PDAPlugin.getBundleContext();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void getBreakpoints(final IBreakpointsTargetDMContext context, final DataRequestMonitor<IBreakpointDMContext[]> rm) {
|
|
||||||
// Validate the context
|
|
||||||
if (!fCommandControl.getDMContext().equals(context)) {
|
|
||||||
PDAPlugin.failRequest(rm, IDsfService.INVALID_HANDLE, "Invalid breakpoints target context");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
rm.setData(fBreakpoints.toArray(new IBreakpointDMContext[fBreakpoints.size()]));
|
|
||||||
rm.done();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void getBreakpointDMData(IBreakpointDMContext dmc, DataRequestMonitor<IBreakpointDMData> rm) {
|
|
||||||
PDAPlugin.failRequest(rm, IDsfService.NOT_SUPPORTED, "Retrieving breakpoint data is not supported");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void insertBreakpoint(IBreakpointsTargetDMContext context, Map<String, Object> attributes,
|
|
||||||
DataRequestMonitor<IBreakpointDMContext> rm)
|
|
||||||
{
|
|
||||||
String type = (String) attributes.get(ATTR_BREAKPOINT_TYPE);
|
|
||||||
|
|
||||||
if (PDA_LINE_BREAKPOINT.equals(type)) {
|
|
||||||
doInsertBreakpoint(attributes, rm);
|
|
||||||
}
|
|
||||||
else if (PDA_WATCHPOINT.equals(type)) {
|
|
||||||
doInsertWatchpoint(attributes, rm);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
PDAPlugin.failRequest(rm, IDsfService.REQUEST_FAILED, "Unknown breakpoint type");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void doInsertBreakpoint(final Map<String, Object> attributes, final DataRequestMonitor<IBreakpointDMContext> rm)
|
|
||||||
{
|
|
||||||
String program = (String)attributes.get(ATTR_PROGRAM_PATH);
|
|
||||||
if (!fProgram.equals(program)) {
|
|
||||||
PDAPlugin.failRequest(rm, IDsfService.REQUEST_FAILED, "Invalid file name");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Integer line = (Integer)attributes.get(IMarker.LINE_NUMBER);
|
|
||||||
if (line == null) {
|
|
||||||
PDAPlugin.failRequest(rm, IDsfService.REQUEST_FAILED, "No breakpoint line specified");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
final BreakpointDMContext breakpointCtx =
|
|
||||||
new BreakpointDMContext(getSession().getId(), fCommandControl.getDMContext(), line);
|
|
||||||
if (fBreakpoints.contains(breakpointCtx)) {
|
|
||||||
PDAPlugin.failRequest(rm, IDsfService.REQUEST_FAILED, "Breakpoint already set");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
fBreakpoints.add(breakpointCtx);
|
|
||||||
fCommandControl.queueCommand(
|
|
||||||
new PDASetBreakpointCommand(fCommandControl.getDMContext(), line),
|
|
||||||
new DataRequestMonitor<PDACommandResult>(getExecutor(), rm) {
|
|
||||||
@Override
|
|
||||||
protected void handleOK() {
|
|
||||||
rm.setData(breakpointCtx);
|
|
||||||
rm.done();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void handleErrorOrCancel() {
|
|
||||||
fBreakpoints.remove(breakpointCtx);
|
|
||||||
super.handleErrorOrCancel();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void doInsertWatchpoint(final Map<String, Object> attributes, final DataRequestMonitor<IBreakpointDMContext> rm)
|
|
||||||
{
|
|
||||||
String function = (String)attributes.get(PDAWatchpoint.FUNCTION_NAME);
|
|
||||||
if (function == null) {
|
|
||||||
PDAPlugin.failRequest(rm, IDsfService.REQUEST_FAILED, "No function specified");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
String variable = (String)attributes.get(PDAWatchpoint.VAR_NAME);
|
|
||||||
if (variable == null) {
|
|
||||||
PDAPlugin.failRequest(rm, IDsfService.REQUEST_FAILED, "No variable specified");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Boolean isAccess = (Boolean)attributes.get(PDAWatchpoint.ACCESS);
|
|
||||||
isAccess = isAccess != null ? isAccess : Boolean.FALSE;
|
|
||||||
|
|
||||||
Boolean isModification = (Boolean)attributes.get(PDAWatchpoint.MODIFICATION);
|
|
||||||
isModification = isModification != null ? isModification : Boolean.FALSE;
|
|
||||||
|
|
||||||
final WatchpointDMContext watchpointCtx =
|
|
||||||
new WatchpointDMContext(getSession().getId(), fCommandControl.getDMContext(), function, variable);
|
|
||||||
if (fBreakpoints.contains(watchpointCtx)) {
|
|
||||||
PDAPlugin.failRequest(rm, IDsfService.REQUEST_FAILED, "Watchpoint already set");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
PDAWatchCommand.WatchOperation watchOperation = PDAWatchCommand.WatchOperation.NONE;
|
|
||||||
if (isAccess && isModification) {
|
|
||||||
watchOperation = PDAWatchCommand.WatchOperation.BOTH;
|
|
||||||
} else if (isAccess) {
|
|
||||||
watchOperation = PDAWatchCommand.WatchOperation.READ;
|
|
||||||
} else if (isModification) {
|
|
||||||
watchOperation = PDAWatchCommand.WatchOperation.WRITE;
|
|
||||||
}
|
|
||||||
|
|
||||||
fBreakpoints.add(watchpointCtx);
|
|
||||||
fCommandControl.queueCommand(
|
|
||||||
new PDAWatchCommand(fCommandControl.getDMContext(), function, variable, watchOperation),
|
|
||||||
new DataRequestMonitor<PDACommandResult>(getExecutor(), rm) {
|
|
||||||
@Override
|
|
||||||
protected void handleOK() {
|
|
||||||
rm.setData(watchpointCtx);
|
|
||||||
rm.done();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void handleErrorOrCancel() {
|
|
||||||
// Since the command failed, we need to remove the breakpoint from
|
|
||||||
// the existing breakpoint set.
|
|
||||||
fBreakpoints.remove(watchpointCtx);
|
|
||||||
super.handleErrorOrCancel();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public void removeBreakpoint(IBreakpointDMContext bpCtx, RequestMonitor rm) {
|
|
||||||
if (!fBreakpoints.contains(bpCtx)) {
|
|
||||||
PDAPlugin.failRequest(rm, IDsfService.REQUEST_FAILED, "Breakpoint already removed");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bpCtx instanceof BreakpointDMContext) {
|
|
||||||
doRemoveBreakpoint((BreakpointDMContext)bpCtx, rm);
|
|
||||||
} else if (bpCtx instanceof WatchpointDMContext) {
|
|
||||||
doRemoveWatchpoint((WatchpointDMContext)bpCtx, rm);
|
|
||||||
} else {
|
|
||||||
PDAPlugin.failRequest(rm, IDsfService.INVALID_HANDLE, "Invalid breakpoint");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void doRemoveBreakpoint(BreakpointDMContext bpCtx, RequestMonitor rm) {
|
|
||||||
// Remove the breakpoint from the table right away, so that even when
|
|
||||||
// the remove is being processed, a new breakpoint can be created at the same
|
|
||||||
// location.
|
|
||||||
fBreakpoints.remove(bpCtx);
|
|
||||||
|
|
||||||
fCommandControl.queueCommand(
|
|
||||||
new PDAClearBreakpointCommand(fCommandControl.getDMContext(), bpCtx.fLine),
|
|
||||||
new DataRequestMonitor<PDACommandResult>(getExecutor(), rm));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void doRemoveWatchpoint(WatchpointDMContext bpCtx, RequestMonitor rm) {
|
|
||||||
fBreakpoints.remove(bpCtx);
|
|
||||||
|
|
||||||
// Watchpoints are cleared using the same command, but with a "no watch" operation
|
|
||||||
fCommandControl.queueCommand(
|
|
||||||
new PDAWatchCommand(fCommandControl.getDMContext(), bpCtx.fFunction, bpCtx.fVariable,
|
|
||||||
PDAWatchCommand.WatchOperation.NONE),
|
|
||||||
new DataRequestMonitor<PDACommandResult>(getExecutor(), rm));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void updateBreakpoint(IBreakpointDMContext dmc, Map<String, Object> properties, RequestMonitor rm) {
|
|
||||||
PDAPlugin.failRequest(rm, IDsfService.NOT_SUPPORTED, "Modifying PDA breakpoints is not supported");
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,54 +0,0 @@
|
||||||
/*******************************************************************************
|
|
||||||
* 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.examples.pda.service.breakpoints;
|
|
||||||
|
|
||||||
import org.eclipse.dd.dsf.concurrent.Immutable;
|
|
||||||
import org.eclipse.dd.dsf.datamodel.AbstractDMContext;
|
|
||||||
import org.eclipse.dd.dsf.datamodel.IDMContext;
|
|
||||||
import org.eclipse.dd.dsf.debug.service.IBreakpoints.IBreakpointDMContext;
|
|
||||||
import org.eclipse.dd.examples.pda.service.command.PDACommandControlDMContext;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Context representing a watch point. In PDA debugger, a watchpoint is
|
|
||||||
* uniquely identified using the function and variable.
|
|
||||||
*/
|
|
||||||
@Immutable
|
|
||||||
class WatchpointDMContext extends AbstractDMContext implements IBreakpointDMContext {
|
|
||||||
final String fFunction;
|
|
||||||
final String fVariable;
|
|
||||||
|
|
||||||
public WatchpointDMContext(String sessionId, PDACommandControlDMContext commandControlCtx, String function,
|
|
||||||
String variable)
|
|
||||||
{
|
|
||||||
super(sessionId, new IDMContext[] { commandControlCtx });
|
|
||||||
fFunction = function;
|
|
||||||
fVariable = variable;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object obj) {
|
|
||||||
if (baseEquals(obj)) {
|
|
||||||
WatchpointDMContext watchpointCtx = (WatchpointDMContext)obj;
|
|
||||||
return fFunction.equals(watchpointCtx.fFunction) && fVariable.equals(watchpointCtx.fVariable);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return baseHashCode() + fFunction.hashCode() + fVariable.hashCode();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return baseToString() + ".watchpoint(" + fFunction + "::" + fVariable + ")";
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,45 +0,0 @@
|
||||||
/*******************************************************************************
|
|
||||||
* Copyright (c) 2007 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.examples.pda.service.command;
|
|
||||||
|
|
||||||
import org.eclipse.dd.dsf.datamodel.AbstractDMContext;
|
|
||||||
import org.eclipse.dd.dsf.datamodel.IDMContext;
|
|
||||||
import org.eclipse.dd.dsf.debug.service.IBreakpoints.IBreakpointsTargetDMContext;
|
|
||||||
import org.eclipse.dd.dsf.debug.service.IRunControl.IExecutionDMContext;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class PDACommandControlDMContext extends AbstractDMContext
|
|
||||||
implements IExecutionDMContext, IBreakpointsTargetDMContext
|
|
||||||
{
|
|
||||||
|
|
||||||
private Object fHashObject = new Object();
|
|
||||||
|
|
||||||
public PDACommandControlDMContext(String sessionId) {
|
|
||||||
super(sessionId, new IDMContext[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object obj) {
|
|
||||||
return obj == this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return fHashObject.hashCode();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "PDA(" + getSessionId() + ")";
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,27 +0,0 @@
|
||||||
/*******************************************************************************
|
|
||||||
* 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.examples.pda.service.command.commands;
|
|
||||||
|
|
||||||
import org.eclipse.dd.examples.pda.service.command.PDACommandResult;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see PDAVarCommand
|
|
||||||
*/
|
|
||||||
public class PDAVarCommandResult extends PDACommandResult {
|
|
||||||
|
|
||||||
final public int fValue;
|
|
||||||
|
|
||||||
PDAVarCommandResult(String response) {
|
|
||||||
super(response);
|
|
||||||
fValue = Integer.parseInt(response);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -8,23 +8,24 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Wind River Systems - initial API and implementation
|
* Wind River Systems - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.dd.examples.pda.service.command.commands;
|
package org.eclipse.dd.examples.pda.service.commands;
|
||||||
|
|
||||||
import org.eclipse.dd.dsf.datamodel.IDMContext;
|
import org.eclipse.dd.dsf.datamodel.IDMContext;
|
||||||
import org.eclipse.dd.dsf.debug.service.command.ICommand;
|
import org.eclipse.dd.dsf.debug.service.command.ICommand;
|
||||||
import org.eclipse.dd.dsf.debug.service.command.ICommandResult;
|
import org.eclipse.dd.dsf.debug.service.command.ICommandResult;
|
||||||
import org.eclipse.dd.examples.pda.service.command.PDACommandControlDMContext;
|
import org.eclipse.dd.examples.pda.service.PDAProgramDMContext;
|
||||||
import org.eclipse.dd.examples.pda.service.command.PDACommandResult;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Base class for PDA commands. The PDA commands consist of a text request and
|
||||||
|
* a context. Since the PDA debugger protocol is stateless, the context is only
|
||||||
|
* needed to satisfy the ICommand interface.
|
||||||
*/
|
*/
|
||||||
abstract public class AbstractPDACommand<V extends PDACommandResult> implements ICommand<V> {
|
abstract public class AbstractPDACommand<V extends PDACommandResult> implements ICommand<V> {
|
||||||
|
|
||||||
final private IDMContext fContext;
|
final private IDMContext fContext;
|
||||||
final private String fRequest;
|
final private String fRequest;
|
||||||
|
|
||||||
public AbstractPDACommand(PDACommandControlDMContext context, String request) {
|
public AbstractPDACommand(PDAProgramDMContext context, String request) {
|
||||||
fContext = context;
|
fContext = context;
|
||||||
fRequest = request;
|
fRequest = request;
|
||||||
}
|
}
|
||||||
|
@ -37,10 +38,19 @@ abstract public class AbstractPDACommand<V extends PDACommandResult> implements
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the request to be sent to PDA.
|
||||||
|
*/
|
||||||
public String getRequest() {
|
public String getRequest() {
|
||||||
return fRequest;
|
return fRequest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the command result based on the given PDA response. This command
|
||||||
|
* uses the class type parameter as the return type to allow the compiler to
|
||||||
|
* enforce the correct command result. This class must be implemented by
|
||||||
|
* each command to create the concrete result type.
|
||||||
|
*/
|
||||||
abstract public V createResult(String resultText);
|
abstract public V createResult(String resultText);
|
||||||
|
|
||||||
@Override
|
@Override
|
|
@ -8,10 +8,9 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Wind River Systems - initial API and implementation
|
* Wind River Systems - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.dd.examples.pda.service.command.commands;
|
package org.eclipse.dd.examples.pda.service.commands;
|
||||||
|
|
||||||
import org.eclipse.dd.examples.pda.service.command.PDACommandControlDMContext;
|
import org.eclipse.dd.examples.pda.service.PDAProgramDMContext;
|
||||||
import org.eclipse.dd.examples.pda.service.command.PDACommandResult;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clears any breakpoint set on given line
|
* Clears any breakpoint set on given line
|
||||||
|
@ -24,7 +23,7 @@ import org.eclipse.dd.examples.pda.service.command.PDACommandResult;
|
||||||
*/
|
*/
|
||||||
public class PDAClearBreakpointCommand extends AbstractPDACommand<PDACommandResult> {
|
public class PDAClearBreakpointCommand extends AbstractPDACommand<PDACommandResult> {
|
||||||
|
|
||||||
public PDAClearBreakpointCommand(PDACommandControlDMContext context, int line) {
|
public PDAClearBreakpointCommand(PDAProgramDMContext context, int line) {
|
||||||
super(context, "clear " + (line - 1));
|
super(context, "clear " + (line - 1));
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,14 +8,16 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Wind River Systems - initial API and implementation
|
* Wind River Systems - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.dd.examples.pda.service.command;
|
package org.eclipse.dd.examples.pda.service.commands;
|
||||||
|
|
||||||
import org.eclipse.dd.dsf.debug.service.command.ICommand;
|
import org.eclipse.dd.dsf.debug.service.command.ICommand;
|
||||||
import org.eclipse.dd.dsf.debug.service.command.ICommandResult;
|
import org.eclipse.dd.dsf.debug.service.command.ICommandResult;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Basic command result object. This command result simply allows access to the
|
||||||
|
* PDA response. Sub-classes may override to optionally parse the response text
|
||||||
|
* and return higher-level objects.
|
||||||
*/
|
*/
|
||||||
public class PDACommandResult implements ICommandResult {
|
public class PDACommandResult implements ICommandResult {
|
||||||
|
|
|
@ -8,10 +8,9 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Wind River Systems - initial API and implementation
|
* Wind River Systems - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.dd.examples.pda.service.command.commands;
|
package org.eclipse.dd.examples.pda.service.commands;
|
||||||
|
|
||||||
import org.eclipse.dd.examples.pda.service.command.PDACommandControlDMContext;
|
import org.eclipse.dd.examples.pda.service.PDAProgramDMContext;
|
||||||
import org.eclipse.dd.examples.pda.service.command.PDACommandResult;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves data stack information
|
* Retrieves data stack information
|
||||||
|
@ -23,7 +22,7 @@ import org.eclipse.dd.examples.pda.service.command.PDACommandResult;
|
||||||
*/
|
*/
|
||||||
public class PDADataCommand extends AbstractPDACommand<PDACommandResult> {
|
public class PDADataCommand extends AbstractPDACommand<PDACommandResult> {
|
||||||
|
|
||||||
public PDADataCommand(PDACommandControlDMContext context) {
|
public PDADataCommand(PDAProgramDMContext context) {
|
||||||
super(context, "data");
|
super(context, "data");
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,35 +8,33 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Wind River Systems - initial API and implementation
|
* Wind River Systems - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.dd.examples.pda.service.command.commands;
|
package org.eclipse.dd.examples.pda.service.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
|
|
||||||
import org.eclipse.dd.examples.pda.service.command.PDACommandResult;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see PDADataCommand
|
* @see PDADataCommand
|
||||||
*/
|
*/
|
||||||
public class PDADataCommandResult extends PDACommandResult {
|
public class PDADataCommandResult extends PDACommandResult {
|
||||||
|
|
||||||
final public int[] fValues;
|
final public String[] fValues;
|
||||||
|
|
||||||
PDADataCommandResult(String response) {
|
PDADataCommandResult(String response) {
|
||||||
super(response);
|
super(response);
|
||||||
StringTokenizer st = new StringTokenizer(response, "|");
|
StringTokenizer st = new StringTokenizer(response, "|");
|
||||||
List<Integer> valuesList = new ArrayList<Integer>();
|
List<String> valuesList = new ArrayList<String>();
|
||||||
|
|
||||||
while (st.hasMoreTokens()) {
|
while (st.hasMoreTokens()) {
|
||||||
String token = st.nextToken();
|
String token = st.nextToken();
|
||||||
if (token.length() != 0) {
|
if (token.length() != 0) {
|
||||||
valuesList.add(new Integer(st.nextToken()));
|
valuesList.add(st.nextToken());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fValues = new String[valuesList.size()];
|
||||||
fValues = new int[valuesList.size()];
|
|
||||||
for (int i = 0; i < valuesList.size(); i++) {
|
for (int i = 0; i < valuesList.size(); i++) {
|
||||||
fValues[i] = valuesList.get(i);
|
fValues[i] = valuesList.get(i);
|
||||||
}
|
}
|
|
@ -8,10 +8,9 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Wind River Systems - initial API and implementation
|
* Wind River Systems - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.dd.examples.pda.service.command.commands;
|
package org.eclipse.dd.examples.pda.service.commands;
|
||||||
|
|
||||||
import org.eclipse.dd.examples.pda.service.command.PDACommandControlDMContext;
|
import org.eclipse.dd.examples.pda.service.PDAProgramDMContext;
|
||||||
import org.eclipse.dd.examples.pda.service.command.PDACommandResult;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns from the current frame without executing the rest of instructions.
|
* Returns from the current frame without executing the rest of instructions.
|
||||||
|
@ -26,7 +25,7 @@ import org.eclipse.dd.examples.pda.service.command.PDACommandResult;
|
||||||
*/
|
*/
|
||||||
public class PDADropFrameCommand extends AbstractPDACommand<PDACommandResult> {
|
public class PDADropFrameCommand extends AbstractPDACommand<PDACommandResult> {
|
||||||
|
|
||||||
public PDADropFrameCommand(PDACommandControlDMContext context) {
|
public PDADropFrameCommand(PDAProgramDMContext context) {
|
||||||
super(context, "drop");
|
super(context, "drop");
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,10 +8,9 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Wind River Systems - initial API and implementation
|
* Wind River Systems - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.dd.examples.pda.service.command.commands;
|
package org.eclipse.dd.examples.pda.service.commands;
|
||||||
|
|
||||||
import org.eclipse.dd.examples.pda.service.command.PDACommandControlDMContext;
|
import org.eclipse.dd.examples.pda.service.PDAProgramDMContext;
|
||||||
import org.eclipse.dd.examples.pda.service.command.PDACommandResult;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets what events cause the execution to stop.
|
* Sets what events cause the execution to stop.
|
||||||
|
@ -28,7 +27,7 @@ import org.eclipse.dd.examples.pda.service.command.PDACommandResult;
|
||||||
*/
|
*/
|
||||||
public class PDAEvalCommand extends AbstractPDACommand<PDACommandResult> {
|
public class PDAEvalCommand extends AbstractPDACommand<PDACommandResult> {
|
||||||
|
|
||||||
public PDAEvalCommand(PDACommandControlDMContext context, String operation) {
|
public PDAEvalCommand(PDAProgramDMContext context, String operation) {
|
||||||
super(context, "eval " + operation);
|
super(context, "eval " + operation);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,10 +8,9 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Wind River Systems - initial API and implementation
|
* Wind River Systems - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.dd.examples.pda.service.command.commands;
|
package org.eclipse.dd.examples.pda.service.commands;
|
||||||
|
|
||||||
import org.eclipse.dd.examples.pda.service.command.PDACommandControlDMContext;
|
import org.eclipse.dd.examples.pda.service.PDAProgramDMContext;
|
||||||
import org.eclipse.dd.examples.pda.service.command.PDACommandResult;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets what events cause the execution to stop.
|
* Sets what events cause the execution to stop.
|
||||||
|
@ -29,7 +28,7 @@ public class PDAEventStopCommand extends AbstractPDACommand<PDACommandResult> {
|
||||||
|
|
||||||
public enum Event { UNIMPINSTR, NOSUCHLABEL };
|
public enum Event { UNIMPINSTR, NOSUCHLABEL };
|
||||||
|
|
||||||
public PDAEventStopCommand(PDACommandControlDMContext context, Event event, boolean enable) {
|
public PDAEventStopCommand(PDAProgramDMContext context, Event event, boolean enable) {
|
||||||
super(context,
|
super(context,
|
||||||
"eventstop " +
|
"eventstop " +
|
||||||
(event == Event.UNIMPINSTR ? "unimpinstr " : "nosuchlabel ") +
|
(event == Event.UNIMPINSTR ? "unimpinstr " : "nosuchlabel ") +
|
|
@ -8,10 +8,9 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Wind River Systems - initial API and implementation
|
* Wind River Systems - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.dd.examples.pda.service.command.commands;
|
package org.eclipse.dd.examples.pda.service.commands;
|
||||||
|
|
||||||
import org.eclipse.dd.examples.pda.service.command.PDACommandControlDMContext;
|
import org.eclipse.dd.examples.pda.service.PDAProgramDMContext;
|
||||||
import org.eclipse.dd.examples.pda.service.command.PDACommandResult;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instructs the debugger to exit.
|
* Instructs the debugger to exit.
|
||||||
|
@ -23,7 +22,7 @@ import org.eclipse.dd.examples.pda.service.command.PDACommandResult;
|
||||||
*/
|
*/
|
||||||
public class PDAExitCommand extends AbstractPDACommand<PDACommandResult> {
|
public class PDAExitCommand extends AbstractPDACommand<PDACommandResult> {
|
||||||
|
|
||||||
public PDAExitCommand(PDACommandControlDMContext context) {
|
public PDAExitCommand(PDAProgramDMContext context) {
|
||||||
super(context, "exit");
|
super(context, "exit");
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Wind River Systems - initial API and implementation
|
* Wind River Systems - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.dd.examples.pda.service.command.commands;
|
package org.eclipse.dd.examples.pda.service.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -17,7 +17,18 @@ import java.util.StringTokenizer;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.Path;
|
import org.eclipse.core.runtime.Path;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Object representing a frame in the stack command results.
|
||||||
|
*
|
||||||
|
* @see PDAStackCommand
|
||||||
|
*/
|
||||||
public class PDAFrame {
|
public class PDAFrame {
|
||||||
|
|
||||||
|
final public IPath fFilePath;
|
||||||
|
final public int fLine;
|
||||||
|
final public String fFunction;
|
||||||
|
final public String[] fVariables;
|
||||||
|
|
||||||
PDAFrame(String frameString) {
|
PDAFrame(String frameString) {
|
||||||
StringTokenizer st = new StringTokenizer(frameString, "|");
|
StringTokenizer st = new StringTokenizer(frameString, "|");
|
||||||
|
|
||||||
|
@ -31,8 +42,4 @@ public class PDAFrame {
|
||||||
}
|
}
|
||||||
fVariables = variablesList.toArray(new String[variablesList.size()]);
|
fVariables = variablesList.toArray(new String[variablesList.size()]);
|
||||||
}
|
}
|
||||||
final public IPath fFilePath;
|
|
||||||
final public int fLine;
|
|
||||||
final public String fFunction;
|
|
||||||
final public String[] fVariables;
|
|
||||||
}
|
}
|
|
@ -8,10 +8,9 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Wind River Systems - initial API and implementation
|
* Wind River Systems - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.dd.examples.pda.service.command.commands;
|
package org.eclipse.dd.examples.pda.service.commands;
|
||||||
|
|
||||||
import org.eclipse.dd.examples.pda.service.command.PDACommandControlDMContext;
|
import org.eclipse.dd.examples.pda.service.PDAProgramDMContext;
|
||||||
import org.eclipse.dd.examples.pda.service.command.PDACommandResult;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pops the top value from the data stack
|
* Pops the top value from the data stack
|
||||||
|
@ -23,7 +22,7 @@ import org.eclipse.dd.examples.pda.service.command.PDACommandResult;
|
||||||
*/
|
*/
|
||||||
public class PDAPopDataCommand extends AbstractPDACommand<PDACommandResult> {
|
public class PDAPopDataCommand extends AbstractPDACommand<PDACommandResult> {
|
||||||
|
|
||||||
public PDAPopDataCommand(PDACommandControlDMContext context) {
|
public PDAPopDataCommand(PDAProgramDMContext context) {
|
||||||
super(context, "popdata");
|
super(context, "popdata");
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,10 +8,9 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Wind River Systems - initial API and implementation
|
* Wind River Systems - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.dd.examples.pda.service.command.commands;
|
package org.eclipse.dd.examples.pda.service.commands;
|
||||||
|
|
||||||
import org.eclipse.dd.examples.pda.service.command.PDACommandControlDMContext;
|
import org.eclipse.dd.examples.pda.service.PDAProgramDMContext;
|
||||||
import org.eclipse.dd.examples.pda.service.command.PDACommandResult;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pushes the given value on top of the data stack.
|
* Pushes the given value on top of the data stack.
|
||||||
|
@ -23,7 +22,7 @@ import org.eclipse.dd.examples.pda.service.command.PDACommandResult;
|
||||||
*/
|
*/
|
||||||
public class PDAPushDataCommand extends AbstractPDACommand<PDACommandResult> {
|
public class PDAPushDataCommand extends AbstractPDACommand<PDACommandResult> {
|
||||||
|
|
||||||
public PDAPushDataCommand(PDACommandControlDMContext context, int value) {
|
public PDAPushDataCommand(PDAProgramDMContext context, int value) {
|
||||||
super(context, "pushdata " + value);
|
super(context, "pushdata " + value);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,10 +8,9 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Wind River Systems - initial API and implementation
|
* Wind River Systems - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.dd.examples.pda.service.command.commands;
|
package org.eclipse.dd.examples.pda.service.commands;
|
||||||
|
|
||||||
import org.eclipse.dd.examples.pda.service.command.PDACommandControlDMContext;
|
import org.eclipse.dd.examples.pda.service.PDAProgramDMContext;
|
||||||
import org.eclipse.dd.examples.pda.service.command.PDACommandResult;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resumes the execution
|
* Resumes the execution
|
||||||
|
@ -24,7 +23,7 @@ import org.eclipse.dd.examples.pda.service.command.PDACommandResult;
|
||||||
*/
|
*/
|
||||||
public class PDAResumeCommand extends AbstractPDACommand<PDACommandResult> {
|
public class PDAResumeCommand extends AbstractPDACommand<PDACommandResult> {
|
||||||
|
|
||||||
public PDAResumeCommand(PDACommandControlDMContext context) {
|
public PDAResumeCommand(PDAProgramDMContext context) {
|
||||||
super(context, "resume");
|
super(context, "resume");
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,10 +8,9 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Wind River Systems - initial API and implementation
|
* Wind River Systems - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.dd.examples.pda.service.command.commands;
|
package org.eclipse.dd.examples.pda.service.commands;
|
||||||
|
|
||||||
import org.eclipse.dd.examples.pda.service.command.PDACommandControlDMContext;
|
import org.eclipse.dd.examples.pda.service.PDAProgramDMContext;
|
||||||
import org.eclipse.dd.examples.pda.service.command.PDACommandResult;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a breakpoint at given line
|
* Sets a breakpoint at given line
|
||||||
|
@ -26,7 +25,7 @@ import org.eclipse.dd.examples.pda.service.command.PDACommandResult;
|
||||||
*/
|
*/
|
||||||
public class PDASetBreakpointCommand extends AbstractPDACommand<PDACommandResult> {
|
public class PDASetBreakpointCommand extends AbstractPDACommand<PDACommandResult> {
|
||||||
|
|
||||||
public PDASetBreakpointCommand(PDACommandControlDMContext context, int line) {
|
public PDASetBreakpointCommand(PDAProgramDMContext context, int line) {
|
||||||
super(context, "set " + (line - 1));
|
super(context, "set " + (line - 1));
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,10 +8,9 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Wind River Systems - initial API and implementation
|
* Wind River Systems - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.dd.examples.pda.service.command.commands;
|
package org.eclipse.dd.examples.pda.service.commands;
|
||||||
|
|
||||||
import org.eclipse.dd.examples.pda.service.command.PDACommandControlDMContext;
|
import org.eclipse.dd.examples.pda.service.PDAProgramDMContext;
|
||||||
import org.eclipse.dd.examples.pda.service.command.PDACommandResult;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a data value in the data stack at the given location
|
* Sets a data value in the data stack at the given location
|
||||||
|
@ -23,7 +22,7 @@ import org.eclipse.dd.examples.pda.service.command.PDACommandResult;
|
||||||
*/
|
*/
|
||||||
public class PDASetDataCommand extends AbstractPDACommand<PDACommandResult> {
|
public class PDASetDataCommand extends AbstractPDACommand<PDACommandResult> {
|
||||||
|
|
||||||
public PDASetDataCommand(PDACommandControlDMContext context, int index, int value) {
|
public PDASetDataCommand(PDAProgramDMContext context, int index, String value) {
|
||||||
super(context, "setdata " + index + " " + value);
|
super(context, "setdata " + index + " " + value);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,23 +8,22 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Wind River Systems - initial API and implementation
|
* Wind River Systems - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.dd.examples.pda.service.command.commands;
|
package org.eclipse.dd.examples.pda.service.commands;
|
||||||
|
|
||||||
import org.eclipse.dd.examples.pda.service.command.PDACommandControlDMContext;
|
import org.eclipse.dd.examples.pda.service.PDAProgramDMContext;
|
||||||
import org.eclipse.dd.examples.pda.service.command.PDACommandResult;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a variable value
|
* Sets a variable value
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* C: setvar {variable} {value}
|
* C: setvar {frame_number} {variable} {value}
|
||||||
* R: ok
|
* R: ok
|
||||||
* </pre>
|
* </pre>
|
||||||
*/
|
*/
|
||||||
public class PDASetVarCommand extends AbstractPDACommand<PDACommandResult> {
|
public class PDASetVarCommand extends AbstractPDACommand<PDACommandResult> {
|
||||||
|
|
||||||
public PDASetVarCommand(PDACommandControlDMContext context, String variable, String value) {
|
public PDASetVarCommand(PDAProgramDMContext context, int frame, String variable, String value) {
|
||||||
super(context, "setvar " + variable + " " + value);
|
super(context, "setvar " + frame + " " + variable + " " + value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
|
@ -8,9 +8,9 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Wind River Systems - initial API and implementation
|
* Wind River Systems - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.dd.examples.pda.service.command.commands;
|
package org.eclipse.dd.examples.pda.service.commands;
|
||||||
|
|
||||||
import org.eclipse.dd.examples.pda.service.command.PDACommandControlDMContext;
|
import org.eclipse.dd.examples.pda.service.PDAProgramDMContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves command stack information
|
* Retrieves command stack information
|
||||||
|
@ -22,7 +22,7 @@ import org.eclipse.dd.examples.pda.service.command.PDACommandControlDMContext;
|
||||||
*/
|
*/
|
||||||
public class PDAStackCommand extends AbstractPDACommand<PDAStackCommandResult> {
|
public class PDAStackCommand extends AbstractPDACommand<PDAStackCommandResult> {
|
||||||
|
|
||||||
public PDAStackCommand(PDACommandControlDMContext context) {
|
public PDAStackCommand(PDAProgramDMContext context) {
|
||||||
super(context, "stack");
|
super(context, "stack");
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,19 +8,22 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Wind River Systems - initial API and implementation
|
* Wind River Systems - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.dd.examples.pda.service.command.commands;
|
package org.eclipse.dd.examples.pda.service.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
|
|
||||||
import org.eclipse.dd.examples.pda.service.command.PDACommandResult;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see PDAStackCommand
|
* @see PDAStackCommand
|
||||||
*/
|
*/
|
||||||
public class PDAStackCommandResult extends PDACommandResult {
|
public class PDAStackCommandResult extends PDACommandResult {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Array of frames return by the stack commands. The frames are ordered
|
||||||
|
* with the highest-level frame first.
|
||||||
|
*/
|
||||||
final public PDAFrame[] fFrames;
|
final public PDAFrame[] fFrames;
|
||||||
|
|
||||||
PDAStackCommandResult(String response) {
|
PDAStackCommandResult(String response) {
|
|
@ -8,10 +8,9 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Wind River Systems - initial API and implementation
|
* Wind River Systems - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.dd.examples.pda.service.command.commands;
|
package org.eclipse.dd.examples.pda.service.commands;
|
||||||
|
|
||||||
import org.eclipse.dd.examples.pda.service.command.PDACommandControlDMContext;
|
import org.eclipse.dd.examples.pda.service.PDAProgramDMContext;
|
||||||
import org.eclipse.dd.examples.pda.service.command.PDACommandResult;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes next instruciton
|
* Executes next instruciton
|
||||||
|
@ -25,7 +24,7 @@ import org.eclipse.dd.examples.pda.service.command.PDACommandResult;
|
||||||
*/
|
*/
|
||||||
public class PDAStepCommand extends AbstractPDACommand<PDACommandResult> {
|
public class PDAStepCommand extends AbstractPDACommand<PDACommandResult> {
|
||||||
|
|
||||||
public PDAStepCommand(PDACommandControlDMContext context) {
|
public PDAStepCommand(PDAProgramDMContext context) {
|
||||||
super(context, "step");
|
super(context, "step");
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,10 +8,9 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Wind River Systems - initial API and implementation
|
* Wind River Systems - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.dd.examples.pda.service.command.commands;
|
package org.eclipse.dd.examples.pda.service.commands;
|
||||||
|
|
||||||
import org.eclipse.dd.examples.pda.service.command.PDACommandControlDMContext;
|
import org.eclipse.dd.examples.pda.service.PDAProgramDMContext;
|
||||||
import org.eclipse.dd.examples.pda.service.command.PDACommandResult;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes instructions until the current subroutine is finished
|
* Executes instructions until the current subroutine is finished
|
||||||
|
@ -25,7 +24,7 @@ import org.eclipse.dd.examples.pda.service.command.PDACommandResult;
|
||||||
*/
|
*/
|
||||||
public class PDAStepReturnCommand extends AbstractPDACommand<PDACommandResult> {
|
public class PDAStepReturnCommand extends AbstractPDACommand<PDACommandResult> {
|
||||||
|
|
||||||
public PDAStepReturnCommand(PDACommandControlDMContext context) {
|
public PDAStepReturnCommand(PDAProgramDMContext context) {
|
||||||
super(context, "stepreturn");
|
super(context, "stepreturn");
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,10 +8,9 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Wind River Systems - initial API and implementation
|
* Wind River Systems - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.dd.examples.pda.service.command.commands;
|
package org.eclipse.dd.examples.pda.service.commands;
|
||||||
|
|
||||||
import org.eclipse.dd.examples.pda.service.command.PDACommandControlDMContext;
|
import org.eclipse.dd.examples.pda.service.PDAProgramDMContext;
|
||||||
import org.eclipse.dd.examples.pda.service.command.PDACommandResult;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Suspends execution
|
* Suspends execution
|
||||||
|
@ -24,7 +23,7 @@ import org.eclipse.dd.examples.pda.service.command.PDACommandResult;
|
||||||
*/
|
*/
|
||||||
public class PDASuspendCommand extends AbstractPDACommand<PDACommandResult> {
|
public class PDASuspendCommand extends AbstractPDACommand<PDACommandResult> {
|
||||||
|
|
||||||
public PDASuspendCommand(PDACommandControlDMContext context) {
|
public PDASuspendCommand(PDAProgramDMContext context) {
|
||||||
super(context, "suspend");
|
super(context, "suspend");
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,10 +8,9 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Wind River Systems - initial API and implementation
|
* Wind River Systems - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.dd.examples.pda.service.command.commands;
|
package org.eclipse.dd.examples.pda.service.commands;
|
||||||
|
|
||||||
import org.eclipse.dd.examples.pda.service.command.PDACommandControlDMContext;
|
import org.eclipse.dd.examples.pda.service.PDAProgramDMContext;
|
||||||
import org.eclipse.dd.examples.pda.service.command.PDACommandResult;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves variable value
|
* Retrieves variable value
|
||||||
|
@ -23,7 +22,7 @@ import org.eclipse.dd.examples.pda.service.command.PDACommandResult;
|
||||||
*/
|
*/
|
||||||
public class PDAVarCommand extends AbstractPDACommand<PDACommandResult> {
|
public class PDAVarCommand extends AbstractPDACommand<PDACommandResult> {
|
||||||
|
|
||||||
public PDAVarCommand(PDACommandControlDMContext context, int frameId, String name) {
|
public PDAVarCommand(PDAProgramDMContext context, int frameId, String name) {
|
||||||
super(context, "var " + frameId + " " + name);
|
super(context, "var " + frameId + " " + name);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,10 +8,9 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Wind River Systems - initial API and implementation
|
* Wind River Systems - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.dd.examples.pda.service.command.commands;
|
package org.eclipse.dd.examples.pda.service.commands;
|
||||||
|
|
||||||
import org.eclipse.dd.examples.pda.service.command.PDACommandControlDMContext;
|
import org.eclipse.dd.examples.pda.service.PDAProgramDMContext;
|
||||||
import org.eclipse.dd.examples.pda.service.command.PDACommandResult;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a watchpoint on a given variable
|
* Sets a watchpoint on a given variable
|
||||||
|
@ -41,7 +40,7 @@ public class PDAWatchCommand extends AbstractPDACommand<PDACommandResult> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public PDAWatchCommand(PDACommandControlDMContext context, String function, String variable, WatchOperation operation) {
|
public PDAWatchCommand(PDAProgramDMContext context, String function, String variable, WatchOperation operation) {
|
||||||
super(context, "watch " + function+ "::" + variable + " " + getWatchOperationCode(operation));
|
super(context, "watch " + function+ "::" + variable + " " + getWatchOperationCode(operation));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,48 +0,0 @@
|
||||||
/*******************************************************************************
|
|
||||||
* 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.examples.pda.service.expressions;
|
|
||||||
|
|
||||||
import org.eclipse.dd.dsf.datamodel.AbstractDMContext;
|
|
||||||
import org.eclipse.dd.dsf.datamodel.IDMContext;
|
|
||||||
import org.eclipse.dd.dsf.debug.service.IExpressions.IExpressionDMContext;
|
|
||||||
import org.eclipse.dd.dsf.debug.service.IStack.IFrameDMContext;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class ExpressionDMContext extends AbstractDMContext implements IExpressionDMContext {
|
|
||||||
|
|
||||||
private final String fExpression;
|
|
||||||
|
|
||||||
ExpressionDMContext(String sessionId, IFrameDMContext frameDmc, String expressin) {
|
|
||||||
super(sessionId, new IDMContext[] { frameDmc });
|
|
||||||
fExpression = expressin;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getExpression() {
|
|
||||||
return fExpression;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object other) {
|
|
||||||
return super.baseEquals(other) && ((ExpressionDMContext)other).fExpression.equals(fExpression);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return super.baseHashCode() + fExpression.hashCode();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return baseToString() + ".expression(" + fExpression + ")"; //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,61 +0,0 @@
|
||||||
/*******************************************************************************
|
|
||||||
* 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.examples.pda.service.expressions;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.eclipse.dd.dsf.debug.service.IExpressions.IExpressionDMData;
|
|
||||||
import org.eclipse.dd.dsf.debug.service.IRegisters.IRegisterDMContext;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class ExpressionDMData implements IExpressionDMData {
|
|
||||||
|
|
||||||
final private String fExpression;
|
|
||||||
|
|
||||||
public ExpressionDMData(String expression) {
|
|
||||||
fExpression = expression;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BasicType getBasicType() {
|
|
||||||
return BasicType.basic;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getEncoding() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Map<String, Integer> getEnumerations() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return fExpression;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IRegisterDMContext getRegister() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getStringValue() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTypeId() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTypeName() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,48 +0,0 @@
|
||||||
/*******************************************************************************
|
|
||||||
* 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.examples.pda.service.expressions;
|
|
||||||
|
|
||||||
import org.eclipse.dd.dsf.datamodel.AbstractDMContext;
|
|
||||||
import org.eclipse.dd.dsf.datamodel.IDMContext;
|
|
||||||
import org.eclipse.dd.dsf.debug.service.IExpressions.IExpressionDMContext;
|
|
||||||
|
|
||||||
class InvalidExpressionDMContext extends AbstractDMContext
|
|
||||||
implements IExpressionDMContext
|
|
||||||
{
|
|
||||||
private final String expression;
|
|
||||||
|
|
||||||
public InvalidExpressionDMContext(String sessionId, IDMContext parent, String expr) {
|
|
||||||
super(sessionId, new IDMContext[] { parent });
|
|
||||||
expression = expr;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object other) {
|
|
||||||
return super.baseEquals(other) &&
|
|
||||||
expression == null
|
|
||||||
? ((InvalidExpressionDMContext) other).getExpression() == null
|
|
||||||
: expression.equals(((InvalidExpressionDMContext) other).getExpression());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return expression == null ? super.baseHashCode() : super.baseHashCode() ^ expression.hashCode();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return baseToString() + ".invalid_expr[" + expression + "]"; //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getExpression() {
|
|
||||||
return expression;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,224 +0,0 @@
|
||||||
/*******************************************************************************
|
|
||||||
* 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.examples.pda.service.expressions;
|
|
||||||
|
|
||||||
import java.util.Hashtable;
|
|
||||||
|
|
||||||
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.RequestMonitor;
|
|
||||||
import org.eclipse.dd.dsf.datamodel.DMContexts;
|
|
||||||
import org.eclipse.dd.dsf.datamodel.IDMContext;
|
|
||||||
import org.eclipse.dd.dsf.debug.service.IExpressions;
|
|
||||||
import org.eclipse.dd.dsf.debug.service.IStack;
|
|
||||||
import org.eclipse.dd.dsf.debug.service.IRunControl.IResumedDMEvent;
|
|
||||||
import org.eclipse.dd.dsf.debug.service.IRunControl.ISuspendedDMEvent;
|
|
||||||
import org.eclipse.dd.dsf.debug.service.IRunControl.StateChangeReason;
|
|
||||||
import org.eclipse.dd.dsf.debug.service.IStack.IFrameDMContext;
|
|
||||||
import org.eclipse.dd.dsf.debug.service.command.CommandCache;
|
|
||||||
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.examples.pda.PDAPlugin;
|
|
||||||
import org.eclipse.dd.examples.pda.service.command.PDACommandControl;
|
|
||||||
import org.eclipse.dd.examples.pda.service.command.PDACommandResult;
|
|
||||||
import org.eclipse.dd.examples.pda.service.command.commands.PDASetVarCommand;
|
|
||||||
import org.eclipse.dd.examples.pda.service.command.commands.PDAVarCommand;
|
|
||||||
import org.osgi.framework.BundleContext;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class PDAExpressions extends AbstractDsfService implements IExpressions {
|
|
||||||
|
|
||||||
private PDACommandControl fCommandControl;
|
|
||||||
private IStack fStack;
|
|
||||||
|
|
||||||
private CommandCache fCommandCache;
|
|
||||||
|
|
||||||
public PDAExpressions(DsfSession session) {
|
|
||||||
super(session);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected BundleContext getBundleContext() {
|
|
||||||
return PDAPlugin.getBundleContext();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void initialize(final RequestMonitor rm) {
|
|
||||||
super.initialize(
|
|
||||||
new RequestMonitor(getExecutor(), rm) {
|
|
||||||
@Override
|
|
||||||
protected void handleOK() {
|
|
||||||
doInitialize(rm);
|
|
||||||
}});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void doInitialize(final RequestMonitor rm) {
|
|
||||||
fCommandControl = getServicesTracker().getService(PDACommandControl.class);
|
|
||||||
fStack = getServicesTracker().getService(IStack.class);
|
|
||||||
fCommandCache = new CommandCache(fCommandControl);
|
|
||||||
|
|
||||||
getSession().addServiceEventListener(this, null);
|
|
||||||
|
|
||||||
register(new String[]{IExpressions.class.getName(), PDAExpressions.class.getName()}, new Hashtable<String,String>());
|
|
||||||
|
|
||||||
rm.done();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void shutdown(final RequestMonitor rm) {
|
|
||||||
getSession().removeServiceEventListener(this);
|
|
||||||
fCommandCache.reset();
|
|
||||||
super.shutdown(rm);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void canWriteExpression(IExpressionDMContext expressionContext, DataRequestMonitor<Boolean> rm) {
|
|
||||||
rm.setData(true);
|
|
||||||
rm.done();
|
|
||||||
}
|
|
||||||
|
|
||||||
public IExpressionDMContext createExpression(IDMContext ctx, String expression) {
|
|
||||||
IFrameDMContext frameCtx = DMContexts.getAncestorOfType(ctx, IFrameDMContext.class);
|
|
||||||
if (frameCtx != null) {
|
|
||||||
return new ExpressionDMContext(getSession().getId(), frameCtx, expression);
|
|
||||||
} else {
|
|
||||||
return new InvalidExpressionDMContext(getSession().getId(), ctx, expression);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void getBaseExpressions(IExpressionDMContext exprContext, DataRequestMonitor<IExpressionDMContext[]> rm) {
|
|
||||||
rm.setStatus(new Status(IStatus.ERROR, PDAPlugin.PLUGIN_ID, NOT_SUPPORTED, "Not supported", null)); //$NON-NLS-1$
|
|
||||||
rm.done();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void getExpressionAddressData(IExpressionDMContext dmc, DataRequestMonitor<IExpressionDMAddress> rm) {
|
|
||||||
rm.setStatus(new Status(IStatus.ERROR, PDAPlugin.PLUGIN_ID, NOT_SUPPORTED, "Not supported", null)); //$NON-NLS-1$
|
|
||||||
rm.done();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void getExpressionData(final IExpressionDMContext exprCtx, final DataRequestMonitor<IExpressionDMData> rm) {
|
|
||||||
if (exprCtx instanceof ExpressionDMContext) {
|
|
||||||
rm.setData(new ExpressionDMData(exprCtx.getExpression()));
|
|
||||||
rm.done();
|
|
||||||
} else {
|
|
||||||
rm.setStatus(new Status(IStatus.ERROR, PDAPlugin.PLUGIN_ID, INVALID_HANDLE, "Invalid expression context " + exprCtx, null)); //$NON-NLS-1$
|
|
||||||
rm.done();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void getSubExpressionCount(IExpressionDMContext exprCtx, DataRequestMonitor<Integer> rm) {
|
|
||||||
rm.setStatus(new Status(IStatus.ERROR, PDAPlugin.PLUGIN_ID, NOT_SUPPORTED, "Not supported", null)); //$NON-NLS-1$
|
|
||||||
rm.done();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void getSubExpressions(IExpressionDMContext exprCtx, DataRequestMonitor<IExpressionDMContext[]> rm) {
|
|
||||||
rm.setStatus(new Status(IStatus.ERROR, PDAPlugin.PLUGIN_ID, NOT_SUPPORTED, "Not supported", null)); //$NON-NLS-1$
|
|
||||||
rm.done();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void getSubExpressions(IExpressionDMContext exprCtx, int startIndex, int length,
|
|
||||||
DataRequestMonitor<IExpressionDMContext[]> rm)
|
|
||||||
{
|
|
||||||
rm.setStatus(new Status(IStatus.ERROR, PDAPlugin.PLUGIN_ID, NOT_SUPPORTED, "Not supported", null)); //$NON-NLS-1$
|
|
||||||
rm.done();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void writeExpression(IExpressionDMContext exprCtx, String exprValue, String formatId, RequestMonitor rm)
|
|
||||||
{
|
|
||||||
if (exprCtx instanceof ExpressionDMContext) {
|
|
||||||
fCommandCache.execute(
|
|
||||||
new PDASetVarCommand(fCommandControl.getDMContext(), exprCtx.getExpression(), exprValue),
|
|
||||||
new DataRequestMonitor<PDACommandResult>(getExecutor(), rm));
|
|
||||||
} else {
|
|
||||||
rm.setStatus(new Status(IStatus.ERROR, PDAPlugin.PLUGIN_ID, INVALID_HANDLE, "Invalid expression context " + exprCtx, null)); //$NON-NLS-1$
|
|
||||||
rm.done();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void getAvailableFormats(IFormattedDataDMContext dmc, DataRequestMonitor<String[]> rm) {
|
|
||||||
rm.setData(new String[] { NATURAL_FORMAT });
|
|
||||||
rm.done();
|
|
||||||
}
|
|
||||||
|
|
||||||
public FormattedValueDMContext getFormattedValueContext(IFormattedDataDMContext dmc, String formatId) {
|
|
||||||
return new FormattedValueDMContext(this, dmc, formatId);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void getFormattedExpressionValue(FormattedValueDMContext formattedCtx, final DataRequestMonitor<FormattedValueDMData> rm) {
|
|
||||||
final ExpressionDMContext exprCtx = DMContexts.getAncestorOfType(formattedCtx, ExpressionDMContext.class);
|
|
||||||
if (exprCtx != null) {
|
|
||||||
getExpressionValue(
|
|
||||||
exprCtx,
|
|
||||||
new DataRequestMonitor<String>(getExecutor(), rm) {
|
|
||||||
@Override
|
|
||||||
protected void handleOK() {
|
|
||||||
rm.setData(new FormattedValueDMData(getData()));
|
|
||||||
rm.done();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
rm.setStatus(new Status(IStatus.ERROR, PDAPlugin.PLUGIN_ID, INVALID_HANDLE, "Invalid expression context " + formattedCtx, null)); //$NON-NLS-1$
|
|
||||||
rm.done();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void getExpressionValue(final ExpressionDMContext exprCtx, final DataRequestMonitor<String> rm) {
|
|
||||||
final IFrameDMContext frameCtx = DMContexts.getAncestorOfType(exprCtx, IFrameDMContext.class);
|
|
||||||
fStack.getStackDepth(
|
|
||||||
frameCtx, 0,
|
|
||||||
new DataRequestMonitor<Integer>(getExecutor(), rm) {
|
|
||||||
@Override
|
|
||||||
protected void handleOK() {
|
|
||||||
int frameId = getData() - frameCtx.getLevel() - 1;
|
|
||||||
fCommandCache.execute(
|
|
||||||
new PDAVarCommand(fCommandControl.getDMContext(), frameId, exprCtx.getExpression()),
|
|
||||||
new DataRequestMonitor<PDACommandResult>(getExecutor(), rm) {
|
|
||||||
@Override
|
|
||||||
protected void handleOK() {
|
|
||||||
rm.setData(getData().fResponseText);
|
|
||||||
rm.done();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public void getModelData(IDMContext dmc, DataRequestMonitor<?> rm) {
|
|
||||||
if (dmc instanceof IExpressionDMContext) {
|
|
||||||
getExpressionData((IExpressionDMContext) dmc, (DataRequestMonitor<IExpressionDMData>) rm);
|
|
||||||
} else if (dmc instanceof FormattedValueDMContext) {
|
|
||||||
getFormattedExpressionValue((FormattedValueDMContext) dmc, (DataRequestMonitor<FormattedValueDMData>) rm);
|
|
||||||
} else {
|
|
||||||
rm.setStatus(new Status(IStatus.ERROR, PDAPlugin.PLUGIN_ID, INVALID_HANDLE, "Unknown DMC type", null)); //$NON-NLS-1$
|
|
||||||
rm.done();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@DsfServiceEventHandler
|
|
||||||
public void eventDispatched(IResumedDMEvent e) {
|
|
||||||
fCommandCache.setTargetAvailable(false);
|
|
||||||
if (!e.getReason().equals(StateChangeReason.STEP)) {
|
|
||||||
fCommandCache.reset();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@DsfServiceEventHandler
|
|
||||||
public void eventDispatched(ISuspendedDMEvent e) {
|
|
||||||
fCommandCache.setTargetAvailable(true);
|
|
||||||
fCommandCache.reset();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,24 +0,0 @@
|
||||||
/*******************************************************************************
|
|
||||||
* 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.examples.pda.service.runcontrol;
|
|
||||||
|
|
||||||
import org.eclipse.dd.dsf.concurrent.Immutable;
|
|
||||||
import org.eclipse.dd.dsf.debug.service.IRunControl.IExecutionDMData;
|
|
||||||
import org.eclipse.dd.dsf.debug.service.IRunControl.StateChangeReason;
|
|
||||||
|
|
||||||
@Immutable
|
|
||||||
class ExecutionData implements IExecutionDMData {
|
|
||||||
private final StateChangeReason fReason;
|
|
||||||
ExecutionData(StateChangeReason reason) {
|
|
||||||
fReason = reason;
|
|
||||||
}
|
|
||||||
public StateChangeReason getStateChangeReason() { return fReason; }
|
|
||||||
}
|
|
|
@ -1,261 +0,0 @@
|
||||||
/*******************************************************************************
|
|
||||||
* 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
|
|
||||||
* Ericsson AB - Modified for handling of multiple threads
|
|
||||||
*******************************************************************************/
|
|
||||||
package org.eclipse.dd.examples.pda.service.runcontrol;
|
|
||||||
|
|
||||||
import java.util.Hashtable;
|
|
||||||
|
|
||||||
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.RequestMonitor;
|
|
||||||
import org.eclipse.dd.dsf.datamodel.IDMContext;
|
|
||||||
import org.eclipse.dd.dsf.datamodel.IDMEvent;
|
|
||||||
import org.eclipse.dd.dsf.debug.service.IRunControl;
|
|
||||||
import org.eclipse.dd.dsf.debug.service.command.CommandCache;
|
|
||||||
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.DsfSession;
|
|
||||||
import org.eclipse.dd.dsf.service.IDsfService;
|
|
||||||
import org.eclipse.dd.examples.pda.PDAPlugin;
|
|
||||||
import org.eclipse.dd.examples.pda.service.command.PDACommandControl;
|
|
||||||
import org.eclipse.dd.examples.pda.service.command.PDACommandResult;
|
|
||||||
import org.eclipse.dd.examples.pda.service.command.commands.PDAResumeCommand;
|
|
||||||
import org.eclipse.dd.examples.pda.service.command.commands.PDAStepCommand;
|
|
||||||
import org.eclipse.dd.examples.pda.service.command.commands.PDASuspendCommand;
|
|
||||||
import org.osgi.framework.BundleContext;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* <p>
|
|
||||||
* Implementation note:
|
|
||||||
* This class implements event handlers for the events that are generated by
|
|
||||||
* this service itself. When the event is dispatched, these handlers will
|
|
||||||
* be called first, before any of the clients. These handlers update the
|
|
||||||
* service's internal state information to make them consistent with the
|
|
||||||
* events being issued. Doing this in the handlers as opposed to when
|
|
||||||
* the events are generated, guarantees that the state of the service will
|
|
||||||
* always be consistent with the events.
|
|
||||||
* The purpose of this pattern is to allow clients that listen to service
|
|
||||||
* events and track service state, to be perfectly in sync with the service
|
|
||||||
* state.
|
|
||||||
*/
|
|
||||||
public class PDARunControl extends AbstractDsfService
|
|
||||||
implements IRunControl, IEventListener
|
|
||||||
{
|
|
||||||
private PDACommandControl fCommandControl;
|
|
||||||
private CommandCache fCommandCache;
|
|
||||||
|
|
||||||
// state flags
|
|
||||||
private boolean fSuspended = true;
|
|
||||||
private boolean fResumePending = false;
|
|
||||||
private boolean fStepping = false;
|
|
||||||
|
|
||||||
private StateChangeReason fStateChangeReason;
|
|
||||||
|
|
||||||
public PDARunControl(DsfSession session) {
|
|
||||||
super(session);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected BundleContext getBundleContext() {
|
|
||||||
return PDAPlugin.getBundleContext();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void initialize(final RequestMonitor rm) {
|
|
||||||
super.initialize(
|
|
||||||
new RequestMonitor(getExecutor(), rm) {
|
|
||||||
@Override
|
|
||||||
protected void handleOK() {
|
|
||||||
doInitialize(rm);
|
|
||||||
}});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void doInitialize(final RequestMonitor rm) {
|
|
||||||
fCommandControl = getServicesTracker().getService(PDACommandControl.class);
|
|
||||||
fCommandCache = new CommandCache(fCommandControl);
|
|
||||||
|
|
||||||
fCommandControl.addEventListener(this);
|
|
||||||
getSession().addServiceEventListener(this, null);
|
|
||||||
|
|
||||||
register(new String[]{IRunControl.class.getName(), PDARunControl.class.getName()}, new Hashtable<String,String>());
|
|
||||||
|
|
||||||
rm.done();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void shutdown(final RequestMonitor rm) {
|
|
||||||
fCommandControl.removeEventListener(this);
|
|
||||||
|
|
||||||
getSession().removeServiceEventListener(this);
|
|
||||||
fCommandCache.reset();
|
|
||||||
super.shutdown(rm);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public void getModelData(IDMContext dmc, DataRequestMonitor<?> rm) {
|
|
||||||
if (dmc instanceof IExecutionDMContext) {
|
|
||||||
getExecutionData((IExecutionDMContext)dmc, (DataRequestMonitor<IExecutionDMData>)rm);
|
|
||||||
} else {
|
|
||||||
rm.setStatus(new Status(IStatus.ERROR, PDAPlugin.PLUGIN_ID, INVALID_HANDLE, "Unknown DMC type", null)); //$NON-NLS-1$
|
|
||||||
rm.done();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void eventReceived(Object output) {
|
|
||||||
if (!(output instanceof String)) return;
|
|
||||||
String event = (String)output;
|
|
||||||
|
|
||||||
if (event.startsWith("suspended")) {
|
|
||||||
suspendedEventReceived(event);
|
|
||||||
} else if (event.startsWith("resumed")) {
|
|
||||||
resumedEventReceived(event);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void suspendedEventReceived(String event) {
|
|
||||||
IDMEvent<?> dmEvent = new SuspendedEvent(fCommandControl.getDMContext(), event);
|
|
||||||
getSession().dispatchEvent(dmEvent, getProperties());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@DsfServiceEventHandler
|
|
||||||
private void resumedEventReceived(String event) {
|
|
||||||
IDMEvent<?> dmEvent = new ResumedEvent(fCommandControl.getDMContext(), event);
|
|
||||||
getSession().dispatchEvent(dmEvent, getProperties());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@DsfServiceEventHandler
|
|
||||||
public void eventDispatched(ResumedEvent e) {
|
|
||||||
fSuspended = false;
|
|
||||||
fResumePending = false;
|
|
||||||
fStateChangeReason = e.getReason();
|
|
||||||
fCommandCache.setTargetAvailable(false);
|
|
||||||
if (e.getReason().equals(StateChangeReason.STEP)) {
|
|
||||||
fStepping = true;
|
|
||||||
} else {
|
|
||||||
fCommandCache.reset();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@DsfServiceEventHandler
|
|
||||||
public void eventDispatched(SuspendedEvent e) {
|
|
||||||
fCommandCache.setTargetAvailable(true);
|
|
||||||
fCommandCache.reset();
|
|
||||||
fStateChangeReason = e.getReason();
|
|
||||||
fResumePending = false;
|
|
||||||
fSuspended = true;
|
|
||||||
fStepping = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public boolean canResume(IExecutionDMContext context) {
|
|
||||||
return isSuspended(context) && !fResumePending;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean canSuspend(IExecutionDMContext context) {
|
|
||||||
return !isSuspended(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isSuspended(IExecutionDMContext context) {
|
|
||||||
return fSuspended;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isStepping(IExecutionDMContext context) {
|
|
||||||
return !isSuspended(context) && fStepping;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void resume(IExecutionDMContext context, final RequestMonitor rm) {
|
|
||||||
assert context != null;
|
|
||||||
|
|
||||||
if (canResume(context)) {
|
|
||||||
fResumePending = true;
|
|
||||||
// Cygwin GDB will accept commands and execute them after the step
|
|
||||||
// which is not what we want, so mark the target as unavailable
|
|
||||||
// as soon as we send a resume command.
|
|
||||||
fCommandCache.setTargetAvailable(false);
|
|
||||||
|
|
||||||
fCommandControl.queueCommand(
|
|
||||||
new PDAResumeCommand(fCommandControl.getDMContext()),
|
|
||||||
new DataRequestMonitor<PDACommandResult>(getExecutor(), rm) {
|
|
||||||
@Override
|
|
||||||
protected void handleOK() {
|
|
||||||
rm.done();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}else {
|
|
||||||
rm.setStatus(new Status(IStatus.ERROR, PDAPlugin.PLUGIN_ID, IDsfService.INVALID_STATE, "Given context: " + context + ", is already running.", null)); //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
rm.done();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void suspend(IExecutionDMContext context, final RequestMonitor rm){
|
|
||||||
assert context != null;
|
|
||||||
|
|
||||||
if (canSuspend(context)) {
|
|
||||||
fCommandControl.queueCommand(
|
|
||||||
new PDASuspendCommand(fCommandControl.getDMContext()),
|
|
||||||
new DataRequestMonitor<PDACommandResult>(getExecutor(), rm));
|
|
||||||
|
|
||||||
} else {
|
|
||||||
rm.setStatus(new Status(IStatus.ERROR, PDAPlugin.PLUGIN_ID, IDsfService.INVALID_STATE, "Given context: " + context + ", is already suspended.", null)); //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
rm.done();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean canStep(IExecutionDMContext context) {
|
|
||||||
return canResume(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void step(IExecutionDMContext context, StepType stepType, final RequestMonitor rm) {
|
|
||||||
assert context != null;
|
|
||||||
|
|
||||||
if (canResume(context)) {
|
|
||||||
fResumePending = true;
|
|
||||||
fStepping = true;
|
|
||||||
fCommandCache.setTargetAvailable(false);
|
|
||||||
|
|
||||||
fCommandControl.queueCommand(
|
|
||||||
new PDAStepCommand(fCommandControl.getDMContext()),
|
|
||||||
new DataRequestMonitor<PDACommandResult>(getExecutor(), rm));
|
|
||||||
|
|
||||||
} else {
|
|
||||||
rm.setStatus(new Status(IStatus.ERROR, PDAPlugin.PLUGIN_ID, INVALID_STATE, "Cannot resume context", null)); //$NON-NLS-1$
|
|
||||||
rm.done();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean canInstructionStep(IExecutionDMContext context) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void instructionStep(IExecutionDMContext context, StepType stepType, RequestMonitor rm) {
|
|
||||||
rm.setStatus(new Status(IStatus.ERROR, PDAPlugin.PLUGIN_ID, NOT_SUPPORTED, "Operation not implemented", null)); //$NON-NLS-1$
|
|
||||||
rm.done();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void getExecutionContexts(final IContainerDMContext containerDmc, final DataRequestMonitor<IExecutionDMContext[]> rm) {
|
|
||||||
rm.setStatus(new Status(IStatus.ERROR, PDAPlugin.PLUGIN_ID, NOT_SUPPORTED, "Operation not implemented", null)); //$NON-NLS-1$
|
|
||||||
rm.done();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void getExecutionData(IExecutionDMContext dmc, DataRequestMonitor<IExecutionDMData> rm){
|
|
||||||
rm.setData( new ExecutionData(fStateChangeReason) );
|
|
||||||
rm.done();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,41 +0,0 @@
|
||||||
/*******************************************************************************
|
|
||||||
* 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.examples.pda.service.runcontrol;
|
|
||||||
|
|
||||||
import org.eclipse.dd.dsf.concurrent.Immutable;
|
|
||||||
import org.eclipse.dd.dsf.datamodel.AbstractDMEvent;
|
|
||||||
import org.eclipse.dd.dsf.debug.service.IRunControl.IExecutionDMContext;
|
|
||||||
import org.eclipse.dd.dsf.debug.service.IRunControl.IResumedDMEvent;
|
|
||||||
import org.eclipse.dd.dsf.debug.service.IRunControl.StateChangeReason;
|
|
||||||
|
|
||||||
@Immutable
|
|
||||||
class ResumedEvent extends AbstractDMEvent<IExecutionDMContext>
|
|
||||||
implements IResumedDMEvent
|
|
||||||
{
|
|
||||||
private final String fPDAEvent;
|
|
||||||
|
|
||||||
ResumedEvent(IExecutionDMContext ctx, String pdaEvent) {
|
|
||||||
super(ctx);
|
|
||||||
fPDAEvent = pdaEvent;
|
|
||||||
}
|
|
||||||
|
|
||||||
public StateChangeReason getReason() {
|
|
||||||
if (fPDAEvent.startsWith("resumed breakpoint") || fPDAEvent.startsWith("suspended watch")) {
|
|
||||||
return StateChangeReason.BREAKPOINT;
|
|
||||||
} else if (fPDAEvent.equals("resumed step") || fPDAEvent.equals("resumed drop")) {
|
|
||||||
return StateChangeReason.STEP;
|
|
||||||
} else if (fPDAEvent.equals("resumed client")) {
|
|
||||||
return StateChangeReason.USER_REQUEST;
|
|
||||||
} else {
|
|
||||||
return StateChangeReason.UNKNOWN;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,34 +0,0 @@
|
||||||
package org.eclipse.dd.examples.pda.service.runcontrol;
|
|
||||||
|
|
||||||
import org.eclipse.dd.dsf.concurrent.Immutable;
|
|
||||||
import org.eclipse.dd.dsf.datamodel.AbstractDMEvent;
|
|
||||||
import org.eclipse.dd.dsf.debug.service.IRunControl.IExecutionDMContext;
|
|
||||||
import org.eclipse.dd.dsf.debug.service.IRunControl.ISuspendedDMEvent;
|
|
||||||
import org.eclipse.dd.dsf.debug.service.IRunControl.StateChangeReason;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Indicates that the given thread has been suspended.
|
|
||||||
*/
|
|
||||||
@Immutable
|
|
||||||
class SuspendedEvent extends AbstractDMEvent<IExecutionDMContext>
|
|
||||||
implements ISuspendedDMEvent
|
|
||||||
{
|
|
||||||
private final String fPDAEvent;
|
|
||||||
|
|
||||||
SuspendedEvent(IExecutionDMContext ctx, String pdaEvent) {
|
|
||||||
super(ctx);
|
|
||||||
fPDAEvent = pdaEvent;
|
|
||||||
}
|
|
||||||
|
|
||||||
public StateChangeReason getReason() {
|
|
||||||
if (fPDAEvent.startsWith("suspended breakpoint") || fPDAEvent.startsWith("suspended watch")) {
|
|
||||||
return StateChangeReason.BREAKPOINT;
|
|
||||||
} else if (fPDAEvent.equals("suspended step") || fPDAEvent.equals("suspended drop")) {
|
|
||||||
return StateChangeReason.STEP;
|
|
||||||
} else if (fPDAEvent.equals("suspended client")) {
|
|
||||||
return StateChangeReason.USER_REQUEST;
|
|
||||||
} else {
|
|
||||||
return StateChangeReason.UNKNOWN;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,46 +0,0 @@
|
||||||
/*******************************************************************************
|
|
||||||
* 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.examples.pda.service.stack;
|
|
||||||
|
|
||||||
import org.eclipse.dd.dsf.datamodel.AbstractDMContext;
|
|
||||||
import org.eclipse.dd.dsf.datamodel.IDMContext;
|
|
||||||
import org.eclipse.dd.dsf.debug.service.IRunControl.IExecutionDMContext;
|
|
||||||
import org.eclipse.dd.dsf.debug.service.IStack.IFrameDMContext;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
class FrameDMContext extends AbstractDMContext implements IFrameDMContext {
|
|
||||||
|
|
||||||
private final int fLevel;
|
|
||||||
|
|
||||||
FrameDMContext(String sessionId, IExecutionDMContext execDmc, int level) {
|
|
||||||
super(sessionId, new IDMContext[] { execDmc });
|
|
||||||
fLevel = level;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getLevel() { return fLevel; }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object other) {
|
|
||||||
return super.baseEquals(other) && ((FrameDMContext)other).fLevel == fLevel;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return super.baseHashCode() ^ fLevel;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return baseToString() + ".frame[" + fLevel + "]"; //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,47 +0,0 @@
|
||||||
/*******************************************************************************
|
|
||||||
* 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.examples.pda.service.stack;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.core.IAddress;
|
|
||||||
import org.eclipse.dd.dsf.debug.service.IStack.IFrameDMData;
|
|
||||||
import org.eclipse.dd.examples.pda.service.command.commands.PDAFrame;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class FrameDMData implements IFrameDMData {
|
|
||||||
|
|
||||||
final private PDAFrame fFrame;
|
|
||||||
|
|
||||||
FrameDMData(PDAFrame frame) {
|
|
||||||
fFrame = frame;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getFile() {
|
|
||||||
return fFrame.fFilePath.lastSegment();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getFunction() {
|
|
||||||
return fFrame.fFunction;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getLine() {
|
|
||||||
return fFrame.fLine + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getColumn() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IAddress getAddress() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,46 +0,0 @@
|
||||||
/*******************************************************************************
|
|
||||||
* 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.examples.pda.service.stack;
|
|
||||||
|
|
||||||
import org.eclipse.dd.dsf.datamodel.AbstractDMContext;
|
|
||||||
import org.eclipse.dd.dsf.datamodel.IDMContext;
|
|
||||||
import org.eclipse.dd.dsf.debug.service.IStack.IFrameDMContext;
|
|
||||||
import org.eclipse.dd.dsf.debug.service.IStack.IVariableDMContext;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
class VariableDMContext extends AbstractDMContext implements IVariableDMContext {
|
|
||||||
|
|
||||||
private final String fVariable;
|
|
||||||
|
|
||||||
VariableDMContext(String sessionId, IFrameDMContext frameCtx, String variable) {
|
|
||||||
super(sessionId, new IDMContext[] { frameCtx });
|
|
||||||
fVariable = variable;
|
|
||||||
}
|
|
||||||
|
|
||||||
String getVariable() { return fVariable; }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object other) {
|
|
||||||
return super.baseEquals(other) && ((VariableDMContext)other).fVariable.equals(fVariable);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return super.baseHashCode() + fVariable.hashCode();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return baseToString() + ".variable(" + fVariable + ")"; //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,33 +0,0 @@
|
||||||
/*******************************************************************************
|
|
||||||
* 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.examples.pda.service.stack;
|
|
||||||
|
|
||||||
import org.eclipse.dd.dsf.debug.service.IStack.IVariableDMData;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class VariableDMData implements IVariableDMData {
|
|
||||||
|
|
||||||
final private String fVariable;
|
|
||||||
|
|
||||||
VariableDMData(String variable) {
|
|
||||||
fVariable = variable;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return fVariable;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getValue() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2005, 2007 IBM Corporation and others.
|
* Copyright (c) 2005, 2008 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -8,8 +8,9 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Corporation - initial API and implementation
|
* IBM Corporation - initial API and implementation
|
||||||
* Bjorn Freeman-Benson - initial API and implementation
|
* Bjorn Freeman-Benson - initial API and implementation
|
||||||
|
* Wind River Systems - adopted to use with DSF
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.debug.examples.core.pda.sourcelookup;
|
package org.eclipse.dd.examples.pda.sourcelookup;
|
||||||
|
|
||||||
import org.eclipse.debug.core.sourcelookup.AbstractSourceLookupDirector;
|
import org.eclipse.debug.core.sourcelookup.AbstractSourceLookupDirector;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2005, 2007 IBM Corporation and others.
|
* Copyright (c) 2005, 2008 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -8,8 +8,9 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Corporation - initial API and implementation
|
* IBM Corporation - initial API and implementation
|
||||||
* Bjorn Freeman-Benson - initial API and implementation
|
* Bjorn Freeman-Benson - initial API and implementation
|
||||||
|
* Wind River Systems - adopted to use with DSF
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.debug.examples.core.pda.sourcelookup;
|
package org.eclipse.dd.examples.pda.sourcelookup;
|
||||||
|
|
||||||
import org.eclipse.core.resources.IContainer;
|
import org.eclipse.core.resources.IContainer;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
|
@ -32,29 +33,25 @@ import org.eclipse.debug.core.sourcelookup.containers.WorkspaceSourceContainer;
|
||||||
* The default source lookup path is the folder or project containing
|
* The default source lookup path is the folder or project containing
|
||||||
* the PDA program being launched. If the program is not specified, the workspace
|
* the PDA program being launched. If the program is not specified, the workspace
|
||||||
* is searched by default.
|
* is searched by default.
|
||||||
|
* <p>
|
||||||
|
* This class is identical to the corresponding in PDA debugger implemented in
|
||||||
|
* org.eclipse.debug.examples.
|
||||||
|
* </p>
|
||||||
*/
|
*/
|
||||||
public class PDASourcePathComputerDelegate implements ISourcePathComputerDelegate {
|
public class PDASourcePathComputerDelegate implements ISourcePathComputerDelegate {
|
||||||
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.debug.internal.core.sourcelookup.ISourcePathComputerDelegate#computeSourceContainers(org.eclipse.debug.core.ILaunchConfiguration, org.eclipse.core.runtime.IProgressMonitor)
|
|
||||||
*/
|
|
||||||
public ISourceContainer[] computeSourceContainers(ILaunchConfiguration configuration, IProgressMonitor monitor) throws CoreException {
|
public ISourceContainer[] computeSourceContainers(ILaunchConfiguration configuration, IProgressMonitor monitor) throws CoreException {
|
||||||
String path = configuration.getAttribute(PDAPlugin.ATTR_PDA_PROGRAM, (String)null);
|
String path = configuration.getAttribute(PDAPlugin.ATTR_PDA_PROGRAM, (String)null);
|
||||||
ISourceContainer sourceContainer = null;
|
ISourceContainer sourceContainer = null;
|
||||||
if (path != null) {
|
if (path != null) {
|
||||||
IResource resource = ResourcesPlugin.getWorkspace().getRoot().findMember(new Path(path));
|
IResource resource = ResourcesPlugin.getWorkspace().getRoot().findMember(new Path(path));
|
||||||
if (resource != null) {
|
if (resource != null) {
|
||||||
//#ifdef ex4
|
|
||||||
//# // TODO: Exercise 4 - seed the source lookup path
|
|
||||||
//#else
|
|
||||||
IContainer container = resource.getParent();
|
IContainer container = resource.getParent();
|
||||||
if (container.getType() == IResource.PROJECT) {
|
if (container.getType() == IResource.PROJECT) {
|
||||||
sourceContainer = new ProjectSourceContainer((IProject)container, false);
|
sourceContainer = new ProjectSourceContainer((IProject)container, false);
|
||||||
} else if (container.getType() == IResource.FOLDER) {
|
} else if (container.getType() == IResource.FOLDER) {
|
||||||
sourceContainer = new FolderSourceContainer(container, false);
|
sourceContainer = new FolderSourceContainer(container, false);
|
||||||
}
|
}
|
||||||
//#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (sourceContainer == null) {
|
if (sourceContainer == null) {
|
|
@ -23,7 +23,7 @@ import org.eclipse.dd.dsf.concurrent.Query;
|
||||||
import org.eclipse.dd.dsf.debug.service.command.ICommand;
|
import org.eclipse.dd.dsf.debug.service.command.ICommand;
|
||||||
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.examples.pda.service.command.PDACommandResult;
|
import org.eclipse.dd.examples.pda.service.commands.PDACommandResult;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ public class BasicTests extends CommandControlTestsBase {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
final PDATestCommand testCommand = new PDATestCommand(fCommandControl.getDMContext(), "data");
|
final PDATestCommand testCommand = new PDATestCommand(fCommandControl.getProgramDMContext(), "data");
|
||||||
|
|
||||||
// Test sending the command and checking all listeners were called.
|
// Test sending the command and checking all listeners were called.
|
||||||
Query<PDACommandResult> sendCommandQuery = new Query<PDACommandResult>() {
|
Query<PDACommandResult> sendCommandQuery = new Query<PDACommandResult>() {
|
||||||
|
|
|
@ -26,8 +26,8 @@ import org.eclipse.dd.dsf.concurrent.DsfExecutor;
|
||||||
import org.eclipse.dd.dsf.concurrent.Query;
|
import org.eclipse.dd.dsf.concurrent.Query;
|
||||||
import org.eclipse.dd.dsf.debug.service.command.IEventListener;
|
import org.eclipse.dd.dsf.debug.service.command.IEventListener;
|
||||||
import org.eclipse.dd.dsf.service.DsfSession;
|
import org.eclipse.dd.dsf.service.DsfSession;
|
||||||
import org.eclipse.dd.examples.pda.service.command.PDACommandControl;
|
import org.eclipse.dd.examples.pda.service.PDACommandControl;
|
||||||
import org.eclipse.dd.examples.pda.service.command.PDACommandResult;
|
import org.eclipse.dd.examples.pda.service.commands.PDACommandResult;
|
||||||
import org.eclipse.dd.tests.pda.util.Launching;
|
import org.eclipse.dd.tests.pda.util.Launching;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
@ -66,7 +66,7 @@ public class CommandControlTestsBase {
|
||||||
|
|
||||||
fExecutor = new DefaultDsfExecutor();
|
fExecutor = new DefaultDsfExecutor();
|
||||||
fSession = DsfSession.startSession(fExecutor, "PDA Test");
|
fSession = DsfSession.startSession(fExecutor, "PDA Test");
|
||||||
fCommandControl = new PDACommandControl(fSession, requestPort, eventPort);
|
fCommandControl = new PDACommandControl(fSession, fProgram, requestPort, eventPort);
|
||||||
|
|
||||||
fCommandControl.addEventListener(new IEventListener() {
|
fCommandControl.addEventListener(new IEventListener() {
|
||||||
public void eventReceived(Object output) {
|
public void eventReceived(Object output) {
|
||||||
|
@ -105,7 +105,7 @@ public class CommandControlTestsBase {
|
||||||
|
|
||||||
protected void sendCommand(String command, String expectedResult) throws Throwable {
|
protected void sendCommand(String command, String expectedResult) throws Throwable {
|
||||||
|
|
||||||
final PDATestCommand testCommand = new PDATestCommand(fCommandControl.getDMContext(), command);
|
final PDATestCommand testCommand = new PDATestCommand(fCommandControl.getProgramDMContext(), command);
|
||||||
|
|
||||||
// Test sending the command and checking all listeners were called.
|
// Test sending the command and checking all listeners were called.
|
||||||
Query<PDACommandResult> sendCommandQuery = new Query<PDACommandResult>() {
|
Query<PDACommandResult> sendCommandQuery = new Query<PDACommandResult>() {
|
||||||
|
|
|
@ -10,15 +10,15 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.dd.tests.pda.service.command;
|
package org.eclipse.dd.tests.pda.service.command;
|
||||||
|
|
||||||
import org.eclipse.dd.examples.pda.service.command.PDACommandControlDMContext;
|
import org.eclipse.dd.examples.pda.service.PDAProgramDMContext;
|
||||||
import org.eclipse.dd.examples.pda.service.command.PDACommandResult;
|
import org.eclipse.dd.examples.pda.service.commands.AbstractPDACommand;
|
||||||
import org.eclipse.dd.examples.pda.service.command.commands.AbstractPDACommand;
|
import org.eclipse.dd.examples.pda.service.commands.PDACommandResult;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class PDATestCommand extends AbstractPDACommand<PDACommandResult> {
|
class PDATestCommand extends AbstractPDACommand<PDACommandResult> {
|
||||||
PDATestCommand(PDACommandControlDMContext context, String command) {
|
PDATestCommand(PDAProgramDMContext context, String command) {
|
||||||
super(context, command);
|
super(context, command);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue