diff --git a/launch/org.eclipse.cdt.launch/ChangeLog b/launch/org.eclipse.cdt.launch/ChangeLog
index a5ae7e89030..f7987f09291 100644
--- a/launch/org.eclipse.cdt.launch/ChangeLog
+++ b/launch/org.eclipse.cdt.launch/ChangeLog
@@ -1,3 +1,12 @@
+2002-11-13 David Inglis
+ * src/.../launch/ui/CDebuggerTab.java
+ * src/.../launch/ui/CLaunchConfigurationTab.java
+ * src/.../launch/ui/CorefileDebuggerTab.java
+ Added support for supported cpus on a debugger and filters list based on
+ selected IBinary.
+ Default debugger selection is not the first exact matching debugger for
+ the specified platform.
+
2002-11-06 David Inglis
* src/.../launch/ui/CMainTab.java
* src/.../launch/ui/ClaunchCOnfigurationTAb.java
diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CDebuggerTab.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CDebuggerTab.java
index 9ff8f288da0..2a4c233fed7 100644
--- a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CDebuggerTab.java
+++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CDebuggerTab.java
@@ -4,6 +4,8 @@
*/
package org.eclipse.cdt.launch.ui;
+import org.eclipse.cdt.core.model.IBinary;
+import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
import org.eclipse.cdt.debug.core.ICDebugConfiguration;
import org.eclipse.cdt.launch.ICDTLaunchConfigurationConstants;
@@ -97,30 +99,40 @@ public class CDebuggerTab extends AbstractCDebuggerTab {
protected void loadDebuggerComboBox(ILaunchConfiguration config, String selection) {
ICDebugConfiguration[] debugConfigs;
- String platform = getPlatform(config);
+ String configPlatform = getPlatform(config);
+ String programCPU = "native";
+ ICElement ce = getContext(config, configPlatform);
+ try {
+ IBinary bin = (IBinary) ce;
+ programCPU = bin.getCPU();
+ }
+ catch (Exception e) {
+ }
fDCombo.removeAll();
debugConfigs = CDebugCorePlugin.getDefault().getDebugConfigurations();
int x = 0;
- int selndx = 0;
+ int selndx = -1;
for (int i = 0; i < debugConfigs.length; i++) {
if (debugConfigs[i].supportsMode(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN)
- || debugConfigs[i].supportsMode(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH) ) {
- String supported[] = debugConfigs[i].getPlatforms();
- boolean isNative = platform.equals(BootLoader.getOS());
- for (int j = 0; j < supported.length; j++) {
- if (supported[j].equalsIgnoreCase(platform) || (isNative && supported[j].equalsIgnoreCase("native"))) {
+ || debugConfigs[i].supportsMode(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH)) {
+ String debuggerPlatform = debugConfigs[i].getPlatform();
+ boolean isNative = configPlatform.equals(BootLoader.getOS());
+ if (debuggerPlatform.equalsIgnoreCase(configPlatform) ||
+ (isNative && debuggerPlatform.equalsIgnoreCase("native"))) {
+ if (debugConfigs[i].supportsCPU(programCPU)) {
fDCombo.add(debugConfigs[i].getName());
fDCombo.setData(Integer.toString(x), debugConfigs[i]);
- if (selection.equals(debugConfigs[i].getID())) {
+ // select first exact matching debugger for platform or requested selection
+ if ((selndx == -1 && debuggerPlatform.equalsIgnoreCase(configPlatform)) ||
+ selection.equals(debugConfigs[i].getID())) {
selndx = x;
}
x++;
- break;
}
}
}
}
- fDCombo.select(selndx);
+ fDCombo.select(selndx == -1 ? 0 : selndx);
//The behaviour is undefined for if the callbacks should be triggered for this,
//so to avoid unnecessary confusion, we force an update.
updateComboFromSelection();
@@ -130,7 +142,7 @@ public class CDebuggerTab extends AbstractCDebuggerTab {
protected void updateComboFromSelection() {
handleDebuggerChanged();
ICDebugConfiguration debugConfig = getConfigForCurrentDebugger();
- if ( debugConfig != null ) {
+ if (debugConfig != null) {
fRunButton.setEnabled(debugConfig.supportsMode(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN));
fRunButton.setSelection(false);
fAttachButton.setEnabled(debugConfig.supportsMode(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH));
@@ -156,6 +168,7 @@ public class CDebuggerTab extends AbstractCDebuggerTab {
catch (CoreException ex) {
}
}
+ updateLaunchConfigurationDialog();
}
public void setDefaults(ILaunchConfigurationWorkingCopy config) {
@@ -199,7 +212,11 @@ public class CDebuggerTab extends AbstractCDebuggerTab {
}
public boolean isValid(ILaunchConfiguration config) {
- if (super.isValid(config) == false ) {
+ if (!validateDebuggerConfig(config)) {
+ setErrorMessage("No debugger available");
+ return false;
+ }
+ if (super.isValid(config) == false) {
return false;
}
if (!fRunButton.getSelection() && !fAttachButton.getSelection()) {
@@ -209,6 +226,33 @@ public class CDebuggerTab extends AbstractCDebuggerTab {
return true;
}
+ private boolean validateDebuggerConfig(ILaunchConfiguration config) {
+ String platform = getPlatform(config);
+ ICElement ce = getContext(config, null);
+ String projectPlatform = getPlatform(config);
+ String projectCPU = "native";
+ if (ce != null) {
+ try {
+ IBinary bin = (IBinary) ce;
+ projectCPU = bin.getCPU();
+ }
+ catch (Exception e) {
+ }
+ }
+ ICDebugConfiguration debugConfig = getDebugConfig();
+ if (debugConfig == null) {
+ return false;
+ }
+ String debuggerPlatform = debugConfig.getPlatform();
+ boolean isNative = platform.equals(projectPlatform);
+ if (debuggerPlatform.equalsIgnoreCase(projectPlatform) || (isNative && debuggerPlatform.equalsIgnoreCase("native"))) {
+ if (debugConfig.supportsCPU(projectCPU)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
/**
* Return the class that implements ILaunchConfigurationTab
* that is registered against the debugger id of the currently selected debugger.
diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CLaunchConfigurationTab.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CLaunchConfigurationTab.java
index a4faaee1937..f72dcc79b9e 100644
--- a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CLaunchConfigurationTab.java
+++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CLaunchConfigurationTab.java
@@ -2,6 +2,7 @@ package org.eclipse.cdt.launch.ui;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.ICDescriptor;
+import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ICProject;
@@ -12,6 +13,7 @@ import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
@@ -30,15 +32,18 @@ public abstract class CLaunchConfigurationTab extends AbstractLaunchConfiguratio
/**
* Returns the current C element context from which to initialize
* default settings, or null
if none.
- *
+ * Note, if possible we will return the IBinary based on config entry
+ * as this may be more usefull then just the project.
* @return C element context.
*/
protected ICElement getContext(ILaunchConfiguration config, String platform) {
String projectName = null;
+ String programName = null;
IWorkbenchPage page = LaunchUIPlugin.getActivePage();
Object obj = null;
try {
projectName = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, (String) null);
+ programName = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, (String) null);
}
catch (CoreException e) {
}
@@ -78,11 +83,26 @@ public abstract class CLaunchConfigurationTab extends AbstractLaunchConfiguratio
return null;
}
String projectPlatform = descriptor.getPlatform();
- if (projectPlatform.equals(platform) || projectPlatform.equals("*")) {
- return (ICElement) obj;
+ if (!projectPlatform.equals(platform) && !projectPlatform.equals("*")) {
+ obj = null;
}
}
- else {
+ if (obj != null) {
+ if (programName == null || programName.equals("")) {
+ return (ICElement) obj;
+ }
+ ICElement ce = (ICElement) obj;
+ IProject project;
+ try {
+ project = (IProject) ce.getCProject().getResource();
+ IPath programFile = project.getFile(programName).getLocation();
+ ce = CCorePlugin.getDefault().getCoreModel().create(programFile);
+ if (ce != null && ce.exists()) {
+ return ce;
+ }
+ }
+ catch (CModelException e) {
+ }
return (ICElement) obj;
}
}
diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CorefileDebuggerTab.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CorefileDebuggerTab.java
index 8ff7df310e6..14da6f31c72 100644
--- a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CorefileDebuggerTab.java
+++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CorefileDebuggerTab.java
@@ -6,6 +6,7 @@ package org.eclipse.cdt.launch.ui;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.ICDescriptor;
+import org.eclipse.cdt.core.model.IBinary;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
import org.eclipse.cdt.debug.core.ICDebugConfiguration;
@@ -56,19 +57,23 @@ public class CorefileDebuggerTab extends AbstractCDebuggerTab {
}
protected void loadDebuggerComboBox(ILaunchConfiguration config, String selection) {
- if ( initializingComboBox ) {
+ if (initializingComboBox) {
return;
}
initializingComboBox = true;
ICDebugConfiguration[] debugConfigs;
- String platform = getPlatform(config);
+ String configPlatform = getPlatform(config);
ICElement ce = getContext(config, null);
- String projectPlatform = "local";
- if ( ce != null ) {
+ String projectPlatform = "native";
+ String projectCPU = "native";
+ if (ce != null) {
try {
ICDescriptor descriptor = CCorePlugin.getDefault().getCProjectDescription(ce.getCProject().getProject());
- projectPlatform = descriptor.getPlatform();
- } catch (Exception e) {
+ projectPlatform = descriptor.getPlatform();
+ IBinary bin = (IBinary) ce;
+ projectCPU = bin.getCPU();
+ }
+ catch (Exception e) {
}
}
fDCombo.removeAll();
@@ -77,24 +82,27 @@ public class CorefileDebuggerTab extends AbstractCDebuggerTab {
int selndx = -1;
for (int i = 0; i < debugConfigs.length; i++) {
if (debugConfigs[i].supportsMode(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_CORE)) {
- String supported[] = debugConfigs[i].getPlatforms();
- boolean isLocal = platform.equals(projectPlatform);
- for (int j = 0; j < supported.length; j++) {
- if (supported[j].equalsIgnoreCase(projectPlatform) || (isLocal && supported[j].equalsIgnoreCase("local"))) {
+ String debuggerPlatform = debugConfigs[i].getPlatform();
+ boolean isNative = configPlatform.equals(projectPlatform);
+ if (debuggerPlatform.equalsIgnoreCase(projectPlatform)
+ || (isNative && debuggerPlatform.equalsIgnoreCase("native"))) {
+ if (debugConfigs[i].supportsCPU(projectCPU)) {
fDCombo.add(debugConfigs[i].getName());
fDCombo.setData(Integer.toString(x), debugConfigs[i]);
- if (selection.equals(debugConfigs[i].getID())) {
+ // select first exact matching debugger for platform or requested selection
+ if ((selndx == -1 && debuggerPlatform.equalsIgnoreCase(projectPlatform)) ||
+ selection.equals(debugConfigs[i].getID())) {
selndx = x;
}
x++;
- break;
}
}
}
}
- if ( selndx != -1 ) {
- fDCombo.select(selndx);
- }
+ fDCombo.select(selndx == -1 ? 0 : selndx);
+ //The behaviour is undefined for if the callbacks should be triggered for this,
+ //so to avoid unnecessary confusion, we force an update.
+ handleDebuggerChanged();
fDCombo.getParent().layout(true);
initializingComboBox = false;
}
@@ -118,7 +126,7 @@ public class CorefileDebuggerTab extends AbstractCDebuggerTab {
}
public boolean isValid(ILaunchConfiguration config) {
- if ( !validateDebuggerConfig(config) ) {
+ if (!validateDebuggerConfig(config)) {
setErrorMessage("No debugger available");
return false;
}
@@ -128,29 +136,32 @@ public class CorefileDebuggerTab extends AbstractCDebuggerTab {
private boolean validateDebuggerConfig(ILaunchConfiguration config) {
String platform = getPlatform(config);
ICElement ce = getContext(config, null);
- String projectPlatform = "local";
- if ( ce != null ) {
+ String projectPlatform = "native";
+ String projectCPU = "native";
+ if (ce != null) {
try {
ICDescriptor descriptor = CCorePlugin.getDefault().getCProjectDescription(ce.getCProject().getProject());
- projectPlatform = descriptor.getPlatform();
- } catch (Exception e) {
+ projectPlatform = descriptor.getPlatform();
+ IBinary bin = (IBinary) ce;
+ projectCPU = bin.getCPU();
+ }
+ catch (Exception e) {
}
}
ICDebugConfiguration debugConfig = getDebugConfig();
- if ( debugConfig == null ) {
+ if (debugConfig == null) {
return false;
}
- String supported[] = debugConfig.getPlatforms();
- boolean isLocal = platform.equals(projectPlatform);
- for (int j = 0; j < supported.length; j++) {
- if (supported[j].equalsIgnoreCase(projectPlatform) || (isLocal && supported[j].equalsIgnoreCase("local"))) {
+ String debuggerPlatform = debugConfig.getPlatform();
+ boolean isNative = platform.equals(projectPlatform);
+ if (debuggerPlatform.equalsIgnoreCase(projectPlatform) || (isNative && debuggerPlatform.equalsIgnoreCase("native"))) {
+ if (debugConfig.supportsCPU(projectCPU)) {
return true;
}
}
return false;
}
-
/**
* Return the class that implements ILaunchConfigurationTab
* that is registered against the debugger id of the currently selected debugger.