Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-patch] CDT Launch update

Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.launch/ChangeLog,v
retrieving revision 1.5
diff -u -r1.5 ChangeLog
--- ChangeLog	6 Nov 2002 16:57:43 -0000	1.5
+++ ChangeLog	13 Nov 2002 13:58:58 -0000
@@ -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
Index: src/org/eclipse/cdt/launch/ui/CDebuggerTab.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CDebuggerTab.java,v
retrieving revision 1.16
diff -u -r1.16 CDebuggerTab.java
--- src/org/eclipse/cdt/launch/ui/CDebuggerTab.java	4 Nov 2002 20:05:14 -0000	1.16
+++ src/org/eclipse/cdt/launch/ui/CDebuggerTab.java	13 Nov 2002 13:58:58 -0000
@@ -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 @@

 	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 @@
 	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 @@
 			catch (CoreException ex) {
 			}
 		}
+		updateLaunchConfigurationDialog();
 	}

 	public void setDefaults(ILaunchConfigurationWorkingCopy config) {
@@ -199,7 +212,11 @@
 	}

 	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()) {
@@ -207,6 +224,33 @@
 			return false;
 		}
 		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;
 	}

 	/**
Index: src/org/eclipse/cdt/launch/ui/CLaunchConfigurationTab.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CLaunchConfigurationTab.java,v
retrieving revision 1.2
diff -u -r1.2 CLaunchConfigurationTab.java
--- src/org/eclipse/cdt/launch/ui/CLaunchConfigurationTab.java	6 Nov 2002 16:57:43 -0000	1.2
+++ src/org/eclipse/cdt/launch/ui/CLaunchConfigurationTab.java	13 Nov 2002 13:58:58 -0000
@@ -2,6 +2,7 @@

 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.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 @@
 	/**
 	 * Returns the current C element context from which to initialize
 	 * default settings, or <code>null</code> 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 @@
 					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;
 			}
 		}
Index: src/org/eclipse/cdt/launch/ui/CorefileDebuggerTab.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CorefileDebuggerTab.java,v
retrieving revision 1.4
diff -u -r1.4 CorefileDebuggerTab.java
--- src/org/eclipse/cdt/launch/ui/CorefileDebuggerTab.java	8 Oct 2002 11:51:11 -0000	1.4
+++ src/org/eclipse/cdt/launch/ui/CorefileDebuggerTab.java	13 Nov 2002 13:58:58 -0000
@@ -6,6 +6,7 @@

 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 @@
 	}

 	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 @@
 		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 boolean isValid(ILaunchConfiguration config) {
-		if ( !validateDebuggerConfig(config) ) {
+		if (!validateDebuggerConfig(config)) {
 			setErrorMessage("No debugger available");
 			return false;
 		}
@@ -128,28 +136,31 @@
 	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 <code>ILaunchConfigurationTab</code>



Back to the top