diff options
author | Anton Leherbauer | 2015-07-02 09:24:46 +0000 |
---|---|---|
committer | Anton Leherbauer | 2015-07-02 09:24:57 +0000 |
commit | 99b3f8d4a90ebe6a7b20d9416b278283715d7168 (patch) | |
tree | 9a322e32b3604ff6f8e5ea7caf20780c73f7aecc | |
parent | 0501f07f0ba12d7603f6de4882763382fcaf15f6 (diff) | |
download | org.eclipse.tcf-99b3f8d4a90ebe6a7b20d9416b278283715d7168.tar.gz org.eclipse.tcf-99b3f8d4a90ebe6a7b20d9416b278283715d7168.tar.xz org.eclipse.tcf-99b3f8d4a90ebe6a7b20d9416b278283715d7168.zip |
Target Explorer: gdbserver: Add support for custom environment
4 files changed, 104 insertions, 29 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/plugin.xml b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/plugin.xml index 5bb5c8633..97eb54bfe 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/plugin.xml +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/plugin.xml @@ -1,14 +1,14 @@ <?xml version="1.0" encoding="UTF-8"?> <!-- Copyright (c) 2006, 2015 PalmSource, 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 +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: -Ewa Matejska (PalmSource) - initial API and implementation -Martin Oberhuber (Wind River) - fix 158529: Migrate docs to HTML / TOC format +Contributors: +Ewa Matejska (PalmSource) - initial API and implementation +Martin Oberhuber (Wind River) - fix 158529: Migrate docs to HTML / TOC format Anna Dushistova (Mentor Graphics) - [314659] added launch delegate for dsf Anna Dushistova (Mentor Graphics) - code restructuring Anna Dushistova (MontaVista) - adapted from org.eclipse.cdt.launch.remote @@ -25,7 +25,7 @@ Anna Dushistova (MontaVista) - adapted from org.eclipse.cdt.launch.remote delegateDescription="%tedsfLaunchDelegate.description" sourceLocatorId="org.eclipse.cdt.debug.core.sourceLocator" sourcePathComputerId="org.eclipse.cdt.debug.core.sourcePathComputer"> - </launchDelegate> + </launchDelegate> <launchDelegate id="org.eclipse.tcf.te.remotecdt.run" type="org.eclipse.cdt.launch.remoteApplicationLaunchType" @@ -43,10 +43,10 @@ Anna Dushistova (MontaVista) - adapted from org.eclipse.cdt.launch.remote delegateDescription="%teattachLaunchDelegate.description" sourceLocatorId="org.eclipse.cdt.debug.core.sourceLocator" sourcePathComputerId="org.eclipse.cdt.debug.core.sourcePathComputer"> - </launchDelegate> - + </launchDelegate> + </extension> - + <extension point="org.eclipse.debug.ui.launchConfigurationTabs"> <!-- Remote Application (Run) --> <tab @@ -55,8 +55,8 @@ Anna Dushistova (MontaVista) - adapted from org.eclipse.cdt.launch.remote name="Main" class="org.eclipse.tcf.te.tcf.launch.cdt.tabs.TEApplicationMainTab"> <associatedDelegate delegate="org.eclipse.tcf.te.remotecdt.run"/> - </tab> - <tab + </tab> + <tab id="org.eclipse.tcf.te.remotecdt.run.argumentsTab" group="org.eclipse.cdt.launch.remoteApplicationRunLaunchTabGroup" name="Arguments" @@ -81,7 +81,7 @@ Anna Dushistova (MontaVista) - adapted from org.eclipse.cdt.launch.remote class="org.eclipse.tcf.te.tcf.launch.cdt.tabs.TEApplicationMainTab"> <associatedDelegate delegate="org.eclipse.tcf.te.remotecdt.debug"/> </tab> - <tab + <tab id="org.eclipse.tcf.te.remotecdt.debug.argumentsTab" group="org.eclipse.cdt.launch.remoteApplicationLaunchTabGroup" name="Arguments" @@ -103,16 +103,24 @@ Anna Dushistova (MontaVista) - adapted from org.eclipse.cdt.launch.remote name="Source" class="org.eclipse.debug.ui.sourcelookup.SourceLookupTab"> <associatedDelegate delegate="org.eclipse.tcf.te.remotecdt.debug"/> - <placement after="org.eclipse.tcf.te.remotecdt.debug.debuggerTab"/> - </tab> + <placement after="org.eclipse.tcf.te.remotecdt.debug.debuggerTab"/> + </tab> <tab id="org.eclipse.tcf.te.remotecdt.debug.commonTab" group="org.eclipse.cdt.launch.remoteApplicationLaunchTabGroup" name="Common" class="org.eclipse.debug.ui.CommonTab"> <associatedDelegate delegate="org.eclipse.tcf.te.remotecdt.debug"/> - <placement after="org.eclipse.debug.ui.sourceLookupTab"/> - </tab> + <placement after="org.eclipse.debug.ui.sourceLookupTab"/> + </tab> + <tab + id="org.eclipse.tcf.te.remotecdt.debug.environmentTab" + group="org.eclipse.cdt.launch.remoteApplicationLaunchTabGroup" + name="Environment" + class="org.eclipse.tcf.te.tcf.launch.cdt.tabs.TEEnvironmentTab"> + <associatedDelegate delegate="org.eclipse.tcf.te.remotecdt.debug"/> + <placement after="org.eclipse.debug.ui.sourceLookupTab"/> + </tab> <!-- Attach Launch --> <tab diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/src/org/eclipse/tcf/te/tcf/launch/cdt/launching/TEGdbAbstractLaunchDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/src/org/eclipse/tcf/te/tcf/launch/cdt/launching/TEGdbAbstractLaunchDelegate.java index 9392b7000..8e1a89fbe 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/src/org/eclipse/tcf/te/tcf/launch/cdt/launching/TEGdbAbstractLaunchDelegate.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/src/org/eclipse/tcf/te/tcf/launch/cdt/launching/TEGdbAbstractLaunchDelegate.java @@ -12,6 +12,7 @@ package org.eclipse.tcf.te.tcf.launch.cdt.launching; import java.io.File; import java.io.IOException; import java.util.List; +import java.util.Map; import java.util.concurrent.ExecutionException; import java.util.concurrent.RejectedExecutionException; import java.util.concurrent.TimeUnit; @@ -45,9 +46,11 @@ import org.eclipse.debug.core.DebugException; import org.eclipse.debug.core.ILaunch; import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; +import org.eclipse.debug.core.ILaunchManager; import org.eclipse.debug.core.model.ISourceLocator; import org.eclipse.osgi.util.NLS; import org.eclipse.tcf.protocol.IPeer; +import org.eclipse.tcf.te.core.utils.text.StringUtil; import org.eclipse.tcf.te.runtime.callback.Callback; import org.eclipse.tcf.te.runtime.services.ServiceUtils; import org.eclipse.tcf.te.tcf.core.streams.StreamsDataReceiver; @@ -140,6 +143,12 @@ public abstract class TEGdbAbstractLaunchDelegate extends GdbLaunchDelegate { } } + // Perform prelaunch command + if (!isAttachLaunch) { + String prelaunchCmd = config.getAttribute(IRemoteTEConfigurationConstants.ATTR_PRERUN_COMMANDS, ""); //$NON-NLS-1$ + TEHelper.launchCmd(peer, null, prelaunchCmd, null, new SubProgressMonitor(monitor, 2), new Callback()); + } + // Launch gdbserver on target final AtomicReference<String> gdbserverPortNumber = new AtomicReference<String>(config.getAttribute(IRemoteTEConfigurationConstants.ATTR_GDBSERVER_PORT, TEHelper.getStringPreferenceValue(isAttachLaunch ? IPreferenceKeys.PREF_GDBSERVER_PORT_ATTACH : IPreferenceKeys.PREF_GDBSERVER_PORT))); final AtomicReference<String> gdbserverPortNumberMappedTo = new AtomicReference<String>(config.getAttribute(IRemoteTEConfigurationConstants.ATTR_GDBSERVER_PORT_MAPPED_TO, TEHelper.getStringPreferenceValue(isAttachLaunch ? IPreferenceKeys.PREF_GDBSERVER_PORT_ATTACH_MAPPED_TO : IPreferenceKeys.PREF_GDBSERVER_PORT_MAPPED_TO))); @@ -168,6 +177,7 @@ public abstract class TEGdbAbstractLaunchDelegate extends GdbLaunchDelegate { final Object lock = new Object(); String commandArguments = ""; //$NON-NLS-1$ + Map<String,String> commandEnv = null; if (isAttachLaunch) { commandArguments = "--once --multi :" + gdbserverPortNumber.get(); //$NON-NLS-1$ monitor.setTaskName(Messages.TEGdbAbstractLaunchDelegate_attaching_program); @@ -175,9 +185,7 @@ public abstract class TEGdbAbstractLaunchDelegate extends GdbLaunchDelegate { commandArguments = "--once :" + gdbserverPortNumber.get() + " " + TEHelper.spaceEscapify(remoteExePath); //$NON-NLS-1$ //$NON-NLS-2$ String arguments = getProgramArguments(config); - String prelaunchCmd = config.getAttribute(IRemoteTEConfigurationConstants.ATTR_PRERUN_COMMANDS, ""); //$NON-NLS-1$ - - TEHelper.launchCmd(peer, null, prelaunchCmd, null, new SubProgressMonitor(monitor, 2), new Callback()); + commandEnv = config.getAttribute(ILaunchManager.ATTR_ENVIRONMENT_VARIABLES, (Map<String,String>)null); if (arguments != null && !arguments.equals("")) { //$NON-NLS-1$ commandArguments += " " + arguments; //$NON-NLS-1$ @@ -204,7 +212,6 @@ public abstract class TEGdbAbstractLaunchDelegate extends GdbLaunchDelegate { }; StreamsDataReceiver.Listener listener = new StreamsDataReceiver.Listener() { - @Override public void dataReceived(String data) { gdbServerOutput.append(data); @@ -249,7 +256,6 @@ public abstract class TEGdbAbstractLaunchDelegate extends GdbLaunchDelegate { lock.notifyAll(); } } - } }; @@ -257,7 +263,9 @@ public abstract class TEGdbAbstractLaunchDelegate extends GdbLaunchDelegate { if (remotePID != null) { peerName = peer.getName() + ", PID " + remotePID; //$NON-NLS-1$ } - launcher = TEHelper.launchCmd(peer, peerName, gdbserverCommand, commandArguments, listener, new SubProgressMonitor(monitor, 3), callback); + + String[] argv = StringUtil.tokenize(gdbserverCommand + ' ' + commandArguments, 0, false); + launcher = TEHelper.launchCmdWithEnv(peer, peerName, argv[0], argv, commandEnv, listener, new SubProgressMonitor(monitor, 3), callback); // Now wait until gdbserver is up and running on the remote host while (!gdbServerReady.get() && !gdbServerExited.get()) { @@ -391,10 +399,11 @@ public abstract class TEGdbAbstractLaunchDelegate extends GdbLaunchDelegate { /** * Shutdown the GDB debug session. + * This method always throws a CoreException and does not return. * * @param launch The GDB launch. Must not be <code>null</code>. * @param details Error message, may be <code>null</code> - * @throws CoreException If the GDB debug session shutdown failed. + * @throws CoreException Always throws a CoreException */ protected void shutdownSession(final GdbLaunch launch, final String details, final ProcessLauncher launcher) throws CoreException { Assert.isNotNull(launch); diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/src/org/eclipse/tcf/te/tcf/launch/cdt/tabs/TEEnvironmentTab.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/src/org/eclipse/tcf/te/tcf/launch/cdt/tabs/TEEnvironmentTab.java new file mode 100644 index 000000000..981c56593 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/src/org/eclipse/tcf/te/tcf/launch/cdt/tabs/TEEnvironmentTab.java @@ -0,0 +1,49 @@ +/******************************************************************************* + * Copyright (c) 2015 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.cdt.tabs; + +import org.eclipse.debug.ui.EnvironmentTab; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; + +/** + * Launch config tab to specify environment variables for the remote process. + */ +public class TEEnvironmentTab extends EnvironmentTab { + + @Override + public void createControl(Composite parent) { + super.createControl(parent); + + // Hide unwanted controls + hide(appendEnvironment); + hide(replaceEnvironment); + hide(envSelectButton); + } + + @Override + public String getId() { + return "org.eclipse.tcf.te.remotecdt.debug.environmentTab"; //$NON-NLS-1$ + } + + private void hide(Control ctrl) { + if (ctrl != null) { + ctrl.setVisible(false); + Object layoutData = ctrl.getLayoutData(); + if (layoutData instanceof GridData) { + GridData gd = (GridData) layoutData; + gd.exclude = true; + } + } + } + +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/src/org/eclipse/tcf/te/tcf/launch/cdt/utils/TEHelper.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/src/org/eclipse/tcf/te/tcf/launch/cdt/utils/TEHelper.java index 356a75dd7..44e413155 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/src/org/eclipse/tcf/te/tcf/launch/cdt/utils/TEHelper.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/src/org/eclipse/tcf/te/tcf/launch/cdt/utils/TEHelper.java @@ -172,25 +172,33 @@ public class TEHelper { public static ProcessLauncher launchCmd(final IPeer peer, String peerName, String command, Listener listener, SubProgressMonitor monitor, ICallback callback) throws CoreException { if (command != null && !command.trim().equals("")) { //$NON-NLS-1$ - String[] args = StringUtil.tokenize(command, 0, true); + String[] args = StringUtil.tokenize(command, 0, false); if (args.length > 0) { String cmd = args[0]; String[] arguments = null; if (args.length > 1) { arguments = Arrays.copyOfRange(args, 1, args.length); } - return launchCmd(peer, peerName, cmd, arguments, listener, monitor, callback); + return launchCmdWithEnv(peer, peerName, cmd, arguments, null, listener, monitor, callback); } } return null; } public static ProcessLauncher launchCmd(final IPeer peer, String peerName, String remoteCommandPath, String arguments, Listener listener, SubProgressMonitor monitor, ICallback callback) throws CoreException { - String[] args = arguments != null && !"".equals(arguments.trim()) ? StringUtil.tokenize(arguments, 0, true) : null; //$NON-NLS-1$ - return launchCmd(peer, peerName, remoteCommandPath, args, listener, monitor, callback); + return launchCmdWithEnv(peer, peerName, remoteCommandPath, arguments, null, listener, monitor, callback); } public static ProcessLauncher launchCmd(final IPeer peer, String peerName, String remoteCommandPath, String[] args, Listener listener, SubProgressMonitor monitor, ICallback callback) throws CoreException { + return launchCmdWithEnv(peer, peerName, remoteCommandPath, args, null, listener, monitor, callback); + } + + public static ProcessLauncher launchCmdWithEnv(final IPeer peer, String peerName, String remoteCommandPath, String arguments, Map<String, String> env, Listener listener, SubProgressMonitor monitor, ICallback callback) throws CoreException { + String[] args = arguments != null && !"".equals(arguments.trim()) ? StringUtil.tokenize(arguments, 0, true) : null; //$NON-NLS-1$ + return launchCmdWithEnv(peer, peerName, remoteCommandPath, args, env, listener, monitor, callback); + } + + public static ProcessLauncher launchCmdWithEnv(final IPeer peer, String peerName, String remoteCommandPath, String[] args, Map<String, String> env, Listener listener, SubProgressMonitor monitor, ICallback callback) throws CoreException { if (remoteCommandPath != null && !remoteCommandPath.trim().equals("")) { //$NON-NLS-1$ monitor.beginTask(NLS.bind(Messages.TEHelper_executing, remoteCommandPath, args), 10); @@ -228,6 +236,7 @@ public class TEHelper { launchAttributes.put(IProcessLauncher.PROP_PROCESS_PATH, spaceEscapify(remoteCommandPath)); launchAttributes.put(IProcessLauncher.PROP_PROCESS_ARGS, args); + launchAttributes.put(IProcessLauncher.PROP_PROCESS_ENV, env); launchAttributes.put(ITerminalsConnectorConstants.PROP_LOCAL_ECHO, Boolean.FALSE); |