1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-04 14:55:41 +02:00
This commit is contained in:
David Inglis 2005-05-18 18:22:39 +00:00
parent 3376e0abe0
commit 6a1a4e7365
10 changed files with 380 additions and 270 deletions

View file

@ -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>

View file

@ -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$

View file

@ -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,17 +59,29 @@ 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);
ICDISession dsession = null; ICDISession dsession = null;
String debugMode = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE, String debugMode = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN); ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN);
if (debugMode.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH)) { 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 // process id
if (config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_ATTACH_PROCESS_ID, -1) == -1) { if (config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_ATTACH_PROCESS_ID, -1) == -1) {
int pid = promptForProcessID(config); int pid = promptForProcessID(config);
@ -79,14 +96,14 @@ public class LocalAttachLaunchDelegate extends AbstractCLaunchDelegate {
cancel("", -1); //$NON-NLS-1$\ cancel("", -1); //$NON-NLS-1$\
} else { } else {
dsession = debugConfig.createDebugger().createDebuggerSession(launch, exeFile, dsession = debugConfig.createDebugger().createDebuggerSession(launch, exeFile,
new SubProgressMonitor(monitor, 8)); new SubProgressMonitor(monitor, 8));
try { try {
// set the default source locator if required // set the default source locator if required
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) {
try { try {
@ -105,17 +122,14 @@ public class LocalAttachLaunchDelegate extends AbstractCLaunchDelegate {
} }
protected int promptForProcessID(ILaunchConfiguration config) throws CoreException { 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 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 processPrompt = new Status(IStatus.INFO, "org.eclipse.cdt.launch", 100, "", null); //$NON-NLS-1$//$NON-NLS-2$
// 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;

View file

@ -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

View file

@ -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()

View file

@ -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

View file

@ -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()

View file

@ -7,9 +7,10 @@
* *
* Contributors: * Contributors:
* QNX Software Systems - Initial API and implementation * QNX Software Systems - Initial API and implementation
***********************************************************************/ ***********************************************************************/
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;
@ -54,24 +61,26 @@ public class CDebuggerTab extends AbstractCDebuggerTab {
/** /**
* Constructor for AdvancedDebuggerOptionsDialog. * Constructor for AdvancedDebuggerOptionsDialog.
*/ */
protected AdvancedDebuggerOptionsDialog( Shell parentShell ) { protected AdvancedDebuggerOptionsDialog(Shell parentShell) {
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) {
Composite composite = (Composite)super.createDialogArea( parent ); Composite composite = (Composite)super.createDialogArea(parent);
Group group = new Group( composite, SWT.NONE ); Group group = new Group(composite, SWT.NONE);
group.setText( LaunchMessages.getString( "CDebuggerTab.Automatically_track_values_of" ) ); //$NON-NLS-1$ group.setText(LaunchMessages.getString("CDebuggerTab.Automatically_track_values_of")); //$NON-NLS-1$
GridLayout layout = new GridLayout(); GridLayout layout = new GridLayout();
group.setLayout( layout ); group.setLayout(layout);
group.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
fVarBookKeeping = new Button( group, SWT.CHECK ); fVarBookKeeping = new Button(group, SWT.CHECK);
fVarBookKeeping.setText( LaunchMessages.getString( "CDebuggerTab.Variables" ) ); //$NON-NLS-1$ fVarBookKeeping.setText(LaunchMessages.getString("CDebuggerTab.Variables")); //$NON-NLS-1$
fRegBookKeeping = new Button( group, SWT.CHECK ); fRegBookKeeping = new Button(group, SWT.CHECK);
fRegBookKeeping.setText( LaunchMessages.getString( "CDebuggerTab.Registers" ) ); //$NON-NLS-1$ fRegBookKeeping.setText(LaunchMessages.getString("CDebuggerTab.Registers")); //$NON-NLS-1$
initialize(); initialize();
return composite; return composite;
} }
@ -83,27 +92,29 @@ public class CDebuggerTab extends AbstractCDebuggerTab {
private void initialize() { private void initialize() {
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);
fVarBookKeeping.setSelection( ( varBookkeeping instanceof Boolean ) ? !((Boolean)varBookkeeping).booleanValue() : true ); fVarBookKeeping.setSelection( (varBookkeeping instanceof Boolean) ? ! ((Boolean)varBookkeeping).booleanValue() : true);
Object regBookkeeping = attr.get( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ENABLE_REGISTER_BOOKKEEPING ); Object regBookkeeping = attr.get(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ENABLE_REGISTER_BOOKKEEPING);
fRegBookKeeping.setSelection( ( regBookkeeping instanceof Boolean ) ? !((Boolean)regBookkeeping).booleanValue() : true ); fRegBookKeeping.setSelection( (regBookkeeping instanceof Boolean) ? ! ((Boolean)regBookkeeping).booleanValue() : true);
} }
private void saveValues() { private void saveValues() {
Map attr = getAdvancedAttributes(); Map attr = getAdvancedAttributes();
Boolean varBookkeeping = ( fVarBookKeeping.getSelection() ) ? Boolean.FALSE : Boolean.TRUE; Boolean varBookkeeping = (fVarBookKeeping.getSelection()) ? Boolean.FALSE : Boolean.TRUE;
attr.put( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ENABLE_VARIABLE_BOOKKEEPING, varBookkeeping ); attr.put(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ENABLE_VARIABLE_BOOKKEEPING, varBookkeeping);
Boolean regBookkeeping = ( fRegBookKeeping.getSelection() ) ? Boolean.FALSE : Boolean.TRUE; Boolean regBookkeeping = (fRegBookKeeping.getSelection()) ? Boolean.FALSE : Boolean.TRUE;
attr.put( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ENABLE_REGISTER_BOOKKEEPING, regBookkeeping ); attr.put(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ENABLE_REGISTER_BOOKKEEPING, regBookkeeping);
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) {
super.configureShell( newShell ); super.configureShell(newShell);
newShell.setText( LaunchMessages.getString( "CDebuggerTab.Advanced_Options_Dialog_Title" ) ); //$NON-NLS-1$ 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 fStopInMain;
protected Button fAttachButton; protected Button fAttachButton;
private Map fAdvancedAttributes = new HashMap( 5 ); private Map fAdvancedAttributes = new HashMap(5);
public CDebuggerTab(boolean attachMode) { public CDebuggerTab(boolean attachMode) {
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(),
LaunchUIPlugin.getDefault().getWorkbench().getHelpSystem().setHelp( getControl(), ICDTLaunchHelpContextIds.LAUNCH_CONFIGURATION_DIALOG_DEBBUGER_TAB ); 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();
gd.horizontalAlignment = GridData.FILL_HORIZONTAL; gd.horizontalAlignment = GridData.FILL_HORIZONTAL;
gd.grabExcessHorizontalSpace = true; gd.grabExcessHorizontalSpace = true;
comp.setLayoutData( gd ); comp.setLayoutData(gd);
createDebuggerCombo( comp, 1 ); createDebuggerCombo(comp, 1);
createOptionsComposite( comp ); createOptionsComposite(comp);
createDebuggerGroup( comp, 2 ); createDebuggerGroup(comp, 2);
} }
protected void loadDebuggerComboBox( ILaunchConfiguration config, String selection ) { protected void loadDebuggerComboBox(ILaunchConfiguration config, String selection) {
ICDebugConfiguration[] debugConfigs; ICDebugConfiguration[] debugConfigs;
String configPlatform = getPlatform( config ); String configPlatform = getPlatform(config);
debugConfigs = CDebugCorePlugin.getDefault().getDebugConfigurations(); 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 ic1 = (ICDebugConfiguration)o1;
ICDebugConfiguration ic2 = (ICDebugConfiguration)o2; 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; String mode;
if (fAttachMode) { if (fAttachMode) {
mode = ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH; mode = ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH;
} else { } else {
mode = ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN; mode = ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN;
} }
String defaultSelection = selection; String defaultSelection = selection;
for( int i = 0; i < debugConfigs.length; i++ ) { for (int i = 0; i < debugConfigs.length; i++) {
if ( debugConfigs[i].supportsMode( mode )) { if (debugConfigs[i].supportsMode(mode)) {
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
if ( (defaultSelection.equals("") && debuggerPlatform.equalsIgnoreCase( configPlatform ))) { //$NON-NLS-1$ // requested selection
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
setInitializeDefault( selection.equals( "" ) ? true : false ); //$NON-NLS-1$ // tab
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);
} }
protected void updateComboFromSelection() { protected void updateComboFromSelection() {
super.updateComboFromSelection(); super.updateComboFromSelection();
initializeCommonControls( getLaunchConfiguration() ); initializeCommonControls(getLaunchConfiguration());
} }
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);
} }
public void initializeFrom( ILaunchConfiguration config ) { public void initializeFrom(ILaunchConfiguration config) {
setInitializing( true ); setInitializing(true);
super.initializeFrom( config ); super.initializeFrom(config);
try { try {
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 );
} }
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 {
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, fStopInMain.getSelection());
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN);
} }
else { applyAdvancedAttributes(config);
config.setAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, fStopInMain.getSelection() );
config.setAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE, ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN );
}
applyAdvancedAttributes( config );
} }
public boolean isValid( ILaunchConfiguration config ) { public boolean isValid(ILaunchConfiguration config) {
if ( !validateDebuggerConfig( config ) ) { if (!validateDebuggerConfig(config)) {
return false; return false;
} }
ICDebugConfiguration debugConfig = getDebugConfig(); ICDebugConfiguration debugConfig = getDebugConfig();
String mode = fAttachMode ? ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH : ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN; String mode = fAttachMode
if ( !debugConfig.supportsMode( mode ) ) { ? ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH
setErrorMessage( MessageFormat.format( LaunchMessages.getString( "CDebuggerTab.Mode_not_supported" ), new String[] { mode } ) ); //$NON-NLS-1$ : 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; return false;
} }
if ( super.isValid( config ) == false ) { if (super.isValid(config) == false) {
return false; return false;
} }
return true; return true;
} }
protected boolean validatePlatform( ILaunchConfiguration config, ICDebugConfiguration debugConfig ) { protected boolean validatePlatform(ILaunchConfiguration config, ICDebugConfiguration debugConfig) {
String configPlatform = getPlatform( config ); String configPlatform = getPlatform(config);
String debuggerPlatform = debugConfig.getPlatform(); 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 ) { protected boolean validateCPU(ILaunchConfiguration config, ICDebugConfiguration debugConfig) {
ICElement ce = getContext( config, null ); IBinaryObject binaryFile = null;
try {
binaryFile = getBinary(config);
} catch (CoreException e) {
setErrorMessage(e.getLocalizedMessage());
}
String projectCPU = ICDebugConfiguration.CPU_NATIVE; String projectCPU = ICDebugConfiguration.CPU_NATIVE;
if ( ce != null ) { if (binaryFile != null) {
if ( ce instanceof IBinary ) { projectCPU = binaryFile.getCPU();
IBinary bin = (IBinary)ce; }
projectCPU = bin.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(); ICDebugConfiguration debugConfig = getDebugConfig();
if ( debugConfig == null ) { if (debugConfig == null) {
setErrorMessage( LaunchMessages.getString( "CDebuggerTab.No_debugger_available" ) ); //$NON-NLS-1$ setErrorMessage(LaunchMessages.getString("CDebuggerTab.No_debugger_available")); //$NON-NLS-1$
return false; return false;
} }
if ( !validatePlatform( config, debugConfig ) ) { if (!validatePlatform(config, debugConfig)) {
setErrorMessage( LaunchMessages.getString( "CDebuggerTab.Platform_is_not_supported" ) ); //$NON-NLS-1$ setErrorMessage(LaunchMessages.getString("CDebuggerTab.Platform_is_not_supported")); //$NON-NLS-1$
return false; return false;
} }
if (!validateCPU( config, debugConfig ) ) { if (!validateCPU(config, debugConfig)) {
setErrorMessage( LaunchMessages.getString( "CDebuggerTab.CPU_is_not_supported" ) ); //$NON-NLS-1$ setErrorMessage(LaunchMessages.getString("CDebuggerTab.CPU_is_not_supported")); //$NON-NLS-1$
return false; return false;
} }
return true; return true;
@ -273,80 +327,88 @@ public class CDebuggerTab extends AbstractCDebuggerTab {
super.updateLaunchConfigurationDialog(); super.updateLaunchConfigurationDialog();
} }
protected void createOptionsComposite( Composite parent ) { protected void createOptionsComposite(Composite parent) {
Composite optionsComp = new Composite( parent, SWT.NONE ); Composite optionsComp = new Composite(parent, SWT.NONE);
if (fAttachMode == true) { if (fAttachMode == true) {
GridLayout layout = new GridLayout( 1, false ); GridLayout layout = new GridLayout(1, false);
optionsComp.setLayout( layout ); optionsComp.setLayout(layout);
optionsComp.setLayoutData( new GridData( GridData.END, GridData.CENTER, true, false, 1, 1 ) ); optionsComp.setLayoutData(new GridData(GridData.END, GridData.CENTER, true, false, 1, 1));
} else { } else {
GridLayout layout = new GridLayout( 2, false ); GridLayout layout = new GridLayout(2, false);
optionsComp.setLayout( layout ); optionsComp.setLayout(layout);
optionsComp.setLayoutData( new GridData( GridData.END, GridData.CENTER, true, false, 1, 1 ) ); 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$ fStopInMain = createCheckButton(optionsComp, LaunchMessages.getString("CDebuggerTab.Stop_at_main_on_startup")); //$NON-NLS-1$
GridData data = new GridData(); GridData data = new GridData();
data.horizontalAlignment = GridData.BEGINNING; data.horizontalAlignment = GridData.BEGINNING;
fStopInMain.setLayoutData( data ); fStopInMain.setLayoutData(data);
fStopInMain.addSelectionListener( new SelectionAdapter() { fStopInMain.addSelectionListener(new SelectionAdapter() {
public void widgetSelected( SelectionEvent e ) { public void widgetSelected(SelectionEvent e) {
if ( !isInitializing() ) { if (!isInitializing()) {
updateLaunchConfigurationDialog(); 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(); GridData data = new GridData();
data.horizontalAlignment = GridData.END; data.horizontalAlignment = GridData.END;
PixelConverter pc = new PixelConverter( parent ); PixelConverter pc = new PixelConverter(parent);
data.widthHint = pc.convertHorizontalDLUsToPixels( IDialogConstants.BUTTON_WIDTH ); data.widthHint = pc.convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
fAdvancedButton.setLayoutData( data ); fAdvancedButton.setLayoutData(data);
fAdvancedButton.addSelectionListener( new SelectionAdapter() { fAdvancedButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected( SelectionEvent e ) { public void widgetSelected(SelectionEvent e) {
Dialog dialog = new AdvancedDebuggerOptionsDialog( getShell() ); Dialog dialog = new AdvancedDebuggerOptionsDialog(getShell());
dialog.open(); dialog.open();
} }
} ); });
} }
protected Map getAdvancedAttributes() { protected Map getAdvancedAttributes() {
return fAdvancedAttributes; return fAdvancedAttributes;
} }
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(
attr.put( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ENABLE_VARIABLE_BOOKKEEPING, varBookkeeping ); ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ENABLE_VARIABLE_BOOKKEEPING, false))
} ? Boolean.TRUE
catch( CoreException e ) { : Boolean.FALSE;
attr.put(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ENABLE_VARIABLE_BOOKKEEPING, varBookkeeping);
} catch (CoreException e) {
} }
try { try {
Boolean regBookkeeping = ( config.getAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ENABLE_REGISTER_BOOKKEEPING, false ) ) ? Boolean.TRUE : Boolean.FALSE; Boolean regBookkeeping = (config.getAttribute(
attr.put( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ENABLE_REGISTER_BOOKKEEPING, regBookkeeping ); ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ENABLE_REGISTER_BOOKKEEPING, false))
} ? Boolean.TRUE
catch( CoreException e ) { : 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(); 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,
Object regBookkeeping = attr.get( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ENABLE_REGISTER_BOOKKEEPING ); ((Boolean)varBookkeeping).booleanValue());
if ( regBookkeeping instanceof Boolean ) Object regBookkeeping = attr.get(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ENABLE_REGISTER_BOOKKEEPING);
config.setAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ENABLE_REGISTER_BOOKKEEPING, ((Boolean)regBookkeeping).booleanValue() ); if (regBookkeeping instanceof Boolean)
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() {
@ -354,21 +416,23 @@ public class CDebuggerTab extends AbstractCDebuggerTab {
super.dispose(); super.dispose();
} }
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) {
super.setInitializeDefault( init ); super.setInitializeDefault(init);
} }
} }

View file

@ -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;
}
}

View file

@ -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,12 +89,10 @@ public class CMainTab extends CLaunchConfigurationTab {
private String filterPlatform = EMPTY_STRING; private String filterPlatform = EMPTY_STRING;
public CMainTab() { public CMainTab() {
this(false); this(false);
} }
public CMainTab(boolean terminalOption) { public CMainTab(boolean terminalOption) {
fWantsTerminalOption = terminalOption; fWantsTerminalOption = terminalOption;
} }
@ -108,9 +105,9 @@ public class CMainTab extends CLaunchConfigurationTab {
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_MAIN_TAB); LaunchUIPlugin.getDefault().getWorkbench().getHelpSystem().setHelp(getControl(), ICDTLaunchHelpContextIds.LAUNCH_CONFIGURATION_DIALOG_MAIN_TAB);
GridLayout topLayout = new GridLayout(); GridLayout topLayout = new GridLayout();
comp.setLayout(topLayout); comp.setLayout(topLayout);
@ -118,7 +115,7 @@ public class CMainTab extends CLaunchConfigurationTab {
createProjectGroup(comp, 1); createProjectGroup(comp, 1);
createExeFileGroup(comp, 1); createExeFileGroup(comp, 1);
createVerticalSpacer(comp, 1); createVerticalSpacer(comp, 1);
if (wantsTerminalOption() /*&& ProcessFactory.supportesTerminal()*/) { if (wantsTerminalOption() /* && ProcessFactory.supportesTerminal() */) {
createTerminalOption(comp, 1); createTerminalOption(comp, 1);
} }
LaunchUIPlugin.setDialogShell(parent.getShell()); LaunchUIPlugin.setDialogShell(parent.getShell());
@ -209,7 +206,7 @@ public class CMainTab extends CLaunchConfigurationTab {
protected boolean wantsTerminalOption() { protected boolean wantsTerminalOption() {
return fWantsTerminalOption; return fWantsTerminalOption;
} }
protected void createTerminalOption(Composite parent, int colSpan) { protected void createTerminalOption(Composite parent, int colSpan) {
Composite mainComp = new Composite(parent, SWT.NONE); Composite mainComp = new Composite(parent, SWT.NONE);
GridLayout mainLayout = new GridLayout(); GridLayout mainLayout = new GridLayout();
@ -242,7 +239,7 @@ public class CMainTab extends CLaunchConfigurationTab {
updateProgramFromConfig(config); updateProgramFromConfig(config);
updateTerminalFromConfig(config); updateTerminalFromConfig(config);
} }
protected void updateTerminalFromConfig(ILaunchConfiguration config) { protected void updateTerminalFromConfig(ILaunchConfiguration config) {
if (fTerminalButton != null) { if (fTerminalButton != null) {
boolean useTerminal = true; boolean useTerminal = true;
@ -305,7 +302,7 @@ public class CMainTab extends CLaunchConfigurationTab {
public String getText(Object element) { public String getText(Object element) {
if (element instanceof IBinary) { if (element instanceof IBinary) {
IBinary bin = (IBinary) element; IBinary bin = (IBinary)element;
StringBuffer name = new StringBuffer(); StringBuffer name = new StringBuffer();
name.append(bin.getPath().lastSegment()); name.append(bin.getPath().lastSegment());
return name.toString(); return name.toString();
@ -314,13 +311,13 @@ public class CMainTab extends CLaunchConfigurationTab {
} }
public Image getImage(Object element) { public Image getImage(Object element) {
if (!(element instanceof ICElement)) { if (! (element instanceof ICElement)) {
return super.getImage(element); return super.getImage(element);
} }
ICElement celement = (ICElement) element; ICElement celement = (ICElement)element;
if (celement.getElementType() == ICElement.C_BINARY) { if (celement.getElementType() == ICElement.C_BINARY) {
IBinary belement = (IBinary) celement; IBinary belement = (IBinary)celement;
if (belement.isExecutable()) { if (belement.isExecutable()) {
Image image = super.getImage(element); Image image = super.getImage(element);
Point size = new Point(image.getBounds().width, image.getBounds().height); Point size = new Point(image.getBounds().width, image.getBounds().height);
@ -337,7 +334,7 @@ public class CMainTab extends CLaunchConfigurationTab {
public String getText(Object element) { public String getText(Object element) {
if (element instanceof IBinary) { if (element instanceof IBinary) {
IBinary bin = (IBinary) element; IBinary bin = (IBinary)element;
StringBuffer name = new StringBuffer(); StringBuffer name = new StringBuffer();
name.append(bin.getCPU() + (bin.isLittleEndian() ? "le" : "be")); //$NON-NLS-1$ //$NON-NLS-2$ name.append(bin.getCPU() + (bin.isLittleEndian() ? "le" : "be")); //$NON-NLS-1$ //$NON-NLS-2$
name.append(" - "); //$NON-NLS-1$ 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.setUpperListLabel(LaunchMessages.getString("Launch.common.BinariesColon")); //$NON-NLS-1$
dialog.setLowerListLabel(LaunchMessages.getString("Launch.common.QualifierColon")); //$NON-NLS-1$ dialog.setLowerListLabel(LaunchMessages.getString("Launch.common.QualifierColon")); //$NON-NLS-1$
dialog.setMultipleSelection(false); dialog.setMultipleSelection(false);
//dialog.set // dialog.set
if (dialog.open() == Window.OK) { if (dialog.open() == Window.OK) {
IBinary binary = (IBinary) dialog.getFirstResult(); IBinary binary = (IBinary)dialog.getFirstResult();
fProgText.setText(binary.getResource().getProjectRelativePath().toString()); 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$ 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 */
}
} }
/** /**
@ -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(); ICProject cProject = getCProject();
if (cProject != null) { if (cProject != null) {
dialog.setInitialSelections(new Object[] { cProject}); dialog.setInitialSelections(new Object[]{cProject});
} }
if (dialog.open() == Window.OK) { if (dialog.open() == Window.OK) {
return (ICProject) dialog.getFirstResult(); return (ICProject)dialog.getFirstResult();
} }
} catch (CModelException e) { } catch (CModelException e) {
LaunchUIPlugin.errorDialog("Launch UI internal error", e); //$NON-NLS-1$ 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++) { for (int i = 0; i < cproject.length; i++) {
ICDescriptor cdesciptor = null; ICDescriptor cdesciptor = null;
try { try {
cdesciptor = CCorePlugin.getDefault().getCProjectDescription((IProject) cproject[i].getResource(), false); cdesciptor = CCorePlugin.getDefault().getCProjectDescription((IProject)cproject[i].getResource(), false);
if (cdesciptor != null) { if (cdesciptor != null) {
String projectPlatform = cdesciptor.getPlatform(); String projectPlatform = cdesciptor.getPlatform();
if (filterPlatform.equals("*") //$NON-NLS-1$ if (filterPlatform.equals("*") //$NON-NLS-1$
@ -519,7 +475,7 @@ public class CMainTab extends CLaunchConfigurationTab {
list.add(cproject[i]); 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; 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()) {
} setErrorMessage(LaunchMessages.getString("CMainTab.Program_does_not_exist")); //$NON-NLS-1$
if (!project.getFile(name).exists()) { return false;
setErrorMessage(LaunchMessages.getString("CMainTab.Program_does_not_exist")); //$NON-NLS-1$ }
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 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)
* *
@ -608,7 +612,7 @@ public class CMainTab extends CLaunchConfigurationTab {
protected void initializeProgramName(ICElement cElement, ILaunchConfigurationWorkingCopy config) { protected void initializeProgramName(ICElement cElement, ILaunchConfigurationWorkingCopy config) {
IBinary binary = null; IBinary binary = null;
if (cElement instanceof ICProject) { if (cElement instanceof ICProject) {
IBinary[] bins = getBinaryFiles((ICProject) cElement); IBinary[] bins = getBinaryFiles((ICProject)cElement);
if (bins != null && bins.length == 1) { if (bins != null && bins.length == 1) {
binary = bins[0]; binary = bins[0];
} }