mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-28 10:43:31 +02:00
[181517] Added field for commands to be executed before launch.
This commit is contained in:
parent
68819bd590
commit
e436a5b4f7
5 changed files with 283 additions and 167 deletions
|
@ -1,12 +1,13 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2006 PalmSource, Inc.
|
* Copyright (c) 2006 PalmSource, Inc. and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Ewa Matejska (PalmSource) - Adapted from IGDBServerMILaunchConfigurationConstants
|
* Ewa Matejska (PalmSource) - Adapted from IGDBServerMILaunchConfigurationConstants
|
||||||
|
* Anna Dushistova (MontaVista) - [181517][usability] Specify commands to be run before remote application launch
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
@ -40,4 +41,7 @@ public interface IRemoteConnectionConfigurationConstants extends
|
||||||
public static final String ATTR_SKIP_DOWNLOAD_TO_TARGET =
|
public static final String ATTR_SKIP_DOWNLOAD_TO_TARGET =
|
||||||
DebugPlugin.getUniqueIdentifier() + ".ATTR_SKIP_DOWNLOAD_TO_TARGET"; //$NON-NLS-1$
|
DebugPlugin.getUniqueIdentifier() + ".ATTR_SKIP_DOWNLOAD_TO_TARGET"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
|
||||||
|
public static final String ATTR_PRERUN_COMMANDS = DebugPlugin.getUniqueIdentifier() + ".ATTR_PRERUN_CMDS"; //$NON-NLS-1$
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
* Ewa Matejska (PalmSource) - [158783] browse button for cdt remote path
|
* Ewa Matejska (PalmSource) - [158783] browse button for cdt remote path
|
||||||
* Johann Draschwandtner (Wind River) - [231827][remotecdt]Auto-compute default for Remote path
|
* Johann Draschwandtner (Wind River) - [231827][remotecdt]Auto-compute default for Remote path
|
||||||
* Anna Dushistova (MontaVista) - [244173][remotecdt][nls] Externalize Strings in RemoteRunLaunchDelegate
|
* Anna Dushistova (MontaVista) - [244173][remotecdt][nls] Externalize Strings in RemoteRunLaunchDelegate
|
||||||
|
* Anna Dushistova (MontaVista) - [181517][usability] Specify commands to be run before remote application launch
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.rse.internal.remotecdt;
|
package org.eclipse.rse.internal.remotecdt;
|
||||||
|
|
||||||
|
@ -26,6 +27,8 @@ public class Messages extends NLS {
|
||||||
|
|
||||||
public static String Remote_GDB_Debugger_Options;
|
public static String Remote_GDB_Debugger_Options;
|
||||||
|
|
||||||
|
public static String RemoteCMainTab_Prerun;
|
||||||
|
|
||||||
public static String RemoteCMainTab_Program;
|
public static String RemoteCMainTab_Program;
|
||||||
|
|
||||||
public static String RemoteCMainTab_Remote_Path_Browse_Button;
|
public static String RemoteCMainTab_Remote_Path_Browse_Button;
|
||||||
|
|
|
@ -6,13 +6,14 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Ewa Matejska (PalmSource) - initial API and implementation
|
* Ewa Matejska (PalmSource) - initial API and implementation
|
||||||
* Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry
|
* Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry
|
||||||
* Martin Oberhuber (Wind River) - [196934] hide disabled system types in remotecdt combo
|
* Martin Oberhuber (Wind River) - [196934] hide disabled system types in remotecdt combo
|
||||||
* Yu-Fen Kuo (MontaVista) - [190613] Fix NPE in Remotecdt when RSEUIPlugin has not been loaded
|
* Yu-Fen Kuo (MontaVista) - [190613] Fix NPE in Remotecdt when RSEUIPlugin has not been loaded
|
||||||
* Martin Oberhuber (Wind River) - [cleanup] Avoid using SystemStartHere in production code
|
* Martin Oberhuber (Wind River) - [cleanup] Avoid using SystemStartHere in production code
|
||||||
* Johann Draschwandtner (Wind River) - [231827][remotecdt]Auto-compute default for Remote path
|
* Johann Draschwandtner (Wind River) - [231827][remotecdt]Auto-compute default for Remote path
|
||||||
* Johann Draschwandtner (Wind River) - [233057][remotecdt]Fix button enablement
|
* Johann Draschwandtner (Wind River) - [233057][remotecdt]Fix button enablement
|
||||||
|
* Anna Dushistova (MontaVista) - [181517][usability] Specify commands to be run before remote application launch
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.rse.internal.remotecdt;
|
package org.eclipse.rse.internal.remotecdt;
|
||||||
|
@ -63,6 +64,7 @@ public class RemoteCMainTab extends CMainTab {
|
||||||
private static final String SKIP_DOWNLOAD_BUTTON_TEXT = Messages.RemoteCMainTab_SkipDownload;
|
private static final String SKIP_DOWNLOAD_BUTTON_TEXT = Messages.RemoteCMainTab_SkipDownload;
|
||||||
private static final String REMOTE_PROG_TEXT_ERROR = Messages.RemoteCMainTab_ErrorNoProgram;
|
private static final String REMOTE_PROG_TEXT_ERROR = Messages.RemoteCMainTab_ErrorNoProgram;
|
||||||
private static final String CONNECTION_TEXT_ERROR = Messages.RemoteCMainTab_ErrorNoConnection;
|
private static final String CONNECTION_TEXT_ERROR = Messages.RemoteCMainTab_ErrorNoConnection;
|
||||||
|
private static final String PRE_RUN_LABEL_TEXT = Messages.RemoteCMainTab_Prerun;
|
||||||
|
|
||||||
/* Defaults */
|
/* Defaults */
|
||||||
private static final String REMOTE_PATH_DEFAULT = EMPTY_STRING;
|
private static final String REMOTE_PATH_DEFAULT = EMPTY_STRING;
|
||||||
|
@ -81,6 +83,8 @@ public class RemoteCMainTab extends CMainTab {
|
||||||
private static int initializedRSE = 0; //0=not initialized; -1=initializing; 1=initialized
|
private static int initializedRSE = 0; //0=not initialized; -1=initializing; 1=initialized
|
||||||
|
|
||||||
SystemNewConnectionAction action = null;
|
SystemNewConnectionAction action = null;
|
||||||
|
private Text preRunText;
|
||||||
|
private Label preRunLabel;
|
||||||
|
|
||||||
public RemoteCMainTab(boolean terminalOption) {
|
public RemoteCMainTab(boolean terminalOption) {
|
||||||
super(terminalOption);
|
super(terminalOption);
|
||||||
|
@ -241,6 +245,25 @@ public class RemoteCMainTab extends CMainTab {
|
||||||
updateLaunchConfigurationDialog();
|
updateLaunchConfigurationDialog();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//Commands to run before execution
|
||||||
|
preRunLabel = new Label(mainComp, SWT.NONE);
|
||||||
|
preRunLabel.setText(PRE_RUN_LABEL_TEXT);
|
||||||
|
gd = new GridData();
|
||||||
|
gd.horizontalSpan = 2;
|
||||||
|
preRunLabel.setLayoutData(gd);
|
||||||
|
|
||||||
|
preRunText = new Text(mainComp, SWT.MULTI | SWT.BORDER);
|
||||||
|
gd = new GridData(GridData.FILL_HORIZONTAL);
|
||||||
|
gd.horizontalSpan = 2;
|
||||||
|
preRunText.setLayoutData(gd);
|
||||||
|
preRunText.addModifyListener(new ModifyListener() {
|
||||||
|
|
||||||
|
public void modifyText(ModifyEvent evt) {
|
||||||
|
updateLaunchConfigurationDialog();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -279,6 +302,7 @@ public class RemoteCMainTab extends CMainTab {
|
||||||
remoteProgText.getText());
|
remoteProgText.getText());
|
||||||
config.setAttribute(IRemoteConnectionConfigurationConstants.ATTR_SKIP_DOWNLOAD_TO_TARGET,
|
config.setAttribute(IRemoteConnectionConfigurationConstants.ATTR_SKIP_DOWNLOAD_TO_TARGET,
|
||||||
skipDownloadButton.getSelection());
|
skipDownloadButton.getSelection());
|
||||||
|
config.setAttribute(IRemoteConnectionConfigurationConstants.ATTR_PRERUN_COMMANDS, preRunText.getText());
|
||||||
super.performApply(config);
|
super.performApply(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -514,6 +538,15 @@ public class RemoteCMainTab extends CMainTab {
|
||||||
// Ignore
|
// Ignore
|
||||||
}
|
}
|
||||||
remoteProgText.setText(targetPath);
|
remoteProgText.setText(targetPath);
|
||||||
|
|
||||||
|
String prelaunchCmd = null;
|
||||||
|
try {
|
||||||
|
prelaunchCmd = config.getAttribute(IRemoteConnectionConfigurationConstants.ATTR_PRERUN_COMMANDS,
|
||||||
|
""); //$NON-NLS-1$
|
||||||
|
} catch (CoreException e) {
|
||||||
|
// Ignore
|
||||||
|
}
|
||||||
|
preRunText.setText(prelaunchCmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void updateSkipDownloadFromConfig(ILaunchConfiguration config) {
|
protected void updateSkipDownloadFromConfig(ILaunchConfiguration config) {
|
||||||
|
|
|
@ -13,9 +13,9 @@
|
||||||
* Anna Dushistova (MontaVista) - [234490][remotecdt] Launching with disconnected target fails
|
* Anna Dushistova (MontaVista) - [234490][remotecdt] Launching with disconnected target fails
|
||||||
* Anna Dushistova (MontaVista) - [235298][remotecdt] Further improve progress reporting and cancellation of Remote CDT Launch
|
* Anna Dushistova (MontaVista) - [235298][remotecdt] Further improve progress reporting and cancellation of Remote CDT Launch
|
||||||
* Anna Dushistova (MontaVista) - [244173][remotecdt][nls] Externalize Strings in RemoteRunLaunchDelegate
|
* Anna Dushistova (MontaVista) - [244173][remotecdt][nls] Externalize Strings in RemoteRunLaunchDelegate
|
||||||
|
* Anna Dushistova (MontaVista) - [181517][usability] Specify commands to be run before remote application launch
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
package org.eclipse.rse.internal.remotecdt;
|
package org.eclipse.rse.internal.remotecdt;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
@ -61,258 +61,332 @@ import org.eclipse.rse.subsystems.shells.core.subsystems.servicesubsystem.IShell
|
||||||
|
|
||||||
public class RemoteRunLaunchDelegate extends AbstractCLaunchDelegate {
|
public class RemoteRunLaunchDelegate extends AbstractCLaunchDelegate {
|
||||||
|
|
||||||
private final static String SHELL_SERVICE = "shell.service"; //$NON-NLS-1$
|
private final static String SHELL_SERVICE = "shell.service"; //$NON-NLS-1$
|
||||||
private final static String FILE_SERVICE = "file.service"; //$NON-NLS-1$
|
private final static String FILE_SERVICE = "file.service"; //$NON-NLS-1$
|
||||||
private final static String EXIT_CMD = "exit"; //$NON-NLS-1$
|
private final static String EXIT_CMD = "exit"; //$NON-NLS-1$
|
||||||
private final static String CMD_DELIMITER = ";"; //$NON-NLS-1$
|
private final static String CMD_DELIMITER = ";"; //$NON-NLS-1$
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
* @see org.eclipse.debug.core.model.ILaunchConfigurationDelegate#launch
|
* @see org.eclipse.debug.core.model.ILaunchConfigurationDelegate#launch
|
||||||
*/
|
*/
|
||||||
public void launch(ILaunchConfiguration config, String mode, ILaunch launch,
|
public void launch(ILaunchConfiguration config, String mode,
|
||||||
IProgressMonitor monitor) throws CoreException {
|
ILaunch launch, IProgressMonitor monitor) throws CoreException {
|
||||||
|
|
||||||
IBinaryObject exeFile = null;
|
IBinaryObject exeFile = null;
|
||||||
IPath exePath = verifyProgramPath(config);
|
IPath exePath = verifyProgramPath(config);
|
||||||
ICProject project = verifyCProject(config);
|
ICProject project = verifyCProject(config);
|
||||||
if (exePath != null) {
|
if (exePath != null) {
|
||||||
exeFile = verifyBinary(project, exePath);
|
exeFile = verifyBinary(project, exePath);
|
||||||
}
|
String arguments = getProgramArguments(config);
|
||||||
|
String remoteExePath = config.getAttribute(
|
||||||
|
IRemoteConnectionConfigurationConstants.ATTR_REMOTE_PATH,
|
||||||
|
""); //$NON-NLS-1$
|
||||||
|
String prelaunchCmd = config
|
||||||
|
.getAttribute(
|
||||||
|
IRemoteConnectionConfigurationConstants.ATTR_PRERUN_COMMANDS,
|
||||||
|
""); //$NON-NLS-1$
|
||||||
|
|
||||||
String arguments = getProgramArguments(config);
|
if (monitor == null)
|
||||||
String remoteExePath = config.getAttribute(IRemoteConnectionConfigurationConstants.ATTR_REMOTE_PATH, ""); //$NON-NLS-1$
|
monitor = new NullProgressMonitor();
|
||||||
|
|
||||||
if(monitor==null)
|
|
||||||
monitor = new NullProgressMonitor();
|
|
||||||
|
|
||||||
|
if (mode.equals(ILaunchManager.DEBUG_MODE)) {
|
||||||
if(mode.equals(ILaunchManager.DEBUG_MODE)){
|
monitor.beginTask(Messages.RemoteRunLaunchDelegate_0, 100);
|
||||||
monitor.beginTask(Messages.RemoteRunLaunchDelegate_0, 100);
|
setDefaultSourceLocator(launch, config);
|
||||||
setDefaultSourceLocator(launch, config);
|
String debugMode = config
|
||||||
String debugMode = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
|
.getAttribute(
|
||||||
ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN);
|
ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
|
||||||
if (debugMode.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN)) {
|
ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN);
|
||||||
Process remoteShellProcess = null;
|
if (debugMode
|
||||||
ICDISession dsession = null;
|
.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN)) {
|
||||||
|
Process remoteShellProcess = null;
|
||||||
|
ICDISession dsession = null;
|
||||||
|
try {
|
||||||
|
// Download the binary to the remote before debugging.
|
||||||
|
monitor.setTaskName(Messages.RemoteRunLaunchDelegate_2);
|
||||||
|
remoteFileDownload(config, launch, exePath.toString(),
|
||||||
|
remoteExePath, new SubProgressMonitor(monitor,
|
||||||
|
80));
|
||||||
|
|
||||||
|
// Automatically start up the gdbserver. In the future
|
||||||
|
// this should be expanded to launch
|
||||||
|
// an arbitrary remote daemon.
|
||||||
|
String gdbserver_port_number = config
|
||||||
|
.getAttribute(
|
||||||
|
IRemoteConnectionConfigurationConstants.ATTR_GDBSERVER_PORT,
|
||||||
|
IRemoteConnectionConfigurationConstants.ATTR_GDBSERVER_PORT_DEFAULT);
|
||||||
|
String gdbserver_command = config
|
||||||
|
.getAttribute(
|
||||||
|
IRemoteConnectionConfigurationConstants.ATTR_GDBSERVER_COMMAND,
|
||||||
|
IRemoteConnectionConfigurationConstants.ATTR_GDBSERVER_COMMAND_DEFAULT);
|
||||||
|
String command_arguments = ":" + gdbserver_port_number + " " //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
+ spaceEscapify(remoteExePath);
|
||||||
|
if (arguments != null && !arguments.equals("")) //$NON-NLS-1$
|
||||||
|
command_arguments += " " + arguments; //$NON-NLS-1$
|
||||||
|
monitor.setTaskName(Messages.RemoteRunLaunchDelegate_9);
|
||||||
|
remoteShellProcess = remoteShellExec(config,
|
||||||
|
prelaunchCmd, gdbserver_command,
|
||||||
|
command_arguments, new SubProgressMonitor(
|
||||||
|
monitor, 5));
|
||||||
|
DebugPlugin.newProcess(launch, remoteShellProcess,
|
||||||
|
Messages.RemoteRunLaunchDelegate_RemoteShell);
|
||||||
|
|
||||||
|
// Pre-set configuration constants for the
|
||||||
|
// GDBSERVERCDIDebugger to indicate how the gdbserver
|
||||||
|
// was automatically started on the remote.
|
||||||
|
// GDBServerCDIDebugger uses these to figure out how
|
||||||
|
// to connect to the remote gdbserver.
|
||||||
|
ILaunchConfigurationWorkingCopy wc = config
|
||||||
|
.getWorkingCopy();
|
||||||
|
wc
|
||||||
|
.setAttribute(
|
||||||
|
IGDBServerMILaunchConfigurationConstants.ATTR_REMOTE_TCP,
|
||||||
|
true);
|
||||||
|
wc
|
||||||
|
.setAttribute(
|
||||||
|
IGDBServerMILaunchConfigurationConstants.ATTR_HOST,
|
||||||
|
getRemoteHostname(config));
|
||||||
|
wc
|
||||||
|
.setAttribute(
|
||||||
|
IGDBServerMILaunchConfigurationConstants.ATTR_PORT,
|
||||||
|
gdbserver_port_number);
|
||||||
|
wc.doSave();
|
||||||
|
|
||||||
|
// Default to using the GDBServerCDIDebugger.
|
||||||
|
GDBServerCDIDebugger2 debugger = new GDBServerCDIDebugger2();
|
||||||
|
dsession = ((ICDIDebugger2) debugger).createSession(
|
||||||
|
launch, exePath.toFile(),
|
||||||
|
new SubProgressMonitor(monitor, 15));
|
||||||
|
|
||||||
|
boolean stopInMain = config
|
||||||
|
.getAttribute(
|
||||||
|
ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN,
|
||||||
|
false);
|
||||||
|
String stopSymbol = null;
|
||||||
|
if (stopInMain)
|
||||||
|
stopSymbol = launch
|
||||||
|
.getLaunchConfiguration()
|
||||||
|
.getAttribute(
|
||||||
|
ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN_SYMBOL,
|
||||||
|
ICDTLaunchConfigurationConstants.DEBUGGER_STOP_AT_MAIN_SYMBOL_DEFAULT);
|
||||||
|
|
||||||
|
ICDITarget[] targets = dsession.getTargets();
|
||||||
|
for (int i = 0; i < targets.length; i++) {
|
||||||
|
Process process = targets[i].getProcess();
|
||||||
|
IProcess iprocess = null;
|
||||||
|
if (process != null) {
|
||||||
|
iprocess = DebugPlugin.newProcess(launch,
|
||||||
|
process, renderProcessLabel(exePath
|
||||||
|
.toOSString()),
|
||||||
|
getDefaultProcessMap());
|
||||||
|
}
|
||||||
|
CDIDebugModel.newDebugTarget(launch, project
|
||||||
|
.getProject(),
|
||||||
|
targets[i],
|
||||||
|
renderProcessLabel("gdbserver debugger"), //$NON-NLS-1$
|
||||||
|
iprocess, exeFile, true, false, stopSymbol,
|
||||||
|
true);
|
||||||
|
}
|
||||||
|
} catch (CoreException e) {
|
||||||
|
try {
|
||||||
|
if (dsession != null)
|
||||||
|
dsession.terminate();
|
||||||
|
if (remoteShellProcess != null)
|
||||||
|
remoteShellProcess.destroy();
|
||||||
|
} catch (CDIException e1) {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
throw e;
|
||||||
|
} finally {
|
||||||
|
monitor.done();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (mode.equals(ILaunchManager.RUN_MODE)) {
|
||||||
|
monitor.beginTask(Messages.RemoteRunLaunchDelegate_0, 100);
|
||||||
|
Process remoteProcess = null;
|
||||||
try {
|
try {
|
||||||
// Download the binary to the remote before debugging.
|
// Download the binary to the remote before debugging.
|
||||||
monitor.setTaskName(Messages.RemoteRunLaunchDelegate_2);
|
monitor.setTaskName(Messages.RemoteRunLaunchDelegate_2);
|
||||||
remoteFileDownload(config, launch, exePath.toString(), remoteExePath, new SubProgressMonitor(monitor, 80));
|
remoteFileDownload(config, launch, exePath.toString(),
|
||||||
|
remoteExePath, new SubProgressMonitor(monitor, 80));
|
||||||
// Automatically start up the gdbserver. In the future this should be expanded to launch
|
// Use a remote shell to launch the binary.
|
||||||
// an arbitrary remote daemon.
|
monitor.setTaskName(Messages.RemoteRunLaunchDelegate_12);
|
||||||
String gdbserver_port_number = config.getAttribute(IRemoteConnectionConfigurationConstants.ATTR_GDBSERVER_PORT,
|
remoteProcess = remoteShellExec(config, prelaunchCmd,
|
||||||
IRemoteConnectionConfigurationConstants.ATTR_GDBSERVER_PORT_DEFAULT);
|
remoteExePath, arguments, new SubProgressMonitor(
|
||||||
String gdbserver_command = config.getAttribute(IRemoteConnectionConfigurationConstants.ATTR_GDBSERVER_COMMAND,
|
monitor, 20));
|
||||||
IRemoteConnectionConfigurationConstants.ATTR_GDBSERVER_COMMAND_DEFAULT);
|
DebugPlugin.newProcess(launch, remoteProcess,
|
||||||
String command_arguments = ":" + gdbserver_port_number + " " //$NON-NLS-1$ //$NON-NLS-2$
|
renderProcessLabel(exePath.toOSString()));
|
||||||
+ spaceEscapify(remoteExePath);
|
|
||||||
if(arguments != null && !arguments.equals("")) //$NON-NLS-1$
|
|
||||||
command_arguments += " " + arguments; //$NON-NLS-1$
|
|
||||||
monitor.setTaskName(Messages.RemoteRunLaunchDelegate_9);
|
|
||||||
remoteShellProcess = remoteShellExec(config, gdbserver_command,
|
|
||||||
command_arguments, new SubProgressMonitor(monitor, 5));
|
|
||||||
DebugPlugin.newProcess(launch, remoteShellProcess, Messages.RemoteRunLaunchDelegate_RemoteShell);
|
|
||||||
|
|
||||||
// Pre-set configuration constants for the GDBSERVERCDIDebugger to indicate how the gdbserver
|
|
||||||
// was automatically started on the remote. GDBServerCDIDebugger uses these to figure out how
|
|
||||||
// to connect to the remote gdbserver.
|
|
||||||
ILaunchConfigurationWorkingCopy wc = config.getWorkingCopy();
|
|
||||||
wc.setAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_REMOTE_TCP, true);
|
|
||||||
wc.setAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_HOST, getRemoteHostname(config));
|
|
||||||
wc.setAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_PORT,
|
|
||||||
gdbserver_port_number);
|
|
||||||
wc.doSave();
|
|
||||||
|
|
||||||
// Default to using the GDBServerCDIDebugger.
|
|
||||||
GDBServerCDIDebugger2 debugger = new GDBServerCDIDebugger2();
|
|
||||||
dsession = ((ICDIDebugger2)debugger).createSession(launch, exePath.toFile(),
|
|
||||||
new SubProgressMonitor(monitor, 15));
|
|
||||||
|
|
||||||
boolean stopInMain = config
|
|
||||||
.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, false);
|
|
||||||
String stopSymbol = null;
|
|
||||||
if ( stopInMain )
|
|
||||||
stopSymbol = launch.getLaunchConfiguration().getAttribute(
|
|
||||||
ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN_SYMBOL,
|
|
||||||
ICDTLaunchConfigurationConstants.DEBUGGER_STOP_AT_MAIN_SYMBOL_DEFAULT );
|
|
||||||
|
|
||||||
ICDITarget[] targets = dsession.getTargets();
|
|
||||||
for (int i = 0; i < targets.length; i++) {
|
|
||||||
Process process = targets[i].getProcess();
|
|
||||||
IProcess iprocess = null;
|
|
||||||
if (process != null) {
|
|
||||||
iprocess = DebugPlugin.newProcess(launch, process,
|
|
||||||
renderProcessLabel(exePath.toOSString()), getDefaultProcessMap());
|
|
||||||
}
|
|
||||||
CDIDebugModel.newDebugTarget(launch, project.getProject(), targets[i],
|
|
||||||
renderProcessLabel("gdbserver debugger"), //$NON-NLS-1$
|
|
||||||
iprocess, exeFile, true, false, stopSymbol, true);
|
|
||||||
}
|
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
try {
|
|
||||||
if(dsession != null)
|
|
||||||
dsession.terminate();
|
|
||||||
if(remoteShellProcess != null)
|
|
||||||
remoteShellProcess.destroy();
|
|
||||||
} catch (CDIException e1) {
|
|
||||||
// ignore
|
|
||||||
}
|
|
||||||
throw e;
|
throw e;
|
||||||
} finally {
|
} finally {
|
||||||
monitor.done();
|
monitor.done();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
} else if(mode.equals(ILaunchManager.RUN_MODE)) {
|
} else {
|
||||||
monitor.beginTask(Messages.RemoteRunLaunchDelegate_0, 100);
|
IStatus status = new Status(IStatus.ERROR, getPluginID(),
|
||||||
Process remoteProcess = null;
|
IStatus.OK, NLS.bind(
|
||||||
try {
|
Messages.RemoteRunLaunchDelegate_1, mode), null);
|
||||||
// Download the binary to the remote before debugging.
|
throw new CoreException(status);
|
||||||
monitor.setTaskName(Messages.RemoteRunLaunchDelegate_2);
|
|
||||||
remoteFileDownload(config, launch, exePath.toString(),remoteExePath, new SubProgressMonitor(monitor,80));
|
|
||||||
// Use a remote shell to launch the binary.
|
|
||||||
monitor.setTaskName(Messages.RemoteRunLaunchDelegate_12);
|
|
||||||
remoteProcess = remoteShellExec(config, remoteExePath, arguments, new SubProgressMonitor(monitor,20));
|
|
||||||
DebugPlugin.newProcess(launch, remoteProcess, renderProcessLabel(exePath.toOSString()));
|
|
||||||
} catch (CoreException e) {
|
|
||||||
if(remoteProcess != null)
|
|
||||||
remoteProcess.destroy();
|
|
||||||
throw e;
|
|
||||||
} finally {
|
|
||||||
monitor.done();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
|
||||||
IStatus status = new Status(IStatus.ERROR, getPluginID(),
|
|
||||||
IStatus.OK, NLS.bind(Messages.RemoteRunLaunchDelegate_1, mode), null);
|
|
||||||
throw new CoreException(status);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String spaceEscapify(String inputString) {
|
private String spaceEscapify(String inputString) {
|
||||||
if(inputString == null)
|
if (inputString == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
return inputString.replaceAll(" ", "\\\\ "); //$NON-NLS-1$ //$NON-NLS-2$
|
return inputString.replaceAll(" ", "\\\\ "); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IHost getCurrentConnection(ILaunchConfiguration config) throws CoreException {
|
protected IHost getCurrentConnection(ILaunchConfiguration config)
|
||||||
String remoteConnection = config.getAttribute(IRemoteConnectionConfigurationConstants.ATTR_REMOTE_CONNECTION, ""); //$NON-NLS-1$
|
throws CoreException {
|
||||||
|
String remoteConnection = config.getAttribute(
|
||||||
|
IRemoteConnectionConfigurationConstants.ATTR_REMOTE_CONNECTION,
|
||||||
|
""); //$NON-NLS-1$
|
||||||
|
|
||||||
IHost[] connections = RSECorePlugin.getTheSystemRegistry().getHosts();
|
IHost[] connections = RSECorePlugin.getTheSystemRegistry().getHosts();
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for(i = 0; i < connections.length; i++)
|
for (i = 0; i < connections.length; i++)
|
||||||
if(connections[i].getAliasName().equals(remoteConnection))
|
if (connections[i].getAliasName().equals(remoteConnection))
|
||||||
break;
|
break;
|
||||||
if(i >= connections.length) {
|
if (i >= connections.length) {
|
||||||
abort(Messages.RemoteRunLaunchDelegate_13, null, ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR);
|
abort(Messages.RemoteRunLaunchDelegate_13, null,
|
||||||
|
ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR);
|
||||||
}
|
}
|
||||||
return connections[i];
|
return connections[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IService getConnectedRemoteService(ILaunchConfiguration config, String kindOfService, IProgressMonitor monitor)
|
protected IService getConnectedRemoteService(ILaunchConfiguration config,
|
||||||
throws CoreException {
|
String kindOfService, IProgressMonitor monitor)
|
||||||
|
throws CoreException {
|
||||||
|
|
||||||
// Check that the service requested is file or shell.
|
// Check that the service requested is file or shell.
|
||||||
if(!kindOfService.equals(SHELL_SERVICE) && !kindOfService.equals(FILE_SERVICE))
|
if (!kindOfService.equals(SHELL_SERVICE)
|
||||||
abort(Messages.RemoteRunLaunchDelegate_3, null, ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR);
|
&& !kindOfService.equals(FILE_SERVICE))
|
||||||
|
abort(Messages.RemoteRunLaunchDelegate_3, null,
|
||||||
|
ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR);
|
||||||
|
|
||||||
IHost currentConnection = getCurrentConnection(config);
|
IHost currentConnection = getCurrentConnection(config);
|
||||||
|
|
||||||
ISubSystem[] subSystems = currentConnection.getSubSystems();
|
ISubSystem[] subSystems = currentConnection.getSubSystems();
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for(i = 0; i < subSystems.length; i++) {
|
for (i = 0; i < subSystems.length; i++) {
|
||||||
if(subSystems[i] instanceof IShellServiceSubSystem && kindOfService.equals(SHELL_SERVICE))
|
if (subSystems[i] instanceof IShellServiceSubSystem
|
||||||
|
&& kindOfService.equals(SHELL_SERVICE))
|
||||||
break;
|
break;
|
||||||
if(subSystems[i] instanceof IFileServiceSubSystem && kindOfService.equals(FILE_SERVICE))
|
if (subSystems[i] instanceof IFileServiceSubSystem
|
||||||
|
&& kindOfService.equals(FILE_SERVICE))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(i >= subSystems.length)
|
if (i >= subSystems.length)
|
||||||
abort(Messages.RemoteRunLaunchDelegate_4, null, ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR);
|
abort(Messages.RemoteRunLaunchDelegate_4, null,
|
||||||
|
ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR);
|
||||||
|
|
||||||
final ISubSystem subsystem = subSystems[i];
|
final ISubSystem subsystem = subSystems[i];
|
||||||
try {
|
try {
|
||||||
subsystem.connect(monitor, false);
|
subsystem.connect(monitor, false);
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
throw e;
|
throw e;
|
||||||
} catch (OperationCanceledException e) {
|
} catch (OperationCanceledException e) {
|
||||||
throw new CoreException(Status.CANCEL_STATUS);
|
throw new CoreException(Status.CANCEL_STATUS);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new CoreException(new Status(IStatus.ERROR, getPluginID() ,IStatus.OK,
|
throw new CoreException(new Status(IStatus.ERROR, getPluginID(),
|
||||||
e.getLocalizedMessage(), e));
|
IStatus.OK, e.getLocalizedMessage(), e));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!subsystem.isConnected())
|
|
||||||
abort(Messages.RemoteRunLaunchDelegate_5, null, ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR);
|
|
||||||
|
|
||||||
if(kindOfService.equals(SHELL_SERVICE))
|
if (!subsystem.isConnected())
|
||||||
return ((IShellServiceSubSystem) subsystem).getShellService();
|
abort(Messages.RemoteRunLaunchDelegate_5, null,
|
||||||
|
ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR);
|
||||||
|
|
||||||
|
if (kindOfService.equals(SHELL_SERVICE))
|
||||||
|
return ((IShellServiceSubSystem) subsystem).getShellService();
|
||||||
else
|
else
|
||||||
return ((IFileServiceSubSystem) subsystem).getFileService();
|
return ((IFileServiceSubSystem) subsystem).getFileService();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Process remoteFileDownload(ILaunchConfiguration config, ILaunch launch,
|
protected Process remoteFileDownload(ILaunchConfiguration config,
|
||||||
String localExePath, String remoteExePath, IProgressMonitor monitor) throws CoreException {
|
ILaunch launch, String localExePath, String remoteExePath,
|
||||||
|
IProgressMonitor monitor) throws CoreException {
|
||||||
|
|
||||||
boolean skipDownload = config.getAttribute(IRemoteConnectionConfigurationConstants.ATTR_SKIP_DOWNLOAD_TO_TARGET, false);
|
boolean skipDownload = config
|
||||||
|
.getAttribute(
|
||||||
|
IRemoteConnectionConfigurationConstants.ATTR_SKIP_DOWNLOAD_TO_TARGET,
|
||||||
|
false);
|
||||||
|
|
||||||
if(skipDownload)
|
if (skipDownload)
|
||||||
// Nothing to do. Download is skipped.
|
// Nothing to do. Download is skipped.
|
||||||
return null;
|
return null;
|
||||||
monitor.beginTask(Messages.RemoteRunLaunchDelegate_2, 100);
|
monitor.beginTask(Messages.RemoteRunLaunchDelegate_2, 100);
|
||||||
IFileService fileService = (IFileService) getConnectedRemoteService(config, FILE_SERVICE, new SubProgressMonitor(monitor, 10));
|
IFileService fileService = (IFileService) getConnectedRemoteService(
|
||||||
|
config, FILE_SERVICE, new SubProgressMonitor(monitor, 10));
|
||||||
File file = new File(localExePath);
|
File file = new File(localExePath);
|
||||||
Path remotePath = new Path(remoteExePath);
|
Path remotePath = new Path(remoteExePath);
|
||||||
try {
|
try {
|
||||||
fileService.upload(file, remotePath.removeLastSegments(1).toString(), remotePath.lastSegment(),
|
fileService.upload(file, remotePath.removeLastSegments(1)
|
||||||
true, null, null, new SubProgressMonitor(monitor, 85));
|
.toString(), remotePath.lastSegment(), true, null, null,
|
||||||
// Need to change the permissions to match the original file permissions because of a bug in upload
|
new SubProgressMonitor(monitor, 85));
|
||||||
Process p = remoteShellExec(config, "chmod", "+x " + spaceEscapify(remotePath.toString()), new SubProgressMonitor(monitor, 5)); //$NON-NLS-1$ //$NON-NLS-2$
|
// Need to change the permissions to match the original file
|
||||||
|
// permissions because of a bug in upload
|
||||||
|
Process p = remoteShellExec(
|
||||||
|
config,
|
||||||
|
"", "chmod", "+x " + spaceEscapify(remotePath.toString()), new SubProgressMonitor(monitor, 5)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||||
Thread.sleep(500);
|
Thread.sleep(500);
|
||||||
p.destroy();
|
p.destroy();
|
||||||
} catch (SystemOperationCancelledException e) {
|
} catch (SystemOperationCancelledException e) {
|
||||||
cancel(e.getLocalizedMessage(), IStatus.CANCEL);
|
cancel(e.getLocalizedMessage(), IStatus.CANCEL);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
abort(Messages.RemoteRunLaunchDelegate_6, e, ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR );
|
abort(Messages.RemoteRunLaunchDelegate_6, e,
|
||||||
|
ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR);
|
||||||
} finally {
|
} finally {
|
||||||
monitor.done();
|
monitor.done();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String getRemoteHostname(ILaunchConfiguration config) throws CoreException {
|
protected String getRemoteHostname(ILaunchConfiguration config)
|
||||||
|
throws CoreException {
|
||||||
IHost currentConnection = getCurrentConnection(config);
|
IHost currentConnection = getCurrentConnection(config);
|
||||||
return currentConnection.getHostName();
|
return currentConnection.getHostName();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Process remoteShellExec(ILaunchConfiguration config, String remoteCommandPath,
|
protected Process remoteShellExec(ILaunchConfiguration config,
|
||||||
String arguments, IProgressMonitor monitor) throws CoreException {
|
String prelaunchCmd, String remoteCommandPath, String arguments,
|
||||||
// The exit command is called to force the remote shell to close after our command
|
IProgressMonitor monitor) throws CoreException {
|
||||||
// is executed. This is to prevent a running process at the end of the debug session.
|
// The exit command is called to force the remote shell to close after
|
||||||
|
// our command
|
||||||
|
// is executed. This is to prevent a running process at the end of the
|
||||||
|
// debug session.
|
||||||
// See Bug 158786.
|
// See Bug 158786.
|
||||||
monitor.beginTask(NLS.bind(Messages.RemoteRunLaunchDelegate_8, remoteCommandPath,arguments), 10);
|
monitor.beginTask(NLS.bind(Messages.RemoteRunLaunchDelegate_8,
|
||||||
String real_remote_command = arguments == null ? spaceEscapify(remoteCommandPath) :
|
remoteCommandPath, arguments), 10);
|
||||||
spaceEscapify(remoteCommandPath) + " " + arguments; //$NON-NLS-1$
|
String real_remote_command = arguments == null ? spaceEscapify(remoteCommandPath)
|
||||||
|
: spaceEscapify(remoteCommandPath) + " " + arguments; //$NON-NLS-1$
|
||||||
|
|
||||||
String remote_command = real_remote_command + CMD_DELIMITER + EXIT_CMD;
|
String remote_command = real_remote_command + CMD_DELIMITER + EXIT_CMD;
|
||||||
|
|
||||||
|
if (!prelaunchCmd.trim().equals("")) //$NON-NLS-1$
|
||||||
IShellService shellService = (IShellService) getConnectedRemoteService(config, SHELL_SERVICE, new SubProgressMonitor(monitor,7));
|
remote_command = prelaunchCmd + CMD_DELIMITER + remote_command;
|
||||||
|
|
||||||
// This is necessary because runCommand does not actually run the command right now.
|
IShellService shellService = (IShellService) getConnectedRemoteService(
|
||||||
|
config, SHELL_SERVICE, new SubProgressMonitor(monitor, 7));
|
||||||
|
|
||||||
|
// This is necessary because runCommand does not actually run the
|
||||||
|
// command right now.
|
||||||
String env[] = new String[0];
|
String env[] = new String[0];
|
||||||
Process p = null;
|
Process p = null;
|
||||||
try {
|
try {
|
||||||
IHostShell hostShell = shellService.launchShell("", env, new SubProgressMonitor(monitor,3)); //$NON-NLS-1$
|
IHostShell hostShell = shellService.launchShell(
|
||||||
|
"", env, new SubProgressMonitor(monitor, 3)); //$NON-NLS-1$
|
||||||
hostShell.writeToShell(remote_command);
|
hostShell.writeToShell(remote_command);
|
||||||
p = new HostShellProcessAdapter(hostShell);
|
p = new HostShellProcessAdapter(hostShell);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
if (p != null) {
|
if (p != null) {
|
||||||
p.destroy();
|
p.destroy();
|
||||||
}
|
}
|
||||||
abort(Messages.RemoteRunLaunchDelegate_7, e, ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR);
|
abort(Messages.RemoteRunLaunchDelegate_7, e,
|
||||||
|
ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR);
|
||||||
}
|
}
|
||||||
monitor.done();
|
monitor.done();
|
||||||
return p;
|
return p;
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
# Ewa Matejska (PalmSource) - [158783] browse button for cdt remote path
|
# Ewa Matejska (PalmSource) - [158783] browse button for cdt remote path
|
||||||
# Johann Draschwandtner (Wind River) - [231827][remotecdt]Auto-compute default for Remote path
|
# Johann Draschwandtner (Wind River) - [231827][remotecdt]Auto-compute default for Remote path
|
||||||
# Anna Dushistova (MontaVista) - [244173][remotecdt][nls] Externalize Strings in RemoteRunLaunchDelegate
|
# Anna Dushistova (MontaVista) - [244173][remotecdt][nls] Externalize Strings in RemoteRunLaunchDelegate
|
||||||
|
# Anna Dushistova (MontaVista) - [181517][usability] Specify commands to be run before remote application launch
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
# NLS_MESSAGEFORMAT_VAR
|
# NLS_MESSAGEFORMAT_VAR
|
||||||
|
@ -29,6 +30,7 @@ RemoteRunLaunchDelegate_7=Could not create the hostShellProcess.\n
|
||||||
RemoteRunLaunchDelegate_8=Executing {0} {1}
|
RemoteRunLaunchDelegate_8=Executing {0} {1}
|
||||||
RemoteRunLaunchDelegate_9=Starting Program
|
RemoteRunLaunchDelegate_9=Starting Program
|
||||||
|
|
||||||
|
RemoteCMainTab_Prerun=Commands to execute before application
|
||||||
RemoteCMainTab_Program=Remote Absolute File Path for C/C++ Application:
|
RemoteCMainTab_Program=Remote Absolute File Path for C/C++ Application:
|
||||||
RemoteCMainTab_SkipDownload=Skip download to target path.
|
RemoteCMainTab_SkipDownload=Skip download to target path.
|
||||||
Remote_GDB_Debugger_Options=Remote GDB Debugger Options
|
Remote_GDB_Debugger_Options=Remote GDB Debugger Options
|
||||||
|
|
Loading…
Add table
Reference in a new issue