1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-23 17:05:26 +02:00

fixed update platform filtering

fixed compiler error prompting
This commit is contained in:
David Inglis 2004-05-31 18:06:16 +00:00
parent 34f6b89386
commit 760c2a22b5
10 changed files with 48 additions and 63 deletions

View file

@ -7,7 +7,7 @@ package org.eclipse.cdt.debug.core;
import org.eclipse.core.runtime.CoreException;
public interface ICDebugConfiguration {
final static String PLATFORM_NATIVE = "native"; //$NON-NLS-1$
final static String CPU_NATIVE = "native"; //$NON-NLS-1$
ICDebugger getDebugger() throws CoreException;
String getName();

View file

@ -45,7 +45,7 @@ public class DebugConfiguration implements ICDebugConfiguration {
public String getPlatform() {
String platform = getConfigurationElement().getAttribute("platform"); //$NON-NLS-1$
if (platform == null) {
return PLATFORM_NATIVE;
return "*"; //$NON-NLS-1$
}
return platform;
}
@ -66,9 +66,9 @@ public class DebugConfiguration implements ICDebugConfiguration {
String nativeCPU = Platform.getOSArch();
boolean ret = false;
if ( nativeCPU.startsWith(cpu) ) {
ret = getCPUs().contains(PLATFORM_NATIVE);
ret = getCPUs().contains(CPU_NATIVE);
}
return ret || getCPUs().contains(cpu);
return ret || getCPUs().contains(cpu) || getCPUs().contains("*"); //$NON-NLS-1$
}
/**
* Returns the set of modes specified in the configuration data.
@ -95,7 +95,7 @@ public class DebugConfiguration implements ICDebugConfiguration {
String cpus = getConfigurationElement().getAttribute("cpu"); //$NON-NLS-1$
if (cpus == null) {
fCPUs = new HashSet(1);
fCPUs.add(PLATFORM_NATIVE);
fCPUs.add(CPU_NATIVE);
}
else {
String nativeCPU = Platform.getOSArch();
@ -105,7 +105,7 @@ public class DebugConfiguration implements ICDebugConfiguration {
String cpu = tokenizer.nextToken().trim();
fCPUs.add(cpu);
if (nativeCPU.startsWith(cpu)) { // os arch be cpu{le/be}
fCPUs.add(PLATFORM_NATIVE);
fCPUs.add(CPU_NATIVE);
}
}
}

View file

@ -24,7 +24,7 @@
<extension
point="org.eclipse.cdt.debug.core.CDebugger">
<debugger
platform="native"
platform="*"
name="%GDBDebugger.name"
modes="run,core,attach"
cpu="native"

View file

@ -51,8 +51,6 @@ import org.eclipse.debug.core.model.LaunchConfigurationDelegate;
abstract public class AbstractCLaunchDelegate extends LaunchConfigurationDelegate {
protected static final IStatus complileErrorPromptStatus = new Status(IStatus.INFO, "org.eclipse.cdt.launch", 202, "", null); //$NON-NLS-1$ //$NON-NLS-2$
/**
* The project containing the programs file being launched
*/
@ -460,22 +458,20 @@ abstract public class AbstractCLaunchDelegate extends LaunchConfigurationDelegat
File dir = new File(path.toOSString());
if (dir.isDirectory()) {
return dir;
} else {
abort(LaunchUIPlugin.getResourceString("AbstractCLaunchDelegate.Working_directory_does_not_exist"), //$NON-NLS-1$
new FileNotFoundException(LaunchUIPlugin.getFormattedResourceString(
"AbstractCLaunchDelegate.PROGRAM_PATH_not_found", path.toOSString())), //$NON-NLS-1$
ICDTLaunchConfigurationConstants.ERR_WORKING_DIRECTORY_DOES_NOT_EXIST);
}
abort(LaunchUIPlugin.getResourceString("AbstractCLaunchDelegate.Working_directory_does_not_exist"), //$NON-NLS-1$
new FileNotFoundException(LaunchUIPlugin.getFormattedResourceString(
"AbstractCLaunchDelegate.PROGRAM_PATH_not_found", path.toOSString())), //$NON-NLS-1$
ICDTLaunchConfigurationConstants.ERR_WORKING_DIRECTORY_DOES_NOT_EXIST);
} else {
IResource res = ResourcesPlugin.getWorkspace().getRoot().findMember(path);
if (res instanceof IContainer && res.exists()) {
return res.getLocation().toFile();
} else {
abort(LaunchUIPlugin.getResourceString("AbstractCLaunchDelegate.Working_directory_does_not_exist"), //$NON-NLS-1$
new FileNotFoundException(LaunchUIPlugin.getFormattedResourceString(
"AbstractCLaunchDelegate.PROGRAM_PATH_does_not_exist", path.toOSString())), //$NON-NLS-1$
ICDTLaunchConfigurationConstants.ERR_WORKING_DIRECTORY_DOES_NOT_EXIST);
}
abort(LaunchUIPlugin.getResourceString("AbstractCLaunchDelegate.Working_directory_does_not_exist"), //$NON-NLS-1$
new FileNotFoundException(LaunchUIPlugin.getFormattedResourceString(
"AbstractCLaunchDelegate.PROGRAM_PATH_does_not_exist", path.toOSString())), //$NON-NLS-1$
ICDTLaunchConfigurationConstants.ERR_WORKING_DIRECTORY_DOES_NOT_EXIST);
}
}
return null;

View file

@ -107,8 +107,8 @@ public class CApplicationLaunchShortcut implements ILaunchShortcut {
// user to choose one.
int candidateCount = candidateConfigs.size();
if (candidateCount < 1) {
// FIXME: should probably have more filtering here base on
// the mode, arch, CPU. For now we only support native.
String programCPU = bin.getCPU();
// Prompt the user if more then 1 debugger.
ICDebugConfiguration debugConfig = null;
ICDebugConfiguration[] debugConfigs = CDebugCorePlugin.getDefault().getDebugConfigurations();
@ -116,8 +116,11 @@ public class CApplicationLaunchShortcut implements ILaunchShortcut {
String os = Platform.getOS();
for (int i = 0; i < debugConfigs.length; i++) {
String platform = debugConfigs[i].getPlatform();
if (platform == null || platform.equals(ICDebugConfiguration.PLATFORM_NATIVE) || platform.equals(os)) {
debugList.add(debugConfigs[i]);
if (debugConfigs[i].supportsMode(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN)) {
if (platform.equals("*") || platform.equals(os)) { //$NON-NLS-1$
if (debugConfigs[i].supportsCPU(programCPU))
debugList.add(debugConfigs[i]);
}
}
}
debugConfigs = (ICDebugConfiguration[]) debugList.toArray(new ICDebugConfiguration[0]);

View file

@ -78,9 +78,8 @@ public abstract class AbstractCDebuggerTab extends CLaunchConfigurationTab {
ILaunchConfigurationTab tab = getDynamicTab();
if ((super.getErrorMessage() != null) || (tab == null)) {
return super.getErrorMessage();
} else {
return tab.getErrorMessage();
}
return tab.getErrorMessage();
}
/**

View file

@ -83,16 +83,14 @@ public class LaunchUIPlugin extends AbstractUIPlugin
public static Shell getShell() {
if (getActiveWorkbenchShell() != null) {
return getActiveWorkbenchShell();
} else {
if (debugDialogShell != null) {
if (!debugDialogShell.isDisposed())
return debugDialogShell;
debugDialogShell = null;
}
IWorkbenchWindow[] windows = getDefault().getWorkbench()
.getWorkbenchWindows();
return windows[0].getShell();
}
if (debugDialogShell != null) {
if (!debugDialogShell.isDisposed())
return debugDialogShell;
debugDialogShell = null;
}
IWorkbenchWindow[] windows = getDefault().getWorkbench().getWorkbenchWindows();
return windows[0].getShell();
}
public static void setDialogShell(Shell shell) {

View file

@ -14,7 +14,6 @@ import org.eclipse.cdt.debug.core.ICDebugConfiguration;
import org.eclipse.cdt.launch.internal.ui.AbstractCDebuggerTab;
import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.Platform;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.swt.SWT;
@ -131,7 +130,7 @@ public class CDebuggerTab extends AbstractCDebuggerTab {
protected void loadDebuggerComboBox(ILaunchConfiguration config, String selection) {
ICDebugConfiguration[] debugConfigs;
String configPlatform = getPlatform(config);
String programCPU = ICDebugConfiguration.PLATFORM_NATIVE;
String programCPU = ICDebugConfiguration.CPU_NATIVE;
ICElement ce = getContext(config, configPlatform);
if (ce instanceof IBinary) {
IBinary bin = (IBinary) ce;
@ -153,9 +152,8 @@ public class CDebuggerTab extends AbstractCDebuggerTab {
if (debugConfigs[i].supportsMode(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN)
|| debugConfigs[i].supportsMode(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH)) {
String debuggerPlatform = debugConfigs[i].getPlatform();
boolean isNative = configPlatform.equals(Platform.getOS());
if (debuggerPlatform.equalsIgnoreCase(configPlatform)
|| (isNative && debuggerPlatform.equalsIgnoreCase(ICDebugConfiguration.PLATFORM_NATIVE))) {
|| (debuggerPlatform.equalsIgnoreCase("*"))) { //$NON-NLS-1$
if (debugConfigs[i].supportsCPU(programCPU)) {
fDCombo.add(debugConfigs[i].getName());
fDCombo.setData(Integer.toString(x), debugConfigs[i]);
@ -176,7 +174,7 @@ public class CDebuggerTab extends AbstractCDebuggerTab {
//The behaviour is undefined for if the callbacks should be triggered for this,
//so to avoid unnecessary confusion, we force an update.
updateComboFromSelection();
fDCombo.getParent().layout(true);
getControl().getParent().layout(true);
}
protected void updateComboFromSelection() {
@ -218,9 +216,7 @@ public class CDebuggerTab extends AbstractCDebuggerTab {
super.activated(workingCopy);
try {
String id = workingCopy.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID, ""); //$NON-NLS-1$
if (getDebugConfig() == null || !getDebugConfig().getID().equals(id) || !validateDebuggerConfig(workingCopy)) {
loadDebuggerComboBox(workingCopy, id);
}
loadDebuggerComboBox(workingCopy, id);
} catch (CoreException e) {
}
}
@ -283,10 +279,9 @@ public class CDebuggerTab extends AbstractCDebuggerTab {
}
private boolean validateDebuggerConfig(ILaunchConfiguration config) {
String platform = getPlatform(config);
ICElement ce = getContext(config, null);
String projectPlatform = getPlatform(config);
String projectCPU = ICDebugConfiguration.PLATFORM_NATIVE;
String projectCPU = ICDebugConfiguration.CPU_NATIVE;
if (ce != null) {
if (ce instanceof IBinary) {
IBinary bin = (IBinary) ce;
@ -298,9 +293,8 @@ public class CDebuggerTab extends AbstractCDebuggerTab {
return false;
}
String debuggerPlatform = debugConfig.getPlatform();
boolean isNative = platform.equals(projectPlatform);
if (debuggerPlatform.equalsIgnoreCase(projectPlatform)
|| (isNative && debuggerPlatform.equalsIgnoreCase(ICDebugConfiguration.PLATFORM_NATIVE))) {
|| (debuggerPlatform.equalsIgnoreCase("*"))) { //$NON-NLS-1$
if (debugConfig.supportsCPU(projectCPU)) {
return true;
}

View file

@ -15,7 +15,6 @@ import org.eclipse.cdt.core.model.IBinary;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
import org.eclipse.cdt.debug.core.ICDebugConfiguration;
import org.eclipse.cdt.internal.ui.CElementImageProvider;
import org.eclipse.cdt.internal.ui.CPluginImages;
import org.eclipse.cdt.launch.internal.ui.LaunchImages;
@ -29,7 +28,6 @@ import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
@ -317,18 +315,17 @@ public class CMainTab extends CLaunchConfigurationTab {
public IStatus validate(Object [] selection) {
if(selection.length == 0 || !(selection[0] instanceof IFile)) {
return new Status(IStatus.ERROR, LaunchUIPlugin.getUniqueIdentifier(), 1, LaunchUIPlugin.getResourceString("CMainTab.Selection_must_be_file"), null); //$NON-NLS-1$
} else {
try {
ICElement celement = cproject.findElement(((IFile)selection[0]).getProjectRelativePath());
if(celement == null ||
(celement.getElementType() != ICElement.C_BINARY && celement.getElementType() != ICElement.C_ARCHIVE)) {
return new Status(IStatus.ERROR, LaunchUIPlugin.getUniqueIdentifier(), 1, LaunchUIPlugin.getResourceString("CMainTab.Selection_must_be_binary_file"), null); //$NON-NLS-1$
}
return new Status(IStatus.OK, LaunchUIPlugin.getUniqueIdentifier(), IStatus.OK, celement.getResource().getName(), null);
} catch(Exception ex) {
return new Status(IStatus.ERROR, LaunchUIPlugin.PLUGIN_ID, 1, LaunchUIPlugin.getResourceString("CMainTab.Selection_must_be_binary_file"), null); //$NON-NLS-1$
}
try {
ICElement celement = cproject.findElement(((IFile)selection[0]).getProjectRelativePath());
if(celement == null ||
(celement.getElementType() != ICElement.C_BINARY && celement.getElementType() != ICElement.C_ARCHIVE)) {
return new Status(IStatus.ERROR, LaunchUIPlugin.getUniqueIdentifier(), 1, LaunchUIPlugin.getResourceString("CMainTab.Selection_must_be_binary_file"), null); //$NON-NLS-1$
}
return new Status(IStatus.OK, LaunchUIPlugin.getUniqueIdentifier(), IStatus.OK, celement.getResource().getName(), null);
} catch(Exception ex) {
return new Status(IStatus.ERROR, LaunchUIPlugin.PLUGIN_ID, 1, LaunchUIPlugin.getResourceString("CMainTab.Selection_must_be_binary_file"), null); //$NON-NLS-1$
}
}
});
@ -422,7 +419,6 @@ public class CMainTab extends CLaunchConfigurationTab {
protected ICProject[] getCProjects() throws CModelException {
ICProject cproject[] = CoreModel.getDefault().getCModel().getCProjects();
ArrayList list = new ArrayList(cproject.length);
boolean isNative = filterPlatform.equals(Platform.getOS());
for (int i = 0; i < cproject.length; i++) {
ICDescriptor cdesciptor = null;
@ -431,8 +427,7 @@ public class CMainTab extends CLaunchConfigurationTab {
String projectPlatform = cdesciptor.getPlatform();
if (filterPlatform.equals("*") //$NON-NLS-1$
|| projectPlatform.equals("*") //$NON-NLS-1$
|| (isNative && cdesciptor.getPlatform().equalsIgnoreCase(ICDebugConfiguration.PLATFORM_NATIVE))
|| filterPlatform.equalsIgnoreCase(cdesciptor.getPlatform()) == true) {
|| filterPlatform.equalsIgnoreCase(projectPlatform) == true) {
list.add(cproject[i]);
}
} catch (CoreException e) {

View file

@ -109,7 +109,7 @@ public class CorefileDebuggerTab extends AbstractCDebuggerTab {
//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);
getControl().getParent().layout(true);
initializingComboBox = false;
}