diff --git a/launch/org.eclipse.cdt.launch/plugin.xml b/launch/org.eclipse.cdt.launch/plugin.xml
index d435a49de3b..b3968c1b899 100644
--- a/launch/org.eclipse.cdt.launch/plugin.xml
+++ b/launch/org.eclipse.cdt.launch/plugin.xml
@@ -23,7 +23,6 @@
-
diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/AbstractCLaunchDelegate.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/AbstractCLaunchDelegate.java
index 04ce1eaaee6..95dfd5355ce 100644
--- a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/AbstractCLaunchDelegate.java
+++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/AbstractCLaunchDelegate.java
@@ -368,9 +368,8 @@ abstract public class AbstractCLaunchDelegate extends LaunchConfigurationDelegat
protected IPath verifyProgramPath(ILaunchConfiguration config) throws CoreException {
ICProject cproject = verifyCProject(config);
IPath programPath = getProgramPath(config);
- if (programPath == null) {
- abort(LaunchMessages.getString("AbstractCLaunchDelegate.Program_file_not_specified"), null, //$NON-NLS-1$
- ICDTLaunchConfigurationConstants.ERR_UNSPECIFIED_PROGRAM);
+ if (programPath == null || programPath.isEmpty()) {
+ return null;
}
if (!programPath.isAbsolute()) {
IFile wsProgramPath = cproject.getProject().getFile(programPath);
@@ -745,7 +744,7 @@ abstract public class AbstractCLaunchDelegate extends LaunchConfigurationDelegat
} catch (IOException e) {
}
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;
MultiStatus status = new MultiStatus(getPluginID(), code, LaunchMessages
.getString("AbstractCLaunchDelegate.Program_is_not_a_recongnized_executable"), exception); //$NON-NLS-1$
diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/LocalAttachLaunchDelegate.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/LocalAttachLaunchDelegate.java
index 31a6e10ad39..bfee79750e2 100644
--- a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/LocalAttachLaunchDelegate.java
+++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/LocalAttachLaunchDelegate.java
@@ -8,6 +8,8 @@
******************************************************************************/
package org.eclipse.cdt.launch.internal;
+import java.io.FileNotFoundException;
+
import org.eclipse.cdt.core.IBinaryParser.IBinaryObject;
import org.eclipse.cdt.core.model.ICProject;
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.internal.ui.LaunchMessages;
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.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -43,6 +46,8 @@ public class LocalAttachLaunchDelegate extends AbstractCLaunchDelegate {
* org.eclipse.core.runtime.IProgressMonitor)
*/
public void launch(ILaunchConfiguration config, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
+ IBinaryObject exeFile = null;
+
if (monitor == null) {
monitor = new NullProgressMonitor();
}
@@ -54,17 +59,29 @@ public class LocalAttachLaunchDelegate extends AbstractCLaunchDelegate {
}
try {
monitor.worked(1);
- IPath exePath = verifyProgramPath(config);
- ICProject project = verifyCProject(config);
- IBinaryObject exeFile = verifyBinary(project, exePath);
+ ICProject cproject = verifyCProject(config);
+ IPath exePath = getProgramPath(config);
+ 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)) {
ICDebugConfiguration debugConfig = getDebugConfig(config);
ICDISession dsession = null;
String debugMode = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
- ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN);
+ ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN);
if (debugMode.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH)) {
- //It may be that we have already been provided with a
+ // It may be that we have already been provided with a
// process id
if (config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_ATTACH_PROCESS_ID, -1) == -1) {
int pid = promptForProcessID(config);
@@ -79,14 +96,14 @@ public class LocalAttachLaunchDelegate extends AbstractCLaunchDelegate {
cancel("", -1); //$NON-NLS-1$\
} else {
dsession = debugConfig.createDebugger().createDebuggerSession(launch, exeFile,
- new SubProgressMonitor(monitor, 8));
+ new SubProgressMonitor(monitor, 8));
try {
// set the default source locator if required
setDefaultSourceLocator(launch, config);
ICDITarget[] targets = dsession.getTargets();
for (int i = 0; i < targets.length; i++) {
- CDIDebugModel.newDebugTarget(launch, project.getProject(), targets[i],
- renderTargetLabel(debugConfig), null, exeFile, true, true, false);
+ CDIDebugModel.newDebugTarget(launch, cproject.getProject(), targets[i],
+ renderTargetLabel(debugConfig), null, exeFile, true, true, false);
}
} catch (CoreException e) {
try {
@@ -105,17 +122,14 @@ public class LocalAttachLaunchDelegate extends AbstractCLaunchDelegate {
}
protected int promptForProcessID(ILaunchConfiguration config) throws CoreException {
- IStatus fPromptStatus = new Status(IStatus.INFO, "org.eclipse.debug.ui", 200, "", null); //$NON-NLS-1$//$NON-NLS-2$
- IStatus processPrompt = new Status(IStatus.INFO, "org.eclipse.cdt.launch", 100, "", null); //$NON-NLS-1$//$NON-NLS-2$
+ IStatus fPromptStatus = new Status(IStatus.INFO, "org.eclipse.debug.ui", 200, "", null); //$NON-NLS-1$//$NON-NLS-2$
+ IStatus processPrompt = new Status(IStatus.INFO, "org.eclipse.cdt.launch", 100, "", null); //$NON-NLS-1$//$NON-NLS-2$
// consult a status handler
IStatusHandler prompter = DebugPlugin.getDefault().getStatusHandler(fPromptStatus);
if (prompter != null) {
- try {
- Object result = prompter.handleStatus(processPrompt, config);
- if (result instanceof Integer) {
- return ((Integer)result).intValue();
- }
- } catch (CoreException e) {
+ Object result = prompter.handleStatus(processPrompt, config);
+ if (result instanceof Integer) {
+ return ((Integer)result).intValue();
}
}
return -1;
diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/LocalRunLaunchDelegate.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/LocalRunLaunchDelegate.java
index b33a48291fe..0d2511a65a4 100644
--- a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/LocalRunLaunchDelegate.java
+++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/LocalRunLaunchDelegate.java
@@ -44,6 +44,7 @@ import org.eclipse.debug.core.model.IProcess;
public class LocalRunLaunchDelegate extends AbstractCLaunchDelegate {
public void launch(ILaunchConfiguration config, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
+ IBinaryObject exeFile = null;
if (monitor == null) {
monitor = new NullProgressMonitor();
}
@@ -56,7 +57,9 @@ public class LocalRunLaunchDelegate extends AbstractCLaunchDelegate {
monitor.worked(1);
IPath exePath = verifyProgramPath(config);
ICProject project = verifyCProject(config);
- IBinaryObject exeFile = verifyBinary(project, exePath);
+ if (exePath != null) {
+ exeFile = verifyBinary(project, exePath);
+ }
String arguments[] = getProgramArgumentsArray(config);
// set the default source locator if required
diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/CoreFileLaunchConfigurationTabGroup.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/CoreFileLaunchConfigurationTabGroup.java
index fda430ad965..99a6f26d5d5 100644
--- a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/CoreFileLaunchConfigurationTabGroup.java
+++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/CoreFileLaunchConfigurationTabGroup.java
@@ -11,7 +11,7 @@
package org.eclipse.cdt.launch.internal.ui;
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.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup;
@@ -27,7 +27,7 @@ public class CoreFileLaunchConfigurationTabGroup extends AbstractLaunchConfigura
*/
public void createTabs(ILaunchConfigurationDialog dialog, String mode) {
ILaunchConfigurationTab[] tabs = new ILaunchConfigurationTab[] {
- new CMainTab(),
+ new CMainAttachTab(),
new CoreFileDebuggerTab(),
new SourceLookupTab(),
new CommonTab()
diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LaunchMessages.properties b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LaunchMessages.properties
index 5e6fbfc3d65..8ad6538a574 100644
--- a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LaunchMessages.properties
+++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LaunchMessages.properties
@@ -25,8 +25,7 @@ AbstractCLaunchDelegate.building=Building
AbstractCLaunchDelegate.searching_for_errors=Searching for compile errors
AbstractCLaunchDelegate.searching_for_errors_in=Searching for compile errors in
AbstractCLaunchDelegate.20=Building prerequisite project list
-AbstractCLaunchDelegate.PROGRAM_PATH_not_binary=Program not Binary
-AbstractCLaunchDelegate.Program_is_not_a_recongnized_executable=Program not a recognized executable.
+AbstractCLaunchDelegate.Program_is_not_a_recongnized_executable=Program is not a recognized executable.
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.
@@ -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.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.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:
@@ -85,10 +83,11 @@ CMainTab.Program_does_not_exist=Program does not exist
CMainTab.Main=Main
CMainTab.&ProjectColon=&Project:
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_from_NAME=Choose a program to run from {0}:
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.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.BinariesColon=Binaries:
Launch.common.QualifierColon=Qualifier:
-Launch.common.Browse_1=&Browse
-Launch.common.Browse_2=B&rowse
+Launch.common.Browse_1=&Browse...
+Launch.common.Browse_2=B&rowse...
Launch.common.Project_does_not_exist=Project does not exist
diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LocalAttachLaunchConfigurationTabGroup.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LocalAttachLaunchConfigurationTabGroup.java
index 9d4570c4621..0e2bb7e045b 100644
--- a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LocalAttachLaunchConfigurationTabGroup.java
+++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LocalAttachLaunchConfigurationTabGroup.java
@@ -11,7 +11,7 @@
package org.eclipse.cdt.launch.internal.ui;
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.CommonTab;
import org.eclipse.debug.ui.ILaunchConfigurationDialog;
@@ -25,7 +25,7 @@ public class LocalAttachLaunchConfigurationTabGroup extends AbstractLaunchConfig
*/
public void createTabs(ILaunchConfigurationDialog dialog, String mode) {
ILaunchConfigurationTab[] tabs = new ILaunchConfigurationTab[] {
- new CMainTab(),
+ new CMainAttachTab(),
new CDebuggerTab(true),
new SourceLookupTab(),
new CommonTab()
diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CDebuggerTab.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CDebuggerTab.java
index 8d0d9874c0e..bbb233c1d59 100644
--- a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CDebuggerTab.java
+++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CDebuggerTab.java
@@ -7,9 +7,10 @@
*
* Contributors:
* QNX Software Systems - Initial API and implementation
-***********************************************************************/
+ ***********************************************************************/
package org.eclipse.cdt.launch.ui;
+import java.io.IOException;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Arrays;
@@ -18,8 +19,10 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import org.eclipse.cdt.core.model.IBinary;
-import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.CCorePlugin;
+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.ICDTLaunchConfigurationConstants;
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.LaunchMessages;
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.IPath;
+import org.eclipse.core.runtime.Path;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.jface.dialogs.Dialog;
@@ -54,24 +61,26 @@ public class CDebuggerTab extends AbstractCDebuggerTab {
/**
* Constructor for AdvancedDebuggerOptionsDialog.
*/
- protected AdvancedDebuggerOptionsDialog( Shell parentShell ) {
- super( parentShell );
+ protected AdvancedDebuggerOptionsDialog(Shell parentShell) {
+ super(parentShell);
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
*/
- protected Control createDialogArea( Composite parent ) {
- Composite composite = (Composite)super.createDialogArea( parent );
- Group group = new Group( composite, SWT.NONE );
- group.setText( LaunchMessages.getString( "CDebuggerTab.Automatically_track_values_of" ) ); //$NON-NLS-1$
+ protected Control createDialogArea(Composite parent) {
+ Composite composite = (Composite)super.createDialogArea(parent);
+ Group group = new Group(composite, SWT.NONE);
+ group.setText(LaunchMessages.getString("CDebuggerTab.Automatically_track_values_of")); //$NON-NLS-1$
GridLayout layout = new GridLayout();
- group.setLayout( layout );
- group.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
- fVarBookKeeping = new Button( group, SWT.CHECK );
- fVarBookKeeping.setText( LaunchMessages.getString( "CDebuggerTab.Variables" ) ); //$NON-NLS-1$
- fRegBookKeeping = new Button( group, SWT.CHECK );
- fRegBookKeeping.setText( LaunchMessages.getString( "CDebuggerTab.Registers" ) ); //$NON-NLS-1$
+ group.setLayout(layout);
+ group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ fVarBookKeeping = new Button(group, SWT.CHECK);
+ fVarBookKeeping.setText(LaunchMessages.getString("CDebuggerTab.Variables")); //$NON-NLS-1$
+ fRegBookKeeping = new Button(group, SWT.CHECK);
+ fRegBookKeeping.setText(LaunchMessages.getString("CDebuggerTab.Registers")); //$NON-NLS-1$
initialize();
return composite;
}
@@ -83,27 +92,29 @@ public class CDebuggerTab extends AbstractCDebuggerTab {
private void initialize() {
Map attr = getAdvancedAttributes();
- Object varBookkeeping = attr.get( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ENABLE_VARIABLE_BOOKKEEPING );
- fVarBookKeeping.setSelection( ( varBookkeeping instanceof Boolean ) ? !((Boolean)varBookkeeping).booleanValue() : true );
- Object regBookkeeping = attr.get( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ENABLE_REGISTER_BOOKKEEPING );
- fRegBookKeeping.setSelection( ( regBookkeeping instanceof Boolean ) ? !((Boolean)regBookkeeping).booleanValue() : true );
+ Object varBookkeeping = attr.get(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ENABLE_VARIABLE_BOOKKEEPING);
+ fVarBookKeeping.setSelection( (varBookkeeping instanceof Boolean) ? ! ((Boolean)varBookkeeping).booleanValue() : true);
+ Object regBookkeeping = attr.get(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ENABLE_REGISTER_BOOKKEEPING);
+ fRegBookKeeping.setSelection( (regBookkeeping instanceof Boolean) ? ! ((Boolean)regBookkeeping).booleanValue() : true);
}
private void saveValues() {
Map attr = getAdvancedAttributes();
- Boolean varBookkeeping = ( fVarBookKeeping.getSelection() ) ? Boolean.FALSE : Boolean.TRUE;
- attr.put( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ENABLE_VARIABLE_BOOKKEEPING, varBookkeeping );
- Boolean regBookkeeping = ( fRegBookKeeping.getSelection() ) ? Boolean.FALSE : Boolean.TRUE;
- attr.put( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ENABLE_REGISTER_BOOKKEEPING, regBookkeeping );
+ Boolean varBookkeeping = (fVarBookKeeping.getSelection()) ? Boolean.FALSE : Boolean.TRUE;
+ attr.put(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ENABLE_VARIABLE_BOOKKEEPING, varBookkeeping);
+ Boolean regBookkeeping = (fRegBookKeeping.getSelection()) ? Boolean.FALSE : Boolean.TRUE;
+ attr.put(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ENABLE_REGISTER_BOOKKEEPING, regBookkeeping);
updateLaunchConfigurationDialog();
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
*/
- protected void configureShell( Shell newShell ) {
- super.configureShell( newShell );
- newShell.setText( LaunchMessages.getString( "CDebuggerTab.Advanced_Options_Dialog_Title" ) ); //$NON-NLS-1$
+ protected void configureShell(Shell newShell) {
+ super.configureShell(newShell);
+ newShell.setText(LaunchMessages.getString("CDebuggerTab.Advanced_Options_Dialog_Title")); //$NON-NLS-1$
}
}
@@ -113,154 +124,197 @@ public class CDebuggerTab extends AbstractCDebuggerTab {
protected Button fStopInMain;
protected Button fAttachButton;
- private Map fAdvancedAttributes = new HashMap( 5 );
+ private Map fAdvancedAttributes = new HashMap(5);
public CDebuggerTab(boolean attachMode) {
fAttachMode = attachMode;
}
-
-
- public void createControl( Composite parent ) {
- Composite comp = new Composite( parent, SWT.NONE );
- setControl( comp );
- LaunchUIPlugin.getDefault().getWorkbench().getHelpSystem().setHelp( getControl(), ICDTLaunchHelpContextIds.LAUNCH_CONFIGURATION_DIALOG_DEBBUGER_TAB );
- GridLayout layout = new GridLayout( 2, true );
- comp.setLayout( layout );
+
+ public void createControl(Composite parent) {
+ Composite comp = new Composite(parent, SWT.NONE);
+ setControl(comp);
+ LaunchUIPlugin.getDefault().getWorkbench().getHelpSystem().setHelp(getControl(),
+ ICDTLaunchHelpContextIds.LAUNCH_CONFIGURATION_DIALOG_DEBBUGER_TAB);
+ GridLayout layout = new GridLayout(2, true);
+ comp.setLayout(layout);
GridData gd = new GridData();
gd.horizontalAlignment = GridData.FILL_HORIZONTAL;
gd.grabExcessHorizontalSpace = true;
- comp.setLayoutData( gd );
+ comp.setLayoutData(gd);
- createDebuggerCombo( comp, 1 );
- createOptionsComposite( comp );
- createDebuggerGroup( comp, 2 );
+ createDebuggerCombo(comp, 1);
+ createOptionsComposite(comp);
+ createDebuggerGroup(comp, 2);
}
- protected void loadDebuggerComboBox( ILaunchConfiguration config, String selection ) {
+ protected void loadDebuggerComboBox(ILaunchConfiguration config, String selection) {
ICDebugConfiguration[] debugConfigs;
- String configPlatform = getPlatform( config );
+ String configPlatform = getPlatform(config);
debugConfigs = CDebugCorePlugin.getDefault().getDebugConfigurations();
- Arrays.sort( debugConfigs, new Comparator() {
+ Arrays.sort(debugConfigs, new Comparator() {
- public int compare( Object o1, Object o2 ) {
+ public int compare(Object o1, Object o2) {
ICDebugConfiguration ic1 = (ICDebugConfiguration)o1;
ICDebugConfiguration ic2 = (ICDebugConfiguration)o2;
- return ic1.getName().compareTo( ic2.getName() );
+ return ic1.getName().compareTo(ic2.getName());
}
- } );
- List list = new ArrayList();
+ });
+ List list = new ArrayList();
String mode;
if (fAttachMode) {
mode = ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH;
} else {
- mode = ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN;
+ mode = ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN;
}
String defaultSelection = selection;
- for( int i = 0; i < debugConfigs.length; i++ ) {
- if ( debugConfigs[i].supportsMode( mode )) {
+ for (int i = 0; i < debugConfigs.length; i++) {
+ if (debugConfigs[i].supportsMode(mode)) {
String debuggerPlatform = debugConfigs[i].getPlatform();
- if ( validatePlatform( config, debugConfigs[i] ) ) {
- list.add( debugConfigs[i] );
- // select first exact matching debugger for platform or requested selection
- if ( (defaultSelection.equals("") && debuggerPlatform.equalsIgnoreCase( configPlatform ))) { //$NON-NLS-1$
+ if (validatePlatform(config, debugConfigs[i])) {
+ list.add(debugConfigs[i]);
+ // select first exact matching debugger for platform or
+ // requested selection
+ if ( (defaultSelection.equals("") && debuggerPlatform.equalsIgnoreCase(configPlatform))) { //$NON-NLS-1$
defaultSelection = debugConfigs[i].getID();
}
}
}
}
- // if no selection meaning nothing in config the force initdefault on tab
- setInitializeDefault( selection.equals( "" ) ? true : false ); //$NON-NLS-1$
+ // if no selection meaning nothing in config the force initdefault on
+ // tab
+ setInitializeDefault(selection.equals("") ? true : false); //$NON-NLS-1$
loadDebuggerCombo((ICDebugConfiguration[])list.toArray(new ICDebugConfiguration[list.size()]), defaultSelection);
}
protected void updateComboFromSelection() {
super.updateComboFromSelection();
- initializeCommonControls( getLaunchConfiguration() );
+ initializeCommonControls(getLaunchConfiguration());
}
- public void setDefaults( ILaunchConfigurationWorkingCopy config ) {
- super.setDefaults( config );
+ public void setDefaults(ILaunchConfigurationWorkingCopy config) {
+ super.setDefaults(config);
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 {
- config.setAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE, ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN );
- config.setAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, ICDTLaunchConfigurationConstants.DEBUGGER_STOP_AT_MAIN_DEFAULT );
+ config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
+ 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_REGISTER_BOOKKEEPING, false );
+ config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ENABLE_VARIABLE_BOOKKEEPING, false);
+ config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ENABLE_REGISTER_BOOKKEEPING, false);
}
- public void initializeFrom( ILaunchConfiguration config ) {
- setInitializing( true );
- super.initializeFrom( config );
+ public void initializeFrom(ILaunchConfiguration config) {
+ setInitializing(true);
+ super.initializeFrom(config);
try {
- String id = config.getAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID, "" ); //$NON-NLS-1$
- loadDebuggerComboBox( config, id );
- initializeCommonControls( config );
+ String id = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID, ""); //$NON-NLS-1$
+ loadDebuggerComboBox(config, id);
+ initializeCommonControls(config);
+ } catch (CoreException e) {
}
- catch( CoreException e ) {
- }
- setInitializing( false );
+ setInitializing(false);
}
- public void performApply( ILaunchConfigurationWorkingCopy config ) {
- super.performApply( config );
- if ( fAttachMode ) {
- config.setAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE, ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH );
+ public void performApply(ILaunchConfigurationWorkingCopy config) {
+ super.performApply(config);
+ if (fAttachMode) {
+ config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
+ ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH);
+ } else {
+ config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, fStopInMain.getSelection());
+ config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
+ ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN);
}
- else {
- config.setAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, fStopInMain.getSelection() );
- config.setAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE, ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN );
- }
- applyAdvancedAttributes( config );
+ applyAdvancedAttributes(config);
}
- public boolean isValid( ILaunchConfiguration config ) {
- if ( !validateDebuggerConfig( config ) ) {
+ public boolean isValid(ILaunchConfiguration config) {
+ if (!validateDebuggerConfig(config)) {
return false;
}
ICDebugConfiguration debugConfig = getDebugConfig();
- String mode = fAttachMode ? ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH : ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN;
- if ( !debugConfig.supportsMode( mode ) ) {
- setErrorMessage( MessageFormat.format( LaunchMessages.getString( "CDebuggerTab.Mode_not_supported" ), new String[] { mode } ) ); //$NON-NLS-1$
+ String mode = fAttachMode
+ ? ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH
+ : ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN;
+ if (!debugConfig.supportsMode(mode)) {
+ setErrorMessage(MessageFormat.format(LaunchMessages.getString("CDebuggerTab.Mode_not_supported"), new String[]{mode})); //$NON-NLS-1$
return false;
}
- if ( super.isValid( config ) == false ) {
+ if (super.isValid(config) == false) {
return false;
}
return true;
}
-
- protected boolean validatePlatform( ILaunchConfiguration config, ICDebugConfiguration debugConfig ) {
- String configPlatform = getPlatform( config );
+
+ protected boolean validatePlatform(ILaunchConfiguration config, ICDebugConfiguration debugConfig) {
+ String configPlatform = getPlatform(config);
String debuggerPlatform = debugConfig.getPlatform();
- return ( debuggerPlatform.equals( "*" ) || debuggerPlatform.equalsIgnoreCase( configPlatform ) ); //$NON-NLS-1$
+ return (debuggerPlatform.equals("*") || debuggerPlatform.equalsIgnoreCase(configPlatform)); //$NON-NLS-1$
}
- protected boolean validateCPU( ILaunchConfiguration config, ICDebugConfiguration debugConfig ) {
- ICElement ce = getContext( config, null );
+ protected boolean validateCPU(ILaunchConfiguration config, ICDebugConfiguration debugConfig) {
+ IBinaryObject binaryFile = null;
+ try {
+ binaryFile = getBinary(config);
+ } catch (CoreException e) {
+ setErrorMessage(e.getLocalizedMessage());
+ }
String projectCPU = ICDebugConfiguration.CPU_NATIVE;
- if ( ce != null ) {
- if ( ce instanceof IBinary ) {
- IBinary bin = (IBinary)ce;
- projectCPU = bin.getCPU();
+ if (binaryFile != null) {
+ projectCPU = binaryFile.getCPU();
+ }
+ 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) {
+ }
}
}
- return debugConfig.supportsCPU( projectCPU );
+ 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();
- if ( debugConfig == null ) {
- setErrorMessage( LaunchMessages.getString( "CDebuggerTab.No_debugger_available" ) ); //$NON-NLS-1$
+ if (debugConfig == null) {
+ setErrorMessage(LaunchMessages.getString("CDebuggerTab.No_debugger_available")); //$NON-NLS-1$
return false;
}
- if ( !validatePlatform( config, debugConfig ) ) {
- setErrorMessage( LaunchMessages.getString( "CDebuggerTab.Platform_is_not_supported" ) ); //$NON-NLS-1$
+ if (!validatePlatform(config, debugConfig)) {
+ setErrorMessage(LaunchMessages.getString("CDebuggerTab.Platform_is_not_supported")); //$NON-NLS-1$
return false;
}
- if (!validateCPU( config, debugConfig ) ) {
- setErrorMessage( LaunchMessages.getString( "CDebuggerTab.CPU_is_not_supported" ) ); //$NON-NLS-1$
+ if (!validateCPU(config, debugConfig)) {
+ setErrorMessage(LaunchMessages.getString("CDebuggerTab.CPU_is_not_supported")); //$NON-NLS-1$
return false;
}
return true;
@@ -273,80 +327,88 @@ public class CDebuggerTab extends AbstractCDebuggerTab {
super.updateLaunchConfigurationDialog();
}
- protected void createOptionsComposite( Composite parent ) {
- Composite optionsComp = new Composite( parent, SWT.NONE );
+ protected void createOptionsComposite(Composite parent) {
+ Composite optionsComp = new Composite(parent, SWT.NONE);
if (fAttachMode == true) {
- GridLayout layout = new GridLayout( 1, false );
- optionsComp.setLayout( layout );
- optionsComp.setLayoutData( new GridData( GridData.END, GridData.CENTER, true, false, 1, 1 ) );
+ GridLayout layout = new GridLayout(1, false);
+ optionsComp.setLayout(layout);
+ optionsComp.setLayoutData(new GridData(GridData.END, GridData.CENTER, true, false, 1, 1));
} else {
- GridLayout layout = new GridLayout( 2, false );
- optionsComp.setLayout( layout );
- optionsComp.setLayoutData( new GridData( GridData.END, GridData.CENTER, true, false, 1, 1 ) );
- fStopInMain = createCheckButton( optionsComp, LaunchMessages.getString( "CDebuggerTab.Stop_at_main_on_startup" ) ); //$NON-NLS-1$
+ GridLayout layout = new GridLayout(2, false);
+ optionsComp.setLayout(layout);
+ optionsComp.setLayoutData(new GridData(GridData.END, GridData.CENTER, true, false, 1, 1));
+ fStopInMain = createCheckButton(optionsComp, LaunchMessages.getString("CDebuggerTab.Stop_at_main_on_startup")); //$NON-NLS-1$
GridData data = new GridData();
data.horizontalAlignment = GridData.BEGINNING;
- fStopInMain.setLayoutData( data );
- fStopInMain.addSelectionListener( new SelectionAdapter() {
-
- public void widgetSelected( SelectionEvent e ) {
- if ( !isInitializing() ) {
+ fStopInMain.setLayoutData(data);
+ fStopInMain.addSelectionListener(new SelectionAdapter() {
+
+ public void widgetSelected(SelectionEvent e) {
+ if (!isInitializing()) {
updateLaunchConfigurationDialog();
}
}
- } );
+ });
}
- fAdvancedButton = createPushButton( optionsComp, LaunchMessages.getString( "CDebuggerTab.Advanced" ), null ); //$NON-NLS-1$
+ fAdvancedButton = createPushButton(optionsComp, LaunchMessages.getString("CDebuggerTab.Advanced"), null); //$NON-NLS-1$
GridData data = new GridData();
data.horizontalAlignment = GridData.END;
- PixelConverter pc = new PixelConverter( parent );
- data.widthHint = pc.convertHorizontalDLUsToPixels( IDialogConstants.BUTTON_WIDTH );
- fAdvancedButton.setLayoutData( data );
- fAdvancedButton.addSelectionListener( new SelectionAdapter() {
-
- public void widgetSelected( SelectionEvent e ) {
- Dialog dialog = new AdvancedDebuggerOptionsDialog( getShell() );
+ PixelConverter pc = new PixelConverter(parent);
+ data.widthHint = pc.convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
+ fAdvancedButton.setLayoutData(data);
+ fAdvancedButton.addSelectionListener(new SelectionAdapter() {
+
+ public void widgetSelected(SelectionEvent e) {
+ Dialog dialog = new AdvancedDebuggerOptionsDialog(getShell());
dialog.open();
}
- } );
+ });
}
protected Map getAdvancedAttributes() {
return fAdvancedAttributes;
}
- private void initializeAdvancedAttributes( ILaunchConfiguration config ) {
+ private void initializeAdvancedAttributes(ILaunchConfiguration config) {
Map attr = getAdvancedAttributes();
try {
- Boolean varBookkeeping = ( config.getAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ENABLE_VARIABLE_BOOKKEEPING, false ) ) ? Boolean.TRUE : Boolean.FALSE;
- attr.put( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ENABLE_VARIABLE_BOOKKEEPING, varBookkeeping );
- }
- catch( CoreException e ) {
+ Boolean varBookkeeping = (config.getAttribute(
+ ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ENABLE_VARIABLE_BOOKKEEPING, false))
+ ? Boolean.TRUE
+ : Boolean.FALSE;
+ attr.put(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ENABLE_VARIABLE_BOOKKEEPING, varBookkeeping);
+ } catch (CoreException e) {
}
try {
- Boolean regBookkeeping = ( config.getAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ENABLE_REGISTER_BOOKKEEPING, false ) ) ? Boolean.TRUE : Boolean.FALSE;
- attr.put( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ENABLE_REGISTER_BOOKKEEPING, regBookkeeping );
- }
- catch( CoreException e ) {
+ Boolean regBookkeeping = (config.getAttribute(
+ ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ENABLE_REGISTER_BOOKKEEPING, false))
+ ? Boolean.TRUE
+ : Boolean.FALSE;
+ attr.put(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ENABLE_REGISTER_BOOKKEEPING, regBookkeeping);
+ } catch (CoreException e) {
}
}
- private void applyAdvancedAttributes( ILaunchConfigurationWorkingCopy config ) {
+ private void applyAdvancedAttributes(ILaunchConfigurationWorkingCopy config) {
Map attr = getAdvancedAttributes();
- Object varBookkeeping = attr.get( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ENABLE_VARIABLE_BOOKKEEPING );
- if ( varBookkeeping instanceof Boolean )
- config.setAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ENABLE_VARIABLE_BOOKKEEPING, ((Boolean)varBookkeeping).booleanValue() );
- Object regBookkeeping = attr.get( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ENABLE_REGISTER_BOOKKEEPING );
- if ( regBookkeeping instanceof Boolean )
- config.setAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ENABLE_REGISTER_BOOKKEEPING, ((Boolean)regBookkeeping).booleanValue() );
+ Object varBookkeeping = attr.get(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ENABLE_VARIABLE_BOOKKEEPING);
+ if (varBookkeeping instanceof Boolean)
+ config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ENABLE_VARIABLE_BOOKKEEPING,
+ ((Boolean)varBookkeeping).booleanValue());
+ Object regBookkeeping = attr.get(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ENABLE_REGISTER_BOOKKEEPING);
+ if (regBookkeeping instanceof Boolean)
+ config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ENABLE_REGISTER_BOOKKEEPING,
+ ((Boolean)regBookkeeping).booleanValue());
}
protected Shell getShell() {
return super.getShell();
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.eclipse.debug.ui.ILaunchConfigurationTab#dispose()
*/
public void dispose() {
@@ -354,21 +416,23 @@ public class CDebuggerTab extends AbstractCDebuggerTab {
super.dispose();
}
- protected void initializeCommonControls( ILaunchConfiguration config ) {
+ protected void initializeCommonControls(ILaunchConfiguration config) {
try {
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 );
- }
- catch( CoreException e ) {
+ initializeAdvancedAttributes(config);
+ } catch (CoreException e) {
}
}
-
- /* (non-Javadoc)
+
+ /*
+ * (non-Javadoc)
+ *
* @see org.eclipse.cdt.launch.internal.ui.AbstractCDebuggerTab#setInitializeDefault(boolean)
*/
- protected void setInitializeDefault( boolean init ) {
- super.setInitializeDefault( init );
+ protected void setInitializeDefault(boolean init) {
+ super.setInitializeDefault(init);
}
}
\ No newline at end of file
diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CMainAttachTab.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CMainAttachTab.java
new file mode 100644
index 00000000000..fb5c0dd8249
--- /dev/null
+++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CMainAttachTab.java
@@ -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;
+ }
+
+}
diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CMainTab.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CMainTab.java
index 6b595b73e99..c86257aa6c4 100644
--- a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CMainTab.java
+++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CMainTab.java
@@ -8,10 +8,14 @@
**************************************************************************************************/
package org.eclipse.cdt.launch.ui;
+import java.io.IOException;
import java.util.ArrayList;
import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.IBinaryParser;
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.CoreModel;
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.CUIPlugin;
import org.eclipse.cdt.utils.pty.PTY;
-import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
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.Composite;
import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
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.model.WorkbenchContentProvider;
-import org.eclipse.ui.model.WorkbenchLabelProvider;
/**
* A launch configuration tab that displays and edits project and main type name launch
@@ -90,12 +89,10 @@ public class CMainTab extends CLaunchConfigurationTab {
private String filterPlatform = EMPTY_STRING;
-
-
public CMainTab() {
this(false);
}
-
+
public CMainTab(boolean terminalOption) {
fWantsTerminalOption = terminalOption;
}
@@ -108,9 +105,9 @@ public class CMainTab extends CLaunchConfigurationTab {
public void createControl(Composite parent) {
Composite comp = new Composite(parent, SWT.NONE);
setControl(comp);
-
+
LaunchUIPlugin.getDefault().getWorkbench().getHelpSystem().setHelp(getControl(), ICDTLaunchHelpContextIds.LAUNCH_CONFIGURATION_DIALOG_MAIN_TAB);
-
+
GridLayout topLayout = new GridLayout();
comp.setLayout(topLayout);
@@ -118,7 +115,7 @@ public class CMainTab extends CLaunchConfigurationTab {
createProjectGroup(comp, 1);
createExeFileGroup(comp, 1);
createVerticalSpacer(comp, 1);
- if (wantsTerminalOption() /*&& ProcessFactory.supportesTerminal()*/) {
+ if (wantsTerminalOption() /* && ProcessFactory.supportesTerminal() */) {
createTerminalOption(comp, 1);
}
LaunchUIPlugin.setDialogShell(parent.getShell());
@@ -209,7 +206,7 @@ public class CMainTab extends CLaunchConfigurationTab {
protected boolean wantsTerminalOption() {
return fWantsTerminalOption;
}
-
+
protected void createTerminalOption(Composite parent, int colSpan) {
Composite mainComp = new Composite(parent, SWT.NONE);
GridLayout mainLayout = new GridLayout();
@@ -242,7 +239,7 @@ public class CMainTab extends CLaunchConfigurationTab {
updateProgramFromConfig(config);
updateTerminalFromConfig(config);
}
-
+
protected void updateTerminalFromConfig(ILaunchConfiguration config) {
if (fTerminalButton != null) {
boolean useTerminal = true;
@@ -305,7 +302,7 @@ public class CMainTab extends CLaunchConfigurationTab {
public String getText(Object element) {
if (element instanceof IBinary) {
- IBinary bin = (IBinary) element;
+ IBinary bin = (IBinary)element;
StringBuffer name = new StringBuffer();
name.append(bin.getPath().lastSegment());
return name.toString();
@@ -314,13 +311,13 @@ public class CMainTab extends CLaunchConfigurationTab {
}
public Image getImage(Object element) {
- if (!(element instanceof ICElement)) {
+ if (! (element instanceof ICElement)) {
return super.getImage(element);
}
- ICElement celement = (ICElement) element;
+ ICElement celement = (ICElement)element;
if (celement.getElementType() == ICElement.C_BINARY) {
- IBinary belement = (IBinary) celement;
+ IBinary belement = (IBinary)celement;
if (belement.isExecutable()) {
Image image = super.getImage(element);
Point size = new Point(image.getBounds().width, image.getBounds().height);
@@ -337,7 +334,7 @@ public class CMainTab extends CLaunchConfigurationTab {
public String getText(Object element) {
if (element instanceof IBinary) {
- IBinary bin = (IBinary) element;
+ IBinary bin = (IBinary)element;
StringBuffer name = new StringBuffer();
name.append(bin.getCPU() + (bin.isLittleEndian() ? "le" : "be")); //$NON-NLS-1$ //$NON-NLS-2$
name.append(" - "); //$NON-NLS-1$
@@ -355,9 +352,9 @@ public class CMainTab extends CLaunchConfigurationTab {
dialog.setUpperListLabel(LaunchMessages.getString("Launch.common.BinariesColon")); //$NON-NLS-1$
dialog.setLowerListLabel(LaunchMessages.getString("Launch.common.QualifierColon")); //$NON-NLS-1$
dialog.setMultipleSelection(false);
- //dialog.set
+ // dialog.set
if (dialog.open() == Window.OK) {
- IBinary binary = (IBinary) dialog.getFirstResult();
+ IBinary binary = (IBinary)dialog.getFirstResult();
fProgText.setText(binary.getResource().getProjectRelativePath().toString());
}
@@ -375,53 +372,12 @@ public class CMainTab extends CLaunchConfigurationTab {
LaunchMessages.getString("CMainTab.Enter_project_before_browsing_for_program")); //$NON-NLS-1$
return;
}
-
- ElementTreeSelectionDialog dialog;
- WorkbenchLabelProvider labelProvider = new WorkbenchLabelProvider();
- WorkbenchContentProvider contentProvider = new WorkbenchContentProvider();
- dialog = new ElementTreeSelectionDialog(getShell(), labelProvider, contentProvider);
- 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;
+ FileDialog fileDialog = new FileDialog(getShell(), SWT.NONE);
+ fileDialog.setFileName(fProgText.getText());
+ String text= fileDialog.open();
+ if (text != null) {
+ fProgText.setText(text);
}
-
- Object[] results = dialog.getResult();
-
- try {
- fProgText.setText(((IResource) results[0]).getProjectRelativePath().toString());
- } catch (Exception ex) {
- /* Make sure it is a file */
- }
-
}
/**
@@ -449,7 +405,7 @@ public class CMainTab extends CLaunchConfigurationTab {
}
});
- return (IBinary[]) ret[0];
+ return (IBinary[])ret[0];
}
/**
@@ -483,10 +439,10 @@ public class CMainTab extends CLaunchConfigurationTab {
ICProject cProject = getCProject();
if (cProject != null) {
- dialog.setInitialSelections(new Object[] { cProject});
+ dialog.setInitialSelections(new Object[]{cProject});
}
if (dialog.open() == Window.OK) {
- return (ICProject) dialog.getFirstResult();
+ return (ICProject)dialog.getFirstResult();
}
} catch (CModelException e) {
LaunchUIPlugin.errorDialog("Launch UI internal error", e); //$NON-NLS-1$
@@ -504,7 +460,7 @@ public class CMainTab extends CLaunchConfigurationTab {
for (int i = 0; i < cproject.length; i++) {
ICDescriptor cdesciptor = null;
try {
- cdesciptor = CCorePlugin.getDefault().getCProjectDescription((IProject) cproject[i].getResource(), false);
+ cdesciptor = CCorePlugin.getDefault().getCProjectDescription((IProject)cproject[i].getResource(), false);
if (cdesciptor != null) {
String projectPlatform = cdesciptor.getPlatform();
if (filterPlatform.equals("*") //$NON-NLS-1$
@@ -519,7 +475,7 @@ public class CMainTab extends CLaunchConfigurationTab {
list.add(cproject[i]);
}
}
- return (ICProject[]) list.toArray(new ICProject[list.size()]);
+ return (ICProject[])list.toArray(new ICProject[list.size()]);
}
/**
@@ -554,6 +510,10 @@ public class CMainTab extends CLaunchConfigurationTab {
return false;
}
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();
if (name.length() == 0) {
@@ -564,17 +524,61 @@ public class CMainTab extends CLaunchConfigurationTab {
setErrorMessage(LaunchMessages.getString("CMainTab.Program_does_not_exist")); //$NON-NLS-1$
return false;
}
- if (!project.isOpen()) {
- setErrorMessage(LaunchMessages.getString("CMainTab.Project_must_be_opened")); //$NON-NLS-1$
- return false;
- }
- if (!project.getFile(name).exists()) {
- setErrorMessage(LaunchMessages.getString("CMainTab.Program_does_not_exist")); //$NON-NLS-1$
+ IPath exePath = new Path(name);
+ if (!exePath.isAbsolute()) {
+ if (!project.getFile(name).exists()) {
+ setErrorMessage(LaunchMessages.getString("CMainTab.Program_does_not_exist")); //$NON-NLS-1$
+ 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;
}
+ /**
+ * @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)
*
@@ -608,7 +612,7 @@ public class CMainTab extends CLaunchConfigurationTab {
protected void initializeProgramName(ICElement cElement, ILaunchConfigurationWorkingCopy config) {
IBinary binary = null;
if (cElement instanceof ICProject) {
- IBinary[] bins = getBinaryFiles((ICProject) cElement);
+ IBinary[] bins = getBinaryFiles((ICProject)cElement);
if (bins != null && bins.length == 1) {
binary = bins[0];
}