Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/com.windriver.debug.tcf.core')
-rw-r--r--plugins/com.windriver.debug.tcf.core/.classpath7
-rw-r--r--plugins/com.windriver.debug.tcf.core/.cvsignore1
-rw-r--r--plugins/com.windriver.debug.tcf.core/.project28
-rw-r--r--plugins/com.windriver.debug.tcf.core/.settings/org.eclipse.jdt.core.prefs13
-rw-r--r--plugins/com.windriver.debug.tcf.core/.settings/org.eclipse.ltk.core.refactoring.prefs3
-rw-r--r--plugins/com.windriver.debug.tcf.core/META-INF/MANIFEST.MF15
-rwxr-xr-xplugins/com.windriver.debug.tcf.core/about.html28
-rw-r--r--plugins/com.windriver.debug.tcf.core/build.properties5
-rw-r--r--plugins/com.windriver.debug.tcf.core/plugin.properties13
-rw-r--r--plugins/com.windriver.debug.tcf.core/plugin.xml46
-rw-r--r--plugins/com.windriver.debug.tcf.core/schema/startup.exsd73
-rw-r--r--plugins/com.windriver.debug.tcf.core/src/com/windriver/debug/tcf/core/TCFCore.java102
-rw-r--r--plugins/com.windriver.debug.tcf.core/src/com/windriver/debug/tcf/core/launch/TCFLaunchDelegate.java60
-rw-r--r--plugins/com.windriver.debug.tcf.core/src/com/windriver/debug/tcf/core/launch/TCFSourceLookupDirector.java25
-rw-r--r--plugins/com.windriver.debug.tcf.core/src/com/windriver/debug/tcf/core/launch/TCFSourceLookupParticipant.java25
-rw-r--r--plugins/com.windriver.debug.tcf.core/src/com/windriver/debug/tcf/core/launch/TCFSourcePathComputerDelegate.java49
-rw-r--r--plugins/com.windriver.debug.tcf.core/src/com/windriver/debug/tcf/core/model/ITCFBreakpointListener.java16
-rw-r--r--plugins/com.windriver.debug.tcf.core/src/com/windriver/debug/tcf/core/model/ITCFConstants.java20
-rw-r--r--plugins/com.windriver.debug.tcf.core/src/com/windriver/debug/tcf/core/model/TCFBreakpoint.java108
-rw-r--r--plugins/com.windriver.debug.tcf.core/src/com/windriver/debug/tcf/core/model/TCFBreakpointsModel.java321
-rw-r--r--plugins/com.windriver.debug.tcf.core/src/com/windriver/debug/tcf/core/model/TCFBreakpointsStatus.java78
-rw-r--r--plugins/com.windriver.debug.tcf.core/src/com/windriver/debug/tcf/core/model/TCFError.java70
-rw-r--r--plugins/com.windriver.debug.tcf.core/src/com/windriver/debug/tcf/core/model/TCFLaunch.java328
23 files changed, 1434 insertions, 0 deletions
diff --git a/plugins/com.windriver.debug.tcf.core/.classpath b/plugins/com.windriver.debug.tcf.core/.classpath
new file mode 100644
index 000000000..751c8f2e5
--- /dev/null
+++ b/plugins/com.windriver.debug.tcf.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.debug.tcf.core/.cvsignore b/plugins/com.windriver.debug.tcf.core/.cvsignore
new file mode 100644
index 000000000..c5e82d745
--- /dev/null
+++ b/plugins/com.windriver.debug.tcf.core/.cvsignore
@@ -0,0 +1 @@
+bin \ No newline at end of file
diff --git a/plugins/com.windriver.debug.tcf.core/.project b/plugins/com.windriver.debug.tcf.core/.project
new file mode 100644
index 000000000..8a5b1f874
--- /dev/null
+++ b/plugins/com.windriver.debug.tcf.core/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>com.windriver.debug.tcf.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.debug.tcf.core/.settings/org.eclipse.jdt.core.prefs b/plugins/com.windriver.debug.tcf.core/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 000000000..f06d39b5d
--- /dev/null
+++ b/plugins/com.windriver.debug.tcf.core/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,13 @@
+#Mon Sep 10 12:24:12 PDT 2007
+eclipse.preferences.version=1
+org.eclipse.jdt.core.builder.cleanOutputFolder=clean
+org.eclipse.jdt.core.builder.duplicateResourceTask=warning
+org.eclipse.jdt.core.builder.invalidClasspath=abort
+org.eclipse.jdt.core.builder.recreateModifiedClassFileInOutputFolder=ignore
+org.eclipse.jdt.core.builder.resourceCopyExclusionFilter=*.launch,.svn/
+org.eclipse.jdt.core.circularClasspath=error
+org.eclipse.jdt.core.classpath.exclusionPatterns=enabled
+org.eclipse.jdt.core.classpath.multipleOutputLocations=enabled
+org.eclipse.jdt.core.compiler.maxProblemPerUnit=100
+org.eclipse.jdt.core.incompatibleJDKLevel=ignore
+org.eclipse.jdt.core.incompleteClasspath=error
diff --git a/plugins/com.windriver.debug.tcf.core/.settings/org.eclipse.ltk.core.refactoring.prefs b/plugins/com.windriver.debug.tcf.core/.settings/org.eclipse.ltk.core.refactoring.prefs
new file mode 100644
index 000000000..2bfce7b08
--- /dev/null
+++ b/plugins/com.windriver.debug.tcf.core/.settings/org.eclipse.ltk.core.refactoring.prefs
@@ -0,0 +1,3 @@
+#Wed Apr 18 17:24:58 PDT 2007
+eclipse.preferences.version=1
+org.eclipse.ltk.core.refactoring.enable.project.refactoring.history=false
diff --git a/plugins/com.windriver.debug.tcf.core/META-INF/MANIFEST.MF b/plugins/com.windriver.debug.tcf.core/META-INF/MANIFEST.MF
new file mode 100644
index 000000000..46a4bff9e
--- /dev/null
+++ b/plugins/com.windriver.debug.tcf.core/META-INF/MANIFEST.MF
@@ -0,0 +1,15 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %pluginName
+Bundle-SymbolicName: com.windriver.debug.tcf.core;singleton:=true
+Bundle-Version: 0.1.0
+Bundle-Activator: com.windriver.debug.tcf.core.TCFCore
+Bundle-Vendor: %providerName
+Require-Bundle: org.eclipse.core.runtime,
+ org.eclipse.debug.core,
+ org.eclipse.core.resources,
+ com.windriver.tcf.api
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Eclipse-LazyStart: true
+Export-Package: com.windriver.debug.tcf.core.model,
+ com.windriver.debug.tcf.core.launch
diff --git a/plugins/com.windriver.debug.tcf.core/about.html b/plugins/com.windriver.debug.tcf.core/about.html
new file mode 100755
index 000000000..6c5b3615b
--- /dev/null
+++ b/plugins/com.windriver.debug.tcf.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.debug.tcf.core/build.properties b/plugins/com.windriver.debug.tcf.core/build.properties
new file mode 100644
index 000000000..e9863e281
--- /dev/null
+++ b/plugins/com.windriver.debug.tcf.core/build.properties
@@ -0,0 +1,5 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml
diff --git a/plugins/com.windriver.debug.tcf.core/plugin.properties b/plugins/com.windriver.debug.tcf.core/plugin.properties
new file mode 100644
index 000000000..d573d34eb
--- /dev/null
+++ b/plugins/com.windriver.debug.tcf.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/Eclipse Debugger Integration Core
+providerName = Eclipse.org
+
diff --git a/plugins/com.windriver.debug.tcf.core/plugin.xml b/plugins/com.windriver.debug.tcf.core/plugin.xml
new file mode 100644
index 000000000..1a9590a32
--- /dev/null
+++ b/plugins/com.windriver.debug.tcf.core/plugin.xml
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.2"?>
+<plugin>
+ <extension-point id="startup" name="TCF Startup" schema="schema/startup.exsd"/>
+ <extension
+ point="org.eclipse.debug.core.breakpoints">
+ <breakpoint
+ markerType="com.windriver.debug.tcf.breakpoint.marker"
+ class="com.windriver.debug.tcf.core.model.TCFBreakpoint"
+ id="com.windriver.debug.tcf.breakpoint"
+ name="TCF Breakpoint">
+ </breakpoint>
+ </extension>
+ <extension
+ id="com.windriver.debug.tcf.breakpoint.marker"
+ point="org.eclipse.core.resources.markers">
+ <super type="org.eclipse.debug.core.breakpointMarker"/>
+ <persistent value="true"/>
+ </extension>
+ <extension
+ point="org.eclipse.debug.core.launchConfigurationTypes">
+ <launchConfigurationType
+ sourceLocatorId="com.windriver.debug.tcf.SourceLocator"
+ name="Target Communication Framework"
+ sourcePathComputerId="com.windriver.debug.tcf.SourcePathComputer"
+ delegate="com.windriver.debug.tcf.core.launch.TCFLaunchDelegate"
+ modes="run, debug"
+ id="com.windriver.debug.tcf.LaunchConfigurationType">
+ </launchConfigurationType>
+ </extension>
+ <extension
+ point="org.eclipse.debug.core.sourceLocators">
+ <sourceLocator
+ name="TCF Source Lookup Director"
+ class="com.windriver.debug.tcf.core.launch.TCFSourceLookupDirector"
+ id="com.windriver.debug.tcf.SourceLocator">
+ </sourceLocator>
+ </extension>
+ <extension
+ point="org.eclipse.debug.core.sourcePathComputers">
+ <sourcePathComputer
+ class="com.windriver.debug.tcf.core.launch.TCFSourcePathComputerDelegate"
+ id="com.windriver.debug.tcf.SourcePathComputer">
+ </sourcePathComputer>
+ </extension>
+</plugin>
diff --git a/plugins/com.windriver.debug.tcf.core/schema/startup.exsd b/plugins/com.windriver.debug.tcf.core/schema/startup.exsd
new file mode 100644
index 000000000..0d41bb8d9
--- /dev/null
+++ b/plugins/com.windriver.debug.tcf.core/schema/startup.exsd
@@ -0,0 +1,73 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="com.windriver.debug.tcf">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="com.windriver.debug.tcf.core" id="startup" name="TCF Startup"/>
+ </appInfo>
+ <documentation>
+ This extension point is used to register plugins
+ that want to be activated on TCF startup.
+ Once the TCF is started, registered plugins will be activated.
+ </documentation>
+
+</annotation>
+
+ <element name="extension">
+ <complexType>
+ <sequence>
+ <element ref="class" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+ a fully qualified identifier of the target extension point
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+ an optional identifier of the extension instance
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+ an optional name of the extension instance
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="class">
+ <complexType>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+ Class will be loaded during statup
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="apiInfo"/>
+ </appInfo>
+ <documentation>
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="implementation"/>
+ </appInfo>
+ <documentation>
+ </documentation>
+ </annotation>
+
+</schema>
diff --git a/plugins/com.windriver.debug.tcf.core/src/com/windriver/debug/tcf/core/TCFCore.java b/plugins/com.windriver.debug.tcf.core/src/com/windriver/debug/tcf/core/TCFCore.java
new file mode 100644
index 000000000..e4ffe006d
--- /dev/null
+++ b/plugins/com.windriver.debug.tcf.core/src/com/windriver/debug/tcf/core/TCFCore.java
@@ -0,0 +1,102 @@
+/*******************************************************************************
+ * 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.debug.tcf.core;
+
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Plugin;
+import org.eclipse.core.runtime.Status;
+import org.osgi.framework.BundleContext;
+
+import com.windriver.debug.tcf.core.model.TCFBreakpointsModel;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class TCFCore extends Plugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "com.windriver.debug.tcf.core";
+
+ // The shared instance
+ private static TCFCore plugin;
+ private static TCFBreakpointsModel bp_model;
+
+ public TCFCore() {
+ plugin = this;
+ }
+
+ @Override
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ bp_model = new TCFBreakpointsModel();
+ runTCFStartup();
+ }
+
+ @Override
+ public void stop(BundleContext context) throws Exception {
+ bp_model.dispose();
+ bp_model = null;
+ plugin = null;
+ super.stop(context);
+ }
+
+ private void runTCFStartup() {
+ try {
+ IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(PLUGIN_ID, "startup");
+ IExtension[] extensions = point.getExtensions();
+ for (int i = 0; i < extensions.length; i++) {
+ try {
+ Platform.getBundle(extensions[i].getNamespaceIdentifier()).start();
+ IConfigurationElement[] e = extensions[i].getConfigurationElements();
+ for (int j = 0; j < e.length; j++) {
+ String nm = e[j].getName();
+ if (nm.equals("class")) { //$NON-NLS-1$
+ Class.forName(e[j].getAttribute("name")); //$NON-NLS-1$
+ }
+ }
+ }
+ catch (Throwable x) {
+ log("TCF startup error", x);
+ }
+ }
+ }
+ catch (Exception x) {
+ log("TCF startup error", x);
+ }
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static TCFCore getDefault() {
+ return plugin;
+ }
+
+ public static TCFBreakpointsModel getBreakpointsModel() {
+ return bp_model;
+ }
+
+ /**
+ * Send error message into Eclipse log.
+ * @param msg - error message test
+ * @param err - exception
+ */
+ public static void log(String msg, Throwable err) {
+ getDefault().getLog().log(new Status(IStatus.ERROR,
+ getDefault().getBundle().getSymbolicName(), IStatus.OK, msg, err));
+ }
+}
diff --git a/plugins/com.windriver.debug.tcf.core/src/com/windriver/debug/tcf/core/launch/TCFLaunchDelegate.java b/plugins/com.windriver.debug.tcf.core/src/com/windriver/debug/tcf/core/launch/TCFLaunchDelegate.java
new file mode 100644
index 000000000..8a555cfc3
--- /dev/null
+++ b/plugins/com.windriver.debug.tcf.core/src/com/windriver/debug/tcf/core/launch/TCFLaunchDelegate.java
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * 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.debug.tcf.core.launch;
+
+import java.io.IOException;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.model.LaunchConfigurationDelegate;
+
+import com.windriver.debug.tcf.core.model.ITCFConstants;
+import com.windriver.debug.tcf.core.model.TCFLaunch;
+import com.windriver.tcf.api.protocol.IPeer;
+import com.windriver.tcf.api.protocol.Protocol;
+
+public class TCFLaunchDelegate extends LaunchConfigurationDelegate {
+
+ public static final String
+ ATTR_PEER_ID = ITCFConstants.ID_TCF_DEBUG_MODEL + ".PeerID",
+ ATTR_PROGRAM_FILE = ITCFConstants.ID_TCF_DEBUG_MODEL + ".ProgramFile",
+ ATTR_PROGRAM_ARGUMENTS = ITCFConstants.ID_TCF_DEBUG_MODEL + ".ProgramArguments",
+ ATTR_WORKING_DIRECTORY = ITCFConstants.ID_TCF_DEBUG_MODEL + ".WorkingDirectory";
+
+ public ILaunch getLaunch(ILaunchConfiguration configuration, String mode) throws CoreException {
+ return new TCFLaunch(configuration, mode);
+ }
+
+ public void launch(final ILaunchConfiguration configuration, final String mode,
+ final ILaunch launch, IProgressMonitor monitor) throws CoreException {
+ if (monitor == null) monitor = new NullProgressMonitor();
+ monitor.beginTask("Launching debugger session", 1); //$NON-NLS-1$
+ Protocol.invokeAndWait(new Runnable() {
+ public void run() {
+ try {
+ String id = configuration.getAttribute(TCFLaunchDelegate.ATTR_PEER_ID, "");
+ IPeer peer = Protocol.getLocator().getPeers().get(id);
+ if (peer == null) throw new IOException("Cannot locate peer " + id);
+ TCFLaunch.TerminateListener term = null;
+ if (peer instanceof TCFLaunch.TerminateListener) term = (TCFLaunch.TerminateListener)peer;
+ ((TCFLaunch)launch).launchTCF(mode, peer, term);
+ }
+ catch (Throwable e) {
+ ((TCFLaunch)launch).setError(e);
+ }
+ }
+ });
+ monitor.done();
+ }
+}
diff --git a/plugins/com.windriver.debug.tcf.core/src/com/windriver/debug/tcf/core/launch/TCFSourceLookupDirector.java b/plugins/com.windriver.debug.tcf.core/src/com/windriver/debug/tcf/core/launch/TCFSourceLookupDirector.java
new file mode 100644
index 000000000..57f07834f
--- /dev/null
+++ b/plugins/com.windriver.debug.tcf.core/src/com/windriver/debug/tcf/core/launch/TCFSourceLookupDirector.java
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * 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.debug.tcf.core.launch;
+
+import org.eclipse.debug.core.sourcelookup.AbstractSourceLookupDirector;
+import org.eclipse.debug.core.sourcelookup.ISourceLookupParticipant;
+
+/**
+ * TCF source lookup director. For TCF source lookup there is one source lookup
+ * participant.
+ */
+public class TCFSourceLookupDirector extends AbstractSourceLookupDirector {
+
+ public void initializeParticipants() {
+ addParticipants(new ISourceLookupParticipant[] { new TCFSourceLookupParticipant() });
+ }
+}
diff --git a/plugins/com.windriver.debug.tcf.core/src/com/windriver/debug/tcf/core/launch/TCFSourceLookupParticipant.java b/plugins/com.windriver.debug.tcf.core/src/com/windriver/debug/tcf/core/launch/TCFSourceLookupParticipant.java
new file mode 100644
index 000000000..765476df1
--- /dev/null
+++ b/plugins/com.windriver.debug.tcf.core/src/com/windriver/debug/tcf/core/launch/TCFSourceLookupParticipant.java
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * 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.debug.tcf.core.launch;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.sourcelookup.AbstractSourceLookupParticipant;
+
+/**
+ * The TCF source lookup participant knows how to translate a TCF stack frame
+ * into a source file name
+ */
+public class TCFSourceLookupParticipant extends AbstractSourceLookupParticipant {
+
+ public String getSourceName(Object object) throws CoreException {
+ return null;
+ }
+}
diff --git a/plugins/com.windriver.debug.tcf.core/src/com/windriver/debug/tcf/core/launch/TCFSourcePathComputerDelegate.java b/plugins/com.windriver.debug.tcf.core/src/com/windriver/debug/tcf/core/launch/TCFSourcePathComputerDelegate.java
new file mode 100644
index 000000000..f14abaae0
--- /dev/null
+++ b/plugins/com.windriver.debug.tcf.core/src/com/windriver/debug/tcf/core/launch/TCFSourcePathComputerDelegate.java
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * 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.debug.tcf.core.launch;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.sourcelookup.ISourceContainer;
+import org.eclipse.debug.core.sourcelookup.ISourcePathComputerDelegate;
+import org.eclipse.debug.core.sourcelookup.containers.WorkspaceSourceContainer;
+
+/**
+ * Computes the default source lookup path for a TCF launch configuration. The
+ * default source lookup path is the folder or project containing the TCF
+ * program being launched. If the program is not specified, the workspace is
+ * searched by default.
+ */
+public class TCFSourcePathComputerDelegate implements
+ ISourcePathComputerDelegate {
+
+ public ISourceContainer[] computeSourceContainers(
+ ILaunchConfiguration configuration, IProgressMonitor monitor)
+ throws CoreException {
+ ISourceContainer sourceContainer = null;
+ /*
+ * String path =
+ * configuration.getAttribute(IPDAConstants.ATTR_PDA_PROGRAM,
+ * (String)null); if (path != null) { IResource resource =
+ * ResourcesPlugin.getWorkspace().getRoot().findMember(new Path(path));
+ * if (resource != null) { IContainer container = resource.getParent();
+ * if (container.getType() == IResource.PROJECT) { sourceContainer = new
+ * ProjectSourceContainer((IProject)container, false); } else if
+ * (container.getType() == IResource.FOLDER) { sourceContainer = new
+ * FolderSourceContainer(container, false); } } }
+ */
+ if (sourceContainer == null) {
+ sourceContainer = new WorkspaceSourceContainer();
+ }
+ return new ISourceContainer[] { sourceContainer };
+ }
+}
diff --git a/plugins/com.windriver.debug.tcf.core/src/com/windriver/debug/tcf/core/model/ITCFBreakpointListener.java b/plugins/com.windriver.debug.tcf.core/src/com/windriver/debug/tcf/core/model/ITCFBreakpointListener.java
new file mode 100644
index 000000000..a78f8127f
--- /dev/null
+++ b/plugins/com.windriver.debug.tcf.core/src/com/windriver/debug/tcf/core/model/ITCFBreakpointListener.java
@@ -0,0 +1,16 @@
+/*******************************************************************************
+ * 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.debug.tcf.core.model;
+
+public interface ITCFBreakpointListener {
+
+ public void breakpointStatusChanged(String id);
+}
diff --git a/plugins/com.windriver.debug.tcf.core/src/com/windriver/debug/tcf/core/model/ITCFConstants.java b/plugins/com.windriver.debug.tcf.core/src/com/windriver/debug/tcf/core/model/ITCFConstants.java
new file mode 100644
index 000000000..66cba6273
--- /dev/null
+++ b/plugins/com.windriver.debug.tcf.core/src/com/windriver/debug/tcf/core/model/ITCFConstants.java
@@ -0,0 +1,20 @@
+/*******************************************************************************
+ * 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.debug.tcf.core.model;
+
+public interface ITCFConstants {
+
+ /**
+ * Unique identifier for the TCF debug model
+ */
+ public static final String ID_TCF_DEBUG_MODEL = "com.windriver.debug.tcf";
+
+}
diff --git a/plugins/com.windriver.debug.tcf.core/src/com/windriver/debug/tcf/core/model/TCFBreakpoint.java b/plugins/com.windriver.debug.tcf.core/src/com/windriver/debug/tcf/core/model/TCFBreakpoint.java
new file mode 100644
index 000000000..3b4e912ab
--- /dev/null
+++ b/plugins/com.windriver.debug.tcf.core/src/com/windriver/debug/tcf/core/model/TCFBreakpoint.java
@@ -0,0 +1,108 @@
+/*******************************************************************************
+ * 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.debug.tcf.core.model;
+
+import java.math.BigInteger;
+import java.util.Map;
+
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRunnable;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.ISchedulingRule;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.model.Breakpoint;
+
+import com.windriver.debug.tcf.core.TCFCore;
+import com.windriver.tcf.api.protocol.Protocol;
+import com.windriver.tcf.api.services.IBreakpoints;
+
+public class TCFBreakpoint extends Breakpoint {
+
+ public static final String MARKER_TYPE = "com.windriver.debug.tcf.breakpoint.marker";
+
+ private static long last_id = 0;
+
+ private static String createNewID() {
+ assert Protocol.isDispatchThread();
+ long id = System.currentTimeMillis();
+ if (id <= last_id) id = last_id + 1;
+ last_id = id;
+ return Long.toHexString(id);
+ }
+
+ private String text;
+
+ public TCFBreakpoint() {
+ }
+
+ public TCFBreakpoint(final IResource resource, Map<String,Object> props) throws DebugException {
+ props.put(IBreakpoints.PROP_ID, createNewID());
+ final Map<String,Object> m = TCFCore.getBreakpointsModel().toMarkerAttributes(props);
+ final IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
+ public void run(IProgressMonitor monitor) throws CoreException {
+ IMarker marker = resource.createMarker(MARKER_TYPE);
+ setMarker(marker);
+ marker.setAttributes(m);
+ DebugPlugin.getDefault().getBreakpointManager().addBreakpoint(TCFBreakpoint.this);
+ }
+ };
+ final ISchedulingRule rule = getMarkerRule(resource);
+ Job job = new Job("Add Breakpoint") { //$NON-NLS-1$
+ protected IStatus run(IProgressMonitor monitor) {
+ try {
+ TCFBreakpoint.this.run(getMarkerRule(resource), runnable);
+ }
+ catch (CoreException e) {
+ return e.getStatus();
+ }
+ return Status.OK_STATUS;
+ }
+ };
+ job.setRule(rule);
+ job.schedule();
+ }
+
+ public String getModelIdentifier() {
+ return ITCFConstants.ID_TCF_DEBUG_MODEL;
+ }
+
+ public String getText() {
+ if (text == null) {
+ IMarker marker = getMarker();
+ if (marker == null) return null;
+ StringBuffer bf = new StringBuffer();
+ String address = marker.getAttribute(
+ ITCFConstants.ID_TCF_DEBUG_MODEL + '.' + IBreakpoints.PROP_ADDRESS, null);
+ if (address != null && address.length() > 0) {
+ bf.append("PC = ");
+ BigInteger n = new BigInteger(address, 10);
+ String s = n.toString(16);
+ int l = Math.min(s.length(), 8);
+ bf.append("0x00000000".substring(0, 10 - l));
+ bf.append(s);
+ }
+ else {
+ String id = marker.getAttribute(
+ ITCFConstants.ID_TCF_DEBUG_MODEL + '.' + IBreakpoints.PROP_ID, null);
+ bf.append("BP");
+ bf.append(id);
+ }
+ text = bf.toString();
+ }
+ return text;
+ }
+}
diff --git a/plugins/com.windriver.debug.tcf.core/src/com/windriver/debug/tcf/core/model/TCFBreakpointsModel.java b/plugins/com.windriver.debug.tcf.core/src/com/windriver/debug/tcf/core/model/TCFBreakpointsModel.java
new file mode 100644
index 000000000..a1998a9e2
--- /dev/null
+++ b/plugins/com.windriver.debug.tcf.core/src/com/windriver/debug/tcf/core/model/TCFBreakpointsModel.java
@@ -0,0 +1,321 @@
+/*******************************************************************************
+ * 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.debug.tcf.core.model;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IMarkerDelta;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceDelta;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.IBreakpointListener;
+import org.eclipse.debug.core.IBreakpointManager;
+import org.eclipse.debug.core.IBreakpointManagerListener;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.model.IBreakpoint;
+
+import com.windriver.debug.tcf.core.TCFCore;
+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.IBreakpoints;
+
+public class TCFBreakpointsModel implements IBreakpointListener, IBreakpointManagerListener {
+
+ private static final String PROP_ID = "ID";
+ private final IBreakpointManager bp_manager = DebugPlugin.getDefault().getBreakpointManager();
+
+ private abstract class BreakpointUpdate implements Runnable {
+
+ private final ILaunch[] launches;
+ private final Map<String,Object> marker_attrs;
+ private final String marker_file;
+
+ IBreakpoints service;
+ IBreakpoints.DoneCommand done;
+ Map<String,Object> tcf_attrs;
+
+ @SuppressWarnings("unchecked")
+ BreakpointUpdate(IBreakpoint breakpoint) throws CoreException, IOException {
+ if (breakpoint == null) {
+ marker_attrs = null;
+ marker_file = null;
+ }
+ else {
+ marker_attrs = new HashMap<String,Object>(breakpoint.getMarker().getAttributes());
+ marker_file = getFilePath(breakpoint.getMarker().getResource());
+ }
+ launches = DebugPlugin.getDefault().getLaunchManager().getLaunches();
+ }
+
+ synchronized void exec() throws InterruptedException {
+ assert !Protocol.isDispatchThread();
+ Protocol.invokeLater(this);
+ wait();
+ }
+
+ public void run() {
+ if (marker_attrs != null) {
+ tcf_attrs = toBreakpointAttributes(marker_file, marker_attrs);
+ }
+ for (int i = 0; i < launches.length; i++) {
+ if (launches[i] instanceof TCFLaunch) {
+ TCFLaunch launch = (TCFLaunch)launches[i];
+ final IChannel channel = launch.getChannel();
+ if (channel == null) continue;
+ if (channel.getState() != IChannel.STATE_OPEN) continue;
+ service = channel.getRemoteService(IBreakpoints.class);
+ if (service == null) continue;
+ done = new IBreakpoints.DoneCommand() {
+ public void doneCommand(IToken token, Exception error) {
+ if (error != null) channel.terminate(error);
+ }
+ };
+ update();
+ }
+ }
+ Protocol.sync(new Runnable() {
+ public void run() {
+ synchronized (BreakpointUpdate.this) {
+ BreakpointUpdate.this.notify();
+ }
+ }
+ });
+ };
+
+ abstract void update();
+ }
+
+ public TCFBreakpointsModel() {
+ bp_manager.addBreakpointListener(this);
+ bp_manager.addBreakpointManagerListener(this);
+ }
+
+ public void dispose() {
+ bp_manager.removeBreakpointListener(this);
+ bp_manager.removeBreakpointManagerListener(this);
+ }
+
+ @SuppressWarnings("unchecked")
+ public void downloadBreakpoints(final IChannel channel, final Runnable done)
+ throws IOException, CoreException {
+ assert Protocol.isDispatchThread();
+ IBreakpoints service = channel.getRemoteService(IBreakpoints.class);
+ if (service != null) {
+ IBreakpoint[] arr = bp_manager.getBreakpoints(ITCFConstants.ID_TCF_DEBUG_MODEL);
+ if (arr != null && arr.length > 0) {
+ Map<String,Object>[] bps = new Map[arr.length];
+ for (int i = 0; i < arr.length; i++) {
+ IMarker marker = arr[i].getMarker();
+ String file = getFilePath(marker.getResource());
+ bps[i] = toBreakpointAttributes(file, marker.getAttributes());
+ }
+ service.set(bps, new IBreakpoints.DoneCommand() {
+ public void doneCommand(IToken token, Exception error) {
+ if (error == null) done.run();
+ else channel.terminate(error);
+ }
+ });
+ return;
+ }
+ }
+ Protocol.invokeLater(done);
+ }
+
+ public void breakpointManagerEnablementChanged(final boolean enabled) {
+ try {
+ IBreakpoint[] arr = bp_manager.getBreakpoints(ITCFConstants.ID_TCF_DEBUG_MODEL);
+ if (arr == null || arr.length == 0) return;
+ final Set<String> ids = new HashSet<String>();
+ for (int i = 0; i < arr.length; i++) {
+ IMarker marker = arr[i].getMarker();
+ Boolean b = marker.getAttribute(IBreakpoint.ENABLED, Boolean.FALSE);
+ if (!b.booleanValue()) continue;
+ ids.add(marker.getAttribute(
+ ITCFConstants.ID_TCF_DEBUG_MODEL + '.' + IBreakpoints.PROP_ID, (String)null));
+ }
+ if (ids.isEmpty()) return;
+ new BreakpointUpdate(null) {
+ @Override
+ void update() {
+ if (enabled) {
+ service.enable(ids.toArray(new String[ids.size()]), done);
+ }
+ else {
+ service.disable(ids.toArray(new String[ids.size()]), done);
+ }
+ }
+ }.exec();
+ }
+ catch (Throwable x) {
+ TCFCore.log("Unhandled exception in breakpoint listener", x);
+ }
+ }
+
+ private String getFilePath(IResource resource) throws IOException {
+ if (resource == ResourcesPlugin.getWorkspace().getRoot()) return null;
+ IPath p = resource.getRawLocation();
+ if (p == null) return null;
+ return p.toFile().getCanonicalPath();
+ }
+
+ public void breakpointAdded(IBreakpoint breakpoint) {
+ try {
+ if (!breakpoint.getModelIdentifier().equals(ITCFConstants.ID_TCF_DEBUG_MODEL)) return;
+ new BreakpointUpdate(breakpoint) {
+ @Override
+ void update() {
+ service.add(tcf_attrs, done);
+ }
+ }.exec();
+ }
+ catch (Throwable x) {
+ TCFCore.log("Unhandled exception in breakpoint listener", x);
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ private Set<String> calcMarkerDeltaKeys(IMarker marker, IMarkerDelta delta) throws CoreException {
+ assert delta.getKind() == IResourceDelta.CHANGED;
+ Map<String,Object> m0 = delta.getAttributes();
+ Map<String,Object> m1 = marker.getAttributes();
+ Set<String> keys = new HashSet<String>();
+ if (m0 != null) keys.addAll(m0.keySet());
+ if (m1 != null) keys.addAll(m1.keySet());
+ for (Iterator<String> i = keys.iterator(); i.hasNext();) {
+ String key = i.next();
+ Object v0 = m0 != null ? m0.get(key) : null;
+ Object v1 = m1 != null ? m1.get(key) : null;
+ if (v0 instanceof String && ((String)v0).length() == 0) v0 = null;
+ if (v1 instanceof String && ((String)v1).length() == 0) v1 = null;
+ if (v0 instanceof Boolean && !((Boolean)v0).booleanValue()) v0 = null;
+ if (v1 instanceof Boolean && !((Boolean)v1).booleanValue()) v1 = null;
+ if ((v0 == null) != (v1 == null)) continue;
+ if (v0 != null && !v0.equals(v1)) continue;
+ i.remove();
+ }
+ return keys;
+ }
+
+ public void breakpointChanged(IBreakpoint breakpoint, IMarkerDelta delta) {
+ try {
+ if (!breakpoint.getModelIdentifier().equals(ITCFConstants.ID_TCF_DEBUG_MODEL)) return;
+ final Set<String> s = calcMarkerDeltaKeys(breakpoint.getMarker(), delta);
+ if (s.isEmpty()) return;
+ new BreakpointUpdate(breakpoint) {
+ @Override
+ void update() {
+ if (s.size() == 1 && s.contains(IBreakpoint.ENABLED)) {
+ Boolean enabled = (Boolean)tcf_attrs.get(IBreakpoints.PROP_ENABLED);
+ if (enabled == null || !enabled.booleanValue()) {
+ service.disable(new String[]{ (String)tcf_attrs.get(PROP_ID) }, done);
+ }
+ else {
+ service.enable(new String[]{ (String)tcf_attrs.get(PROP_ID) }, done);
+ }
+ }
+ else {
+ service.change(tcf_attrs, done);
+ }
+ }
+ }.exec();
+ }
+ catch (Throwable x) {
+ TCFCore.log("Unhandled exception in breakpoint listener", x);
+ }
+ }
+
+ public void breakpointRemoved(IBreakpoint breakpoint, IMarkerDelta delta) {
+ try {
+ if (!breakpoint.getModelIdentifier().equals(ITCFConstants.ID_TCF_DEBUG_MODEL)) return;
+ new BreakpointUpdate(breakpoint) {
+ @Override
+ void update() {
+ service.remove(new String[]{ (String)tcf_attrs.get(PROP_ID) }, done);
+ }
+ }.exec();
+ }
+ catch (Throwable x) {
+ TCFCore.log("Unhandled exception in breakpoint listener", x);
+ }
+ }
+
+ public Map<String,Object> toMarkerAttributes(Map<String,Object> p) {
+ assert Protocol.isDispatchThread();
+ Map<String,Object> m = new HashMap<String,Object>();
+ for (Iterator<Map.Entry<String,Object>> i = p.entrySet().iterator(); i.hasNext();) {
+ Map.Entry<String,Object> e = i.next();
+ String key = e.getKey();
+ Object val = e.getValue();
+ if (key.equals(IBreakpoints.PROP_ENABLED)) continue;
+ if (key.equals(IBreakpoints.PROP_FILE)) continue;
+ if (key.equals(IBreakpoints.PROP_LINE)) continue;
+ if (key.equals(IBreakpoints.PROP_COLUMN)) continue;
+ m.put(ITCFConstants.ID_TCF_DEBUG_MODEL + '.' + key, val);
+ }
+ Boolean enabled = (Boolean)p.get(IBreakpoints.PROP_ENABLED);
+ if (enabled == null) m.put(IBreakpoint.ENABLED, Boolean.FALSE);
+ else m.put(IBreakpoint.ENABLED, enabled);
+ m.put(IBreakpoint.REGISTERED, Boolean.TRUE);
+ m.put(IBreakpoint.PERSISTED, Boolean.TRUE);
+ m.put(IBreakpoint.ID, ITCFConstants.ID_TCF_DEBUG_MODEL);
+ String msg = "";
+ if (p.get(IBreakpoints.PROP_ADDRESS) != null) msg += p.get(IBreakpoints.PROP_ADDRESS);
+ m.put(IMarker.MESSAGE, "Breakpoint: " + msg);
+ Number line = (Number)p.get(IBreakpoints.PROP_LINE);
+ if (line != null) {
+ m.put(IMarker.LINE_NUMBER, Integer.toString(line.intValue() + 1));
+ Number column = (Number)p.get(IBreakpoints.PROP_COLUMN);
+ if (column != null) {
+ m.put(IMarker.CHAR_START, column.toString());
+ m.put(IMarker.CHAR_END, Integer.toString(column.intValue() + 1));
+ }
+ }
+ return m;
+ }
+
+ public Map<String,Object> toBreakpointAttributes(String file, Map<String,Object> p) {
+ assert Protocol.isDispatchThread();
+ Map<String,Object> m = new HashMap<String,Object>();
+ for (Iterator<Map.Entry<String,Object>> i = p.entrySet().iterator(); i.hasNext();) {
+ Map.Entry<String,Object> e = i.next();
+ String key = e.getKey();
+ Object val = e.getValue();
+ if (!key.startsWith(ITCFConstants.ID_TCF_DEBUG_MODEL)) continue;
+ m.put(key.substring(ITCFConstants.ID_TCF_DEBUG_MODEL.length() + 1), val);
+ }
+ Boolean enabled = (Boolean)p.get(IBreakpoint.ENABLED);
+ if (enabled != null && enabled.booleanValue() && bp_manager.isEnabled()) {
+ m.put(IBreakpoints.PROP_ENABLED, enabled);
+ }
+ if (file != null) {
+ m.put(IBreakpoints.PROP_FILE, file);
+ String line = (String)p.get(IMarker.LINE_NUMBER);
+ if (line != null) {
+ m.put(IBreakpoints.PROP_LINE, new Integer(Integer.parseInt(line) - 1));
+ String column = (String)p.get(IMarker.CHAR_START);
+ if (column != null) {
+ m.put(IBreakpoints.PROP_COLUMN, new Integer(column));
+ }
+ }
+ }
+ return m;
+ }
+}
diff --git a/plugins/com.windriver.debug.tcf.core/src/com/windriver/debug/tcf/core/model/TCFBreakpointsStatus.java b/plugins/com.windriver.debug.tcf.core/src/com/windriver/debug/tcf/core/model/TCFBreakpointsStatus.java
new file mode 100644
index 000000000..a9a6cb735
--- /dev/null
+++ b/plugins/com.windriver.debug.tcf.core/src/com/windriver/debug/tcf/core/model/TCFBreakpointsStatus.java
@@ -0,0 +1,78 @@
+/*******************************************************************************
+ * 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.debug.tcf.core.model;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.debug.core.model.IBreakpoint;
+
+import com.windriver.tcf.api.protocol.Protocol;
+import com.windriver.tcf.api.services.IBreakpoints;
+
+public class TCFBreakpointsStatus {
+
+ private final IBreakpoints service;
+ private final Map<String,Map<String,Object>> status = new HashMap<String,Map<String,Object>>();
+ private final Set<ITCFBreakpointListener> listeners = new HashSet<ITCFBreakpointListener>();
+
+ private static final Map<String,Object> status_not_supported = new HashMap<String,Object>();
+
+ static {
+ status_not_supported.put(IBreakpoints.STATUS_ERROR, "Not supported");
+ }
+
+ TCFBreakpointsStatus(TCFLaunch launch) {
+ assert Protocol.isDispatchThread();
+ service = launch.getChannel().getRemoteService(IBreakpoints.class);
+ if (service != null) {
+ service.addListener(new IBreakpoints.BreakpointsListener() {
+
+ public void breakpointStatusChanged(String id, Map<String, Object> status) {
+ assert Protocol.isDispatchThread();
+ TCFBreakpointsStatus.this.status.put(id, status);
+ for (Iterator<ITCFBreakpointListener> i = listeners.iterator(); i.hasNext();) {
+ i.next().breakpointStatusChanged(id);
+ }
+ }
+ });
+ }
+ }
+
+ public Map<String, Object> getStatus(String id) {
+ assert id != null;
+ assert Protocol.isDispatchThread();
+ if (service == null) return status_not_supported;
+ return status.get(id);
+ }
+
+ public Map<String, Object> getStatus(IBreakpoint bp) {
+ if (!bp.getModelIdentifier().equals(ITCFConstants.ID_TCF_DEBUG_MODEL)) return status_not_supported;
+ IMarker marker = bp.getMarker();
+ if (marker == null) return null;
+ return getStatus(marker.getAttribute(
+ ITCFConstants.ID_TCF_DEBUG_MODEL + '.' + IBreakpoints.PROP_ID, null));
+ }
+
+ public void addListener(ITCFBreakpointListener listener) {
+ assert Protocol.isDispatchThread();
+ listeners.add(listener);
+ }
+
+ public void removeListener(ITCFBreakpointListener listener) {
+ assert Protocol.isDispatchThread();
+ listeners.remove(listener);
+ }
+}
diff --git a/plugins/com.windriver.debug.tcf.core/src/com/windriver/debug/tcf/core/model/TCFError.java b/plugins/com.windriver.debug.tcf.core/src/com/windriver/debug/tcf/core/model/TCFError.java
new file mode 100644
index 000000000..f754eb7c2
--- /dev/null
+++ b/plugins/com.windriver.debug.tcf.core/src/com/windriver/debug/tcf/core/model/TCFError.java
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * 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.debug.tcf.core.model;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.debug.core.DebugException;
+
+import com.windriver.debug.tcf.core.TCFCore;
+
+public class TCFError extends DebugException {
+
+ private static final long serialVersionUID = -4261097789666829020L;
+
+ public TCFError(Throwable exception) {
+ super(new Status(exception));
+ }
+
+ private static class Status implements IStatus {
+
+ private final Throwable exception;
+
+ private Status(Throwable exception) {
+ this.exception = exception;
+ }
+
+ public IStatus[] getChildren() {
+ return null;
+ }
+
+ public int getCode() {
+ return 1;
+ }
+
+ public Throwable getException() {
+ return exception;
+ }
+
+ public String getMessage() {
+ return exception.getMessage();
+ }
+
+ public String getPlugin() {
+ return TCFCore.PLUGIN_ID;
+ }
+
+ public int getSeverity() {
+ return ERROR;
+ }
+
+ public boolean isMultiStatus() {
+ return false;
+ }
+
+ public boolean isOK() {
+ return false;
+ }
+
+ public boolean matches(int severityMask) {
+ return false;
+ }
+ }
+}
diff --git a/plugins/com.windriver.debug.tcf.core/src/com/windriver/debug/tcf/core/model/TCFLaunch.java b/plugins/com.windriver.debug.tcf.core/src/com/windriver/debug/tcf/core/model/TCFLaunch.java
new file mode 100644
index 000000000..a7a07eda7
--- /dev/null
+++ b/plugins/com.windriver.debug.tcf.core/src/com/windriver/debug/tcf/core/model/TCFLaunch.java
@@ -0,0 +1,328 @@
+/*******************************************************************************
+ * 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.debug.tcf.core.model;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.debug.core.Launch;
+
+import com.windriver.debug.tcf.core.TCFCore;
+import com.windriver.debug.tcf.core.launch.TCFLaunchDelegate;
+import com.windriver.tcf.api.protocol.IChannel;
+import com.windriver.tcf.api.protocol.IPeer;
+import com.windriver.tcf.api.protocol.IService;
+import com.windriver.tcf.api.protocol.IToken;
+import com.windriver.tcf.api.protocol.Protocol;
+import com.windriver.tcf.api.services.IProcesses;
+import com.windriver.tcf.api.services.IProcesses.ProcessContext;
+
+public class TCFLaunch extends Launch {
+
+ public interface Listener {
+
+ public void onConnected(TCFLaunch launch);
+
+ public void onDisconnected(TCFLaunch launch);
+
+ }
+
+ public interface TerminateListener {
+
+ public boolean canTerminate();
+
+ public boolean isTerminated();
+
+ public void terminate(Runnable done);
+ }
+
+ private static final Collection<Listener> listeners = new ArrayList<Listener>();
+
+ private IChannel channel;
+ private Throwable error;
+ private TerminateListener terminate_listener;
+ private TCFBreakpointsStatus breakpoints_status;
+ private String mode;
+ private boolean connecting;
+ private ProcessContext process;
+
+ public TCFLaunch(ILaunchConfiguration launchConfiguration, String mode) {
+ super(launchConfiguration, mode, null);
+ }
+
+ private void onConnected() {
+ try {
+ final Runnable done = new Runnable() {
+ public void run() {
+ connecting = false;
+ for (Listener l : listeners) l.onConnected(TCFLaunch.this);
+ fireChanged();
+ }
+ };
+ if (mode.equals(ILaunchManager.DEBUG_MODE)) {
+ TCFCore.getBreakpointsModel().downloadBreakpoints(channel, new Runnable() {
+ public void run() {
+ if (channel.getState() != IChannel.STATE_OPEN) return;
+ breakpoints_status = new TCFBreakpointsStatus(TCFLaunch.this);
+ downloadApplication(done);
+ }
+ });
+ }
+ else {
+ downloadApplication(done);
+ }
+ }
+ catch (Exception x) {
+ channel.terminate(x);
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ protected void downloadApplication(final Runnable done) {
+ try {
+ ILaunchConfiguration cfg = getLaunchConfiguration();
+ final String file = cfg.getAttribute(TCFLaunchDelegate.ATTR_PROGRAM_FILE, "");
+ if (file.length() == 0) {
+ Protocol.invokeLater(done);
+ return;
+ }
+ final String dir = cfg.getAttribute(TCFLaunchDelegate.ATTR_WORKING_DIRECTORY, "");
+ final String args = cfg.getAttribute(TCFLaunchDelegate.ATTR_PROGRAM_ARGUMENTS, "");
+ final Map<String,String> env = cfg.getAttribute(ILaunchManager.ATTR_ENVIRONMENT_VARIABLES, (Map)null);
+ final boolean append = cfg.getAttribute(ILaunchManager.ATTR_APPEND_ENVIRONMENT_VARIABLES, true);
+ final boolean attach = mode.equals(ILaunchManager.DEBUG_MODE);
+ final IProcesses ps = channel.getRemoteService(IProcesses.class);
+ if (ps == null) throw new Exception("Target does not provide Processes service");
+ IProcesses.DoneGetEnvironment done_env = new IProcesses.DoneGetEnvironment() {
+ public void doneGetEnvironment(IToken token, Exception error, Map<String,String> def) {
+ if (error != null) {
+ channel.terminate(error);
+ return;
+ }
+ Map<String,String> vars = new HashMap<String,String>();
+ if (append) vars.putAll(def);
+ if (env != null) vars.putAll(env);
+ ps.start(dir, file, toArgsArray(args), vars, attach, new IProcesses.DoneStart() {
+ public void doneStart(IToken token, Exception error, ProcessContext process) {
+ if (error != null) {
+ channel.terminate(error);
+ return;
+ }
+ TCFLaunch.this.process = process;
+ Protocol.invokeLater(done);
+ }
+ });
+ }
+ };
+ if (append) ps.getEnvironment(done_env);
+ else done_env.doneGetEnvironment(null, null, null);
+ }
+ catch (Exception x) {
+ channel.terminate(x);
+ }
+ }
+
+ private String[] toArgsArray(String cmd) {
+ int i = 0;
+ int l = cmd.length();
+ List<String> arr = new ArrayList<String>();
+ for (;;) {
+ while (i < l && cmd.charAt(i) == ' ') i++;
+ if (i >= l) break;
+ String s = null;
+ if (cmd.charAt(i) == '"') {
+ i++;
+ StringBuffer bf = new StringBuffer();
+ while (i < l) {
+ char ch = cmd.charAt(i++);
+ if (ch == '"') break;
+ if (ch == '\\' && i < l) ch = cmd.charAt(i++);
+ bf.append(ch);
+ }
+ s = bf.toString();
+ }
+ else {
+ int i0 = i;
+ while (i < l && cmd.charAt(i) != ' ') i++;
+ s = cmd.substring(i0, i);
+ }
+ arr.add(s);
+ }
+ return arr.toArray(new String[arr.size()]);
+ }
+
+ private void onDisconnected(Throwable error) {
+ this.error = error;
+ breakpoints_status = null;
+ connecting = false;
+ for (Iterator<Listener> i = listeners.iterator(); i.hasNext();) {
+ i.next().onDisconnected(this);
+ }
+ if (DebugPlugin.getDefault() != null) fireTerminate();
+ }
+
+ /*--------------------------------------------------------------------------------------------*/
+
+ public Throwable getError() {
+ return error;
+ }
+
+ public void setError(Throwable x) {
+ if (error != null) return;
+ error = x;
+ if (channel != null && channel.getState() == IChannel.STATE_OPEN) {
+ channel.terminate(x);
+ }
+ fireChanged();
+ }
+
+ public TCFBreakpointsStatus getBreakpointsStatus() {
+ return breakpoints_status;
+ }
+
+ public static void addListener(Listener listener) {
+ assert Protocol.isDispatchThread();
+ listeners.add(listener);
+ }
+
+ public static void removeListener(Listener listener) {
+ assert Protocol.isDispatchThread();
+ listeners.remove(listener);
+ }
+
+ public IChannel getChannel() {
+ assert Protocol.isDispatchThread();
+ if (channel == null || channel.getState() != IChannel.STATE_OPEN) return null;
+ return channel;
+ }
+
+ public IProcesses.ProcessContext getProcessContext() {
+ return process;
+ }
+
+ public boolean isConnecting() {
+ return connecting;
+ }
+
+ public IPeer getPeer() {
+ assert Protocol.isDispatchThread();
+ return channel.getRemotePeer();
+ }
+
+ public <V extends IService> V getService(Class<V> cls) {
+ assert Protocol.isDispatchThread();
+ return channel.getRemoteService(cls);
+ }
+
+ public boolean canTerminate() {
+ final boolean res[] = new boolean[1];
+ Protocol.invokeAndWait(new Runnable() {
+ public void run() {
+ if (terminate_listener == null) res[0] = false;
+ else res[0] = terminate_listener.canTerminate();
+ }
+ });
+ return res[0];
+ }
+
+ public boolean isTerminated() {
+ final boolean res[] = new boolean[1];
+ Protocol.invokeAndWait(new Runnable() {
+ public void run() {
+ if (channel == null || channel.getState() == IChannel.STATE_CLOSED) res[0] = true;
+ else if (terminate_listener == null) res[0] = false;
+ else res[0] = terminate_listener.isTerminated();
+ }
+ });
+ return res[0];
+ }
+
+ public void terminate() {
+ Protocol.invokeAndWait(new Runnable() {
+ public void run() {
+ if (terminate_listener == null) return;
+ terminate_listener.terminate(new Runnable() {
+ public void run() {
+ fireTerminate();
+ }
+ });
+ }
+ });
+ }
+
+ public void terminate(Runnable done) {
+ if (terminate_listener == null) done.run();
+ else terminate_listener.terminate(done);
+ }
+
+ public boolean canDisconnect() {
+ final boolean res[] = new boolean[1];
+ Protocol.invokeAndWait(new Runnable() {
+ public void run() {
+ res[0] = channel != null && channel.getState() != IChannel.STATE_CLOSED;
+ }
+ });
+ return res[0];
+ }
+
+ public boolean isDisconnected() {
+ final boolean res[] = new boolean[1];
+ Protocol.invokeAndWait(new Runnable() {
+ public void run() {
+ res[0] = channel == null || channel.getState() == IChannel.STATE_CLOSED;
+ }
+ });
+ return res[0];
+ }
+
+ public void disconnect() throws DebugException {
+ Protocol.invokeAndWait(new Runnable() {
+ public void run() {
+ if (channel != null && channel.getState() != IChannel.STATE_CLOSED) {
+ channel.close();
+ }
+ fireTerminate();
+ }
+ });
+ }
+
+ public void launchTCF(String mode, IPeer peer, TerminateListener terminate_listener) throws DebugException {
+ assert Protocol.isDispatchThread();
+ this.mode = mode;
+ this.terminate_listener = terminate_listener;
+ connecting = true;
+ channel = peer.openChannel();
+ channel.addChannelListener(new IChannel.IChannelListener() {
+
+ public void onChannelOpened() {
+ onConnected();
+ }
+
+ public void congestionLevel(int level) {
+ }
+
+ public void onChannelClosed(Throwable error) {
+ channel.removeChannelListener(this);
+ onDisconnected(error);
+ }
+
+ });
+ assert channel.getState() == IChannel.STATE_OPENNING;
+ }
+}

Back to the top