diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugCorePlugin.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugCorePlugin.java index 15af99f8a9d..784705a0918 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugCorePlugin.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugCorePlugin.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2007 QNX Software Systems and others. + * Copyright (c) 2004, 2010 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 @@ -41,6 +41,10 @@ import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Plugin; import org.eclipse.core.runtime.Status; import org.eclipse.debug.core.DebugException; +import org.eclipse.debug.core.DebugPlugin; +import org.eclipse.debug.core.ILaunchConfigurationType; +import org.eclipse.debug.core.ILaunchDelegate; +import org.eclipse.debug.core.ILaunchManager; import org.osgi.framework.BundleContext; /** @@ -338,6 +342,7 @@ public class CDebugCorePlugin extends Plugin { createBreakpointListenersList(); createDisassemblyContextService(); setSessionManager( new SessionManager() ); + setDefaultLaunchDelegates(); } /* (non-Javadoc) @@ -429,4 +434,67 @@ public class CDebugCorePlugin extends Plugin { if ( fDisassemblyContextService != null ) fDisassemblyContextService.dispose(); } + + private void setDefaultLaunchDelegates() { + // Set the default launch delegates as early as possible, and do it only once (Bug 312997) + ILaunchManager launchMgr = DebugPlugin.getDefault().getLaunchManager(); + + HashSet debugSet = new HashSet(); + debugSet.add(ILaunchManager.DEBUG_MODE); + + ILaunchConfigurationType localCfg = launchMgr.getLaunchConfigurationType(ICDTLaunchConfigurationConstants.ID_LAUNCH_C_APP); + try { + if (localCfg.getPreferredDelegate(debugSet) == null) { + ILaunchDelegate[] delegates = localCfg.getDelegates(debugSet); + for (ILaunchDelegate delegate : delegates) { + if (ICDTLaunchConfigurationConstants.PREFERRED_DEBUG_LOCAL_LAUNCH_DELEGATE.equals(delegate.getId())) { + localCfg.setPreferredDelegate(debugSet, delegate); + break; + } + } + } + } catch (CoreException e) {} + + ILaunchConfigurationType attachCfg = launchMgr.getLaunchConfigurationType(ICDTLaunchConfigurationConstants.ID_LAUNCH_C_ATTACH); + try { + if (attachCfg.getPreferredDelegate(debugSet) == null) { + ILaunchDelegate[] delegates = attachCfg.getDelegates(debugSet); + for (ILaunchDelegate delegate : delegates) { + if (ICDTLaunchConfigurationConstants.PREFERRED_DEBUG_ATTACH_LAUNCH_DELEGATE.equals(delegate.getId())) { + attachCfg.setPreferredDelegate(debugSet, delegate); + break; + } + } + } + } catch (CoreException e) {} + + ILaunchConfigurationType postMortemCfg = launchMgr.getLaunchConfigurationType(ICDTLaunchConfigurationConstants.ID_LAUNCH_C_POST_MORTEM); + try { + if (postMortemCfg.getPreferredDelegate(debugSet) == null) { + ILaunchDelegate[] delegates = postMortemCfg.getDelegates(debugSet); + for (ILaunchDelegate delegate : delegates) { + if (ICDTLaunchConfigurationConstants.PREFERRED_DEBUG_POSTMORTEM_LAUNCH_DELEGATE.equals(delegate.getId())) { + postMortemCfg.setPreferredDelegate(debugSet, delegate); + break; + } + } + } + } catch (CoreException e) {} + + HashSet runSet = new HashSet(); + runSet.add(ILaunchManager.RUN_MODE); + + try { + if (localCfg.getPreferredDelegate(runSet) == null) { + ILaunchDelegate[] delegates = localCfg.getDelegates(runSet); + for (ILaunchDelegate delegate : delegates) { + if (ICDTLaunchConfigurationConstants.PREFERRED_RUN_LAUNCH_DELEGATE.equals(delegate.getId())) { + localCfg.setPreferredDelegate(runSet, delegate); + break; + } + } + } + } catch (CoreException e) {} + } + } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/CApplicationLaunchShortcut.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/CApplicationLaunchShortcut.java index 8c1b2b610fe..0604189202d 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/CApplicationLaunchShortcut.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/CApplicationLaunchShortcut.java @@ -15,7 +15,6 @@ package org.eclipse.cdt.debug.internal.ui.launch; import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; import java.util.Collections; -import java.util.HashSet; import java.util.Iterator; import java.util.List; @@ -202,26 +201,6 @@ public class CApplicationLaunchShortcut implements ILaunchShortcut2 { ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN); wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID, debugConfig.getID()); - // Workaround for bug 262840 - try { - HashSet set = new HashSet(); - set.add(ILaunchManager.RUN_MODE); - if (wc.getPreferredDelegate(set) == null && wc.getType().getPreferredDelegate(set) == null) { - wc.setPreferredLaunchDelegate(set, ICDTLaunchConfigurationConstants.PREFERRED_RUN_LAUNCH_DELEGATE); - } - } catch (CoreException e) {} - - // We must also set the debug mode delegate because this configuration can be re-used - // in Debug mode. - try { - HashSet set = new HashSet(); - set.add(ILaunchManager.DEBUG_MODE); - if (wc.getPreferredDelegate(set) == null && wc.getType().getPreferredDelegate(set) == null) { - wc.setPreferredLaunchDelegate(set, ICDTLaunchConfigurationConstants.PREFERRED_DEBUG_LOCAL_LAUNCH_DELEGATE); - } - } catch (CoreException e) {} - // End workaround for bug 262840 - ICProjectDescription projDes = CCorePlugin.getDefault().getProjectDescription(bin.getCProject().getProject()); if (projDes != null) { diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CMainTab.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CMainTab.java index 2c92c2eecc1..99861b8c525 100644 --- a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CMainTab.java +++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CMainTab.java @@ -12,8 +12,6 @@ *******************************************************************************/ package org.eclipse.cdt.launch.ui; -import java.util.HashSet; - import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.model.IBinary; import org.eclipse.cdt.core.model.ICElement; @@ -34,7 +32,6 @@ import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; -import org.eclipse.debug.core.ILaunchManager; import org.eclipse.debug.ui.DebugUITools; import org.eclipse.debug.ui.IDebugUIConstants; import org.eclipse.jface.dialogs.MessageDialog; @@ -533,31 +530,6 @@ public class CMainTab extends CAbstractMainTab { * @see org.eclipse.debug.ui.ILaunchConfigurationTab#setDefaults(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) */ public void setDefaults(ILaunchConfigurationWorkingCopy config) { - // Workaround for bug 262840 - try { - HashSet set = new HashSet(); - set.add(ILaunchManager.DEBUG_MODE); - if ( config.getPreferredDelegate(set) == null && config.getType().getPreferredDelegate(set) == null) { - if (config.getType().getIdentifier().equals(ICDTLaunchConfigurationConstants.ID_LAUNCH_C_APP)) { - config.setPreferredLaunchDelegate(set, ICDTLaunchConfigurationConstants.PREFERRED_DEBUG_LOCAL_LAUNCH_DELEGATE); - } else if (config.getType().getIdentifier().equals(ICDTLaunchConfigurationConstants.ID_LAUNCH_C_ATTACH)) { - config.setPreferredLaunchDelegate(set, ICDTLaunchConfigurationConstants.PREFERRED_DEBUG_ATTACH_LAUNCH_DELEGATE); - } else if (config.getType().getIdentifier().equals(ICDTLaunchConfigurationConstants.ID_LAUNCH_C_POST_MORTEM)) { - config.setPreferredLaunchDelegate(set, ICDTLaunchConfigurationConstants.PREFERRED_DEBUG_POSTMORTEM_LAUNCH_DELEGATE); - } - } - } catch (CoreException e) {} - - // We must also set the preferred delegate for Run mode, because this configuration - // can be used in Run mode. - try { - HashSet set = new HashSet(); - set.add(ILaunchManager.RUN_MODE); - if ( config.getPreferredDelegate(set) == null && config.getType().getPreferredDelegate(set) == null) { - config.setPreferredLaunchDelegate(set, ICDTLaunchConfigurationConstants.PREFERRED_RUN_LAUNCH_DELEGATE); - } - } catch (CoreException e) {} - // We set empty attributes for project & program so that when one config // is // compared to another, the existence of empty attributes doesn't cause