1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-05 15:25:49 +02:00

added supported cpu list to debugger extension

This commit is contained in:
David Inglis 2002-11-13 14:00:33 +00:00
parent 0b999fef42
commit 2abb649ea3
4 changed files with 80 additions and 21 deletions

View file

@ -1,3 +1,9 @@
2002-11-13
* schema/CDebugger.exsd
* src/org/eclipse/cdt/debug/core/ICDebugConfiguration.java
* src/org/eclipse/cdt/debug/internal/core/DebugConfiguration.java
Added supported CPU to Debugger extension.
2002-11-07 Mikhail Khodjaiants 2002-11-07 Mikhail Khodjaiants
When a referenced project is deleted it's location is null. The source locator should When a referenced project is deleted it's location is null. The source locator should
check this when it returns the path array. check this when it returns the path array.

View file

@ -72,6 +72,20 @@
</documentation> </documentation>
</annotation> </annotation>
</attribute> </attribute>
<attribute name="platform" type="string">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="cpu" type="string">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
</complexType> </complexType>
</element> </element>

View file

@ -7,9 +7,12 @@ package org.eclipse.cdt.debug.core;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
public interface ICDebugConfiguration { public interface ICDebugConfiguration {
public ICDebugger getDebugger() throws CoreException; ICDebugger getDebugger() throws CoreException;
public String getName(); String getName();
public String getID(); String getID();
public String[] getPlatforms(); String getPlatform();
public boolean supportsMode(String mode); String[] getCPUList();
String[] getModeList();
boolean supportsCPU(String cpu);
boolean supportsMode(String mode);
} }

View file

@ -10,6 +10,7 @@ import java.util.StringTokenizer;
import org.eclipse.cdt.debug.core.ICDebugConfiguration; import org.eclipse.cdt.debug.core.ICDebugConfiguration;
import org.eclipse.cdt.debug.core.ICDebugger; import org.eclipse.cdt.debug.core.ICDebugger;
import org.eclipse.core.boot.BootLoader;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.IConfigurationElement;
@ -19,17 +20,19 @@ public class DebugConfiguration implements ICDebugConfiguration {
*/ */
private IConfigurationElement fElement; private IConfigurationElement fElement;
private HashSet fModes; private HashSet fModes;
private HashSet fCPUs;
public static final String NATIVE = "native";
public DebugConfiguration(IConfigurationElement element) { public DebugConfiguration(IConfigurationElement element) {
fElement = element; fElement = element;
} }
private IConfigurationElement getConfigurationElement() { private IConfigurationElement getConfigurationElement() {
return fElement; return fElement;
} }
public ICDebugger getDebugger() throws CoreException { public ICDebugger getDebugger() throws CoreException {
return (ICDebugger)getConfigurationElement().createExecutableExtension("class"); return (ICDebugger) getConfigurationElement().createExecutableExtension("class");
} }
public String getName() { public String getName() {
@ -41,23 +44,33 @@ public class DebugConfiguration implements ICDebugConfiguration {
return getConfigurationElement().getAttribute("id"); //$NON-NLS-1$ return getConfigurationElement().getAttribute("id"); //$NON-NLS-1$
} }
public String[] getPlatforms() { public String getPlatform() {
String platform = getConfigurationElement().getAttribute("platform"); String platform = getConfigurationElement().getAttribute("platform");
if ( platform == null ) { if (platform == null) {
return new String[] {"local"}; return NATIVE;
} }
StringTokenizer stoken = new StringTokenizer(platform, ","); return platform;
String[] platforms = new String[stoken.countTokens()];
for( int i = 0; i < platforms.length; i++ ) {
platforms[i] = stoken.nextToken();
}
return platforms;
} }
public String[] getCPUList() {
return (String[]) getCPUs().toArray(new String[0]);
}
public String[] getModeList() {
return (String[]) getModes().toArray(new String[0]);
}
public boolean supportsMode(String mode) { public boolean supportsMode(String mode) {
return getModes().contains(mode); return getModes().contains(mode);
} }
public boolean supportsCPU(String cpu) {
String nativeCPU = BootLoader.getOSArch();
if ( nativeCPU.startsWith(cpu) ) {
cpu = NATIVE;
}
return getCPUs().contains(cpu);
}
/** /**
* Returns the set of modes specified in the configuration data. * Returns the set of modes specified in the configuration data.
* *
@ -65,11 +78,11 @@ public class DebugConfiguration implements ICDebugConfiguration {
*/ */
protected Set getModes() { protected Set getModes() {
if (fModes == null) { if (fModes == null) {
String modes= getConfigurationElement().getAttribute("modes"); //$NON-NLS-1$ String modes = getConfigurationElement().getAttribute("modes"); //$NON-NLS-1$
if (modes == null) { if (modes == null) {
return new HashSet(0); return new HashSet(0);
} }
StringTokenizer tokenizer= new StringTokenizer(modes, ","); //$NON-NLS-1$ StringTokenizer tokenizer = new StringTokenizer(modes, ","); //$NON-NLS-1$
fModes = new HashSet(tokenizer.countTokens()); fModes = new HashSet(tokenizer.countTokens());
while (tokenizer.hasMoreTokens()) { while (tokenizer.hasMoreTokens()) {
fModes.add(tokenizer.nextToken().trim()); fModes.add(tokenizer.nextToken().trim());
@ -78,4 +91,27 @@ public class DebugConfiguration implements ICDebugConfiguration {
return fModes; return fModes;
} }
protected Set getCPUs() {
if (fCPUs == null) {
String cpus = getConfigurationElement().getAttribute("cpu"); //$NON-NLS-1$
if (cpus == null) {
fCPUs = new HashSet(1);
fCPUs.add(NATIVE);
}
else {
String nativeCPU = BootLoader.getOSArch();
StringTokenizer tokenizer = new StringTokenizer(cpus, ","); //$NON-NLS-1$
fCPUs = new HashSet(tokenizer.countTokens());
while (tokenizer.hasMoreTokens()) {
String cpu = tokenizer.nextToken().trim();
fCPUs.add(cpu);
if (nativeCPU.startsWith(cpu)) { // os arch be cpu{le/be}
fCPUs.add(NATIVE);
}
}
}
}
return fCPUs;
}
} }