diff --git a/plugins/org.eclipse.dd.gdb.ui/META-INF/MANIFEST.MF b/plugins/org.eclipse.dd.gdb.ui/META-INF/MANIFEST.MF index 8bbe89cf2f6..1359901c6f7 100644 --- a/plugins/org.eclipse.dd.gdb.ui/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.dd.gdb.ui/META-INF/MANIFEST.MF @@ -17,7 +17,9 @@ Require-Bundle: org.eclipse.ui, org.eclipse.dd.dsf.debug, org.eclipse.cdt.debug.ui, org.eclipse.cdt.core, - org.eclipse.cdt.ui + org.eclipse.cdt.ui, + org.eclipse.ui.ide, + org.eclipse.core.variables Bundle-ActivationPolicy: lazy Bundle-RequiredExecutionEnvironment: J2SE-1.5 Export-Package: org.eclipse.dd.gdb.internal.ui.launching diff --git a/plugins/org.eclipse.dd.gdb.ui/icons/full/view16/arguments_tab.gif b/plugins/org.eclipse.dd.gdb.ui/icons/full/view16/arguments_tab.gif new file mode 100644 index 00000000000..44660b5f0b5 Binary files /dev/null and b/plugins/org.eclipse.dd.gdb.ui/icons/full/view16/arguments_tab.gif differ diff --git a/plugins/org.eclipse.dd.gdb.ui/src/org/eclipse/dd/gdb/internal/ui/launching/CArgumentsTab.java b/plugins/org.eclipse.dd.gdb.ui/src/org/eclipse/dd/gdb/internal/ui/launching/CArgumentsTab.java new file mode 100644 index 00000000000..3762a5f67bb --- /dev/null +++ b/plugins/org.eclipse.dd.gdb.ui/src/org/eclipse/dd/gdb/internal/ui/launching/CArgumentsTab.java @@ -0,0 +1,279 @@ +/******************************************************************************* + * Copyright (c) 2005, 2007 QNX Software Systems and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * QNX Software Systems - Initial API and implementation + * IBM Corporation + *******************************************************************************/ +package org.eclipse.dd.gdb.internal.ui.launching; + +import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.dd.gdb.internal.provisional.launching.LaunchMessages; +import org.eclipse.dd.gdb.internal.ui.GdbUIPlugin; +import org.eclipse.debug.core.ILaunchConfiguration; +import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; +import org.eclipse.debug.ui.ILaunchConfigurationDialog; +import org.eclipse.debug.ui.StringVariableSelectionDialog; +import org.eclipse.swt.SWT; +import org.eclipse.swt.accessibility.AccessibleAdapter; +import org.eclipse.swt.accessibility.AccessibleEvent; +import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Text; + + +/** + * A launch configuration tab that displays and edits program arguments, + * and working directory launch configuration attributes. + *

+ * This class may be instantiated. This class is not intended to be subclassed. + *

+ */ +public class CArgumentsTab extends CLaunchConfigurationTab { + + // Program arguments UI widgets + protected Label fPrgmArgumentsLabel; + protected Text fPrgmArgumentsText; + protected Button fArgumentVariablesButton; + + // Working directory + protected WorkingDirectoryBlock fWorkingDirectoryBlock = new WorkingDirectoryBlock(); + + /* (non-Javadoc) + * @see org.eclipse.debug.ui.ILaunchConfigurationTab#createControl(org.eclipse.swt.widgets.Composite) + */ + public void createControl(Composite parent) { + Font font = parent.getFont(); + Composite comp = new Composite(parent, SWT.NONE); + GridLayout layout = new GridLayout(1, true); + comp.setLayout(layout); + comp.setFont(font); + + GridData gd = new GridData(GridData.FILL_BOTH); + comp.setLayoutData(gd); + setControl(comp); + + GdbUIPlugin.getDefault().getWorkbench().getHelpSystem().setHelp(getControl(), ICDTLaunchHelpContextIds.LAUNCH_CONFIGURATION_DIALOG_ARGUMNETS_TAB); + + createArgumentComponent(comp, 1); + + fWorkingDirectoryBlock.createControl(comp); + } + + protected void createArgumentComponent(Composite comp, int horizontalSpan) { + Font font = comp.getFont(); + Group group = new Group(comp, SWT.NONE); + group.setFont(font); + group.setLayout(new GridLayout()); + GridData gd = new GridData(GridData.FILL_BOTH); + gd.horizontalSpan = horizontalSpan; + group.setLayoutData(gd); + + group.setText(LaunchMessages.getString("CArgumentsTab.C/C++_Program_Arguments")); //$NON-NLS-1$ + fPrgmArgumentsText = new Text(group, SWT.MULTI | SWT.WRAP | SWT.BORDER | SWT.V_SCROLL); + fPrgmArgumentsText.getAccessible().addAccessibleListener( + new AccessibleAdapter() { + @Override + public void getName(AccessibleEvent e) { + e.result = LaunchMessages.getString("CArgumentsTab.C/C++_Program_Arguments"); //$NON-NLS-1$ + } + } + ); + gd = new GridData(GridData.FILL_BOTH); + gd.heightHint = 40; + gd.widthHint = 100; + fPrgmArgumentsText.setLayoutData(gd); + fPrgmArgumentsText.setFont(font); + fPrgmArgumentsText.addModifyListener(new ModifyListener() { + public void modifyText(ModifyEvent evt) { + updateLaunchConfigurationDialog(); + } + }); + fArgumentVariablesButton= createPushButton(group, LaunchMessages.getString("CArgumentsTab.Variables"), null); //$NON-NLS-1$ + gd = new GridData(GridData.HORIZONTAL_ALIGN_END); + fArgumentVariablesButton.setLayoutData(gd); + fArgumentVariablesButton.addSelectionListener(new SelectionAdapter() { + + /* (non-Javadoc) + * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent) + */ + @Override + public void widgetSelected(SelectionEvent arg0) { + handleVariablesButtonSelected(fPrgmArgumentsText); + } + + }); + addControlAccessibleListener(fArgumentVariablesButton, fArgumentVariablesButton.getText()); // need to strip the mnemonic from buttons + } + + /** + * A variable entry button has been pressed for the given text + * field. Prompt the user for a variable and enter the result + * in the given field. + */ + protected void handleVariablesButtonSelected(Text textField) { + String variable = getVariable(); + if (variable != null) { + textField.append(variable); + } + } + + /** + * Prompts the user to choose and configure a variable and returns + * the resulting string, suitable to be used as an attribute. + */ + private String getVariable() { + StringVariableSelectionDialog dialog = new StringVariableSelectionDialog(getShell()); + dialog.open(); + return dialog.getVariableExpression(); + } + + public void addControlAccessibleListener(Control control, String controlName) { + //strip mnemonic (&) + String[] strs = controlName.split("&"); //$NON-NLS-1$ + StringBuffer stripped = new StringBuffer(); + for (int i = 0; i < strs.length; i++) { + stripped.append(strs[i]); + } + control.getAccessible().addAccessibleListener(new ControlAccessibleListener(stripped.toString())); + } + + private class ControlAccessibleListener extends AccessibleAdapter { + private String controlName; + ControlAccessibleListener(String name) { + controlName = name; + } + @Override + public void getName(AccessibleEvent e) { + e.result = controlName; + } + + } + + /* (non-Javadoc) + * @see org.eclipse.debug.ui.ILaunchConfigurationTab#isValid(org.eclipse.debug.core.ILaunchConfiguration) + */ + @Override + public boolean isValid(ILaunchConfiguration config) { + return fWorkingDirectoryBlock.isValid(config); + } + + /* (non-Javadoc) + * @see org.eclipse.debug.ui.ILaunchConfigurationTab#setDefaults(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) + */ + public void setDefaults(ILaunchConfigurationWorkingCopy config) { + config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, (String) null); + config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, (String) null); + } + + /* (non-Javadoc) + * @see org.eclipse.debug.ui.ILaunchConfigurationTab#initializeFrom(org.eclipse.debug.core.ILaunchConfiguration) + */ + public void initializeFrom(ILaunchConfiguration configuration) { + try { + fPrgmArgumentsText.setText(configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, "")); //$NON-NLS-1$ + fWorkingDirectoryBlock.initializeFrom(configuration); + } + catch (CoreException e) { + setErrorMessage(LaunchMessages.getFormattedString("Launch.common.Exception_occurred_reading_configuration_EXCEPTION", e.getStatus().getMessage())); //$NON-NLS-1$ + GdbUIPlugin.log(e); + } + } + + /* (non-Javadoc) + * @see org.eclipse.debug.ui.ILaunchConfigurationTab#performApply(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) + */ + public void performApply(ILaunchConfigurationWorkingCopy configuration) { + configuration.setAttribute( + ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, + getAttributeValueFrom(fPrgmArgumentsText)); + fWorkingDirectoryBlock.performApply(configuration); + } + + /** + * Retuns the string in the text widget, or null if empty. + * + * @return text or null + */ + protected String getAttributeValueFrom(Text text) { + String content = text.getText().trim(); + // bug #131513 - eliminate Windows \r line delimiter + content = content.replaceAll("\r\n", "\n"); //$NON-NLS-1$//$NON-NLS-2$ + if (content.length() > 0) { + return content; + } + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getName() + */ + public String getName() { + return LaunchMessages.getString("CArgumentsTab.Arguments"); //$NON-NLS-1$ + } + + /* (non-Javadoc) + * @see org.eclipse.debug.ui.ILaunchConfigurationTab#setLaunchConfigurationDialog(org.eclipse.debug.ui.ILaunchConfigurationDialog) + */ + @Override + public void setLaunchConfigurationDialog(ILaunchConfigurationDialog dialog) { + super.setLaunchConfigurationDialog(dialog); + fWorkingDirectoryBlock.setLaunchConfigurationDialog(dialog); + } + + /* (non-Javadoc) + * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getErrorMessage() + */ + @Override + public String getErrorMessage() { + String m = super.getErrorMessage(); + if (m == null) { + return fWorkingDirectoryBlock.getErrorMessage(); + } + return m; + } + + /* (non-Javadoc) + * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getMessage() + */ + @Override + public String getMessage() { + String m = super.getMessage(); + if (m == null) { + return fWorkingDirectoryBlock.getMessage(); + } + return m; + } + + /* (non-Javadoc) + * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getImage() + */ + @Override + public Image getImage() { + return LaunchImages.get(LaunchImages.IMG_VIEW_ARGUMENTS_TAB); + } + + /* (non-Javadoc) + * @see org.eclipse.debug.ui.AbstractLaunchConfigurationTab#updateLaunchConfigurationDialog() + */ + @Override + protected void updateLaunchConfigurationDialog() { + super.updateLaunchConfigurationDialog(); + } +} diff --git a/plugins/org.eclipse.dd.gdb.ui/src/org/eclipse/dd/gdb/internal/ui/launching/GdbLocalRunLaunchConfigurationTabGroup.java b/plugins/org.eclipse.dd.gdb.ui/src/org/eclipse/dd/gdb/internal/ui/launching/GdbLocalRunLaunchConfigurationTabGroup.java index 5e1b0e3c71b..c776907cbb9 100644 --- a/plugins/org.eclipse.dd.gdb.ui/src/org/eclipse/dd/gdb/internal/ui/launching/GdbLocalRunLaunchConfigurationTabGroup.java +++ b/plugins/org.eclipse.dd.gdb.ui/src/org/eclipse/dd/gdb/internal/ui/launching/GdbLocalRunLaunchConfigurationTabGroup.java @@ -26,8 +26,10 @@ public class GdbLocalRunLaunchConfigurationTabGroup extends AbstractLaunchConfig public void createTabs(ILaunchConfigurationDialog dialog, String mode) { ILaunchConfigurationTab[] tabs = new ILaunchConfigurationTab[] { new CMainTab(), - new CDebuggerTab(SessionType.LOCAL, false), + new CArgumentsTab(), + new CDebuggerTab(SessionType.LOCAL, false), new SourceLookupTab(), +// new EnvironmentTab(), new CommonTab() }; setTabs(tabs); diff --git a/plugins/org.eclipse.dd.gdb.ui/src/org/eclipse/dd/gdb/internal/ui/launching/LaunchImages.java b/plugins/org.eclipse.dd.gdb.ui/src/org/eclipse/dd/gdb/internal/ui/launching/LaunchImages.java index 2eca2e3f837..39fea960263 100644 --- a/plugins/org.eclipse.dd.gdb.ui/src/org/eclipse/dd/gdb/internal/ui/launching/LaunchImages.java +++ b/plugins/org.eclipse.dd.gdb.ui/src/org/eclipse/dd/gdb/internal/ui/launching/LaunchImages.java @@ -37,9 +37,11 @@ public class LaunchImages { private static final String T_OBJS = "full/obj16/"; //$NON-NLS-1$ public static String IMG_VIEW_MAIN_TAB = NAME_PREFIX + "main_tab.gif"; //$NON-NLS-1$ + public static String IMG_VIEW_ARGUMENTS_TAB = NAME_PREFIX + "arguments_tab.gif"; //$NON-NLS-1$ public static String IMG_VIEW_DEBUGGER_TAB = NAME_PREFIX + "debugger_tab.gif"; //$NON-NLS-1$ public static final ImageDescriptor DESC_TAB_MAIN= createManaged(T_TABS, IMG_VIEW_MAIN_TAB); + public static final ImageDescriptor DESC_TAB_ARGUMENTS = createManaged(T_TABS, IMG_VIEW_ARGUMENTS_TAB); public static final ImageDescriptor DESC_TAB_DEBUGGER = createManaged(T_TABS, IMG_VIEW_DEBUGGER_TAB); public static String IMG_OBJS_EXEC= NAME_PREFIX + "exec_obj.gif"; //$NON-NLS-1$ diff --git a/plugins/org.eclipse.dd.gdb.ui/src/org/eclipse/dd/gdb/internal/ui/launching/LaunchUIMessages.properties b/plugins/org.eclipse.dd.gdb.ui/src/org/eclipse/dd/gdb/internal/ui/launching/LaunchUIMessages.properties index b8023908379..6dd5cf12abb 100644 --- a/plugins/org.eclipse.dd.gdb.ui/src/org/eclipse/dd/gdb/internal/ui/launching/LaunchUIMessages.properties +++ b/plugins/org.eclipse.dd.gdb.ui/src/org/eclipse/dd/gdb/internal/ui/launching/LaunchUIMessages.properties @@ -1,5 +1,5 @@ ############################################################################### -# Copyright (c) 2003, 2006 QNX Software Systems and others. +# Copyright (c) 2003, 2008 QNX Software Systems and others. # All rights reserved. This program and the accompanying materials # are made available under the terms of the Eclipse Public License v1.0 # which accompanies this distribution, and is available at @@ -7,6 +7,7 @@ # # Contributors: # QNX Software Systems - initial API and implementation +# Ericsson - Updated for DSF ############################################################################### CygwinDebuggerPage.0=Cygwin GDB Debugger Options @@ -73,3 +74,150 @@ TCPSettingsBlock.2=Host name or IP address must be specified. TCPSettingsBlock.3=Invalid host name or IP address. TCPSettingsBlock.4=Port number must be specified. TCPSettingsBlock.5=Invalid port number. + +AbstractCLaunchDelegate.Debugger_not_installed=CDT Debugger not installed +AbstractCLaunchDelegate.C_Project_not_specified=C Project not specified +AbstractCLaunchDelegate.Not_a_C_CPP_project=Project is not a C/C++ project +AbstractCLaunchDelegate.Program_file_not_specified=Program file not specified +AbstractCLaunchDelegate.Program_file_does_not_exist=Program file does not exist +AbstractCLaunchDelegate.PROGRAM_PATH_not_found={0} not found +AbstractCLaunchDelegate.Working_directory_does_not_exist=Working directory does not exist +AbstractCLaunchDelegate.WORKINGDIRECTORY_PATH_not_found=The working directory {0} does not exist. +AbstractCLaunchDelegate.Project_NAME_does_not_exist=Project {0} does not exist. Please check that your launch configuration specifies a valid project in your workspace. +AbstractCLaunchDelegate.Project_NAME_is_closed=Project {0} is closed +AbstractCLaunchDelegate.Debugger_Process=Debugger Process +AbstractCLaunchDelegate.building_projects=Building prerequisite project list +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_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, environment or working directory. +LocalRunLaunchDelegate.Error_starting_process=Error starting process +LocalRunLaunchDelegate.Does_not_support_working_dir=Eclipse runtime does not support working directory + +LocalAttachLaunchDelegate.Attaching_to_Local_C_Application=Attaching to Local C/C++ Application +LocalAttachLaunchDelegate.No_Process_ID_selected=No Process ID selected +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: +LocalAttachLaunchDelegate.CDT_Launch_Error=CDT Launch Error + +CoreFileLaunchDelegate.Launching_postmortem_debugger=Launching postmortem debugger +CoreFileLaunchDelegate.No_Corefile_selected=No Corefile selected +CoreFileLaunchDelegate.No_Shell_available_in_Launch=No Shell available in Launch +CoreFileLaunchDelegate.Select_Corefile=Select Corefile +CoreFileLaunchDelegate.Corefile_not_accessible=Core file is not accessible. +CoreFileLaunchDelegate.Corefile_not_readable=Core file does not exist or is not readable. +CoreFileLaunchDelegate.postmortem_debugging_failed=Post-mortem debugging failed + +CApplicationLaunchShortcut.Application_Launcher=Application Launcher +CApplicationLaunchShortcut.ChooseConfigToDebug=Choose a debug configuration to debug +CApplicationLaunchShortcut.ChooseConfigToRun=Choose a configuration to run +CApplicationLaunchShortcut.CLocalApplication=C Local Application +CApplicationLaunchShortcut.ChooseLocalAppToDebug=Choose a local application to debug +CApplicationLaunchShortcut.ChooseLocalAppToRun=Choose a local application to run +CApplicationLaunchShortcut.Launch_failed_no_binaries=Launch failed. Binary not found. +CApplicationLaunchShortcut.LaunchFailed=Launch failed +CApplicationLaunchShortcut.LaunchDebugConfigSelection=Launch Debug Configuration Selection +CApplicationLaunchShortcut.LaunchConfigSelection=Launch Configuration Selection +CApplicationLaunchShortcut.Invalid_launch_mode_1=Invalid launch mode +CApplicationLaunchShortcut.Invalid_launch_mode_2=Invalid launch mode. +CApplicationLaunchShortcut.Invalid_launch_mode_3=Invalid launch mode. +CApplicationLaunchShortcut.ChooseLaunchConfigToDebug=Choose a launch configuration to debug +CApplicationLaunchShortcut.ChooseLaunchConfigToRun=Choose a launch configuration to run +CApplicationLaunchShortcut.Launch_failed_no_project_selected=Launch failed no project selected + +AbstractCDebuggerTab.No_debugger_available=No debugger available +AbstractCDebuggerTab.Debugger=Debugger +AbstractCDebuggerTab.ErrorLoadingDebuggerPage=Error Loading Debugger UI Component. + +LaunchUIPlugin.Error=Error + +CMainTab.Project_required=Project required +CMainTab.Enter_project_before_searching_for_program=Project must first be entered before searching for a program +CMainTab.Program_Selection=Program Selection +CMainTab.Enter_project_before_browsing_for_program=Project must first be entered before browsing for a program +CMainTab.Program_selection=Program selection +CMainTab.Selection_must_be_file=Selection must be a file +CMainTab.Selection_must_be_binary_file=Selection must be a binary file +CMainTab.Project_Selection=Project Selection +CMainTab.Choose_project_to_constrain_search_for_program=Choose a &project to constrain the search for a program +CMainTab.Project_not_specified=Project not specified +CMainTab.Program_not_specified=Program not specified +CMainTab.Project_must_be_opened=Project must be opened +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 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 on startup at: +CDebuggerTab.Automatically_track_values_of=Automatically track the values of +CDebuggerTab.Stop_on_startup_at_can_not_be_empty=The "Stop on startup at" field can not be empty. +CDebuggerTab.Debugger_Options=Debugger Options +CDebuggerTab.Mode_not_supported=Mode ''{0}'' is not supported by the selected debugger +CDebuggerTab.Advanced=Advanced... +CDebuggerTab.Variables=Variables +CDebuggerTab.Registers=Registers +CDebuggerTab.No_debugger_available=No debugger available +CDebuggerTab.CPU_is_not_supported=The CPU is not supported by the selected debugger. +CDebuggerTab.Platform_is_not_supported=The project platform is not supported by the selected debugger. + +CoreFileDebuggerTab.No_debugger_available=No debugger available +CoreFileDebuggerTab.platform_is_not_supported=The project platform is not supported by the selected debugger. + +CEnvironmentTab.Edit_Variable=Edit Variable +CEnvironmentTab.New_Variable=New Variable +CEnvironmentTab.NameColon=Name: +CEnvironmentTab.ValueColon=Value: +CEnvironmentTab.Name=Name +CEnvironmentTab.Value=Value +CEnvironmentTab.New...=New... +CEnvironmentTab.Import...=Import... +CEnvironmentTab.Edit...=Edit... +CEnvironmentTab.Remove=Remove +CEnvironmentTab.Environment=Environment +CEnvironmentTab.Existing_Environment_Variable=Existing Environment Variable +CEnvironmentTab.Environment_variable_NAME_exists=Environment variable \" {0} \" exists.\nDo you want to overwrite? + +CArgumentsTab.C/C++_Program_Arguments=Program arguments: +CArgumentsTab.Arguments=Arguments +CArgumentsTab.Variables=Variables... + +WorkingDirectoryBlock.4=Select a &workspace relative working directory: +WorkingDirectoryBlock.7=Select a working directory for the launch configuration: +WorkingDirectoryBlock.0=W&orkspace... +WorkingDirectoryBlock.Working_Directory_8=Working Directory +WorkingDirectoryBlock.Working_directory=Working directory: +WorkingDirectoryBlock.10=Working directory does not exist +WorkingDirectoryBlock.Use_default=Use de&fault +WorkingDirectoryBlock.17=Variabl&es... +WorkingDirectoryBlock.1=File S&ystem... +WorkingDirectoryBlock.Exception_occurred_reading_configuration___15=Exception occurred reading configuration: + +Launch.common.Exception_occurred_reading_configuration_EXCEPTION=Exception occurred reading configuration {0} +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.Project_does_not_exist=Project does not exist +LocalCDILaunchDelegate.0=Launching Local C/C++ Application +LocalCDILaunchDelegate.1=Launching debugger session +LocalCDILaunchDelegate.2=Debugging local C/C++ application +LocalCDILaunchDelegate.3=Attaching to Local C/C++ Application +LocalCDILaunchDelegate.4=No Process ID selected. +LocalCDILaunchDelegate.5=Launching postmortem debugger session +LocalCDILaunchDelegate.6=No core file selected +LocalCDILaunchDelegate.7=Core file does not exist or is not readable. +LocalCDILaunchDelegate.8=Error starting process. +LocalCDILaunchDelegate.9=Eclipse runtime does not support working directory. +LocalCDILaunchDelegate.10=Failed to set program arguments, environment or working directory. diff --git a/plugins/org.eclipse.dd.gdb.ui/src/org/eclipse/dd/gdb/internal/ui/launching/WorkingDirectoryBlock.java b/plugins/org.eclipse.dd.gdb.ui/src/org/eclipse/dd/gdb/internal/ui/launching/WorkingDirectoryBlock.java new file mode 100644 index 00000000000..366b3d2f71e --- /dev/null +++ b/plugins/org.eclipse.dd.gdb.ui/src/org/eclipse/dd/gdb/internal/ui/launching/WorkingDirectoryBlock.java @@ -0,0 +1,393 @@ +/******************************************************************************* + * Copyright (c) 2000, 2007 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.dd.gdb.internal.ui.launching; + +import java.io.File; + +import org.eclipse.cdt.core.model.ICProject; +import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; +import org.eclipse.core.resources.IContainer; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IWorkspaceRoot; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.variables.IStringVariableManager; +import org.eclipse.core.variables.VariablesPlugin; +import org.eclipse.dd.gdb.internal.provisional.launching.GdbLaunchDelegate; +import org.eclipse.dd.gdb.internal.ui.GdbUIPlugin; +import org.eclipse.debug.core.ILaunchConfiguration; +import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; +import org.eclipse.debug.ui.StringVariableSelectionDialog; +import org.eclipse.swt.SWT; +import org.eclipse.swt.accessibility.AccessibleAdapter; +import org.eclipse.swt.accessibility.AccessibleEvent; +import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.DirectoryDialog; +import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.dialogs.ContainerSelectionDialog; + + +/** + * A control for setting the working directory associated with a launch + * configuration. + */ +public class WorkingDirectoryBlock extends CLaunchConfigurationTab { + + // Local directory + protected Text fWorkingDirText; + protected Button fWorkspaceButton; + protected Button fFileSystemButton; + protected Button fVariablesButton; + + // use default button + protected Button fUseDefaultWorkingDirButton; + + /** + * The last launch config this tab was initialized from + */ + protected ILaunchConfiguration fLaunchConfiguration; + + /** + * A listener to update for text changes and widget selection + */ + private class WidgetListener extends SelectionAdapter implements ModifyListener { + + public void modifyText(ModifyEvent e) { + updateLaunchConfigurationDialog(); + } + + @Override + public void widgetSelected(SelectionEvent e) { + Object source = e.getSource(); + if (source == fWorkspaceButton) { + handleWorkspaceDirBrowseButtonSelected(); + } else if (source == fFileSystemButton) { + handleWorkingDirBrowseButtonSelected(); + } else if (source == fUseDefaultWorkingDirButton) { + handleUseDefaultWorkingDirButtonSelected(); + } else if (source == fVariablesButton) { + handleWorkingDirVariablesButtonSelected(); + } + } + } + + private WidgetListener fListener = new WidgetListener(); + + /* + * (non-Javadoc) + * + * @see org.eclipse.debug.ui.ILaunchConfigurationTab#createControl(org.eclipse.swt.widgets.Composite) + */ + public void createControl(Composite parent) { + Font font = parent.getFont(); + + Group group = new Group(parent, SWT.NONE); + // WorkbenchHelp.setHelp(group, + // IJavaDebugHelpContextIds.WORKING_DIRECTORY_BLOCK); + GridLayout workingDirLayout = new GridLayout(); + workingDirLayout.makeColumnsEqualWidth = false; + group.setLayout(workingDirLayout); + GridData gd = new GridData(GridData.FILL_HORIZONTAL); + group.setLayoutData(gd); + group.setFont(font); + setControl(group); + + group.setText(LaunchUIMessages.getString("WorkingDirectoryBlock.Working_directory")); //$NON-NLS-1$ + + fWorkingDirText = new Text(group, SWT.SINGLE | SWT.BORDER); + fWorkingDirText.getAccessible().addAccessibleListener( + new AccessibleAdapter() { + @Override + public void getName(AccessibleEvent e) { + e.result = LaunchUIMessages.getString("WorkingDirectoryBlock.Working_directory"); //$NON-NLS-1$ + } + } + ); + gd = new GridData(GridData.FILL_HORIZONTAL); + fWorkingDirText.setLayoutData(gd); + fWorkingDirText.setFont(font); + fWorkingDirText.addModifyListener(fListener); + + fUseDefaultWorkingDirButton = new Button(group, SWT.CHECK); + fUseDefaultWorkingDirButton.setText(LaunchUIMessages.getString("WorkingDirectoryBlock.Use_default")); //$NON-NLS-1$ + gd = new GridData(GridData.FILL, GridData.BEGINNING, true, false); + fUseDefaultWorkingDirButton.setLayoutData(gd); + fUseDefaultWorkingDirButton.setFont(font); + fUseDefaultWorkingDirButton.addSelectionListener(fListener); + + Composite buttonComp = new Composite(group, SWT.NONE); + GridLayout layout = new GridLayout(3, false); + layout.marginHeight = 0; + layout.marginWidth = 0; + buttonComp.setLayout(layout); + gd = new GridData(GridData.HORIZONTAL_ALIGN_END); + buttonComp.setLayoutData(gd); + buttonComp.setFont(font); + fWorkspaceButton = createPushButton(buttonComp, LaunchUIMessages.getString("WorkingDirectoryBlock.0"), null); //$NON-NLS-1$ + fWorkspaceButton.addSelectionListener(fListener); + + fFileSystemButton = createPushButton(buttonComp, LaunchUIMessages.getString("WorkingDirectoryBlock.1"), null); //$NON-NLS-1$ + fFileSystemButton.addSelectionListener(fListener); + + fVariablesButton = createPushButton(buttonComp, LaunchUIMessages.getString("WorkingDirectoryBlock.17"), null); //$NON-NLS-1$ + fVariablesButton.addSelectionListener(fListener); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.debug.ui.ILaunchConfigurationTab#dispose() + */ + @Override + public void dispose() { + } + + /** + * Show a dialog that lets the user select a working directory + */ + protected void handleWorkingDirBrowseButtonSelected() { + DirectoryDialog dialog = new DirectoryDialog(getShell()); + dialog.setMessage(LaunchUIMessages.getString("WorkingDirectoryBlock.7")); //$NON-NLS-1$ + String currentWorkingDir = fWorkingDirText.getText(); + if (!currentWorkingDir.trim().equals("")) { //$NON-NLS-1$ + File path = new File(currentWorkingDir); + if (path.exists()) { + dialog.setFilterPath(currentWorkingDir); + } + } + + String selectedDirectory = dialog.open(); + if (selectedDirectory != null) { + fWorkingDirText.setText(selectedDirectory); + } + } + + /** + * Show a dialog that lets the user select a working directory from the + * workspace + */ + protected void handleWorkspaceDirBrowseButtonSelected() { + ContainerSelectionDialog dialog = new ContainerSelectionDialog(getShell(), ResourcesPlugin.getWorkspace().getRoot(), false, + LaunchUIMessages.getString("WorkingDirectoryBlock.4")); //$NON-NLS-1$ + + IContainer currentContainer = getContainer(); + if (currentContainer != null) { + IPath path = currentContainer.getFullPath(); + dialog.setInitialSelections(new Object[] { path}); + } + + dialog.showClosedProjects(false); + dialog.open(); + Object[] results = dialog.getResult(); + if ((results != null) && (results.length > 0) && (results[0] instanceof IPath)) { + IPath path = (IPath) results[0]; + String containerName = path.makeRelative().toString(); + fWorkingDirText.setText("${workspace_loc:" + containerName + "}"); //$NON-NLS-1$ //$NON-NLS-2$ + } + } + + /** + * Returns the selected workspace container,or null + */ + protected IContainer getContainer() { + String path = fWorkingDirText.getText().trim(); + if (path.length() > 0) { + IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); + IResource res = root.findMember(path); + if (res instanceof IContainer) { + return (IContainer) res; + } + } + return null; + } + + /** + * The default working dir check box has been toggled. + */ + protected void handleUseDefaultWorkingDirButtonSelected() { + boolean def = isDefaultWorkingDirectory(); + if (def) { + setDefaultWorkingDir(); + } + fWorkingDirText.setEnabled(!def); + fWorkspaceButton.setEnabled(!def); + fVariablesButton.setEnabled(!def); + fFileSystemButton.setEnabled(!def); + } + + protected void handleWorkingDirVariablesButtonSelected() { + String variableText = getVariable(); + if (variableText != null) { + fWorkingDirText.append(variableText); + } + } + + private String getVariable() { + StringVariableSelectionDialog dialog = new StringVariableSelectionDialog(getShell()); + dialog.open(); + return dialog.getVariableExpression(); + } + + /** + * Sets the default working directory + */ + protected void setDefaultWorkingDir() { + try { + ILaunchConfiguration config = getLaunchConfiguration(); + if (config != null) { + ICProject cProject = GdbLaunchDelegate.LaunchUtils.getCProject(config); + if (cProject != null) { + fWorkingDirText.setText("${workspace_loc:" + cProject.getPath().makeRelative().toOSString() + "}"); //$NON-NLS-1$ //$NON-NLS-2$ + return; + } + } + } catch (CoreException ce) { + } + fWorkingDirText.setText(System.getProperty("user.dir")); //$NON-NLS-1$ + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.debug.ui.ILaunchConfigurationTab#isValid(org.eclipse.debug.core.ILaunchConfiguration) + */ + @Override + public boolean isValid(ILaunchConfiguration config) { + + setErrorMessage(null); + setMessage(null); + + // if variables are present, we cannot resolve the directory + String workingDirPath = fWorkingDirText.getText().trim(); + if (workingDirPath.indexOf("${") >= 0) { //$NON-NLS-1$ + IStringVariableManager manager = VariablesPlugin.getDefault().getStringVariableManager(); + try { + manager.validateStringVariables(workingDirPath); + } catch (CoreException e) { + setErrorMessage(e.getMessage()); + return false; + } + } else if (workingDirPath.length() > 0) { + IContainer container = getContainer(); + if (container == null) { + File dir = new File(workingDirPath); + if (dir.isDirectory()) { + return true; + } + setErrorMessage(LaunchUIMessages.getString("WorkingDirectoryBlock.10")); //$NON-NLS-1$ + return false; + } + } + return true; + } + + /** + * Defaults are empty. + * + * @see org.eclipse.debug.ui.ILaunchConfigurationTab#setDefaults(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) + */ + public void setDefaults(ILaunchConfigurationWorkingCopy config) { + // config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, + // (String)null); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.debug.ui.ILaunchConfigurationTab#initializeFrom(org.eclipse.debug.core.ILaunchConfiguration) + */ + public void initializeFrom(ILaunchConfiguration configuration) { + setLaunchConfiguration(configuration); + try { + String wd = configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, (String) null); + fWorkingDirText.setText(""); //$NON-NLS-1$ + if (wd == null) { + fUseDefaultWorkingDirButton.setSelection(true); + } else { + fWorkingDirText.setText(wd); + fUseDefaultWorkingDirButton.setSelection(false); + } + handleUseDefaultWorkingDirButtonSelected(); + } catch (CoreException e) { + setErrorMessage(LaunchUIMessages.getString("WorkingDirectoryBlock.Exception_occurred_reading_configuration___15") + e.getStatus().getMessage()); //$NON-NLS-1$ + GdbUIPlugin.log(e); + } + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.debug.ui.ILaunchConfigurationTab#performApply(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) + */ + public void performApply(ILaunchConfigurationWorkingCopy configuration) { + String wd = null; + if (!isDefaultWorkingDirectory()) { + wd = getAttributeValueFrom(fWorkingDirText); + } + configuration.setAttribute(ICDTLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, wd); + } + + /** + * Retuns the string in the text widget, or null if empty. + * + * @return text or null + */ + protected String getAttributeValueFrom(Text text) { + String content = text.getText().trim(); + if (content.length() > 0) { + return content; + } + return null; + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getName() + */ + public String getName() { + return LaunchUIMessages.getString("WorkingDirectoryBlock.Working_Directory_8"); //$NON-NLS-1$ + } + + /** + * Returns whether the default working directory is to be used + */ + protected boolean isDefaultWorkingDirectory() { + return fUseDefaultWorkingDirButton.getSelection(); + } + + /** + * Sets the c project currently specified by the given launch config, if + * any. + */ + protected void setLaunchConfiguration(ILaunchConfiguration config) { + fLaunchConfiguration = config; + } + + /** + * Returns the current c project context + */ + protected ILaunchConfiguration getLaunchConfiguration() { + return fLaunchConfiguration; + } + +} + diff --git a/plugins/org.eclipse.dd.gdb/META-INF/MANIFEST.MF b/plugins/org.eclipse.dd.gdb/META-INF/MANIFEST.MF index 7bb5830b4e8..3858b1c5d4c 100644 --- a/plugins/org.eclipse.dd.gdb/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.dd.gdb/META-INF/MANIFEST.MF @@ -11,7 +11,8 @@ Require-Bundle: org.eclipse.core.runtime, org.eclipse.dd.mi, org.eclipse.debug.core, org.eclipse.cdt.core, - org.eclipse.cdt.debug.core + org.eclipse.cdt.debug.core, + org.eclipse.core.variables Bundle-ActivationPolicy: lazy Bundle-RequiredExecutionEnvironment: J2SE-1.5 Export-Package: org.eclipse.dd.gdb.internal.provisional, diff --git a/plugins/org.eclipse.dd.gdb/src/org/eclipse/dd/gdb/internal/provisional/launching/FinalLaunchSequence.java b/plugins/org.eclipse.dd.gdb/src/org/eclipse/dd/gdb/internal/provisional/launching/FinalLaunchSequence.java index 43703848ca1..66ebbe93e6e 100644 --- a/plugins/org.eclipse.dd.gdb/src/org/eclipse/dd/gdb/internal/provisional/launching/FinalLaunchSequence.java +++ b/plugins/org.eclipse.dd.gdb/src/org/eclipse/dd/gdb/internal/provisional/launching/FinalLaunchSequence.java @@ -24,6 +24,7 @@ import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.core.variables.VariablesPlugin; import org.eclipse.dd.dsf.concurrent.DataRequestMonitor; import org.eclipse.dd.dsf.concurrent.DsfExecutor; import org.eclipse.dd.dsf.concurrent.RequestMonitor; @@ -38,6 +39,7 @@ import org.eclipse.dd.mi.service.MIBreakpointsManager; import org.eclipse.dd.mi.service.command.commands.CLIAttach; import org.eclipse.dd.mi.service.command.commands.CLIMonitorListProcesses; import org.eclipse.dd.mi.service.command.commands.CLISource; +import org.eclipse.dd.mi.service.command.commands.MIGDBSetArgs; import org.eclipse.dd.mi.service.command.commands.MIFileExecAndSymbols; import org.eclipse.dd.mi.service.command.commands.MIGDBSetAutoSolib; import org.eclipse.dd.mi.service.command.commands.MIGDBSetSolibSearchPath; @@ -111,6 +113,28 @@ public class FinalLaunchSequence extends Sequence { } else { requestMonitor.done(); } + }}, + /* + * Specify the arguments to the executable file + */ + new Step() { @Override + public void execute(final RequestMonitor requestMonitor) { + try { + String args = fLaunch.getLaunchConfiguration().getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, + (String)null); + if (args != null) { + args = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(args); + + fCommandControl.queueCommand( + new MIGDBSetArgs(fCommandControl.getControlDMContext(), args), + new DataRequestMonitor(getExecutor(), requestMonitor)); + } else { + requestMonitor.done(); + } + } catch (CoreException e) { + requestMonitor.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, -1, "Cannot get inferior arguments", e)); //$NON-NLS-1$ + requestMonitor.done(); + } }}, /* * Tell GDB to automatically load or not the shared library symbols diff --git a/plugins/org.eclipse.dd.gdb/src/org/eclipse/dd/gdb/internal/provisional/launching/GdbLaunchDelegate.java b/plugins/org.eclipse.dd.gdb/src/org/eclipse/dd/gdb/internal/provisional/launching/GdbLaunchDelegate.java index 74d34502e31..57286d2fe07 100644 --- a/plugins/org.eclipse.dd.gdb/src/org/eclipse/dd/gdb/internal/provisional/launching/GdbLaunchDelegate.java +++ b/plugins/org.eclipse.dd.gdb/src/org/eclipse/dd/gdb/internal/provisional/launching/GdbLaunchDelegate.java @@ -317,7 +317,7 @@ public class GdbLaunchDelegate extends LaunchConfigurationDelegate return false; } - private static class LaunchUtils { + public static class LaunchUtils { /** * Verify the following things about the project: * - is a valid project name given @@ -444,7 +444,7 @@ public class GdbLaunchDelegate extends LaunchConfigurationDelegate * Returns an ICProject based on the project name provided in the configuration. * First look for a project by name, and then confirm it is a C/C++ project. */ - private static ICProject getCProject(ILaunchConfiguration configuration) throws CoreException { + public static ICProject getCProject(ILaunchConfiguration configuration) throws CoreException { String projectName = getProjectName(configuration); if (projectName != null) { projectName = projectName.trim(); diff --git a/plugins/org.eclipse.dd.mi/src/org/eclipse/dd/mi/service/command/commands/MIGDBSetArgs.java b/plugins/org.eclipse.dd.mi/src/org/eclipse/dd/mi/service/command/commands/MIGDBSetArgs.java new file mode 100644 index 00000000000..366471ff847 --- /dev/null +++ b/plugins/org.eclipse.dd.mi/src/org/eclipse/dd/mi/service/command/commands/MIGDBSetArgs.java @@ -0,0 +1,42 @@ +/******************************************************************************* + * Copyright (c) 2008 Ericsson and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Ericsson - Initial API and implementation + *******************************************************************************/ + +package org.eclipse.dd.mi.service.command.commands; + +import org.eclipse.dd.mi.service.command.MIControlDMContext; + +/** + * + * -gdb-set args ARGS + * + * Set the inferior program arguments, to be used in the next `-exec-run'. + * + */ +public class MIGDBSetArgs extends MIGDBSet +{ + public MIGDBSetArgs(MIControlDMContext dmc) { + super(dmc, new String[] {"args"}); //$NON-NLS-1$ + } + + public MIGDBSetArgs(MIControlDMContext dmc, String arguments) { + super(dmc, null); + + // We do not want to quote the arguments of this command so we must + // split them into individual strings + String[] argArray = arguments.split(" "); //$NON-NLS-1$ + String[] cmdArray = new String[argArray.length + 1]; + cmdArray[0] = "args"; //$NON-NLS-1$ + for (int i=0; i