Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/com.windriver.tcf.dsf.core')
-rw-r--r--plugins/com.windriver.tcf.dsf.core/.classpath7
-rw-r--r--plugins/com.windriver.tcf.dsf.core/.project28
-rw-r--r--plugins/com.windriver.tcf.dsf.core/META-INF/MANIFEST.MF18
-rwxr-xr-xplugins/com.windriver.tcf.dsf.core/about.html28
-rw-r--r--plugins/com.windriver.tcf.dsf.core/build.properties5
-rw-r--r--plugins/com.windriver.tcf.dsf.core/plugin.properties13
-rw-r--r--plugins/com.windriver.tcf.dsf.core/plugin.xml15
-rw-r--r--plugins/com.windriver.tcf.dsf.core/src/com/windriver/tcf/dsf/core/Activator.java65
-rw-r--r--plugins/com.windriver.tcf.dsf.core/src/com/windriver/tcf/dsf/core/launch/TCFDSFExecuter.java201
-rw-r--r--plugins/com.windriver.tcf.dsf.core/src/com/windriver/tcf/dsf/core/launch/TCFDSFLaunch.java38
-rw-r--r--plugins/com.windriver.tcf.dsf.core/src/com/windriver/tcf/dsf/core/launch/TCFDSFLaunchDelegate.java24
-rw-r--r--plugins/com.windriver.tcf.dsf.core/src/com/windriver/tcf/dsf/core/services/TCFDSFExecutionDMC.java26
-rw-r--r--plugins/com.windriver.tcf.dsf.core/src/com/windriver/tcf/dsf/core/services/TCFDSFNativeProcesses.java332
-rw-r--r--plugins/com.windriver.tcf.dsf.core/src/com/windriver/tcf/dsf/core/services/TCFDSFProcessDMC.java23
-rw-r--r--plugins/com.windriver.tcf.dsf.core/src/com/windriver/tcf/dsf/core/services/TCFDSFRunControl.java829
-rw-r--r--plugins/com.windriver.tcf.dsf.core/src/com/windriver/tcf/dsf/core/services/TCFDSFThreadDMC.java23
16 files changed, 1675 insertions, 0 deletions
diff --git a/plugins/com.windriver.tcf.dsf.core/.classpath b/plugins/com.windriver.tcf.dsf.core/.classpath
new file mode 100644
index 000000000..751c8f2e5
--- /dev/null
+++ b/plugins/com.windriver.tcf.dsf.core/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/plugins/com.windriver.tcf.dsf.core/.project b/plugins/com.windriver.tcf.dsf.core/.project
new file mode 100644
index 000000000..afac03b39
--- /dev/null
+++ b/plugins/com.windriver.tcf.dsf.core/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>com.windriver.tcf.dsf.core</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/plugins/com.windriver.tcf.dsf.core/META-INF/MANIFEST.MF b/plugins/com.windriver.tcf.dsf.core/META-INF/MANIFEST.MF
new file mode 100644
index 000000000..31b80627c
--- /dev/null
+++ b/plugins/com.windriver.tcf.dsf.core/META-INF/MANIFEST.MF
@@ -0,0 +1,18 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %pluginName
+Bundle-SymbolicName: com.windriver.tcf.dsf.core;singleton:=true
+Bundle-Version: 0.1.0
+Bundle-Activator: com.windriver.tcf.dsf.core.Activator
+Bundle-Vendor: %providerName
+Require-Bundle: org.eclipse.core.runtime,
+ org.eclipse.debug.core,
+ org.eclipse.core.resources,
+ org.eclipse.dd.dsf,
+ org.eclipse.dd.dsf.debug,
+ com.windriver.tcf.api,
+ com.windriver.debug.tcf.core
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Eclipse-LazyStart: true
+Export-Package: com.windriver.tcf.dsf.core.launch,
+ com.windriver.tcf.dsf.core.services
diff --git a/plugins/com.windriver.tcf.dsf.core/about.html b/plugins/com.windriver.tcf.dsf.core/about.html
new file mode 100755
index 000000000..6c5b3615b
--- /dev/null
+++ b/plugins/com.windriver.tcf.dsf.core/about.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
+<title>About</title>
+</head>
+<body lang="EN-US">
+<h2>About This Content</h2>
+
+<p>January 10, 2008</p>
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available
+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
+being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
+apply to your use of any object code in the Content. Check the Redistributor's license that was
+provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p>
+
+</body>
+</html> \ No newline at end of file
diff --git a/plugins/com.windriver.tcf.dsf.core/build.properties b/plugins/com.windriver.tcf.dsf.core/build.properties
new file mode 100644
index 000000000..e9863e281
--- /dev/null
+++ b/plugins/com.windriver.tcf.dsf.core/build.properties
@@ -0,0 +1,5 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml
diff --git a/plugins/com.windriver.tcf.dsf.core/plugin.properties b/plugins/com.windriver.tcf.dsf.core/plugin.properties
new file mode 100644
index 000000000..250c86adf
--- /dev/null
+++ b/plugins/com.windriver.tcf.dsf.core/plugin.properties
@@ -0,0 +1,13 @@
+###############################################################################
+# Copyright (c) 2007 Wind River Systems, Inc. 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 implementation
+###############################################################################
+pluginName = TCF/DSF Integration Core
+providerName = Eclipse.org
+
diff --git a/plugins/com.windriver.tcf.dsf.core/plugin.xml b/plugins/com.windriver.tcf.dsf.core/plugin.xml
new file mode 100644
index 000000000..272eed3aa
--- /dev/null
+++ b/plugins/com.windriver.tcf.dsf.core/plugin.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.2"?>
+<plugin>
+ <extension
+ point="org.eclipse.debug.core.launchConfigurationTypes">
+ <launchConfigurationType
+ sourceLocatorId="com.windriver.debug.tcf.SourceLocator"
+ name="DSF over TCF"
+ sourcePathComputerId="com.windriver.debug.tcf.SourcePathComputer"
+ delegate="com.windriver.tcf.dsf.core.launch.TCFDSFLaunchDelegate"
+ modes="debug"
+ id="com.windriver.tcf.dsf.LaunchConfigurationType">
+ </launchConfigurationType>
+ </extension>
+</plugin>
diff --git a/plugins/com.windriver.tcf.dsf.core/src/com/windriver/tcf/dsf/core/Activator.java b/plugins/com.windriver.tcf.dsf.core/src/com/windriver/tcf/dsf/core/Activator.java
new file mode 100644
index 000000000..e8153f7ef
--- /dev/null
+++ b/plugins/com.windriver.tcf.dsf.core/src/com/windriver/tcf/dsf/core/Activator.java
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Wind River Systems, Inc. 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 com.windriver.tcf.dsf.core;
+
+import org.eclipse.core.runtime.Plugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator extends Plugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "com.windriver.tcf.dsf.core";
+
+ // The shared instance
+ private static Activator plugin;
+ private static BundleContext bundle_context;
+
+ /**
+ * The constructor
+ */
+ public Activator() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ bundle_context = context;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+ public static BundleContext getBundleContext() {
+ return bundle_context;
+ }
+}
diff --git a/plugins/com.windriver.tcf.dsf.core/src/com/windriver/tcf/dsf/core/launch/TCFDSFExecuter.java b/plugins/com.windriver.tcf.dsf.core/src/com/windriver/tcf/dsf/core/launch/TCFDSFExecuter.java
new file mode 100644
index 000000000..94b3cc18e
--- /dev/null
+++ b/plugins/com.windriver.tcf.dsf.core/src/com/windriver/tcf/dsf/core/launch/TCFDSFExecuter.java
@@ -0,0 +1,201 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Wind River Systems, Inc. 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 com.windriver.tcf.dsf.core.launch;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.TreeSet;
+import java.util.concurrent.AbstractExecutorService;
+import java.util.concurrent.Callable;
+import java.util.concurrent.Delayed;
+import java.util.concurrent.FutureTask;
+import java.util.concurrent.RejectedExecutionException;
+import java.util.concurrent.ScheduledFuture;
+import java.util.concurrent.TimeUnit;
+
+import org.eclipse.dd.dsf.concurrent.DsfExecutor;
+
+import com.windriver.tcf.api.protocol.Protocol;
+
+public class TCFDSFExecuter extends AbstractExecutorService implements DsfExecutor {
+
+ private class ScheduledFutureTask<V> extends FutureTask<V> implements ScheduledFuture<V> {
+
+ private long time; // Milliseconds
+ private final int id;
+ private final long period; // Milliseconds
+
+ public ScheduledFutureTask(long delay, long period, Runnable runnable, V result) {
+ super(runnable, result);
+ time = System.currentTimeMillis() + delay;
+ id = sf_count++;
+ this.period = period;
+ }
+
+ public ScheduledFutureTask(long delay, Callable<V> callable) {
+ super(callable);
+ time = System.currentTimeMillis() + delay;
+ id = sf_count++;
+ period = 0;
+ }
+
+ public long getDelay(TimeUnit unit) {
+ return unit.convert(time - System.currentTimeMillis(), TimeUnit.MILLISECONDS);
+ }
+
+ public int compareTo(Delayed o) {
+ if (o == this) return 0;
+ ScheduledFutureTask<?> x = (ScheduledFutureTask<?>)o;
+ if (time < x.time) return -1;
+ if (time > x.time) return +1;
+ if (id < x.id) return -1;
+ if (id > x.id) return +1;
+ assert false;
+ return 0;
+ }
+
+ public void run() {
+ if (period == 0) {
+ super.run();
+ }
+ else {
+ boolean ok = super.runAndReset();
+ synchronized (TCFDSFExecuter.this) {
+ // Reschedule if not canceled and not shutdown
+ if (ok && !is_shutdown) {
+ time = period > 0 ? time + period : System.currentTimeMillis() - period;
+ queue.add(this);
+ notify();
+ }
+ }
+ }
+ }
+ }
+
+ private static int sf_count = 0;
+ private final TreeSet<ScheduledFutureTask<?>> queue = new TreeSet<ScheduledFutureTask<?>>();
+ private final Thread thread;
+ private boolean is_shutdown;
+ private boolean is_terminated;
+
+ public TCFDSFExecuter() {
+ thread = new Thread(new Runnable() {
+ public void run() {
+ synchronized (TCFDSFExecuter.this) {
+ try {
+ while (true) {
+ if (queue.isEmpty()) {
+ if (is_shutdown) break;
+ TCFDSFExecuter.this.wait();
+ }
+ else {
+ long time = System.currentTimeMillis();
+ ScheduledFutureTask<?> s = queue.first();
+ if (s.time <= time) {
+ queue.remove(s);
+ Protocol.invokeLater(s);
+ }
+ else {
+ TCFDSFExecuter.this.wait(s.time - time);
+ }
+ }
+ }
+ }
+ catch (Throwable x) {
+ x.printStackTrace();
+ }
+ is_terminated = true;
+ }
+ }
+ });
+ thread.setName("TCF Future Task Scheduler");
+ thread.start();
+ }
+
+ public boolean isInExecutorThread() {
+ return Protocol.isDispatchThread();
+ }
+
+ public synchronized ScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit) {
+ if (command == null || unit == null) throw new NullPointerException();
+ if (is_shutdown) throw new RejectedExecutionException();
+ delay = unit.toMillis(delay);
+ ScheduledFutureTask<Boolean> s = new ScheduledFutureTask<Boolean>(delay, 0, command, Boolean.TRUE);
+ queue.add(s);
+ notify();
+ return s;
+ }
+
+ public synchronized <V> ScheduledFuture<V> schedule(Callable<V> callable, long delay, TimeUnit unit) {
+ if (callable == null || unit == null) throw new NullPointerException();
+ if (is_shutdown) throw new RejectedExecutionException();
+ delay = unit.toMillis(delay);
+ ScheduledFutureTask<V> s = new ScheduledFutureTask<V>(delay, callable);
+ queue.add(s);
+ notify();
+ return s;
+ }
+
+ public ScheduledFuture<?> scheduleAtFixedRate(Runnable command,
+ long initialDelay, long period, TimeUnit unit) {
+ if (command == null || unit == null) throw new NullPointerException();
+ if (is_shutdown) throw new RejectedExecutionException();
+ if (period <= 0) throw new RejectedExecutionException();
+ ScheduledFutureTask<Boolean> s = new ScheduledFutureTask<Boolean>(
+ unit.toMillis(initialDelay), unit.toMillis(period), command, Boolean.TRUE);
+ queue.add(s);
+ notify();
+ return s;
+ }
+
+ public ScheduledFuture<?> scheduleWithFixedDelay(Runnable command,
+ long initialDelay, long delay, TimeUnit unit) {
+ if (command == null || unit == null) throw new NullPointerException();
+ if (is_shutdown) throw new RejectedExecutionException();
+ if (delay <= 0) throw new RejectedExecutionException();
+ ScheduledFutureTask<Boolean> s = new ScheduledFutureTask<Boolean>(
+ unit.toMillis(initialDelay), -unit.toMillis(delay), command, Boolean.TRUE);
+ queue.add(s);
+ notify();
+ return s;
+ }
+
+ public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException {
+ thread.join(unit.toMillis(timeout));
+ return is_terminated;
+ }
+
+ public synchronized boolean isShutdown() {
+ return is_shutdown;
+ }
+
+ public synchronized boolean isTerminated() {
+ return is_terminated;
+ }
+
+ public synchronized void shutdown() {
+ is_shutdown = true;
+ notify();
+ }
+
+ public synchronized List<Runnable> shutdownNow() {
+ List<Runnable> res = new ArrayList<Runnable>(queue);
+ queue.clear();
+ is_shutdown = true;
+ notify();
+ return res;
+ }
+
+ public synchronized void execute(Runnable command) {
+ if (is_shutdown) throw new RejectedExecutionException();
+ Protocol.invokeLater(command);
+ }
+}
diff --git a/plugins/com.windriver.tcf.dsf.core/src/com/windriver/tcf/dsf/core/launch/TCFDSFLaunch.java b/plugins/com.windriver.tcf.dsf.core/src/com/windriver/tcf/dsf/core/launch/TCFDSFLaunch.java
new file mode 100644
index 000000000..f9535ce5e
--- /dev/null
+++ b/plugins/com.windriver.tcf.dsf.core/src/com/windriver/tcf/dsf/core/launch/TCFDSFLaunch.java
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Wind River Systems, Inc. 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 com.windriver.tcf.dsf.core.launch;
+
+import org.eclipse.dd.dsf.concurrent.DsfExecutor;
+import org.eclipse.dd.dsf.service.DsfSession;
+import org.eclipse.debug.core.ILaunchConfiguration;
+
+import com.windriver.debug.tcf.core.model.ITCFConstants;
+import com.windriver.debug.tcf.core.model.TCFLaunch;
+
+public class TCFDSFLaunch extends TCFLaunch {
+
+ private final TCFDSFExecuter executor;
+ private final DsfSession session;
+
+ public TCFDSFLaunch(ILaunchConfiguration launchConfiguration, String mode) {
+ super(launchConfiguration, mode);
+ executor = new TCFDSFExecuter();
+ session = DsfSession.startSession(executor, ITCFConstants.ID_TCF_DEBUG_MODEL);
+ }
+
+ public DsfExecutor getDsfExecutor() {
+ return executor;
+ }
+
+ public DsfSession getSession() {
+ return session;
+ }
+}
diff --git a/plugins/com.windriver.tcf.dsf.core/src/com/windriver/tcf/dsf/core/launch/TCFDSFLaunchDelegate.java b/plugins/com.windriver.tcf.dsf.core/src/com/windriver/tcf/dsf/core/launch/TCFDSFLaunchDelegate.java
new file mode 100644
index 000000000..a672e46e4
--- /dev/null
+++ b/plugins/com.windriver.tcf.dsf.core/src/com/windriver/tcf/dsf/core/launch/TCFDSFLaunchDelegate.java
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Wind River Systems, Inc. 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 com.windriver.tcf.dsf.core.launch;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.ILaunchConfiguration;
+
+import com.windriver.debug.tcf.core.launch.TCFLaunchDelegate;
+
+public class TCFDSFLaunchDelegate extends TCFLaunchDelegate {
+
+ public ILaunch getLaunch(ILaunchConfiguration configuration, String mode) throws CoreException {
+ return new TCFDSFLaunch(configuration, mode);
+ }
+}
diff --git a/plugins/com.windriver.tcf.dsf.core/src/com/windriver/tcf/dsf/core/services/TCFDSFExecutionDMC.java b/plugins/com.windriver.tcf.dsf.core/src/com/windriver/tcf/dsf/core/services/TCFDSFExecutionDMC.java
new file mode 100644
index 000000000..b648df9dc
--- /dev/null
+++ b/plugins/com.windriver.tcf.dsf.core/src/com/windriver/tcf/dsf/core/services/TCFDSFExecutionDMC.java
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Wind River Systems, Inc. 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 com.windriver.tcf.dsf.core.services;
+
+import org.eclipse.dd.dsf.datamodel.AbstractDMContext;
+import org.eclipse.dd.dsf.datamodel.IDMContext;
+import org.eclipse.dd.dsf.debug.service.IRunControl.IContainerDMContext;
+import org.eclipse.dd.dsf.debug.service.IRunControl.IExecutionDMContext;
+import org.eclipse.dd.dsf.service.IDsfService;
+
+public abstract class TCFDSFExecutionDMC extends AbstractDMContext implements IExecutionDMContext, IContainerDMContext {
+
+ TCFDSFExecutionDMC(IDsfService service, IDMContext[] parents) {
+ super(service, parents);
+ }
+
+ public abstract String getTcfContextId();
+}
diff --git a/plugins/com.windriver.tcf.dsf.core/src/com/windriver/tcf/dsf/core/services/TCFDSFNativeProcesses.java b/plugins/com.windriver.tcf.dsf.core/src/com/windriver/tcf/dsf/core/services/TCFDSFNativeProcesses.java
new file mode 100644
index 000000000..5c1235ae6
--- /dev/null
+++ b/plugins/com.windriver.tcf.dsf.core/src/com/windriver/tcf/dsf/core/services/TCFDSFNativeProcesses.java
@@ -0,0 +1,332 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Wind River Systems, Inc. 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 com.windriver.tcf.dsf.core.services;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+
+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.ServiceDMContext;
+import org.eclipse.dd.dsf.debug.service.INativeProcesses;
+import org.eclipse.dd.dsf.service.AbstractDsfService;
+import org.eclipse.dd.dsf.service.DsfSession;
+import org.osgi.framework.BundleContext;
+
+import com.windriver.tcf.api.protocol.IChannel;
+import com.windriver.tcf.api.protocol.IToken;
+import com.windriver.tcf.api.services.IProcesses;
+import com.windriver.tcf.api.services.IProcesses.ProcessContext;
+import com.windriver.tcf.dsf.core.Activator;
+
+public class TCFDSFNativeProcesses extends AbstractDsfService implements INativeProcesses {
+
+ private class ProcessDMC extends TCFDSFProcessDMC {
+
+ final String id;
+
+ ProcessDMC(String id) {
+ super(TCFDSFNativeProcesses.this, new IDMContext[0]);
+ this.id = id;
+ }
+
+ @Override
+ public String toString() {
+ return baseToString() + ".context[" + id + "]"; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ return super.baseEquals(obj) && ((ProcessDMC)obj).id.equals(id);
+ }
+
+ @Override
+ public int hashCode() {
+ return id.hashCode();
+ }
+ }
+
+ private class ThreadDMC extends TCFDSFThreadDMC {
+
+ final String id;
+
+ ThreadDMC(String id) {
+ super(TCFDSFNativeProcesses.this, new IDMContext[0]);
+ this.id = id;
+ }
+
+ @Override
+ public String toString() {
+ return baseToString() + ".context[" + id + "]"; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ return super.baseEquals(obj) && ((ThreadDMC)obj).id.equals(id);
+ }
+
+ @Override
+ public int hashCode() {
+ return id.hashCode();
+ }
+ }
+
+ private static class ProcessData implements IProcessDMData {
+
+ private final IProcesses.ProcessContext ctx;
+
+ ProcessData(IProcesses.ProcessContext ctx) {
+ this.ctx = ctx;
+ }
+
+ public IDMContext getDebugContext() {
+ // TODO Auto-generated method stub
+ assert false;
+ return null;
+ }
+
+ public String getId() {
+ return ctx.getID();
+ }
+
+ public String getName() {
+ return ctx.getName();
+ }
+
+ public boolean isDebuggerAttached() {
+ return ctx.isAttached();
+ }
+
+ public boolean isValid() {
+ return true;
+ }
+ }
+
+ private static class ThreadData implements IThreadDMData {
+
+ private final IProcesses.ProcessContext ctx;
+
+ ThreadData(IProcesses.ProcessContext ctx) {
+ this.ctx = ctx;
+ }
+
+ public IDMContext getDebugContext() {
+ // TODO Auto-generated method stub
+ assert false;
+ return null;
+ }
+
+ public String getId() {
+ return ctx.getID();
+ }
+
+ public String getName() {
+ return ctx.getName();
+ }
+
+ public boolean isDebuggerAttached() {
+ return ctx.isAttached();
+ }
+
+ public boolean isValid() {
+ return true;
+ }
+
+ }
+
+ final IProcesses service;
+ private IDMContext service_dmc;
+
+ TCFDSFNativeProcesses(DsfSession session, IChannel channel) {
+ super(session);
+ service = channel.getRemoteService(IProcesses.class);
+ service_dmc = new ServiceDMContext(this, "#native_process");
+ }
+
+ @Override
+ protected BundleContext getBundleContext() {
+ return Activator.getBundleContext();
+ }
+
+ public IDMContext getServiceContext() {
+ return service_dmc;
+ }
+
+ public boolean isValid() {
+ return true;
+ }
+
+ public void attachDebuggerToProcess(IProcessDMContext ctx, RequestMonitor rm) {
+ // TODO Auto-generated method stub
+ assert false;
+ }
+
+ public void canTerminate(IDMContext ctx, DataRequestMonitor<Boolean> rm) {
+ // TODO Auto-generated method stub
+ assert false;
+ }
+
+ public void terminate(IDMContext ctx, RequestMonitor requestMonitor) {
+ // TODO Auto-generated method stub
+ assert false;
+ }
+
+ public void debugNewProcess(String file, DataRequestMonitor<IProcessDMContext> rm) {
+ // TODO Auto-generated method stub
+ assert false;
+ }
+
+ public void runNewProcess(String file, DataRequestMonitor<IProcessDMContext> rm) {
+ // TODO Auto-generated method stub
+ assert false;
+ }
+
+ public IProcessDMContext getProcessForDebugContext(IDMContext ctx) {
+ if (ctx instanceof IProcessDMContext) {
+ return (IProcessDMContext)ctx;
+ }
+ if (ctx instanceof TCFDSFExecutionDMC) {
+ String id = ((TCFDSFExecutionDMC)ctx).getTcfContextId();
+ return new ProcessDMC(id);
+ }
+ return null;
+ }
+
+ public IThreadDMContext getThreadForDebugContext(IDMContext ctx) {
+ if (ctx instanceof IThreadDMContext) {
+ return (IThreadDMContext)ctx;
+ }
+ if (ctx instanceof TCFDSFExecutionDMC) {
+ String id = ((TCFDSFExecutionDMC)ctx).getTcfContextId();
+ return new ThreadDMC(id);
+ }
+ return null;
+ }
+
+ public void getProcessesBeingDebugged(final DataRequestMonitor<IProcessDMContext[]> rm) {
+ final Collection<String> list = new ArrayList<String>();
+ final Set<IToken> cmds = new HashSet<IToken>();
+ final IProcesses.DoneGetChildren done = new IProcesses.DoneGetChildren() {
+ public void doneGetChildren(IToken token, Exception error, String[] context_ids) {
+ if (cmds.isEmpty()) return;
+ assert cmds.contains(token);
+ cmds.remove(token);
+ if (error != null) {
+ for (IToken t : cmds) t.cancel();
+ cmds.clear();
+ rm.setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID,
+ REQUEST_FAILED, "Command error", error)); //$NON-NLS-1$
+ rm.done();
+ }
+ else {
+ for (String id : context_ids) {
+ list.add(id);
+ cmds.add(service.getChildren(id, true, this));
+ }
+ if (cmds.isEmpty()) createDMContexts(list, rm);
+ }
+ }
+ };
+ cmds.add(service.getChildren(null, true, done));
+ }
+
+ public void getRunningProcesses(final DataRequestMonitor<IProcessDMContext[]> rm) {
+ final Collection<String> list = new ArrayList<String>();
+ final Set<IToken> cmds = new HashSet<IToken>();
+ final IProcesses.DoneGetChildren done = new IProcesses.DoneGetChildren() {
+ public void doneGetChildren(IToken token, Exception error, String[] context_ids) {
+ if (cmds.isEmpty()) return;
+ assert cmds.contains(token);
+ cmds.remove(token);
+ if (error != null) {
+ for (IToken t : cmds) t.cancel();
+ cmds.clear();
+ rm.setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID,
+ REQUEST_FAILED, "Command error", error)); //$NON-NLS-1$
+ rm.done();
+ }
+ else {
+ for (String id : context_ids) {
+ list.add(id);
+ cmds.add(service.getChildren(id, false, this));
+ }
+ if (cmds.isEmpty()) createDMContexts(list, rm);
+ }
+ }
+ };
+ cmds.add(service.getChildren(null, false, done));
+ }
+
+ @SuppressWarnings("unchecked")
+ public void getModelData(IDMContext dmc, final DataRequestMonitor<?> rm) {
+ if (dmc instanceof ProcessDMC) {
+ service.getContext(((ProcessDMC)dmc).id, new IProcesses.DoneGetContext() {
+
+ @SuppressWarnings("unchecked")
+ public void doneGetContext(IToken token, Exception error, ProcessContext context) {
+ if (error != null) {
+ rm.setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID,
+ REQUEST_FAILED, "Data error", error)); //$NON-NLS-1$
+ }
+ else {
+ ((DataRequestMonitor<IProcessDMData>)rm).setData(new ProcessData(context));
+ }
+ rm.done();
+ }
+ });
+ }
+ else if (dmc instanceof ThreadDMC) {
+ service.getContext(((ProcessDMC)dmc).id, new IProcesses.DoneGetContext() {
+
+ @SuppressWarnings("unchecked")
+ public void doneGetContext(IToken token, Exception error, ProcessContext context) {
+ if (error != null) {
+ rm.setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID,
+ REQUEST_FAILED, "Data error", error)); //$NON-NLS-1$
+ }
+ else {
+ ((DataRequestMonitor<IThreadDMData>)rm).setData(new ThreadData(context));
+ }
+ rm.done();
+ }
+ });
+ }
+ else if (dmc == service_dmc) {
+ ((DataRequestMonitor<TCFDSFNativeProcesses>)rm).setData(this);
+ rm.done();
+ }
+ else {
+ rm.setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID,
+ INVALID_HANDLE, "Unknown DMC type", null)); //$NON-NLS-1$
+ rm.done();
+ }
+ }
+
+ private void createDMContexts(Collection<String> ids, DataRequestMonitor<IProcessDMContext[]> rm) {
+ assert false;
+ }
+
+ public void getProcessData(IProcessDMContext dmc,
+ DataRequestMonitor<IProcessDMData> rm) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void getThreadData(IThreadDMContext dmc, DataRequestMonitor<IThreadDMData> rm) {
+ // TODO Auto-generated method stub
+ assert false;
+ }
+}
diff --git a/plugins/com.windriver.tcf.dsf.core/src/com/windriver/tcf/dsf/core/services/TCFDSFProcessDMC.java b/plugins/com.windriver.tcf.dsf.core/src/com/windriver/tcf/dsf/core/services/TCFDSFProcessDMC.java
new file mode 100644
index 000000000..427fb92bf
--- /dev/null
+++ b/plugins/com.windriver.tcf.dsf.core/src/com/windriver/tcf/dsf/core/services/TCFDSFProcessDMC.java
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Wind River Systems, Inc. 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 com.windriver.tcf.dsf.core.services;
+
+import org.eclipse.dd.dsf.datamodel.AbstractDMContext;
+import org.eclipse.dd.dsf.datamodel.IDMContext;
+import org.eclipse.dd.dsf.debug.service.INativeProcesses.IProcessDMContext;
+import org.eclipse.dd.dsf.service.IDsfService;
+
+public abstract class TCFDSFProcessDMC extends AbstractDMContext implements IProcessDMContext {
+
+ TCFDSFProcessDMC(IDsfService service, IDMContext[] parents) {
+ super(service, parents);
+ }
+}
diff --git a/plugins/com.windriver.tcf.dsf.core/src/com/windriver/tcf/dsf/core/services/TCFDSFRunControl.java b/plugins/com.windriver.tcf.dsf.core/src/com/windriver/tcf/dsf/core/services/TCFDSFRunControl.java
new file mode 100644
index 000000000..3564e25cf
--- /dev/null
+++ b/plugins/com.windriver.tcf.dsf.core/src/com/windriver/tcf/dsf/core/services/TCFDSFRunControl.java
@@ -0,0 +1,829 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Wind River Systems, Inc. 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 com.windriver.tcf.dsf.core.services;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.SortedMap;
+import java.util.TreeMap;
+
+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.AbstractDMEvent;
+import org.eclipse.dd.dsf.datamodel.IDMContext;
+import org.eclipse.dd.dsf.datamodel.ServiceDMContext;
+import org.eclipse.dd.dsf.service.AbstractDsfService;
+import org.eclipse.dd.dsf.service.DsfSession;
+import org.osgi.framework.BundleContext;
+
+import com.windriver.tcf.dsf.core.Activator;
+import com.windriver.tcf.api.protocol.IChannel;
+import com.windriver.tcf.api.protocol.IToken;
+import com.windriver.tcf.api.protocol.Protocol;
+import com.windriver.tcf.api.services.IRunControl;
+import com.windriver.tcf.api.services.IRunControl.RunControlContext;
+
+public class TCFDSFRunControl extends AbstractDsfService implements org.eclipse.dd.dsf.debug.service.IRunControl {
+
+ public static class SuspendedEvent extends AbstractDMEvent<IExecutionDMContext> implements ISuspendedDMEvent {
+
+ private final StateChangeReason reason;
+
+ public SuspendedEvent(IExecutionDMContext dmc, String reason) {
+ super(dmc);
+ this.reason = toStateChangeReason(reason);
+ }
+
+ public StateChangeReason getReason() {
+ return reason;
+ }
+ }
+
+ public static class ResumedEvent extends AbstractDMEvent<IExecutionDMContext> implements IResumedDMEvent {
+
+ public ResumedEvent(IExecutionDMContext dmc) {
+ super(dmc);
+ }
+
+ public StateChangeReason getReason() {
+ return StateChangeReason.USER_REQUEST;
+ }
+ }
+
+ public class ContainerSuspendedEvent extends AbstractDMEvent<IExecutionDMContext> implements IContainerSuspendedDMEvent {
+
+ private final String trigger_id;
+ private final StateChangeReason reason;
+
+ public ContainerSuspendedEvent(IExecutionDMContext dmc, String trigger_id, String reason) {
+ super(dmc);
+ this.trigger_id = trigger_id;
+ this.reason = toStateChangeReason(reason);
+ }
+
+ public IExecutionDMContext getTriggeringContext() {
+ return model.get(trigger_id);
+ }
+
+ public StateChangeReason getReason() {
+ return reason;
+ }
+ }
+
+ public static class ContainerResumedEvent extends AbstractDMEvent<IExecutionDMContext> implements IContainerResumedDMEvent {
+
+ public ContainerResumedEvent(IExecutionDMContext dmc) {
+ super(dmc);
+ }
+
+ public StateChangeReason getReason() {
+ return StateChangeReason.USER_REQUEST;
+ }
+ }
+
+ public static class StartedEvent extends AbstractDMEvent<IContainerDMContext> implements IStartedDMEvent {
+
+ private final IExecutionDMContext exe;
+
+ public StartedEvent(IContainerDMContext dmc, IExecutionDMContext exe) {
+ super(dmc);
+ this.exe = exe;
+ }
+
+ public IExecutionDMContext getExecutionContext() {
+ return exe;
+ }
+ }
+
+ public static class ChangedEvent extends AbstractDMEvent<IExecutionDMContext> {
+
+ public ChangedEvent(IExecutionDMContext dmc) {
+ super(dmc);
+ }
+ }
+
+ public static class ExitedEvent extends AbstractDMEvent<IContainerDMContext> implements IExitedDMEvent {
+
+ private final IExecutionDMContext exe;
+
+ public ExitedEvent(IContainerDMContext dmc, IExecutionDMContext exe) {
+ super(dmc);
+ this.exe = exe;
+ }
+
+ public IExecutionDMContext getExecutionContext() {
+ return exe;
+ }
+ }
+
+ private final com.windriver.tcf.api.services.IRunControl.RunControlListener run_listener =
+ new com.windriver.tcf.api.services.IRunControl.RunControlListener() {
+
+ public void containerResumed(String[] context_ids) {
+ for (String id : context_ids) {
+ ExecutionDMC n = model.get(id);
+ if (n != null) n.onContextResumed();
+ }
+ for (String id : context_ids) {
+ ExecutionDMC n = model.get(id);
+ if (n != null && n.ctx.isContainer()) {
+ getSession().dispatchEvent(new ContainerResumedEvent(n), getProperties());
+ }
+ }
+ }
+
+ public void containerSuspended(String trigger_id, String pc,
+ String reason, Map<String, Object> params,
+ String[] suspended_ids) {
+ if (trigger_id != null) {
+ ExecutionDMC n = model.get(trigger_id);
+ if (n != null) n.onContextSuspended(pc, reason, params);
+ }
+ for (String id : suspended_ids) {
+ if (id.equals(trigger_id)) continue;
+ ExecutionDMC n = model.get(id);
+ if (n != null) n.onContainerSuspended(reason);
+ }
+ for (String id : suspended_ids) {
+ ExecutionDMC n = model.get(id);
+ if (n != null && n.ctx.isContainer()) {
+ getSession().dispatchEvent(new ContainerSuspendedEvent(n, trigger_id, reason), getProperties());
+ }
+ }
+ }
+
+ public void contextAdded(RunControlContext[] contexts) {
+ for (RunControlContext ctx : contexts) {
+ ExecutionDMC n = model.get(ctx.getParentID());
+ if (n != null) n.onContextAdded(ctx);
+ }
+ }
+
+ public void contextChanged(RunControlContext[] contexts) {
+ for (RunControlContext ctx : contexts) {
+ ExecutionDMC n = model.get(ctx.getID());
+ if (n != null) n.onContextChanged(ctx);
+ }
+ }
+
+ public void contextException(String id, String msg) {
+ ExecutionDMC n = model.get(id);
+ if (n != null) n.onContextException(msg);
+ }
+
+ public void contextRemoved(String[] context_ids) {
+ for (String id : context_ids) {
+ ExecutionDMC n = model.get(id);
+ if (n != null) n.onContextRemoved();
+ }
+ }
+
+ public void contextResumed(String id) {
+ ExecutionDMC n = model.get(id);
+ if (n != null) n.onContextResumed();
+ }
+
+ public void contextSuspended(String id, String pc, String reason, Map<String, Object> params) {
+ ExecutionDMC n = model.get(id);
+ if (n != null) n.onContextSuspended(pc, reason, params);
+ }
+ };
+
+ private interface IDataRequest {
+ void cancel();
+ void done();
+ }
+
+ private static final int
+ VALID_CHILDREN = 4,
+ VALID_CONTEXT = 8,
+ VALID_STATE = 16,
+ VALID_ALL = VALID_CHILDREN | VALID_CONTEXT | VALID_STATE;
+
+ private class ExecutionDMC extends TCFDSFExecutionDMC {
+
+ final String id;
+ final ExecutionDMC parent;
+
+ final SortedMap<String,ExecutionDMC> children = new TreeMap<String,ExecutionDMC>();
+ final Map<String,ExecutionDMC> children_next = new HashMap<String,ExecutionDMC>();
+ final Collection<IDataRequest> node_wait_list = new ArrayList<IDataRequest>();
+
+ int valid;
+ Throwable error;
+ boolean disposed;
+ IToken command;
+
+ RunControlContext ctx;
+ int is_stepping;
+ int is_resuming;
+ boolean is_suspended;
+ boolean is_running;
+ String suspend_pc;
+ String suspend_reason;
+ String exception_msg;
+ Map<String,Object> suspend_params;
+
+ public ExecutionDMC(ExecutionDMC parent, String id) {
+ super(TCFDSFRunControl.this, parent == null ? null : new IDMContext[] { parent });
+ this.parent = parent;
+ this.id = id;
+ }
+
+ @Override
+ public String toString() {
+ return baseToString() + ".context[" + id + "]"; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ return super.baseEquals(obj) && ((ExecutionDMC)obj).id.equals(id);
+ }
+
+ @Override
+ public int hashCode() {
+ return id.hashCode();
+ }
+
+ @Override
+ public String getTcfContextId() {
+ return id;
+ }
+
+ void dispose() {
+ assert !disposed;
+ ExecutionDMC arr[] = children.values().toArray(new ExecutionDMC[children.size()]);
+ for (int i = 0; i < arr.length; i++) arr[i].dispose();
+ assert children.isEmpty();
+ if (parent != null) {
+ parent.children.remove(id);
+ parent.children_next.remove(id);
+ }
+ model.remove(id);
+ disposed = true;
+ }
+
+ void invalidateDMC(int flags) {
+ // cancel current data retrieval command
+ if (command != null) {
+ command.cancel();
+ command = null;
+ }
+
+ // cancel waiting requests
+ if (!node_wait_list.isEmpty()) {
+ IDataRequest[] arr = node_wait_list.toArray(new IDataRequest[node_wait_list.size()]);
+ node_wait_list.clear();
+ for (IDataRequest r : arr) r.cancel();
+ }
+
+ if ((flags & VALID_STATE) != 0) {
+ is_suspended = false;
+ is_running = false;
+ }
+
+ if ((flags & VALID_CHILDREN) != 0) {
+ children_next.clear();
+ for (ExecutionDMC n : children.values()) n.invalidateDMC(VALID_ALL);
+ }
+
+ if (flags == VALID_ALL) {
+ error = null;
+ }
+
+ valid &= ~flags;
+ }
+
+ boolean validateDMC(IDataRequest done) {
+ assert Protocol.isDispatchThread();
+ assert (valid & ~VALID_ALL) == 0;
+ assert parent == null || parent.children.get(id) == model.get(id);
+ if (channel.getState() != IChannel.STATE_OPEN) {
+ children_next.clear();
+ error = null;
+ command = null;
+ valid = VALID_ALL;
+ }
+ if (command != null) {
+ if (done != null) node_wait_list.add(done);
+ return false;
+ }
+ if (parent != null && parent.error != null) {
+ valid = VALID_ALL;
+ }
+ if ((valid & VALID_CONTEXT) == 0 && !validateRunControlContext(done)) return false;
+ if ((valid & VALID_STATE) == 0 && !validateRunControlState(done)) return false;
+ if ((valid & VALID_CHILDREN) == 0 && !validateRunControlChildren(done)) return false;
+ assert valid == VALID_ALL;
+ assert command == null;
+ ExecutionDMC[] a = children.values().toArray(new ExecutionDMC[children.size()]);
+ for (ExecutionDMC n : a) {
+ if (children_next.get(n.id) == null) n.dispose();
+ }
+ for (ExecutionDMC n : children_next.values()) {
+ if (children.get(n.id) == null) {
+ children.put(n.id, n);
+ model.put(n.id, n);
+ }
+ }
+ if (!node_wait_list.isEmpty()) {
+ IDataRequest[] arr = node_wait_list.toArray(new IDataRequest[node_wait_list.size()]);
+ node_wait_list.clear();
+ for (IDataRequest r : arr) r.done();
+ }
+ assert valid == VALID_ALL;
+ return true;
+ }
+
+ private boolean validateRunControlChildren(IDataRequest done) {
+ assert command == null;
+ if (tcf_run_service == null) {
+ valid |= VALID_CHILDREN;
+ return true;
+ }
+ if (done != null) node_wait_list.add(done);
+ command = tcf_run_service.getChildren(id, new IRunControl.DoneGetChildren() {
+ public void doneGetChildren(IToken token, Exception error, String[] contexts) {
+ if (command != token) return;
+ command = null;
+ if (error != null) {
+ ExecutionDMC.this.error = error;
+ }
+ else {
+ for (int i = 0; i < contexts.length; i++) {
+ String id = contexts[i];
+ ExecutionDMC node = model.get(id);
+ if (node == null) node = new ExecutionDMC(ExecutionDMC.this, id);
+ children_next.put(id, node);
+ }
+ }
+ valid |= VALID_CHILDREN;
+ validateDMC(null);
+ }
+ });
+ return false;
+ }
+
+ private boolean validateRunControlContext(IDataRequest done) {
+ assert command == null;
+ if (tcf_run_service == null) {
+ valid |= VALID_CONTEXT;
+ return true;
+ }
+ if (done != null) node_wait_list.add(done);
+ command = tcf_run_service.getContext(id, new IRunControl.DoneGetContext() {
+ public void doneGetContext(IToken token, Exception error, IRunControl.RunControlContext ctx) {
+ if (command != token) return;
+ command = null;
+ if (error != null) {
+ ExecutionDMC.this.error = error;
+ }
+ else {
+ ExecutionDMC.this.ctx = ctx;
+ }
+ valid |= VALID_CONTEXT;
+ validateDMC(null);
+ }
+ });
+ return false;
+ }
+
+ private boolean validateRunControlState(IDataRequest done) {
+ assert command == null;
+ if (ctx == null) {
+ valid |= VALID_STATE;
+ return true;
+ }
+ if (error != null || !ctx.hasState()) {
+ is_running = false;
+ is_suspended = false;
+ suspend_pc = null;
+ suspend_reason = null;
+ suspend_params = null;
+ valid |= VALID_STATE;
+ return true;
+ }
+ if (done != null) node_wait_list.add(done);
+ command = ctx.getState(new IRunControl.DoneGetState() {
+ public void doneGetState(IToken token, Exception error, boolean suspend, String pc, String reason, Map<String,Object> params) {
+ if (token != command) return;
+ command = null;
+ if (error != null) {
+ is_running = false;
+ is_suspended = false;
+ suspend_pc = null;
+ suspend_reason = null;
+ suspend_params = null;
+ ExecutionDMC.this.error = error;
+ }
+ else {
+ is_running = !suspend;
+ is_suspended = suspend;
+ if (suspend) {
+ suspend_pc = pc;
+ suspend_reason = reason;
+ suspend_params = params;
+ }
+ else {
+ suspend_pc = null;
+ suspend_reason = null;
+ suspend_params = null;
+ }
+ }
+ valid |= VALID_STATE;
+ validateDMC(null);
+ }
+ });
+ return false;
+ }
+
+ /*--------------------------------------------------------------------------------------*/
+ /* Events */
+
+ void onContextAdded(IRunControl.RunControlContext context) {
+ String id = context.getID();
+ assert !disposed;
+ assert children.get(id) == null;
+ ExecutionDMC n = new ExecutionDMC(this, id);
+ n.ctx = context;
+ n.valid |= VALID_CONTEXT;
+ children.put(id, n);
+ model.put(id, n);
+ getSession().dispatchEvent(new StartedEvent(this, n), getProperties());
+ }
+
+ void onContextChanged(IRunControl.RunControlContext context) {
+ assert !disposed;
+ ctx = context;
+ invalidateDMC(VALID_CHILDREN);
+ getSession().dispatchEvent(new ChangedEvent(this), getProperties());
+ }
+
+ void onContextRemoved() {
+ assert !disposed;
+ dispose();
+ getSession().dispatchEvent(new ExitedEvent(parent, this), getProperties());
+ }
+
+ void onContainerSuspended(String reason) {
+ assert !disposed;
+ if (ctx == null) return;
+ if (!ctx.hasState()) return;
+ invalidateDMC(VALID_STATE);
+ getSession().dispatchEvent(new SuspendedEvent(this, reason), getProperties());
+ }
+
+ void onContextSuspended(String pc, String reason, Map<String,Object> params) {
+ assert !disposed;
+ if (ctx == null) return;
+ assert ctx.hasState();
+ is_suspended = true;
+ suspend_pc = pc;
+ suspend_reason = reason;
+ suspend_params = params;
+ is_running = false;
+ valid |= VALID_STATE;
+ getSession().dispatchEvent(new SuspendedEvent(this, reason), getProperties());
+ }
+
+ void onContextResumed() {
+ assert !disposed;
+ if (ctx == null) return;
+ assert ctx.hasState();
+ exception_msg = null;
+ is_suspended = false;
+ suspend_pc = null;
+ suspend_reason = null;
+ suspend_params = null;
+ is_running = true;
+ valid |= VALID_STATE;
+ getSession().dispatchEvent(new ResumedEvent(this), getProperties());
+ }
+
+ void onContextException(String msg) {
+ assert !disposed;
+ exception_msg = msg;
+ }
+ }
+
+ private static class ExecutionData implements IExecutionDMData {
+
+ private final StateChangeReason reason;
+
+ ExecutionData(StateChangeReason reason) {
+ this.reason = reason;
+ }
+
+ public boolean isValid() {
+ return true;
+ }
+
+ public StateChangeReason getStateChangeReason() {
+ return reason;
+ }
+ }
+
+ private static StateChangeReason toStateChangeReason(String s) {
+ if (s == null) return StateChangeReason.UNKNOWN;
+ if (s.equals(com.windriver.tcf.api.services.IRunControl.REASON_USER_REQUEST)) return StateChangeReason.USER_REQUEST;
+ if (s.equals(com.windriver.tcf.api.services.IRunControl.REASON_STEP)) return StateChangeReason.STEP;
+ if (s.equals(com.windriver.tcf.api.services.IRunControl.REASON_BREAKPOINT)) return StateChangeReason.BREAKPOINT;
+ if (s.equals(com.windriver.tcf.api.services.IRunControl.REASON_EXCEPTION)) return StateChangeReason.EXCEPTION;
+ if (s.equals(com.windriver.tcf.api.services.IRunControl.REASON_CONTAINER)) return StateChangeReason.CONTAINER;
+ if (s.equals(com.windriver.tcf.api.services.IRunControl.REASON_WATCHPOINT)) return StateChangeReason.WATCHPOINT;
+ if (s.equals(com.windriver.tcf.api.services.IRunControl.REASON_SIGNAL)) return StateChangeReason.SIGNAL;
+ if (s.equals(com.windriver.tcf.api.services.IRunControl.REASON_SHAREDLIB)) return StateChangeReason.SHAREDLIB;
+ if (s.equals(com.windriver.tcf.api.services.IRunControl.REASON_ERROR)) return StateChangeReason.ERROR;
+ return StateChangeReason.UNKNOWN;
+ }
+
+ private final IChannel channel;
+ private final com.windriver.tcf.api.services.IRunControl tcf_run_service;
+ private final Map<String,ExecutionDMC> model = new HashMap<String,ExecutionDMC>();
+ private IDMContext service_dmc;
+
+ public TCFDSFRunControl(DsfSession session, IChannel channel) {
+ super(session);
+ this.channel = channel;
+ tcf_run_service = channel.getRemoteService(com.windriver.tcf.api.services.IRunControl.class);
+ if (tcf_run_service != null) tcf_run_service.addListener(run_listener);
+ service_dmc = new ServiceDMContext(this, "#run_control");
+ }
+
+ @Override
+ protected BundleContext getBundleContext() {
+ return Activator.getBundleContext();
+ }
+
+ @SuppressWarnings("unchecked")
+ public void getModelData(IDMContext dmc, final DataRequestMonitor<?> rm) {
+ if (dmc instanceof ExecutionDMC) {
+ final ExecutionDMC ctx = (ExecutionDMC)dmc;
+ IDataRequest done = new IDataRequest() {
+
+ public void cancel() {
+ rm.setCanceled(true);
+ rm.done();
+ }
+
+ @SuppressWarnings("unchecked")
+ public void done() {
+ if (ctx.error != null) {
+ rm.setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID,
+ REQUEST_FAILED, "Data error", ctx.error)); //$NON-NLS-1$
+ }
+ else {
+ ExecutionData dt = new ExecutionData(toStateChangeReason(ctx.suspend_reason));
+ ((DataRequestMonitor<IExecutionDMData>)rm).setData(dt);
+ }
+ rm.done();
+ }
+ };
+ if (ctx.validateDMC(done)) done.done();
+ }
+ else if (dmc == service_dmc) {
+ ((DataRequestMonitor<TCFDSFRunControl>)rm).setData(this);
+ rm.done();
+ }
+ else {
+ rm.setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID,
+ INVALID_HANDLE, "Unknown DMC type", null)); //$NON-NLS-1$
+ rm.done();
+ }
+ }
+
+ public IDMContext getServiceContext() {
+ return service_dmc;
+ }
+
+ public boolean isValid() {
+ return true;
+ }
+
+ public IContainerDMContext getContainerDMC() {
+ // TODO: getContainerDMC()
+ assert false;
+ return null;
+ }
+
+ public boolean canInstructionStep(IDMContext context) {
+ if (context instanceof ExecutionDMC) {
+ ExecutionDMC x = (ExecutionDMC)context;
+ return x.ctx.canResume(com.windriver.tcf.api.services.IRunControl.RM_STEP_INTO);
+ }
+ return false;
+ }
+
+ public boolean canResume(IDMContext context) {
+ if (context instanceof ExecutionDMC) {
+ ExecutionDMC x = (ExecutionDMC)context;
+ return x.ctx.canResume(com.windriver.tcf.api.services.IRunControl.RM_RESUME);
+ }
+ return false;
+ }
+
+ public boolean canStep(IDMContext context) {
+ if (context instanceof ExecutionDMC) {
+ ExecutionDMC x = (ExecutionDMC)context;
+ return x.ctx.canResume(com.windriver.tcf.api.services.IRunControl.RM_STEP_OVER);
+ }
+ return false;
+ }
+
+ public boolean canSuspend(IDMContext context) {
+ if (context instanceof ExecutionDMC) {
+ ExecutionDMC x = (ExecutionDMC)context;
+ return x.ctx.canSuspend();
+ }
+ return false;
+ }
+
+ public void getExecutionContexts(IContainerDMContext context, final DataRequestMonitor<IExecutionDMContext[]> rm) {
+ if (context instanceof ExecutionDMC) {
+ final ExecutionDMC ctx = (ExecutionDMC)context;
+ IDataRequest done = new IDataRequest() {
+
+ public void cancel() {
+ rm.setCanceled(true);
+ rm.done();
+ }
+
+ @SuppressWarnings("unchecked")
+ public void done() {
+ if (ctx.error != null) {
+ rm.setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID,
+ REQUEST_FAILED, "Data error", ctx.error)); //$NON-NLS-1$
+ }
+ else {
+ rm.setData(ctx.children.values().toArray(new ExecutionDMC[ctx.children.size()]));
+ }
+ rm.done();
+ }
+ };
+ if (ctx.validateDMC(done)) done.done();
+ }
+ else {
+ rm.setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID,
+ INVALID_HANDLE, "Unknown DMC type", null)); //$NON-NLS-1$
+ rm.done();
+ }
+ }
+
+ public void step(IDMContext context, StepType stepType, final RequestMonitor rm) {
+ if (context instanceof ExecutionDMC) {
+ final ExecutionDMC x = (ExecutionDMC)context;
+ int md = -1;
+ switch (stepType) {
+ case STEP_OVER:
+ md = com.windriver.tcf.api.services.IRunControl.RM_STEP_OVER_LINE;
+ break;
+ case STEP_INTO:
+ md = com.windriver.tcf.api.services.IRunControl.RM_STEP_INTO_LINE;
+ break;
+ case STEP_RETURN:
+ md = com.windriver.tcf.api.services.IRunControl.RM_STEP_OUT;
+ break;
+ }
+ if (md < 0) {
+ rm.setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID,
+ NOT_SUPPORTED, "Invalid step type", null)); //$NON-NLS-1$
+ rm.done();
+ }
+ else {
+ x.ctx.resume(md, 1, new com.windriver.tcf.api.services.IRunControl.DoneCommand() {
+ public void doneCommand(IToken token, Exception error) {
+ if (error != null) {
+ rm.setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID,
+ REQUEST_FAILED, "Command error", error)); //$NON-NLS-1$
+ }
+ x.is_stepping--;
+ rm.done();
+ }
+ });
+ x.is_stepping++;
+ }
+ }
+ else {
+ rm.setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID,
+ INVALID_HANDLE, "Unknown DMC type", null)); //$NON-NLS-1$
+ rm.done();
+ }
+ }
+
+ public void instructionStep(IDMContext context, StepType stepType, final RequestMonitor rm) {
+ if (context instanceof ExecutionDMC) {
+ final ExecutionDMC x = (ExecutionDMC)context;
+ int md = -1;
+ switch (stepType) {
+ case STEP_OVER:
+ md = com.windriver.tcf.api.services.IRunControl.RM_STEP_OVER;
+ break;
+ case STEP_INTO:
+ md = com.windriver.tcf.api.services.IRunControl.RM_STEP_INTO;
+ break;
+ case STEP_RETURN:
+ md = com.windriver.tcf.api.services.IRunControl.RM_STEP_OUT;
+ break;
+ }
+ if (md < 0) {
+ rm.setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID,
+ NOT_SUPPORTED, "Invalid step type", null)); //$NON-NLS-1$
+ rm.done();
+ }
+ else {
+ x.ctx.resume(md, 1, new com.windriver.tcf.api.services.IRunControl.DoneCommand() {
+ public void doneCommand(IToken token, Exception error) {
+ if (error != null) {
+ rm.setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID,
+ REQUEST_FAILED, "Command error", error)); //$NON-NLS-1$
+ }
+ x.is_stepping--;
+ rm.done();
+ }
+ });
+ x.is_stepping++;
+ }
+ }
+ else {
+ rm.setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID,
+ INVALID_HANDLE, "Unknown DMC type", null)); //$NON-NLS-1$
+ rm.done();
+ }
+ }
+
+ public boolean isStepping(IDMContext context) {
+ if (context instanceof ExecutionDMC) {
+ ExecutionDMC x = (ExecutionDMC)context;
+ return x.is_stepping > 0;
+ }
+ return false;
+ }
+
+ public void resume(IDMContext context, final RequestMonitor rm) {
+ if (context instanceof ExecutionDMC) {
+ final ExecutionDMC x = (ExecutionDMC)context;
+ x.ctx.resume(com.windriver.tcf.api.services.IRunControl.RM_RESUME, 1,
+ new com.windriver.tcf.api.services.IRunControl.DoneCommand() {
+ public void doneCommand(IToken token, Exception error) {
+ if (error != null) {
+ rm.setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID,
+ REQUEST_FAILED, "Command error", error)); //$NON-NLS-1$
+ }
+ x.is_resuming--;
+ rm.done();
+ }
+ });
+ x.is_resuming++;
+ }
+ else {
+ rm.setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID,
+ INVALID_HANDLE, "Unknown DMC type", null)); //$NON-NLS-1$
+ rm.done();
+ }
+ }
+
+ public void suspend(IDMContext context, final RequestMonitor rm) {
+ if (context instanceof ExecutionDMC) {
+ final ExecutionDMC x = (ExecutionDMC)context;
+ x.ctx.suspend(new com.windriver.tcf.api.services.IRunControl.DoneCommand() {
+ public void doneCommand(IToken token, Exception error) {
+ if (error != null) {
+ rm.setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID,
+ REQUEST_FAILED, "Command error", error)); //$NON-NLS-1$
+ }
+ rm.done();
+ }
+ });
+ }
+ else {
+ rm.setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID,
+ INVALID_HANDLE, "Unknown DMC type", null)); //$NON-NLS-1$
+ rm.done();
+ }
+ }
+
+ public boolean isSuspended(IDMContext context) {
+ if (context instanceof ExecutionDMC) {
+ ExecutionDMC x = (ExecutionDMC)context;
+ return x.is_suspended && x.is_resuming == 0 && x.is_stepping == 0;
+ }
+ return false;
+ }
+
+ public void getExecutionData(IExecutionDMContext dmc, DataRequestMonitor<IExecutionDMData> rm) {
+ // TODO Auto-generated method stub
+ assert false;
+ }
+}
diff --git a/plugins/com.windriver.tcf.dsf.core/src/com/windriver/tcf/dsf/core/services/TCFDSFThreadDMC.java b/plugins/com.windriver.tcf.dsf.core/src/com/windriver/tcf/dsf/core/services/TCFDSFThreadDMC.java
new file mode 100644
index 000000000..ec91b6911
--- /dev/null
+++ b/plugins/com.windriver.tcf.dsf.core/src/com/windriver/tcf/dsf/core/services/TCFDSFThreadDMC.java
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Wind River Systems, Inc. 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 com.windriver.tcf.dsf.core.services;
+
+import org.eclipse.dd.dsf.datamodel.AbstractDMContext;
+import org.eclipse.dd.dsf.datamodel.IDMContext;
+import org.eclipse.dd.dsf.debug.service.INativeProcesses.IThreadDMContext;
+import org.eclipse.dd.dsf.service.IDsfService;
+
+public abstract class TCFDSFThreadDMC extends AbstractDMContext implements IThreadDMContext {
+
+ public TCFDSFThreadDMC(IDsfService service, IDMContext[] parents) {
+ super(service, parents);
+ }
+}

Back to the top