summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorTobias Schwarz2012-06-06 04:53:12 (EDT)
committer Uwe Stieber2012-06-06 04:53:12 (EDT)
commit638a04bb161f40d930818f7b31c5e80f3d7adc6a (patch)
tree714b26391ef944cb47a29f392a6bf0068368abad
parent218b1e8d4b1145d5015a5e482e9ee29665b9c4b6 (diff)
downloadorg.eclipse.tcf-638a04bb161f40d930818f7b31c5e80f3d7adc6a.zip
org.eclipse.tcf-638a04bb161f40d930818f7b31c5e80f3d7adc6a.tar.gz
org.eclipse.tcf-638a04bb161f40d930818f7b31c5e80f3d7adc6a.tar.bz2
Target Explorer: FIX launch channel management
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/plugin.properties1
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/plugin.xml2
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/steps/AttachDebuggerStep.java70
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/steps/FileTransferStep.java7
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/steps/LaunchProcessStep.java23
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/launcher/ProcessLauncher.java14
6 files changed, 64 insertions, 53 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/plugin.properties b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/plugin.properties
index f510657..fb594a3 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/plugin.properties
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/plugin.properties
@@ -25,4 +25,5 @@ LaunchStepGroup.FileTransfer.name=File Transfer
LaunchStep.OpenChannel.name=Open TCF Channel
LaunchStep.FileTransfer.name=Transfer File
LaunchStep.LaunchProcess.name=Launch Process
+LaunchStep.AttachDebugger.name=Attach Debugger
LaunchStep.CloseChannel.name=Close TCF Channel
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 08cde64..45870b1 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
@@ -118,13 +118,11 @@
id="org.eclipse.tcf.te.tcf.launch.core.launchProcessStep"
class="org.eclipse.tcf.te.tcf.launch.core.steps.LaunchProcessStep"
label="%LaunchStep.LaunchProcess.name">
- <requires id="org.eclipse.tcf.te.tcf.launch.core.openChannelStep"/>
</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"/>
</step>
<step
id="org.eclipse.tcf.te.tcf.launch.core.closeChannelStep"
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
index 8f869cb..d3b47fe 100644
--- 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
@@ -9,14 +9,12 @@
*******************************************************************************/
package org.eclipse.tcf.te.tcf.launch.core.steps;
-import org.eclipse.core.runtime.Assert;
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.protocol.IChannel;
import org.eclipse.tcf.protocol.IToken;
-import org.eclipse.tcf.protocol.Protocol;
import org.eclipse.tcf.services.IProcesses;
import org.eclipse.tcf.services.IRunControl;
import org.eclipse.tcf.services.IRunControl.RunControlContext;
@@ -30,9 +28,11 @@ 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.runtime.utils.ProgressHelper;
import org.eclipse.tcf.te.runtime.utils.StatusHelper;
+import org.eclipse.tcf.te.tcf.core.Tcf;
+import org.eclipse.tcf.te.tcf.core.interfaces.IChannelManager;
import org.eclipse.tcf.te.tcf.launch.core.activator.CoreBundleActivator;
-import org.eclipse.tcf.te.tcf.launch.core.interfaces.ICommonTCFLaunchAttributes;
import org.eclipse.tcf.te.tcf.launch.core.interfaces.IRemoteAppLaunchAttributes;
/**
@@ -60,49 +60,49 @@ public class AttachDebuggerStep 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, final IPropertiesContainer data, final IFullQualifiedId fullQualifiedId, IProgressMonitor monitor, final ICallback callback) {
+ public void execute(IStepContext context, final IPropertiesContainer data, final IFullQualifiedId fullQualifiedId, final IProgressMonitor monitor, final ICallback callback) {
IDebugService dbgService = ServiceManager.getInstance().getService(getActivePeerModel(data), IDebugService.class, false);
if (dbgService != null) {
Callback cb = new Callback();
dbgService.attach(getActivePeerModel(data), new PropertiesContainer(), cb);
ExecutorsUtil.waitAndExecute(0, cb.getDoneConditionTester(monitor));
- Runnable runnable = new Runnable() {
+ Tcf.getChannelManager().openChannel(getActivePeerModel(data).getPeer(), null, new IChannelManager.DoneOpenChannel() {
@Override
- public void run() {
- IProcesses.ProcessContext processContext = (IProcesses.ProcessContext)StepperAttributeUtil.getProperty(IRemoteAppLaunchAttributes.ATTR_PROCESS_CONTEXT, fullQualifiedId, data);
- IChannel channel = (IChannel)StepperAttributeUtil.getProperty(ICommonTCFLaunchAttributes.ATTR_CHANNEL, fullQualifiedId, data);
- Assert.isNotNull(channel);
- IRunControl runControl = channel.getRemoteService(IRunControl.class);
- if (runControl != null) {
- runControl.getContext(processContext.getID(), new IRunControl.DoneGetContext() {
- @Override
- public void doneGetContext(IToken token, Exception error, RunControlContext context) {
- if (error == null) {
- context.resume(IRunControl.RM_RESUME, 1, new IRunControl.DoneCommand() {
- @Override
- public void doneCommand(IToken token, Exception error) {
- callback.done(AttachDebuggerStep.this, StatusHelper.getStatus(error));
- }
- });
+ public void doneOpenChannel(final Throwable error, final IChannel channel) {
+ if (!ProgressHelper.isCancelOrError(AttachDebuggerStep.this, StatusHelper.getStatus(error), monitor, callback)) {
+ IProcesses.ProcessContext processContext = (IProcesses.ProcessContext)StepperAttributeUtil.getProperty(IRemoteAppLaunchAttributes.ATTR_PROCESS_CONTEXT, fullQualifiedId, data);
+ IRunControl runControl = channel.getRemoteService(IRunControl.class);
+ if (runControl != null) {
+ runControl.getContext(processContext.getID(), new IRunControl.DoneGetContext() {
+ @Override
+ public void doneGetContext(IToken token, Exception error, RunControlContext context) {
+ if (error == null) {
+ context.resume(IRunControl.RM_RESUME, 1, new IRunControl.DoneCommand() {
+ @Override
+ public void doneCommand(IToken token, Exception error) {
+ Tcf.getChannelManager().closeChannel(channel);
+ callback.done(AttachDebuggerStep.this, StatusHelper.getStatus(error));
+ }
+ });
+ }
+ else {
+ Tcf.getChannelManager().closeChannel(channel);
+ callback.done(AttachDebuggerStep.this, StatusHelper.getStatus(error));
+ }
}
- else {
- callback.done(AttachDebuggerStep.this, StatusHelper.getStatus(error));
- }
- }
- });
+ });
+ }
+ else {
+ Tcf.getChannelManager().closeChannel(channel);
+ callback.done(this, new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(), "missing run control service")); //$NON-NLS-1$
+ }
}
- else {
- callback.done(this, new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(), "missing run control service")); //$NON-NLS-1$
+ else if (channel != null) {
+ Tcf.getChannelManager().closeChannel(channel);
}
}
- };
- if (Protocol.isDispatchThread()) {
- runnable.run();
- }
- else {
- Protocol.invokeLater(runnable);
- }
+ });
}
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/FileTransferStep.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/steps/FileTransferStep.java
index a3aed42..7fd9ae2 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/steps/FileTransferStep.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/steps/FileTransferStep.java
@@ -55,7 +55,12 @@ public class FileTransferStep extends AbstractTcfLaunchStep {
IChannel channel = (IChannel)StepperAttributeUtil.getProperty(ICommonTCFLaunchAttributes.ATTR_CHANNEL, fullQualifiedId, data);
IFileTransferItem item = (IFileTransferItem)StepperAttributeUtil.getProperty(IFileTransferLaunchAttributes.ATTR_ACTIVE_FILE_TRANSFER, fullQualifiedId, data);
- FileTransferService.transfer(getActivePeerModel(data).getPeer(), channel, item, monitor, callback);
+ if (item.isEnabled()) {
+ FileTransferService.transfer(getActivePeerModel(data).getPeer(), channel, item, monitor, callback);
+ }
+ else if (callback != null) {
+ callback.done(this, Status.OK_STATUS);
+ }
}
/* (non-Javadoc)
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 a4791f4..fe75075 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
@@ -12,6 +12,7 @@ package org.eclipse.tcf.te.tcf.launch.core.steps;
import java.util.HashMap;
import java.util.Map;
+import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
@@ -59,6 +60,11 @@ public class LaunchProcessStep extends AbstractTcfLaunchStep {
throw new CoreException(new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(), "missing process image name")); //$NON-NLS-1$
}
+ IChannel channel = (IChannel)StepperAttributeUtil.getProperty(ICommonTCFLaunchAttributes.ATTR_CHANNEL, fullQualifiedId, data);
+ if (channel == null || channel.getState() != IChannel.STATE_OPEN) {
+ throw new CoreException(new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(), "missing or closed channel")); //$NON-NLS-1$
+ }
+
String processArguments = DefaultPersistenceDelegate.getAttribute(getLaunchConfiguration(context), IRemoteAppLaunchAttributes.ATTR_PROCESS_ARGUMENTS, (String)null);
StepperAttributeUtil.setProperty(IRemoteAppLaunchAttributes.ATTR_PROCESS_ARGUMENTS, fullQualifiedId, data, processArguments);
}
@@ -68,9 +74,10 @@ public class LaunchProcessStep extends AbstractTcfLaunchStep {
*/
@Override
public void execute(IStepContext context, final IPropertiesContainer data, final IFullQualifiedId fullQualifiedId, IProgressMonitor monitor, final ICallback callback) {
- IChannel channel = (IChannel)StepperAttributeUtil.getProperty(ICommonTCFLaunchAttributes.ATTR_CHANNEL, fullQualifiedId, data);
+ final IChannel channel = (IChannel)StepperAttributeUtil.getProperty(ICommonTCFLaunchAttributes.ATTR_CHANNEL, fullQualifiedId, data);
+ Assert.isTrue(channel != null && channel.getState() == IChannel.STATE_OPEN, "channel is missing or closed"); //$NON-NLS-1$
// Construct the launcher object
- ProcessLauncher launcher = new ProcessLauncher(channel);
+ ProcessLauncher launcher = new ProcessLauncher();
Map<String, Object> launchAttributes = new HashMap<String, Object>();
@@ -81,7 +88,16 @@ public class LaunchProcessStep extends AbstractTcfLaunchStep {
launchAttributes.put(IProcessLauncher.PROP_PROCESS_ARGS, args);
launchAttributes.put(ITerminalsConnectorConstants.PROP_LOCAL_ECHO, Boolean.FALSE);
- launchAttributes.put(IProcessLauncher.PROP_PROCESS_ASSOCIATE_CONSOLE, Boolean.TRUE);
+
+ boolean outputConsole = DefaultPersistenceDelegate.getAttribute(getLaunchConfiguration(context), "org.eclipse.debug.ui.ATTR_CONSOLE_OUTPUT_ON", true); //$NON-NLS-1$
+ if (outputConsole) {
+ launchAttributes.put(IProcessLauncher.PROP_PROCESS_ASSOCIATE_CONSOLE, Boolean.TRUE);
+ }
+ String outputFile = DefaultPersistenceDelegate.getAttribute(getLaunchConfiguration(context), "org.eclipse.debug.ui.ATTR_CAPTURE_IN_FILE", (String)null); //$NON-NLS-1$
+ if (outputFile != null) {
+ launchAttributes.put(IProcessLauncher.PROP_PROCESS_OUTPUT_REDIRECT_TO_FILE, outputFile);
+ }
+
if (ILaunchManager.DEBUG_MODE.equals(getLaunchMode(context))) {
launchAttributes.put(IProcessLauncher.PROP_PROCESS_ATTACH, Boolean.TRUE);
}
@@ -96,6 +112,7 @@ public class LaunchProcessStep extends AbstractTcfLaunchStep {
if (status.isOK() && result instanceof IProcesses.ProcessContext) {
StepperAttributeUtil.setProperty(IRemoteAppLaunchAttributes.ATTR_PROCESS_CONTEXT, fullQualifiedId.getParentId(), data, result);
}
+ Assert.isTrue(channel.getState() == IChannel.STATE_OPEN, "channel is closed"); //$NON-NLS-1$
super.internalDone(caller, status);
}
});
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/launcher/ProcessLauncher.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/launcher/ProcessLauncher.java
index a2469d0..ff904b9 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/launcher/ProcessLauncher.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/launcher/ProcessLauncher.java
@@ -74,7 +74,6 @@ import org.eclipse.tcf.te.tcf.processes.core.nls.Messages;
public class ProcessLauncher extends PlatformObject implements IProcessLauncher {
// The channel instance
/* default */ IChannel channel = null;
- /* default */ boolean externalChannel = false;
// The process properties instance
/* default */ IPropertiesContainer properties;
@@ -108,15 +107,6 @@ public class ProcessLauncher extends PlatformObject implements IProcessLauncher
/**
* Constructor.
*/
- public ProcessLauncher(IChannel channel) {
- super();
- externalChannel = channel != null;
- this.channel = channel;
- }
-
- /**
- * Constructor.
- */
public ProcessLauncher(IProcessStreamsProxy streamsProxy) {
super();
this.streamsProxy = streamsProxy;
@@ -145,7 +135,7 @@ public class ProcessLauncher extends PlatformObject implements IProcessLauncher
protected void internalDone(Object caller, IStatus status) {
Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$
// Close the channel as all disposal is done
- if (finChannel != null && externalChannel) {
+ if (finChannel != null) {
Tcf.getChannelManager().closeChannel(finChannel);
}
}
@@ -341,7 +331,7 @@ public class ProcessLauncher extends PlatformObject implements IProcessLauncher
// Open a dedicated channel to the given peer
Map<String, Boolean> flags = new HashMap<String, Boolean>();
flags.put(IChannelManager.FLAG_FORCE_NEW, Boolean.TRUE);
- if (channel != null && externalChannel) {
+ if (channel != null && channel.getState() == IChannel.STATE_OPEN) {
onChannelOpenDone(peer);
}
else {