mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-09 01:05:38 +02:00
implemented better debug configuration handling
This commit is contained in:
parent
1354f9e661
commit
1bb2dc9562
6 changed files with 103 additions and 112 deletions
|
@ -6,14 +6,21 @@
|
||||||
|
|
||||||
package org.eclipse.cdt.debug.core;
|
package org.eclipse.cdt.debug.core;
|
||||||
|
|
||||||
import org.eclipse.cdt.debug.internal.core.CDebuggerManager;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.debug.internal.core.DebugConfiguration;
|
||||||
import org.eclipse.core.resources.IWorkspace;
|
import org.eclipse.core.resources.IWorkspace;
|
||||||
import org.eclipse.core.resources.ResourcesPlugin;
|
import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
|
import org.eclipse.core.runtime.IConfigurationElement;
|
||||||
|
import org.eclipse.core.runtime.IExtensionPoint;
|
||||||
import org.eclipse.core.runtime.IPluginDescriptor;
|
import org.eclipse.core.runtime.IPluginDescriptor;
|
||||||
import org.eclipse.core.runtime.IStatus;
|
import org.eclipse.core.runtime.IStatus;
|
||||||
import org.eclipse.core.runtime.Plugin;
|
import org.eclipse.core.runtime.Plugin;
|
||||||
import org.eclipse.core.runtime.Status;
|
import org.eclipse.core.runtime.Status;
|
||||||
import org.eclipse.debug.core.DebugException;
|
import org.eclipse.debug.core.DebugException;
|
||||||
|
import org.eclipse.debug.core.DebugPlugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The main plugin class to be used in the desktop.
|
* The main plugin class to be used in the desktop.
|
||||||
|
@ -28,7 +35,7 @@ public class CDebugCorePlugin extends Plugin
|
||||||
//The shared instance.
|
//The shared instance.
|
||||||
private static CDebugCorePlugin plugin;
|
private static CDebugCorePlugin plugin;
|
||||||
|
|
||||||
private CDebuggerManager debuggerManager;
|
private HashMap fDebugConfigurations;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The constructor.
|
* The constructor.
|
||||||
|
@ -108,10 +115,29 @@ public class CDebugCorePlugin extends Plugin
|
||||||
getDefault().getLog().log( status );
|
getDefault().getLog().log( status );
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICDebuggerManager getDebuggerManager() {
|
private void initializeDebugConfiguration() {
|
||||||
if ( debuggerManager == null ) {
|
IPluginDescriptor descriptor= getDefault().getDescriptor();
|
||||||
debuggerManager = new CDebuggerManager();
|
IExtensionPoint extensionPoint= descriptor.getExtensionPoint("CDebugger");
|
||||||
}
|
IConfigurationElement[] infos= extensionPoint.getConfigurationElements();
|
||||||
return debuggerManager;
|
fDebugConfigurations = new HashMap(infos.length);
|
||||||
|
for (int i= 0; i < infos.length; i++) {
|
||||||
|
IConfigurationElement configurationElement = infos[i];
|
||||||
|
DebugConfiguration configType = new DebugConfiguration(configurationElement);
|
||||||
|
fDebugConfigurations.put(configType.getID(), configType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICDebugConfiguration[] getDebugConfigurations() {
|
||||||
|
if (fDebugConfigurations == null) {
|
||||||
|
initializeDebugConfiguration();
|
||||||
|
}
|
||||||
|
return (ICDebugConfiguration[]) fDebugConfigurations.values().toArray(new ICDebugConfiguration[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICDebugConfiguration getDebugConfiguration(String id) {
|
||||||
|
if (fDebugConfigurations == null) {
|
||||||
|
initializeDebugConfiguration();
|
||||||
|
}
|
||||||
|
return (ICDebugConfiguration) fDebugConfigurations.get(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
/*
|
||||||
|
* (c) Copyright QNX Software System Ltd. 2002.
|
||||||
|
* All Rights Reserved.
|
||||||
|
*/
|
||||||
|
package org.eclipse.cdt.debug.core;
|
||||||
|
|
||||||
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
|
public interface ICDebugConfiguration {
|
||||||
|
public ICDebugger getDebugger() throws CoreException;
|
||||||
|
public String getName();
|
||||||
|
public String getID();
|
||||||
|
public String[] getPlatforms();
|
||||||
|
}
|
|
@ -1,10 +0,0 @@
|
||||||
/*
|
|
||||||
* (c) Copyright QNX Software System Ltd. 2002.
|
|
||||||
* All Rights Reserved.
|
|
||||||
*/package org.eclipse.cdt.debug.core;
|
|
||||||
|
|
||||||
public interface ICDebuggerInfo {
|
|
||||||
String getID();
|
|
||||||
String getName();
|
|
||||||
String[] getSupportedPlatforms();
|
|
||||||
}
|
|
|
@ -1,12 +0,0 @@
|
||||||
/*
|
|
||||||
* (c) Copyright QNX Software System Ltd. 2002.
|
|
||||||
* All Rights Reserved.
|
|
||||||
*/
|
|
||||||
package org.eclipse.cdt.debug.core;
|
|
||||||
|
|
||||||
import org.eclipse.core.runtime.CoreException;
|
|
||||||
|
|
||||||
public interface ICDebuggerManager {
|
|
||||||
public ICDebugger createDebugger(String id) throws CoreException;
|
|
||||||
public ICDebuggerInfo[] queryDebuggers(String platform_id);
|
|
||||||
}
|
|
|
@ -1,83 +0,0 @@
|
||||||
/*
|
|
||||||
* (c) Copyright QNX Software System Ltd. 2002.
|
|
||||||
* All Rights Reserved.
|
|
||||||
*/
|
|
||||||
package org.eclipse.cdt.debug.internal.core;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.StringTokenizer;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
|
|
||||||
import org.eclipse.cdt.debug.core.ICDebugger;
|
|
||||||
import org.eclipse.cdt.debug.core.ICDebuggerManager;
|
|
||||||
import org.eclipse.cdt.debug.core.ICDebuggerInfo;
|
|
||||||
import org.eclipse.core.runtime.CoreException;
|
|
||||||
import org.eclipse.core.runtime.IConfigurationElement;
|
|
||||||
import org.eclipse.core.runtime.IExtension;
|
|
||||||
import org.eclipse.core.runtime.IExtensionPoint;
|
|
||||||
|
|
||||||
public class CDebuggerManager implements ICDebuggerManager {
|
|
||||||
|
|
||||||
public CDebuggerManager() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public ICDebugger createDebugger(String id) throws CoreException {
|
|
||||||
ICDebugger debugger = null;
|
|
||||||
|
|
||||||
IExtensionPoint extension = CDebugCorePlugin.getDefault().getDescriptor().getExtensionPoint("CDebugger");
|
|
||||||
if (extension != null) {
|
|
||||||
IExtension[] extensions = extension.getExtensions();
|
|
||||||
for(int i = 0; i < extensions.length; i++){
|
|
||||||
if ( id.equals(extensions[i].getUniqueIdentifier()) ) {
|
|
||||||
IConfigurationElement [] configElements = extensions[i].getConfigurationElements();
|
|
||||||
debugger = (ICDebugger)configElements[0].createExecutableExtension("class");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return debugger;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ICDebuggerInfo[] queryDebuggers(String platform_id) {
|
|
||||||
IExtensionPoint extension = CDebugCorePlugin.getDefault().getDescriptor().getExtensionPoint("CDebugger");
|
|
||||||
if (extension != null) {
|
|
||||||
IExtension[] extensions = extension.getExtensions();
|
|
||||||
CDebuggerInfo dinfo;
|
|
||||||
ArrayList dlist = new ArrayList(extensions.length);
|
|
||||||
for(int i = 0; i < extensions.length; i++){
|
|
||||||
IConfigurationElement [] configElements = extensions[i].getConfigurationElements();
|
|
||||||
String platform = configElements[0].getAttribute("platform");
|
|
||||||
if ( platform == null || platform.equals("*") || platform.indexOf(platform_id) != -1 ) {
|
|
||||||
dlist.add(dinfo = new CDebuggerInfo());
|
|
||||||
dinfo.name = extensions[i].getLabel();
|
|
||||||
dinfo.id = extensions[i].getUniqueIdentifier();
|
|
||||||
dinfo.platforms = platform;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return (ICDebuggerInfo[]) dlist.toArray(new ICDebuggerInfo[dlist.size()]);
|
|
||||||
}
|
|
||||||
return new ICDebuggerInfo[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
class CDebuggerInfo implements ICDebuggerInfo {
|
|
||||||
String id;
|
|
||||||
String name;
|
|
||||||
String platforms;
|
|
||||||
|
|
||||||
public String getID() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String[] getSupportedPlatforms() {
|
|
||||||
StringTokenizer stoken = new StringTokenizer(platforms, ",");
|
|
||||||
String[] platforms = new String[stoken.countTokens()];
|
|
||||||
for( int i = 0; i < platforms.length; i++ ) {
|
|
||||||
platforms[i] = stoken.nextToken();
|
|
||||||
}
|
|
||||||
return platforms;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,56 @@
|
||||||
|
/*
|
||||||
|
* (c) Copyright QNX Software System Ltd. 2002.
|
||||||
|
* All Rights Reserved.
|
||||||
|
*/
|
||||||
|
package org.eclipse.cdt.debug.internal.core;
|
||||||
|
|
||||||
|
import java.util.StringTokenizer;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.debug.core.ICDebugConfiguration;
|
||||||
|
import org.eclipse.cdt.debug.core.ICDebugger;
|
||||||
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
import org.eclipse.core.runtime.IConfigurationElement;
|
||||||
|
|
||||||
|
public class DebugConfiguration implements ICDebugConfiguration {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The configuration element of the extension.
|
||||||
|
*/
|
||||||
|
private IConfigurationElement fElement;
|
||||||
|
|
||||||
|
public DebugConfiguration(IConfigurationElement element) {
|
||||||
|
fElement = element;
|
||||||
|
}
|
||||||
|
|
||||||
|
private IConfigurationElement getConfigurationElement() {
|
||||||
|
return fElement;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICDebugger getDebugger() throws CoreException {
|
||||||
|
return (ICDebugger)getConfigurationElement().createExecutableExtension("class");
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return getConfigurationElement().getAttribute("name"); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getID() {
|
||||||
|
return getConfigurationElement().getAttribute("id"); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
public String[] getPlatforms() {
|
||||||
|
String platform = getConfigurationElement().getAttribute("platform");
|
||||||
|
if ( platform == null ) {
|
||||||
|
return new String[] {"*"};
|
||||||
|
}
|
||||||
|
StringTokenizer stoken = new StringTokenizer(platform, ",");
|
||||||
|
String[] platforms = new String[stoken.countTokens()];
|
||||||
|
for( int i = 0; i < platforms.length; i++ ) {
|
||||||
|
platforms[i] = stoken.nextToken();
|
||||||
|
}
|
||||||
|
return platforms;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue