mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-05 07:15:39 +02:00
fixed bug #39581
This commit is contained in:
parent
3376e0abe0
commit
6a1a4e7365
10 changed files with 380 additions and 270 deletions
|
@ -23,7 +23,6 @@
|
||||||
<import plugin="org.eclipse.cdt.ui"/>
|
<import plugin="org.eclipse.cdt.ui"/>
|
||||||
<import plugin="org.eclipse.cdt.debug.core"/>
|
<import plugin="org.eclipse.cdt.debug.core"/>
|
||||||
<import plugin="org.eclipse.cdt.debug.ui"/>
|
<import plugin="org.eclipse.cdt.debug.ui"/>
|
||||||
<import plugin="org.eclipse.core.boot"/>
|
|
||||||
<import plugin="org.eclipse.core.runtime"/>
|
<import plugin="org.eclipse.core.runtime"/>
|
||||||
<import plugin="org.eclipse.core.variables"/>
|
<import plugin="org.eclipse.core.variables"/>
|
||||||
</requires>
|
</requires>
|
||||||
|
|
|
@ -368,9 +368,8 @@ abstract public class AbstractCLaunchDelegate extends LaunchConfigurationDelegat
|
||||||
protected IPath verifyProgramPath(ILaunchConfiguration config) throws CoreException {
|
protected IPath verifyProgramPath(ILaunchConfiguration config) throws CoreException {
|
||||||
ICProject cproject = verifyCProject(config);
|
ICProject cproject = verifyCProject(config);
|
||||||
IPath programPath = getProgramPath(config);
|
IPath programPath = getProgramPath(config);
|
||||||
if (programPath == null) {
|
if (programPath == null || programPath.isEmpty()) {
|
||||||
abort(LaunchMessages.getString("AbstractCLaunchDelegate.Program_file_not_specified"), null, //$NON-NLS-1$
|
return null;
|
||||||
ICDTLaunchConfigurationConstants.ERR_UNSPECIFIED_PROGRAM);
|
|
||||||
}
|
}
|
||||||
if (!programPath.isAbsolute()) {
|
if (!programPath.isAbsolute()) {
|
||||||
IFile wsProgramPath = cproject.getProject().getFile(programPath);
|
IFile wsProgramPath = cproject.getProject().getFile(programPath);
|
||||||
|
@ -745,7 +744,7 @@ abstract public class AbstractCLaunchDelegate extends LaunchConfigurationDelegat
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
}
|
}
|
||||||
Throwable exception = new FileNotFoundException(LaunchMessages.getFormattedString(
|
Throwable exception = new FileNotFoundException(LaunchMessages.getFormattedString(
|
||||||
"AbstractCLaunchDelegate.PROGRAM_PATH_not_binary", exePath.toOSString())); //$NON-NLS-1$
|
"AbstractCLaunchDelegate.Program_is_not_a_recongnized_executable", exePath.toOSString())); //$NON-NLS-1$
|
||||||
int code = ICDTLaunchConfigurationConstants.ERR_PROGRAM_NOT_BINARY;
|
int code = ICDTLaunchConfigurationConstants.ERR_PROGRAM_NOT_BINARY;
|
||||||
MultiStatus status = new MultiStatus(getPluginID(), code, LaunchMessages
|
MultiStatus status = new MultiStatus(getPluginID(), code, LaunchMessages
|
||||||
.getString("AbstractCLaunchDelegate.Program_is_not_a_recongnized_executable"), exception); //$NON-NLS-1$
|
.getString("AbstractCLaunchDelegate.Program_is_not_a_recongnized_executable"), exception); //$NON-NLS-1$
|
||||||
|
|
|
@ -8,6 +8,8 @@
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package org.eclipse.cdt.launch.internal;
|
package org.eclipse.cdt.launch.internal;
|
||||||
|
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.IBinaryParser.IBinaryObject;
|
import org.eclipse.cdt.core.IBinaryParser.IBinaryObject;
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
import org.eclipse.cdt.debug.core.CDIDebugModel;
|
import org.eclipse.cdt.debug.core.CDIDebugModel;
|
||||||
|
@ -19,6 +21,7 @@ import org.eclipse.cdt.debug.core.cdi.model.ICDITarget;
|
||||||
import org.eclipse.cdt.launch.AbstractCLaunchDelegate;
|
import org.eclipse.cdt.launch.AbstractCLaunchDelegate;
|
||||||
import org.eclipse.cdt.launch.internal.ui.LaunchMessages;
|
import org.eclipse.cdt.launch.internal.ui.LaunchMessages;
|
||||||
import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin;
|
import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin;
|
||||||
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
@ -43,6 +46,8 @@ public class LocalAttachLaunchDelegate extends AbstractCLaunchDelegate {
|
||||||
* org.eclipse.core.runtime.IProgressMonitor)
|
* org.eclipse.core.runtime.IProgressMonitor)
|
||||||
*/
|
*/
|
||||||
public void launch(ILaunchConfiguration config, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
|
public void launch(ILaunchConfiguration config, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
|
||||||
|
IBinaryObject exeFile = null;
|
||||||
|
|
||||||
if (monitor == null) {
|
if (monitor == null) {
|
||||||
monitor = new NullProgressMonitor();
|
monitor = new NullProgressMonitor();
|
||||||
}
|
}
|
||||||
|
@ -54,9 +59,21 @@ public class LocalAttachLaunchDelegate extends AbstractCLaunchDelegate {
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
monitor.worked(1);
|
monitor.worked(1);
|
||||||
IPath exePath = verifyProgramPath(config);
|
ICProject cproject = verifyCProject(config);
|
||||||
ICProject project = verifyCProject(config);
|
IPath exePath = getProgramPath(config);
|
||||||
IBinaryObject exeFile = verifyBinary(project, exePath);
|
if (exePath != null && !exePath.isEmpty()) {
|
||||||
|
if (!exePath.isAbsolute()) {
|
||||||
|
IFile wsProgramPath = cproject.getProject().getFile(exePath);
|
||||||
|
exePath = wsProgramPath.getLocation();
|
||||||
|
}
|
||||||
|
if (!exePath.toFile().exists()) {
|
||||||
|
abort(LaunchMessages.getString("AbstractCLaunchDelegate.Program_file_does_not_exist"), //$NON-NLS-1$
|
||||||
|
new FileNotFoundException(LaunchMessages.getFormattedString(
|
||||||
|
"AbstractCLaunchDelegate.PROGRAM_PATH_not_found", exePath.toOSString())), //$NON-NLS-1$
|
||||||
|
ICDTLaunchConfigurationConstants.ERR_PROGRAM_NOT_EXIST);
|
||||||
|
}
|
||||||
|
exeFile = verifyBinary(cproject, exePath);
|
||||||
|
}
|
||||||
|
|
||||||
if (mode.equals(ILaunchManager.DEBUG_MODE)) {
|
if (mode.equals(ILaunchManager.DEBUG_MODE)) {
|
||||||
ICDebugConfiguration debugConfig = getDebugConfig(config);
|
ICDebugConfiguration debugConfig = getDebugConfig(config);
|
||||||
|
@ -85,7 +102,7 @@ public class LocalAttachLaunchDelegate extends AbstractCLaunchDelegate {
|
||||||
setDefaultSourceLocator(launch, config);
|
setDefaultSourceLocator(launch, config);
|
||||||
ICDITarget[] targets = dsession.getTargets();
|
ICDITarget[] targets = dsession.getTargets();
|
||||||
for (int i = 0; i < targets.length; i++) {
|
for (int i = 0; i < targets.length; i++) {
|
||||||
CDIDebugModel.newDebugTarget(launch, project.getProject(), targets[i],
|
CDIDebugModel.newDebugTarget(launch, cproject.getProject(), targets[i],
|
||||||
renderTargetLabel(debugConfig), null, exeFile, true, true, false);
|
renderTargetLabel(debugConfig), null, exeFile, true, true, false);
|
||||||
}
|
}
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
|
@ -110,13 +127,10 @@ public class LocalAttachLaunchDelegate extends AbstractCLaunchDelegate {
|
||||||
// consult a status handler
|
// consult a status handler
|
||||||
IStatusHandler prompter = DebugPlugin.getDefault().getStatusHandler(fPromptStatus);
|
IStatusHandler prompter = DebugPlugin.getDefault().getStatusHandler(fPromptStatus);
|
||||||
if (prompter != null) {
|
if (prompter != null) {
|
||||||
try {
|
|
||||||
Object result = prompter.handleStatus(processPrompt, config);
|
Object result = prompter.handleStatus(processPrompt, config);
|
||||||
if (result instanceof Integer) {
|
if (result instanceof Integer) {
|
||||||
return ((Integer)result).intValue();
|
return ((Integer)result).intValue();
|
||||||
}
|
}
|
||||||
} catch (CoreException e) {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,6 +44,7 @@ import org.eclipse.debug.core.model.IProcess;
|
||||||
public class LocalRunLaunchDelegate extends AbstractCLaunchDelegate {
|
public class LocalRunLaunchDelegate extends AbstractCLaunchDelegate {
|
||||||
|
|
||||||
public void launch(ILaunchConfiguration config, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
|
public void launch(ILaunchConfiguration config, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
|
||||||
|
IBinaryObject exeFile = null;
|
||||||
if (monitor == null) {
|
if (monitor == null) {
|
||||||
monitor = new NullProgressMonitor();
|
monitor = new NullProgressMonitor();
|
||||||
}
|
}
|
||||||
|
@ -56,7 +57,9 @@ public class LocalRunLaunchDelegate extends AbstractCLaunchDelegate {
|
||||||
monitor.worked(1);
|
monitor.worked(1);
|
||||||
IPath exePath = verifyProgramPath(config);
|
IPath exePath = verifyProgramPath(config);
|
||||||
ICProject project = verifyCProject(config);
|
ICProject project = verifyCProject(config);
|
||||||
IBinaryObject exeFile = verifyBinary(project, exePath);
|
if (exePath != null) {
|
||||||
|
exeFile = verifyBinary(project, exePath);
|
||||||
|
}
|
||||||
String arguments[] = getProgramArgumentsArray(config);
|
String arguments[] = getProgramArgumentsArray(config);
|
||||||
|
|
||||||
// set the default source locator if required
|
// set the default source locator if required
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
package org.eclipse.cdt.launch.internal.ui;
|
package org.eclipse.cdt.launch.internal.ui;
|
||||||
|
|
||||||
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
|
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
|
||||||
import org.eclipse.cdt.launch.ui.CMainTab;
|
import org.eclipse.cdt.launch.ui.CMainAttachTab;
|
||||||
import org.eclipse.cdt.launch.ui.CoreFileDebuggerTab;
|
import org.eclipse.cdt.launch.ui.CoreFileDebuggerTab;
|
||||||
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
|
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
|
||||||
import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup;
|
import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup;
|
||||||
|
@ -27,7 +27,7 @@ public class CoreFileLaunchConfigurationTabGroup extends AbstractLaunchConfigura
|
||||||
*/
|
*/
|
||||||
public void createTabs(ILaunchConfigurationDialog dialog, String mode) {
|
public void createTabs(ILaunchConfigurationDialog dialog, String mode) {
|
||||||
ILaunchConfigurationTab[] tabs = new ILaunchConfigurationTab[] {
|
ILaunchConfigurationTab[] tabs = new ILaunchConfigurationTab[] {
|
||||||
new CMainTab(),
|
new CMainAttachTab(),
|
||||||
new CoreFileDebuggerTab(),
|
new CoreFileDebuggerTab(),
|
||||||
new SourceLookupTab(),
|
new SourceLookupTab(),
|
||||||
new CommonTab()
|
new CommonTab()
|
||||||
|
|
|
@ -25,8 +25,7 @@ AbstractCLaunchDelegate.building=Building
|
||||||
AbstractCLaunchDelegate.searching_for_errors=Searching for compile errors
|
AbstractCLaunchDelegate.searching_for_errors=Searching for compile errors
|
||||||
AbstractCLaunchDelegate.searching_for_errors_in=Searching for compile errors in
|
AbstractCLaunchDelegate.searching_for_errors_in=Searching for compile errors in
|
||||||
AbstractCLaunchDelegate.20=Building prerequisite project list
|
AbstractCLaunchDelegate.20=Building prerequisite project list
|
||||||
AbstractCLaunchDelegate.PROGRAM_PATH_not_binary=Program not Binary
|
AbstractCLaunchDelegate.Program_is_not_a_recongnized_executable=Program is not a recognized executable.
|
||||||
AbstractCLaunchDelegate.Program_is_not_a_recongnized_executable=Program not a recognized executable.
|
|
||||||
|
|
||||||
LocalRunLaunchDelegate.Launching_Local_C_Application=Launching Local C/C++ Application
|
LocalRunLaunchDelegate.Launching_Local_C_Application=Launching Local C/C++ Application
|
||||||
LocalRunLaunchDelegate.Failed_setting_runtime_option_though_debugger=Failed to set program arguments, environemt or working directory.
|
LocalRunLaunchDelegate.Failed_setting_runtime_option_though_debugger=Failed to set program arguments, environemt or working directory.
|
||||||
|
@ -35,7 +34,6 @@ LocalRunLaunchDelegate.Does_not_support_working_dir=Eclipse runtime does not sup
|
||||||
|
|
||||||
LocalAttachLaunchDelegate.Attaching_to_Local_C_Application=Attaching to Local C/C++ Application
|
LocalAttachLaunchDelegate.Attaching_to_Local_C_Application=Attaching to Local C/C++ Application
|
||||||
LocalAttachLaunchDelegate.No_Process_ID_selected=No Process ID selected
|
LocalAttachLaunchDelegate.No_Process_ID_selected=No Process ID selected
|
||||||
LocalAttachLaunchDelegate.No_Shell_available_in_Launch=No Shell available in Launch
|
|
||||||
LocalAttachLaunchDelegate.Select_Process=Select Process
|
LocalAttachLaunchDelegate.Select_Process=Select Process
|
||||||
LocalAttachLaunchDelegate.Platform_cannot_list_processes=Current platform does not support listing processes
|
LocalAttachLaunchDelegate.Platform_cannot_list_processes=Current platform does not support listing processes
|
||||||
LocalAttachLaunchDelegate.Select_Process_to_attach_debugger_to=Select a Process to attach debugger to:
|
LocalAttachLaunchDelegate.Select_Process_to_attach_debugger_to=Select a Process to attach debugger to:
|
||||||
|
@ -85,10 +83,11 @@ CMainTab.Program_does_not_exist=Program does not exist
|
||||||
CMainTab.Main=Main
|
CMainTab.Main=Main
|
||||||
CMainTab.&ProjectColon=&Project:
|
CMainTab.&ProjectColon=&Project:
|
||||||
CMainTab.C/C++_Application=C/C++ Application:
|
CMainTab.C/C++_Application=C/C++ Application:
|
||||||
CMainTab.Search...=Searc&h...
|
CMainTab.Search...=Searc&h Project...
|
||||||
CMainTab.Choose_program_to_run=Choose a &program to run:
|
CMainTab.Choose_program_to_run=Choose a &program to run:
|
||||||
CMainTab.Choose_program_to_run_from_NAME=Choose a program to run from {0}:
|
CMainTab.Choose_program_to_run_from_NAME=Choose a program to run from {0}:
|
||||||
CMainTab.UseTerminal=Connect process input && output to a terminal.
|
CMainTab.UseTerminal=Connect process input && output to a terminal.
|
||||||
|
CMainTab.Program_is_not_a_recongnized_executable=Program is not a recognized executable.
|
||||||
|
|
||||||
CDebuggerTab.Advanced_Options_Dialog_Title=Advanced Options
|
CDebuggerTab.Advanced_Options_Dialog_Title=Advanced Options
|
||||||
CDebuggerTab.Stop_at_main_on_startup=Stop at main() on startup
|
CDebuggerTab.Stop_at_main_on_startup=Stop at main() on startup
|
||||||
|
@ -137,6 +136,6 @@ Launch.common.Exception_occurred_reading_configuration_EXCEPTION=Exception occur
|
||||||
Launch.common.DebuggerColon=Debugger:
|
Launch.common.DebuggerColon=Debugger:
|
||||||
Launch.common.BinariesColon=Binaries:
|
Launch.common.BinariesColon=Binaries:
|
||||||
Launch.common.QualifierColon=Qualifier:
|
Launch.common.QualifierColon=Qualifier:
|
||||||
Launch.common.Browse_1=&Browse
|
Launch.common.Browse_1=&Browse...
|
||||||
Launch.common.Browse_2=B&rowse
|
Launch.common.Browse_2=B&rowse...
|
||||||
Launch.common.Project_does_not_exist=Project does not exist
|
Launch.common.Project_does_not_exist=Project does not exist
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
package org.eclipse.cdt.launch.internal.ui;
|
package org.eclipse.cdt.launch.internal.ui;
|
||||||
|
|
||||||
import org.eclipse.cdt.launch.ui.CDebuggerTab;
|
import org.eclipse.cdt.launch.ui.CDebuggerTab;
|
||||||
import org.eclipse.cdt.launch.ui.CMainTab;
|
import org.eclipse.cdt.launch.ui.CMainAttachTab;
|
||||||
import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup;
|
import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup;
|
||||||
import org.eclipse.debug.ui.CommonTab;
|
import org.eclipse.debug.ui.CommonTab;
|
||||||
import org.eclipse.debug.ui.ILaunchConfigurationDialog;
|
import org.eclipse.debug.ui.ILaunchConfigurationDialog;
|
||||||
|
@ -25,7 +25,7 @@ public class LocalAttachLaunchConfigurationTabGroup extends AbstractLaunchConfig
|
||||||
*/
|
*/
|
||||||
public void createTabs(ILaunchConfigurationDialog dialog, String mode) {
|
public void createTabs(ILaunchConfigurationDialog dialog, String mode) {
|
||||||
ILaunchConfigurationTab[] tabs = new ILaunchConfigurationTab[] {
|
ILaunchConfigurationTab[] tabs = new ILaunchConfigurationTab[] {
|
||||||
new CMainTab(),
|
new CMainAttachTab(),
|
||||||
new CDebuggerTab(true),
|
new CDebuggerTab(true),
|
||||||
new SourceLookupTab(),
|
new SourceLookupTab(),
|
||||||
new CommonTab()
|
new CommonTab()
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
package org.eclipse.cdt.launch.ui;
|
package org.eclipse.cdt.launch.ui;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
@ -18,8 +19,10 @@ import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.IBinary;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import org.eclipse.cdt.core.IBinaryParser;
|
||||||
|
import org.eclipse.cdt.core.ICExtensionReference;
|
||||||
|
import org.eclipse.cdt.core.IBinaryParser.IBinaryObject;
|
||||||
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
|
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
|
||||||
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
|
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
|
||||||
import org.eclipse.cdt.debug.core.ICDebugConfiguration;
|
import org.eclipse.cdt.debug.core.ICDebugConfiguration;
|
||||||
|
@ -27,7 +30,11 @@ import org.eclipse.cdt.debug.internal.ui.PixelConverter;
|
||||||
import org.eclipse.cdt.launch.internal.ui.AbstractCDebuggerTab;
|
import org.eclipse.cdt.launch.internal.ui.AbstractCDebuggerTab;
|
||||||
import org.eclipse.cdt.launch.internal.ui.LaunchMessages;
|
import org.eclipse.cdt.launch.internal.ui.LaunchMessages;
|
||||||
import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin;
|
import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin;
|
||||||
|
import org.eclipse.core.resources.IProject;
|
||||||
|
import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
import org.eclipse.core.runtime.Path;
|
||||||
import org.eclipse.debug.core.ILaunchConfiguration;
|
import org.eclipse.debug.core.ILaunchConfiguration;
|
||||||
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
|
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
|
||||||
import org.eclipse.jface.dialogs.Dialog;
|
import org.eclipse.jface.dialogs.Dialog;
|
||||||
|
@ -58,7 +65,9 @@ public class CDebuggerTab extends AbstractCDebuggerTab {
|
||||||
super(parentShell);
|
super(parentShell);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
* @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
|
* @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
|
||||||
*/
|
*/
|
||||||
protected Control createDialogArea(Composite parent) {
|
protected Control createDialogArea(Composite parent) {
|
||||||
|
@ -98,7 +107,9 @@ public class CDebuggerTab extends AbstractCDebuggerTab {
|
||||||
updateLaunchConfigurationDialog();
|
updateLaunchConfigurationDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
* @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
|
* @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
|
||||||
*/
|
*/
|
||||||
protected void configureShell(Shell newShell) {
|
protected void configureShell(Shell newShell) {
|
||||||
|
@ -119,11 +130,11 @@ public class CDebuggerTab extends AbstractCDebuggerTab {
|
||||||
fAttachMode = attachMode;
|
fAttachMode = attachMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void createControl(Composite parent) {
|
public void createControl(Composite parent) {
|
||||||
Composite comp = new Composite(parent, SWT.NONE);
|
Composite comp = new Composite(parent, SWT.NONE);
|
||||||
setControl(comp);
|
setControl(comp);
|
||||||
LaunchUIPlugin.getDefault().getWorkbench().getHelpSystem().setHelp( getControl(), ICDTLaunchHelpContextIds.LAUNCH_CONFIGURATION_DIALOG_DEBBUGER_TAB );
|
LaunchUIPlugin.getDefault().getWorkbench().getHelpSystem().setHelp(getControl(),
|
||||||
|
ICDTLaunchHelpContextIds.LAUNCH_CONFIGURATION_DIALOG_DEBBUGER_TAB);
|
||||||
GridLayout layout = new GridLayout(2, true);
|
GridLayout layout = new GridLayout(2, true);
|
||||||
comp.setLayout(layout);
|
comp.setLayout(layout);
|
||||||
GridData gd = new GridData();
|
GridData gd = new GridData();
|
||||||
|
@ -161,14 +172,16 @@ public class CDebuggerTab extends AbstractCDebuggerTab {
|
||||||
String debuggerPlatform = debugConfigs[i].getPlatform();
|
String debuggerPlatform = debugConfigs[i].getPlatform();
|
||||||
if (validatePlatform(config, debugConfigs[i])) {
|
if (validatePlatform(config, debugConfigs[i])) {
|
||||||
list.add(debugConfigs[i]);
|
list.add(debugConfigs[i]);
|
||||||
// select first exact matching debugger for platform or requested selection
|
// select first exact matching debugger for platform or
|
||||||
|
// requested selection
|
||||||
if ( (defaultSelection.equals("") && debuggerPlatform.equalsIgnoreCase(configPlatform))) { //$NON-NLS-1$
|
if ( (defaultSelection.equals("") && debuggerPlatform.equalsIgnoreCase(configPlatform))) { //$NON-NLS-1$
|
||||||
defaultSelection = debugConfigs[i].getID();
|
defaultSelection = debugConfigs[i].getID();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// if no selection meaning nothing in config the force initdefault on tab
|
// if no selection meaning nothing in config the force initdefault on
|
||||||
|
// tab
|
||||||
setInitializeDefault(selection.equals("") ? true : false); //$NON-NLS-1$
|
setInitializeDefault(selection.equals("") ? true : false); //$NON-NLS-1$
|
||||||
loadDebuggerCombo((ICDebugConfiguration[])list.toArray(new ICDebugConfiguration[list.size()]), defaultSelection);
|
loadDebuggerCombo((ICDebugConfiguration[])list.toArray(new ICDebugConfiguration[list.size()]), defaultSelection);
|
||||||
}
|
}
|
||||||
|
@ -181,10 +194,13 @@ public class CDebuggerTab extends AbstractCDebuggerTab {
|
||||||
public void setDefaults(ILaunchConfigurationWorkingCopy config) {
|
public void setDefaults(ILaunchConfigurationWorkingCopy config) {
|
||||||
super.setDefaults(config);
|
super.setDefaults(config);
|
||||||
if (fAttachMode) {
|
if (fAttachMode) {
|
||||||
config.setAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE, ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH );
|
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
|
||||||
|
ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH);
|
||||||
} else {
|
} else {
|
||||||
config.setAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE, ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN );
|
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
|
||||||
config.setAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, ICDTLaunchConfigurationConstants.DEBUGGER_STOP_AT_MAIN_DEFAULT );
|
ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN);
|
||||||
|
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN,
|
||||||
|
ICDTLaunchConfigurationConstants.DEBUGGER_STOP_AT_MAIN_DEFAULT);
|
||||||
}
|
}
|
||||||
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ENABLE_VARIABLE_BOOKKEEPING, false);
|
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ENABLE_VARIABLE_BOOKKEEPING, false);
|
||||||
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ENABLE_REGISTER_BOOKKEEPING, false);
|
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ENABLE_REGISTER_BOOKKEEPING, false);
|
||||||
|
@ -197,8 +213,7 @@ public class CDebuggerTab extends AbstractCDebuggerTab {
|
||||||
String id = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID, ""); //$NON-NLS-1$
|
String id = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID, ""); //$NON-NLS-1$
|
||||||
loadDebuggerComboBox(config, id);
|
loadDebuggerComboBox(config, id);
|
||||||
initializeCommonControls(config);
|
initializeCommonControls(config);
|
||||||
}
|
} catch (CoreException e) {
|
||||||
catch( CoreException e ) {
|
|
||||||
}
|
}
|
||||||
setInitializing(false);
|
setInitializing(false);
|
||||||
}
|
}
|
||||||
|
@ -206,11 +221,12 @@ public class CDebuggerTab extends AbstractCDebuggerTab {
|
||||||
public void performApply(ILaunchConfigurationWorkingCopy config) {
|
public void performApply(ILaunchConfigurationWorkingCopy config) {
|
||||||
super.performApply(config);
|
super.performApply(config);
|
||||||
if (fAttachMode) {
|
if (fAttachMode) {
|
||||||
config.setAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE, ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH );
|
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
|
||||||
}
|
ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH);
|
||||||
else {
|
} else {
|
||||||
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, fStopInMain.getSelection());
|
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, fStopInMain.getSelection());
|
||||||
config.setAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE, ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN );
|
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
|
||||||
|
ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN);
|
||||||
}
|
}
|
||||||
applyAdvancedAttributes(config);
|
applyAdvancedAttributes(config);
|
||||||
}
|
}
|
||||||
|
@ -220,7 +236,9 @@ public class CDebuggerTab extends AbstractCDebuggerTab {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
ICDebugConfiguration debugConfig = getDebugConfig();
|
ICDebugConfiguration debugConfig = getDebugConfig();
|
||||||
String mode = fAttachMode ? ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH : ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN;
|
String mode = fAttachMode
|
||||||
|
? ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH
|
||||||
|
: ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN;
|
||||||
if (!debugConfig.supportsMode(mode)) {
|
if (!debugConfig.supportsMode(mode)) {
|
||||||
setErrorMessage(MessageFormat.format(LaunchMessages.getString("CDebuggerTab.Mode_not_supported"), new String[]{mode})); //$NON-NLS-1$
|
setErrorMessage(MessageFormat.format(LaunchMessages.getString("CDebuggerTab.Mode_not_supported"), new String[]{mode})); //$NON-NLS-1$
|
||||||
return false;
|
return false;
|
||||||
|
@ -238,17 +256,53 @@ public class CDebuggerTab extends AbstractCDebuggerTab {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean validateCPU(ILaunchConfiguration config, ICDebugConfiguration debugConfig) {
|
protected boolean validateCPU(ILaunchConfiguration config, ICDebugConfiguration debugConfig) {
|
||||||
ICElement ce = getContext( config, null );
|
IBinaryObject binaryFile = null;
|
||||||
String projectCPU = ICDebugConfiguration.CPU_NATIVE;
|
try {
|
||||||
if ( ce != null ) {
|
binaryFile = getBinary(config);
|
||||||
if ( ce instanceof IBinary ) {
|
} catch (CoreException e) {
|
||||||
IBinary bin = (IBinary)ce;
|
setErrorMessage(e.getLocalizedMessage());
|
||||||
projectCPU = bin.getCPU();
|
|
||||||
}
|
}
|
||||||
|
String projectCPU = ICDebugConfiguration.CPU_NATIVE;
|
||||||
|
if (binaryFile != null) {
|
||||||
|
projectCPU = binaryFile.getCPU();
|
||||||
}
|
}
|
||||||
return debugConfig.supportsCPU(projectCPU);
|
return debugConfig.supportsCPU(projectCPU);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected IBinaryObject getBinary(ILaunchConfiguration config) throws CoreException {
|
||||||
|
String programName = null;
|
||||||
|
String projectName = null;
|
||||||
|
try {
|
||||||
|
projectName = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, (String)null);
|
||||||
|
programName = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, (String)null);
|
||||||
|
} catch (CoreException e) {
|
||||||
|
}
|
||||||
|
IPath exePath = new Path(programName);
|
||||||
|
if (projectName != null && !projectName.equals("")) { //$NON-NLS-1$
|
||||||
|
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
|
||||||
|
ICExtensionReference[] parserRef = CCorePlugin.getDefault().getBinaryParserExtensions(project);
|
||||||
|
for (int i = 0; i < parserRef.length; i++) {
|
||||||
|
try {
|
||||||
|
IBinaryParser parser = (IBinaryParser)parserRef[i].createExtension();
|
||||||
|
IBinaryObject exe = (IBinaryObject)parser.getBinary(exePath);
|
||||||
|
if (exe != null) {
|
||||||
|
return exe;
|
||||||
|
}
|
||||||
|
} catch (ClassCastException e) {
|
||||||
|
} catch (IOException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
IBinaryParser parser = CCorePlugin.getDefault().getDefaultBinaryParser();
|
||||||
|
try {
|
||||||
|
IBinaryObject exe = (IBinaryObject)parser.getBinary(exePath);
|
||||||
|
return exe;
|
||||||
|
} catch (ClassCastException e) {
|
||||||
|
} catch (IOException e) {
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
protected boolean validateDebuggerConfig(ILaunchConfiguration config) {
|
protected boolean validateDebuggerConfig(ILaunchConfiguration config) {
|
||||||
ICDebugConfiguration debugConfig = getDebugConfig();
|
ICDebugConfiguration debugConfig = getDebugConfig();
|
||||||
if (debugConfig == null) {
|
if (debugConfig == null) {
|
||||||
|
@ -319,16 +373,20 @@ public class CDebuggerTab extends AbstractCDebuggerTab {
|
||||||
private void initializeAdvancedAttributes(ILaunchConfiguration config) {
|
private void initializeAdvancedAttributes(ILaunchConfiguration config) {
|
||||||
Map attr = getAdvancedAttributes();
|
Map attr = getAdvancedAttributes();
|
||||||
try {
|
try {
|
||||||
Boolean varBookkeeping = ( config.getAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ENABLE_VARIABLE_BOOKKEEPING, false ) ) ? Boolean.TRUE : Boolean.FALSE;
|
Boolean varBookkeeping = (config.getAttribute(
|
||||||
|
ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ENABLE_VARIABLE_BOOKKEEPING, false))
|
||||||
|
? Boolean.TRUE
|
||||||
|
: Boolean.FALSE;
|
||||||
attr.put(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ENABLE_VARIABLE_BOOKKEEPING, varBookkeeping);
|
attr.put(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ENABLE_VARIABLE_BOOKKEEPING, varBookkeeping);
|
||||||
}
|
} catch (CoreException e) {
|
||||||
catch( CoreException e ) {
|
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
Boolean regBookkeeping = ( config.getAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ENABLE_REGISTER_BOOKKEEPING, false ) ) ? Boolean.TRUE : Boolean.FALSE;
|
Boolean regBookkeeping = (config.getAttribute(
|
||||||
|
ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ENABLE_REGISTER_BOOKKEEPING, false))
|
||||||
|
? Boolean.TRUE
|
||||||
|
: Boolean.FALSE;
|
||||||
attr.put(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ENABLE_REGISTER_BOOKKEEPING, regBookkeeping);
|
attr.put(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ENABLE_REGISTER_BOOKKEEPING, regBookkeeping);
|
||||||
}
|
} catch (CoreException e) {
|
||||||
catch( CoreException e ) {
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -336,17 +394,21 @@ public class CDebuggerTab extends AbstractCDebuggerTab {
|
||||||
Map attr = getAdvancedAttributes();
|
Map attr = getAdvancedAttributes();
|
||||||
Object varBookkeeping = attr.get(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ENABLE_VARIABLE_BOOKKEEPING);
|
Object varBookkeeping = attr.get(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ENABLE_VARIABLE_BOOKKEEPING);
|
||||||
if (varBookkeeping instanceof Boolean)
|
if (varBookkeeping instanceof Boolean)
|
||||||
config.setAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ENABLE_VARIABLE_BOOKKEEPING, ((Boolean)varBookkeeping).booleanValue() );
|
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ENABLE_VARIABLE_BOOKKEEPING,
|
||||||
|
((Boolean)varBookkeeping).booleanValue());
|
||||||
Object regBookkeeping = attr.get(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ENABLE_REGISTER_BOOKKEEPING);
|
Object regBookkeeping = attr.get(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ENABLE_REGISTER_BOOKKEEPING);
|
||||||
if (regBookkeeping instanceof Boolean)
|
if (regBookkeeping instanceof Boolean)
|
||||||
config.setAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ENABLE_REGISTER_BOOKKEEPING, ((Boolean)regBookkeeping).booleanValue() );
|
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ENABLE_REGISTER_BOOKKEEPING,
|
||||||
|
((Boolean)regBookkeeping).booleanValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Shell getShell() {
|
protected Shell getShell() {
|
||||||
return super.getShell();
|
return super.getShell();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
* @see org.eclipse.debug.ui.ILaunchConfigurationTab#dispose()
|
* @see org.eclipse.debug.ui.ILaunchConfigurationTab#dispose()
|
||||||
*/
|
*/
|
||||||
public void dispose() {
|
public void dispose() {
|
||||||
|
@ -357,15 +419,17 @@ public class CDebuggerTab extends AbstractCDebuggerTab {
|
||||||
protected void initializeCommonControls(ILaunchConfiguration config) {
|
protected void initializeCommonControls(ILaunchConfiguration config) {
|
||||||
try {
|
try {
|
||||||
if (!fAttachMode) {
|
if (!fAttachMode) {
|
||||||
fStopInMain.setSelection( config.getAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, ICDTLaunchConfigurationConstants.DEBUGGER_STOP_AT_MAIN_DEFAULT ) );
|
fStopInMain.setSelection(config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN,
|
||||||
|
ICDTLaunchConfigurationConstants.DEBUGGER_STOP_AT_MAIN_DEFAULT));
|
||||||
}
|
}
|
||||||
initializeAdvancedAttributes(config);
|
initializeAdvancedAttributes(config);
|
||||||
}
|
} catch (CoreException e) {
|
||||||
catch( CoreException e ) {
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
* @see org.eclipse.cdt.launch.internal.ui.AbstractCDebuggerTab#setInitializeDefault(boolean)
|
* @see org.eclipse.cdt.launch.internal.ui.AbstractCDebuggerTab#setInitializeDefault(boolean)
|
||||||
*/
|
*/
|
||||||
protected void setInitializeDefault(boolean init) {
|
protected void setInitializeDefault(boolean init) {
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2005 QNX Software Systems and others. All rights reserved. This
|
||||||
|
* program and the accompanying materials are made available under the terms of
|
||||||
|
* the Common Public License v1.0 which accompanies this distribution, and is
|
||||||
|
* available at http://www.eclipse.org/legal/cpl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors: QNX Software Systems - initial API and implementation
|
||||||
|
******************************************************************************/
|
||||||
|
package org.eclipse.cdt.launch.ui;
|
||||||
|
|
||||||
|
import org.eclipse.debug.core.ILaunchConfiguration;
|
||||||
|
|
||||||
|
|
||||||
|
public class CMainAttachTab extends CMainTab {
|
||||||
|
|
||||||
|
public boolean isValid(ILaunchConfiguration config) {
|
||||||
|
if (super.isValid(config) == false) {
|
||||||
|
String name = fProgText.getText().trim();
|
||||||
|
if (name.length() == 0) { // allow no program for attach config.
|
||||||
|
setErrorMessage(null);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -8,10 +8,14 @@
|
||||||
**************************************************************************************************/
|
**************************************************************************************************/
|
||||||
package org.eclipse.cdt.launch.ui;
|
package org.eclipse.cdt.launch.ui;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
|
import org.eclipse.cdt.core.IBinaryParser;
|
||||||
import org.eclipse.cdt.core.ICDescriptor;
|
import org.eclipse.cdt.core.ICDescriptor;
|
||||||
|
import org.eclipse.cdt.core.ICExtensionReference;
|
||||||
|
import org.eclipse.cdt.core.IBinaryParser.IBinaryObject;
|
||||||
import org.eclipse.cdt.core.model.CModelException;
|
import org.eclipse.cdt.core.model.CModelException;
|
||||||
import org.eclipse.cdt.core.model.CoreModel;
|
import org.eclipse.cdt.core.model.CoreModel;
|
||||||
import org.eclipse.cdt.core.model.IBinary;
|
import org.eclipse.cdt.core.model.IBinary;
|
||||||
|
@ -27,13 +31,11 @@ import org.eclipse.cdt.ui.CElementImageDescriptor;
|
||||||
import org.eclipse.cdt.ui.CElementLabelProvider;
|
import org.eclipse.cdt.ui.CElementLabelProvider;
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
import org.eclipse.cdt.utils.pty.PTY;
|
import org.eclipse.cdt.utils.pty.PTY;
|
||||||
import org.eclipse.core.resources.IFile;
|
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.resources.IResource;
|
|
||||||
import org.eclipse.core.resources.ResourcesPlugin;
|
import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IStatus;
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.Status;
|
import org.eclipse.core.runtime.Path;
|
||||||
import org.eclipse.debug.core.ILaunchConfiguration;
|
import org.eclipse.debug.core.ILaunchConfiguration;
|
||||||
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
|
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
|
||||||
import org.eclipse.jface.dialogs.MessageDialog;
|
import org.eclipse.jface.dialogs.MessageDialog;
|
||||||
|
@ -52,14 +54,11 @@ import org.eclipse.swt.layout.GridLayout;
|
||||||
import org.eclipse.swt.widgets.Button;
|
import org.eclipse.swt.widgets.Button;
|
||||||
import org.eclipse.swt.widgets.Composite;
|
import org.eclipse.swt.widgets.Composite;
|
||||||
import org.eclipse.swt.widgets.Display;
|
import org.eclipse.swt.widgets.Display;
|
||||||
|
import org.eclipse.swt.widgets.FileDialog;
|
||||||
import org.eclipse.swt.widgets.Label;
|
import org.eclipse.swt.widgets.Label;
|
||||||
import org.eclipse.swt.widgets.Text;
|
import org.eclipse.swt.widgets.Text;
|
||||||
import org.eclipse.ui.dialogs.ElementListSelectionDialog;
|
import org.eclipse.ui.dialogs.ElementListSelectionDialog;
|
||||||
import org.eclipse.ui.dialogs.ElementTreeSelectionDialog;
|
|
||||||
import org.eclipse.ui.dialogs.ISelectionStatusValidator;
|
|
||||||
import org.eclipse.ui.dialogs.TwoPaneElementSelector;
|
import org.eclipse.ui.dialogs.TwoPaneElementSelector;
|
||||||
import org.eclipse.ui.model.WorkbenchContentProvider;
|
|
||||||
import org.eclipse.ui.model.WorkbenchLabelProvider;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A launch configuration tab that displays and edits project and main type name launch
|
* A launch configuration tab that displays and edits project and main type name launch
|
||||||
|
@ -90,8 +89,6 @@ public class CMainTab extends CLaunchConfigurationTab {
|
||||||
|
|
||||||
private String filterPlatform = EMPTY_STRING;
|
private String filterPlatform = EMPTY_STRING;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public CMainTab() {
|
public CMainTab() {
|
||||||
this(false);
|
this(false);
|
||||||
}
|
}
|
||||||
|
@ -375,53 +372,12 @@ public class CMainTab extends CLaunchConfigurationTab {
|
||||||
LaunchMessages.getString("CMainTab.Enter_project_before_browsing_for_program")); //$NON-NLS-1$
|
LaunchMessages.getString("CMainTab.Enter_project_before_browsing_for_program")); //$NON-NLS-1$
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
FileDialog fileDialog = new FileDialog(getShell(), SWT.NONE);
|
||||||
ElementTreeSelectionDialog dialog;
|
fileDialog.setFileName(fProgText.getText());
|
||||||
WorkbenchLabelProvider labelProvider = new WorkbenchLabelProvider();
|
String text= fileDialog.open();
|
||||||
WorkbenchContentProvider contentProvider = new WorkbenchContentProvider();
|
if (text != null) {
|
||||||
dialog = new ElementTreeSelectionDialog(getShell(), labelProvider, contentProvider);
|
fProgText.setText(text);
|
||||||
dialog.setTitle(LaunchMessages.getString("CMainTab.Program_selection")); //$NON-NLS-1$
|
|
||||||
dialog.setMessage(LaunchMessages.getFormattedString(
|
|
||||||
"CMainTab.Choose_program_to_run_from_NAME", cproject.getResource().getName())); //$NON-NLS-1$
|
|
||||||
dialog.setBlockOnOpen(true);
|
|
||||||
dialog.setAllowMultiple(false);
|
|
||||||
dialog.setInput(cproject.getResource());
|
|
||||||
dialog.setValidator(new ISelectionStatusValidator() {
|
|
||||||
|
|
||||||
public IStatus validate(Object[] selection) {
|
|
||||||
if (selection.length == 0 || !(selection[0] instanceof IFile)) {
|
|
||||||
return new Status(IStatus.ERROR, LaunchUIPlugin.getUniqueIdentifier(), 1, LaunchMessages
|
|
||||||
.getString("CMainTab.Selection_must_be_file"), null); //$NON-NLS-1$
|
|
||||||
}
|
}
|
||||||
try {
|
|
||||||
ICElement celement = cproject.findElement(((IFile) selection[0]).getProjectRelativePath());
|
|
||||||
if (celement == null
|
|
||||||
|| (celement.getElementType() != ICElement.C_BINARY && celement.getElementType() != ICElement.C_ARCHIVE)) {
|
|
||||||
return new Status(IStatus.ERROR, LaunchUIPlugin.getUniqueIdentifier(), 1, LaunchMessages
|
|
||||||
.getString("CMainTab.Selection_must_be_binary_file"), null); //$NON-NLS-1$
|
|
||||||
}
|
|
||||||
|
|
||||||
return new Status(IStatus.OK, LaunchUIPlugin.getUniqueIdentifier(), IStatus.OK, celement.getResource()
|
|
||||||
.getName(), null);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
return new Status(IStatus.ERROR, LaunchUIPlugin.PLUGIN_ID, 1, LaunchMessages
|
|
||||||
.getString("CMainTab.Selection_must_be_binary_file"), null); //$NON-NLS-1$
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (dialog.open() == Window.CANCEL) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Object[] results = dialog.getResult();
|
|
||||||
|
|
||||||
try {
|
|
||||||
fProgText.setText(((IResource) results[0]).getProjectRelativePath().toString());
|
|
||||||
} catch (Exception ex) {
|
|
||||||
/* Make sure it is a file */
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -554,6 +510,10 @@ public class CMainTab extends CLaunchConfigurationTab {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(name);
|
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(name);
|
||||||
|
if (!project.isOpen()) {
|
||||||
|
setErrorMessage(LaunchMessages.getString("CMainTab.Project_must_be_opened")); //$NON-NLS-1$
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
name = fProgText.getText().trim();
|
name = fProgText.getText().trim();
|
||||||
if (name.length() == 0) {
|
if (name.length() == 0) {
|
||||||
|
@ -564,17 +524,61 @@ public class CMainTab extends CLaunchConfigurationTab {
|
||||||
setErrorMessage(LaunchMessages.getString("CMainTab.Program_does_not_exist")); //$NON-NLS-1$
|
setErrorMessage(LaunchMessages.getString("CMainTab.Program_does_not_exist")); //$NON-NLS-1$
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!project.isOpen()) {
|
IPath exePath = new Path(name);
|
||||||
setErrorMessage(LaunchMessages.getString("CMainTab.Project_must_be_opened")); //$NON-NLS-1$
|
if (!exePath.isAbsolute()) {
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!project.getFile(name).exists()) {
|
if (!project.getFile(name).exists()) {
|
||||||
setErrorMessage(LaunchMessages.getString("CMainTab.Program_does_not_exist")); //$NON-NLS-1$
|
setErrorMessage(LaunchMessages.getString("CMainTab.Program_does_not_exist")); //$NON-NLS-1$
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
exePath = project.getFile(name).getLocation();
|
||||||
|
} else {
|
||||||
|
if (!exePath.toFile().exists()) {
|
||||||
|
setErrorMessage(LaunchMessages.getString("CMainTab.Program_does_not_exist")); //$NON-NLS-1$
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
if (!isBinary(project, exePath)) {
|
||||||
|
setErrorMessage(LaunchMessages.getString("CMainTab.Program_is_not_a_recongnized_executable")); //$NON-NLS-1$
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} catch (CoreException e) {
|
||||||
|
LaunchUIPlugin.log(e);
|
||||||
|
setErrorMessage(e.getLocalizedMessage());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param project
|
||||||
|
* @param exePath
|
||||||
|
* @return
|
||||||
|
* @throws CoreException
|
||||||
|
*/
|
||||||
|
protected boolean isBinary(IProject project, IPath exePath) throws CoreException {
|
||||||
|
ICExtensionReference[] parserRef = CCorePlugin.getDefault().getBinaryParserExtensions(project);
|
||||||
|
for (int i = 0; i < parserRef.length; i++) {
|
||||||
|
try {
|
||||||
|
IBinaryParser parser = (IBinaryParser)parserRef[i].createExtension();
|
||||||
|
IBinaryObject exe = (IBinaryObject)parser.getBinary(exePath);
|
||||||
|
if (exe != null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} catch (ClassCastException e) {
|
||||||
|
} catch (IOException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
IBinaryParser parser = CCorePlugin.getDefault().getDefaultBinaryParser();
|
||||||
|
try {
|
||||||
|
IBinaryObject exe = (IBinaryObject)parser.getBinary(exePath);
|
||||||
|
return exe != null;
|
||||||
|
} catch (ClassCastException e) {
|
||||||
|
} catch (IOException e) {
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Reference in a new issue