Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core')
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/plugin.xml15
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/interfaces/IRemoteAppLaunchAttributes.java2
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/services/DebugService.java55
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/steps/AttachDebuggerStep.java61
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/steps/LaunchProcessStep.java19
5 files changed, 132 insertions, 20 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/plugin.xml b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/plugin.xml
index a1c88bf46..b7a3cbea8 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/plugin.xml
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/plugin.xml
@@ -86,15 +86,14 @@
<reference id="org.eclipse.tcf.te.tcf.launch.core.fileTransferStepGroup"/>
<reference id="org.eclipse.tcf.te.tcf.launch.core.launchProcessStep"/>
<reference id="org.eclipse.tcf.te.tcf.launch.core.closeChannelStep"/>
- <reference id="org.eclipse.tcf.te.launch.core.removeLaunchStep">
+ <reference id="org.eclipse.tcf.te.tcf.launch.core.attachDebuggerStep">
<enablement>
<with variable="context">
- <not>
- <test property="org.eclipse.tcf.te.launch.core.launchMode" value="debug"/>
- </not>
+ <test property="org.eclipse.tcf.te.launch.core.launchMode" value="debug"/>
</with>
</enablement>
</reference>
+ <reference id="org.eclipse.tcf.te.launch.core.removeLaunchStep"/>
</references>
</stepGroup>
<stepGroup
@@ -132,6 +131,14 @@
</requires>
</step>
<step
+ id="org.eclipse.tcf.te.tcf.launch.core.attachDebuggerStep"
+ class="org.eclipse.tcf.te.tcf.launch.core.steps.AttachDebuggerStep"
+ label="%LaunchStep.AttachDebugger.name">
+ <requires
+ id="org.eclipse.tcf.te.tcf.launch.core.openChannelStep">
+ </requires>
+ </step>
+ <step
id="org.eclipse.tcf.te.tcf.launch.core.closeChannelStep"
class="org.eclipse.tcf.te.tcf.launch.core.steps.CloseChannelStep"
label="%LaunchStep.CloseChannel.name">
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/interfaces/IRemoteAppLaunchAttributes.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/interfaces/IRemoteAppLaunchAttributes.java
index 7dcdd501e..d3604448c 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/interfaces/IRemoteAppLaunchAttributes.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/interfaces/IRemoteAppLaunchAttributes.java
@@ -30,4 +30,6 @@ public interface IRemoteAppLaunchAttributes {
* Launch configuration attribute: The process arguments.
*/
public static final String ATTR_PROCESS_ARGUMENTS = ICommonLaunchAttributes.ATTR_PREFIX + ".process_arguments"; //$NON-NLS-1$
+
+ public static final String ATTR_PROCESS_CONTEXT = ICommonLaunchAttributes.ATTR_PREFIX + ".process_context"; //$NON-NLS-1$
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/services/DebugService.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/services/DebugService.java
index cec53b9e2..c011709d7 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/services/DebugService.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/services/DebugService.java
@@ -107,10 +107,14 @@ public class DebugService extends AbstractService implements IDebugService {
break;
}
}
- if (lc != null) break;
+ if (lc != null) {
+ break;
+ }
}
// If there is none with an active launch, take the first one
- if (lc == null) lc = configs[0];
+ if (lc == null) {
+ lc = configs[0];
+ }
} else {
// No existing launch configuration -> create a new one
lc = createNewConfig(peer);
@@ -120,7 +124,7 @@ public class DebugService extends AbstractService implements IDebugService {
try {
// Attach the launch listener to wait firing the callback until
// the TCFLaunch got connect
- TCFLaunch.addListener(new TCFLaunch.LaunchListener() {
+ final TCFLaunch.LaunchListener listener = new TCFLaunch.LaunchListener() {
@Override
public void onProcessStreamError(TCFLaunch launch, String process_id, int stream_id, Exception error, int lost_size) {}
@Override
@@ -139,7 +143,18 @@ public class DebugService extends AbstractService implements IDebugService {
callback.done(DebugService.this, Status.OK_STATUS);
}
}
- });
+ };
+ if (Protocol.isDispatchThread()) {
+ TCFLaunch.addListener(listener);
+ }
+ else {
+ Protocol.invokeAndWait(new Runnable() {
+ @Override
+ public void run() {
+ TCFLaunch.addListener(listener);
+ }
+ });
+ }
// Execute the launch configuration
l = lc.launch(ILaunchManager.DEBUG_MODE, new NullProgressMonitor(), false, true);
@@ -178,8 +193,12 @@ public class DebugService extends AbstractService implements IDebugService {
peerId.set(peer.getID());
}
};
- if (Protocol.isDispatchThread()) runnable.run();
- else Protocol.invokeAndWait(runnable);
+ if (Protocol.isDispatchThread()) {
+ runnable.run();
+ }
+ else {
+ Protocol.invokeAndWait(runnable);
+ }
// Get the launch manager
ILaunchManager lm = DebugPlugin.getDefault().getLaunchManager();
@@ -198,7 +217,9 @@ public class DebugService extends AbstractService implements IDebugService {
// Save the working copy
lc = wc.doSave();
} catch (CoreException e) {
- if (Platform.inDebugMode()) e.printStackTrace();
+ if (Platform.inDebugMode()) {
+ e.printStackTrace();
+ }
}
}
@@ -226,8 +247,12 @@ public class DebugService extends AbstractService implements IDebugService {
peerId.set(peer.getID());
}
};
- if (Protocol.isDispatchThread()) runnable.run();
- else Protocol.invokeAndWait(runnable);
+ if (Protocol.isDispatchThread()) {
+ runnable.run();
+ }
+ else {
+ Protocol.invokeAndWait(runnable);
+ }
// Get the launch manager
ILaunchManager lm = DebugPlugin.getDefault().getLaunchManager();
@@ -239,13 +264,15 @@ public class DebugService extends AbstractService implements IDebugService {
ILaunchConfiguration[] candidates = lm.getLaunchConfigurations(lct);
for (ILaunchConfiguration candidate : candidates) {
// If the peer id is matching, it is a valid candidate
- String lcPeerId = candidate.getAttribute(TCFLaunchDelegate.ATTR_PEER_ID, (String)null);
- if (lcPeerId != null && lcPeerId.equals(peerId.get())) {
- configs.add(candidate);
- }
+ String lcPeerId = candidate.getAttribute(TCFLaunchDelegate.ATTR_PEER_ID, (String)null);
+ if (lcPeerId != null && lcPeerId.equals(peerId.get())) {
+ configs.add(candidate);
+ }
}
} catch (CoreException e) {
- if (Platform.inDebugMode()) e.printStackTrace();
+ if (Platform.inDebugMode()) {
+ e.printStackTrace();
+ }
}
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/steps/AttachDebuggerStep.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/steps/AttachDebuggerStep.java
new file mode 100644
index 000000000..673cac066
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/steps/AttachDebuggerStep.java
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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 org.eclipse.tcf.te.tcf.launch.core.steps;
+
+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.tcf.te.runtime.interfaces.callback.ICallback;
+import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
+import org.eclipse.tcf.te.runtime.properties.PropertiesContainer;
+import org.eclipse.tcf.te.runtime.services.ServiceManager;
+import org.eclipse.tcf.te.runtime.services.interfaces.IDebugService;
+import org.eclipse.tcf.te.runtime.stepper.StepperAttributeUtil;
+import org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId;
+import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext;
+import org.eclipse.tcf.te.tcf.launch.core.activator.CoreBundleActivator;
+import org.eclipse.tcf.te.tcf.launch.core.interfaces.IRemoteAppLaunchAttributes;
+
+/**
+ * Launch process step implementation.
+ */
+public class AttachDebuggerStep extends AbstractTcfLaunchStep {
+
+ /**
+ * Constructor.
+ */
+ public AttachDebuggerStep() {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IExtendedStep#validateExecute(org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public void validateExecute(IStepContext context, IPropertiesContainer data, IFullQualifiedId fullQualifiedId, IProgressMonitor monitor) throws CoreException {
+ if (StepperAttributeUtil.getProperty(IRemoteAppLaunchAttributes.ATTR_PROCESS_CONTEXT, fullQualifiedId, data) == null) {
+ throw new CoreException(new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(), "missing process context")); //$NON-NLS-1$
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStep#execute(org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId, org.eclipse.core.runtime.IProgressMonitor, org.eclipse.tcf.te.runtime.interfaces.callback.ICallback)
+ */
+ @Override
+ public void execute(IStepContext context, final IPropertiesContainer data, final IFullQualifiedId fullQualifiedId, IProgressMonitor monitor, final ICallback callback) {
+ IDebugService dbgService = ServiceManager.getInstance().getService(getActivePeerModel(data), IDebugService.class, false);
+ if (dbgService != null) {
+ dbgService.attach(getActivePeerModel(data), new PropertiesContainer(), callback);
+ }
+ else {
+ callback.done(this, new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(), "missing debugger service")); //$NON-NLS-1$
+ }
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/steps/LaunchProcessStep.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/steps/LaunchProcessStep.java
index 638fd6712..177430c9f 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/steps/LaunchProcessStep.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/steps/LaunchProcessStep.java
@@ -16,8 +16,11 @@ 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.debug.core.ILaunchManager;
+import org.eclipse.tcf.services.IProcesses;
import org.eclipse.tcf.te.core.utils.text.StringUtil;
import org.eclipse.tcf.te.launch.core.persistence.DefaultPersistenceDelegate;
+import org.eclipse.tcf.te.runtime.callback.Callback;
import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback;
import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
import org.eclipse.tcf.te.runtime.properties.PropertiesContainer;
@@ -62,7 +65,7 @@ public class LaunchProcessStep extends AbstractTcfLaunchStep {
* @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStep#execute(org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId, org.eclipse.core.runtime.IProgressMonitor, org.eclipse.tcf.te.runtime.interfaces.callback.ICallback)
*/
@Override
- public void execute(IStepContext context, IPropertiesContainer data, IFullQualifiedId fullQualifiedId, IProgressMonitor monitor, final ICallback callback) {
+ public void execute(IStepContext context, final IPropertiesContainer data, final IFullQualifiedId fullQualifiedId, IProgressMonitor monitor, final ICallback callback) {
// Construct the launcher object
ProcessLauncher launcher = new ProcessLauncher();
@@ -76,10 +79,22 @@ public class LaunchProcessStep extends AbstractTcfLaunchStep {
launchAttributes.put(ITerminalsConnectorConstants.PROP_LOCAL_ECHO, Boolean.FALSE);
launchAttributes.put(IProcessLauncher.PROP_PROCESS_ASSOCIATE_CONSOLE, Boolean.TRUE);
+ if (ILaunchManager.DEBUG_MODE.equals(getLaunchMode(context))) {
+ launchAttributes.put(IProcessLauncher.PROP_PROCESS_ATTACH, Boolean.TRUE);
+ }
// Launch the process
IPropertiesContainer container = new PropertiesContainer();
container.setProperties(launchAttributes);
- launcher.launch(getActivePeerModel(data).getPeer(), container, callback);
+ launcher.launch(getActivePeerModel(data).getPeer(), container, new Callback(callback) {
+ @Override
+ protected void internalDone(Object caller, IStatus status) {
+ Object result = getResult();
+ if (status.isOK() && result instanceof IProcesses.ProcessContext) {
+ StepperAttributeUtil.setProperty(IRemoteAppLaunchAttributes.ATTR_PROCESS_CONTEXT, fullQualifiedId.getParentId(), data, result);
+ }
+ super.internalDone(caller, status);
+ }
+ });
}
}

Back to the top