So this is what I ended up doing:
In my debug launch plugin activator:
public
void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
CDebugCorePlugin.getDefault();//make sure this is loaded first
//set the default delegates
setDefaultLaunchDelegates();
}
This ensures that the CDebugCorePlugin gets started before my code. I changed the setDefaultLaunchDelegates method to not check for existing default but to just set the one that I want.
From: cdt-dev-bounces@xxxxxxxxxxx [mailto:cdt-dev-bounces@xxxxxxxxxxx]
On Behalf Of Marc Khouzam
Sent: Tuesday, May 20, 2014 10:08 AM
To: 'CDT General developers list.'
Subject: Re: [cdt-dev] Setting default delegate for a launch configuration.
If you rebuild CDT, you can change the values in ICDTLaunchConfigurationConstants.
However, if you just extend CDT, then I think what will work is to run the same code as CDebugCorePlugin#setDefaultLaunchDelegates() but setting your own delegate.
If CDebugCorePlugin#setDefaultLaunchDelegates() runs before yours, you should change your code a little to allow to set a new delegate although there is already one set. By this I mean to be careful about lines
like:
if (localCfg.getPreferredDelegate(debugSet) == null)
which will prevent setting a new default delegate if there is already one.
If your code runs first, you should be able to run the exact same logic as CDebugCorePlugin#setDefaultLaunchDelegates(). Although the check for an existing delegate may cause you problems if the user re-uses
an old workspace or maybe imports preferences. I’m sure you’ll figure it out if you try things out.
Marc
So I found the bug you were talking about
https://bugs.eclipse.org/bugs/show_bug.cgi?id=304384.
It appears that the default delegate is keyed off of a global preference (which I cant change.. or can I?).
I don't have the code in front of me, but you can look at how we set the default delegate to dsf-gdb. I believe it is in the plugin class of one of the debug plugins, probably o.e.cdt.debug. Look for the string "preferred".
Out you can look in bugzilla for a bug titled something like " make dsf-gdb the default debugger... "
BR,
Marc
----- Original Message -----
From: Joseph Henry <Joseph.Henry@xxxxxxx>
To: "CDT General developers list." <cdt-dev@xxxxxxxxxxx>
Sent: 19/05/2014 14:37
Subject: [cdt-dev] Setting default delegate for a launch configuration.
Hi all,
I have a custom launch Delegate that can be assigned to the C/C++ Application launch configuration.
Currently users must create a launch configuration and then select my custom delegate manually. Is there any way that I can make my delegate the default?
Thanks,
Joseph Henry.