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

filter debugger list base on selected IBinary cpu

This commit is contained in:
David Inglis 2002-11-13 14:01:09 +00:00
parent 83ca00e7b1
commit b9b786dcfd
4 changed files with 126 additions and 42 deletions

View file

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

View file

@ -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 <code>ILaunchConfigurationTab</code>
* that is registered against the debugger id of the currently selected debugger.

View file

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

View file

@ -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 <code>ILaunchConfigurationTab</code>
* that is registered against the debugger id of the currently selected debugger.