summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorTobias Schwarz2012-05-08 08:17:34 (EDT)
committer Uwe Stieber2012-05-08 08:17:34 (EDT)
commit462dc7afcea7e5844762e15908fc52b59fd1c748 (patch)
tree4b745a9eb0fbc44804e9e3db954bf26274059b53
parent1069257d6c67377d53336eb1a62ff99874c529cc (diff)
downloadorg.eclipse.tcf-462dc7afcea7e5844762e15908fc52b59fd1c748.zip
org.eclipse.tcf-462dc7afcea7e5844762e15908fc52b59fd1c748.tar.gz
org.eclipse.tcf-462dc7afcea7e5844762e15908fc52b59fd1c748.tar.bz2
Target Explorer: ADD attach debugger on remote application debug
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/steps/AbstractLaunchStep.java11
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.ui/plugin.xml4
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/LaunchNodePropertyTester.java8
-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
8 files changed, 150 insertions, 25 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/steps/AbstractLaunchStep.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/steps/AbstractLaunchStep.java
index 6d4daf0..18c1c5d 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/steps/AbstractLaunchStep.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/steps/AbstractLaunchStep.java
@@ -35,6 +35,17 @@ public abstract class AbstractLaunchStep extends AbstractStep {
}
/**
+ * Returns the current launch mode.
+ *
+ * @param context The step context.
+ * @return The launch mode or <code>null</code>.
+ */
+ protected String getLaunchMode(IStepContext context) {
+ ILaunch launch = getLaunch(context);
+ return launch != null ? launch.getLaunchMode() : null;
+ }
+
+ /**
* Returns the active launch context model node that is currently used.
*
* @param data The data giving object. Must not be <code>null</code>.
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/plugin.xml b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/plugin.xml
index 2d249bd..38a3aed 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/plugin.xml
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/plugin.xml
@@ -586,7 +586,7 @@
ifEmpty="false">
<and>
<test property="org.eclipse.tcf.te.launch.ui.model.hasLaunchMode" value="run"/>
- <test property="org.eclipse.tcf.te.launch.ui.model.isLaunchConfig"/>
+ <test property="org.eclipse.tcf.te.launch.ui.model.isValidLaunchConfig" value="run"/>
</and>
</iterate>
</with>
@@ -610,7 +610,7 @@
ifEmpty="false">
<and>
<test property="org.eclipse.tcf.te.launch.ui.model.hasLaunchMode" value="debug"/>
- <test property="org.eclipse.tcf.te.launch.ui.model.isLaunchConfig"/>
+ <test property="org.eclipse.tcf.te.launch.ui.model.isValidLaunchConfig" value="debug"/>
</and>
</iterate>
</with>
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/LaunchNodePropertyTester.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/LaunchNodePropertyTester.java
index 079f75b..cca15c2 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/LaunchNodePropertyTester.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/LaunchNodePropertyTester.java
@@ -31,8 +31,7 @@ public class LaunchNodePropertyTester extends PropertyTester {
LaunchNode node = (LaunchNode)receiver;
if (property.equals("isLaunchConfigType")) { //$NON-NLS-1$
if (LaunchNode.TYPE_LAUNCH_CONFIG_TYPE.equals(node.getType())) {
- boolean isValue = expectedValue == null || expectedValue.equals(node.getLaunchConfigurationType().getIdentifier());
- return isValue;
+ return expectedValue == null || expectedValue.equals(node.getLaunchConfigurationType().getIdentifier());
}
}
else if (property.equals("isLaunchConfig")) { //$NON-NLS-1$
@@ -50,7 +49,10 @@ public class LaunchNodePropertyTester extends PropertyTester {
}
}
else if (property.equals("isValidLaunchConfig")) { //$NON-NLS-1$
- return true;
+ if (expectedValue instanceof String) {
+ return node.isValidFor((String)expectedValue);
+ }
+ return node.isValidFor(null);
}
}
return false;
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 a1c88bf..b7a3cbe 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 7dcdd50..d360444 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 cec53b9..c011709 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 0000000..673cac0
--- /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 638fd67..177430c 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);
+ }
+ });
}
}