From 0ea73d63b0c7d91aa19329bd630dbb6c6b33109b Mon Sep 17 00:00:00 2001 From: Marc Khouzam Date: Wed, 20 Aug 2008 19:28:14 +0000 Subject: [PATCH] Bug 244567 Make the executable optional in the Main launch tab, when doing an attach session. The project is still mandatory for two reasons: 1- platform does not allow an empty project 2- Source lookup was not able to find the code with an empty project; since the platform did not allow for an empty project anyway, I did not investigate the source lookup issue. --- .../gdb/internal/ui/launching/CMainTab.java | 6 ++-- .../GdbAttachLaunchConfigurationTabGroup.java | 2 +- .../launching/GdbLaunchDelegate.java | 29 +++++++++++++++---- .../provisional/launching/LaunchUtils.java | 3 +- 4 files changed, 30 insertions(+), 10 deletions(-) diff --git a/plugins/org.eclipse.dd.gdb.ui/src/org/eclipse/dd/gdb/internal/ui/launching/CMainTab.java b/plugins/org.eclipse.dd.gdb.ui/src/org/eclipse/dd/gdb/internal/ui/launching/CMainTab.java index c5123862c5c..2e434cb49ee 100644 --- a/plugins/org.eclipse.dd.gdb.ui/src/org/eclipse/dd/gdb/internal/ui/launching/CMainTab.java +++ b/plugins/org.eclipse.dd.gdb.ui/src/org/eclipse/dd/gdb/internal/ui/launching/CMainTab.java @@ -527,9 +527,6 @@ public class CMainTab extends CLaunchConfigurationTab { setErrorMessage(null); setMessage(null); - if (dontCheckProgram) - return true; - String name = fProjText.getText().trim(); if (name.length() == 0) { setErrorMessage(LaunchMessages.getString("CMainTab.Project_not_specified")); //$NON-NLS-1$ @@ -545,6 +542,9 @@ public class CMainTab extends CLaunchConfigurationTab { return false; } + if (dontCheckProgram) + return true; + name = fProgText.getText().trim(); if (name.length() == 0) { setErrorMessage(LaunchMessages.getString("CMainTab.Program_not_specified")); //$NON-NLS-1$ diff --git a/plugins/org.eclipse.dd.gdb.ui/src/org/eclipse/dd/gdb/internal/ui/launching/GdbAttachLaunchConfigurationTabGroup.java b/plugins/org.eclipse.dd.gdb.ui/src/org/eclipse/dd/gdb/internal/ui/launching/GdbAttachLaunchConfigurationTabGroup.java index 5224c1b347d..8c0ed68cc40 100644 --- a/plugins/org.eclipse.dd.gdb.ui/src/org/eclipse/dd/gdb/internal/ui/launching/GdbAttachLaunchConfigurationTabGroup.java +++ b/plugins/org.eclipse.dd.gdb.ui/src/org/eclipse/dd/gdb/internal/ui/launching/GdbAttachLaunchConfigurationTabGroup.java @@ -24,7 +24,7 @@ public class GdbAttachLaunchConfigurationTabGroup extends AbstractLaunchConfigur */ public void createTabs(ILaunchConfigurationDialog dialog, String mode) { ILaunchConfigurationTab[] tabs = new ILaunchConfigurationTab[] { - new CMainTab(), + new CMainTab(2), // In some case, we don't need to specify an executable // We don't know yet if we are going to do a remote or local session new CDebuggerTab(null, true), new SourceLookupTab(), 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 33b0d62f120..77fd42a03ee 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 @@ -26,6 +26,7 @@ import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Status; import org.eclipse.dd.dsf.concurrent.DsfExecutor; import org.eclipse.dd.dsf.concurrent.Sequence; @@ -98,12 +99,30 @@ public class GdbLaunchDelegate extends LaunchConfigurationDelegate monitor.subTask( "Debugging local C/C++ application" ); //$NON-NLS-1$ } + IPath exePath = new Path(""); //$NON-NLS-1$ + // An attach session does not need to necessarily have an + // executable specified. This is because: + // - In remote multi-process attach, there will be more than one executable + // In this case executables need to be specified differently. + // The current solution is to use the solib-search-path to specify + // the path of any executable we can attach to. + // - In local single process, GDB has the ability to find the executable + // automatically. + // + // An attach session also does not need to necessarily have a project + // specified. This is because we can perform source lookup towards + // code that is outside the workspace. + // However, the Platform does not support this, so for now, we check + // See bug 244567 + // First verify we are dealing with a proper project. - ICProject project = LaunchUtils.verifyCProject(config); - // Now verify we know the program to debug. - IPath exePath = LaunchUtils.verifyProgramPath(config, project); - // Finally, make sure the program is a proper binary. - LaunchUtils.verifyBinary(config, exePath); + ICProject project = LaunchUtils.verifyCProject(config); + if (!attach) { + // Now verify we know the program to debug. + exePath = LaunchUtils.verifyProgramPath(config, project); + // Finally, make sure the program is a proper binary. + LaunchUtils.verifyBinary(config, exePath); + } monitor.worked( 1 ); diff --git a/plugins/org.eclipse.dd.gdb/src/org/eclipse/dd/gdb/internal/provisional/launching/LaunchUtils.java b/plugins/org.eclipse.dd.gdb/src/org/eclipse/dd/gdb/internal/provisional/launching/LaunchUtils.java index 34696ecc61e..66d149ddd9b 100644 --- a/plugins/org.eclipse.dd.gdb/src/org/eclipse/dd/gdb/internal/provisional/launching/LaunchUtils.java +++ b/plugins/org.eclipse.dd.gdb/src/org/eclipse/dd/gdb/internal/provisional/launching/LaunchUtils.java @@ -55,9 +55,10 @@ public class LaunchUtils { if (name == null) { abort(LaunchMessages.getString("AbstractCLaunchDelegate.C_Project_not_specified"), null, //$NON-NLS-1$ ICDTLaunchConfigurationConstants.ERR_UNSPECIFIED_PROJECT); + return null; } ICProject cproject = getCProject(configuration); - if (cproject == null) { + if (cproject == null && name.length() > 0) { IProject proj = ResourcesPlugin.getWorkspace().getRoot().getProject(name); if (!proj.exists()) { abort(