mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-16 04:35:45 +02:00
new post-mortem debug launcher
This commit is contained in:
parent
d862e1f83c
commit
947c512932
15 changed files with 754 additions and 370 deletions
|
@ -11,4 +11,5 @@
|
|||
pluginName=CDT Launching Support
|
||||
providerName=Eclipse.org
|
||||
|
||||
LocalCDTLaunch.name= Local C/C++ Application
|
||||
LocalCDTLaunch.name= C/C++ Application
|
||||
CoreFileCDTLaunch.name= C/C++ Post-mortem debugger
|
||||
|
|
|
@ -32,6 +32,13 @@
|
|||
public="true"
|
||||
id="org.eclipse.cdt.launch.localCLaunch">
|
||||
</launchConfigurationType>
|
||||
<launchConfigurationType
|
||||
name="%CoreFileCDTLaunch.name"
|
||||
delegate="org.eclipse.cdt.launch.internal.CoreFileLaunchDelegate"
|
||||
modes="debug"
|
||||
public="true"
|
||||
id="org.eclipse.cdt.launch.coreFileCLaunch">
|
||||
</launchConfigurationType>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.debug.ui.launchConfigurationTypeImages">
|
||||
|
@ -40,6 +47,11 @@
|
|||
configTypeID="org.eclipse.cdt.launch.localCLaunch"
|
||||
id="org.eclipse.cdt.launch.localCLaunchImage">
|
||||
</launchConfigurationTypeImage>
|
||||
<launchConfigurationTypeImage
|
||||
icon="icons/c_app.gif"
|
||||
configTypeID="org.eclipse.cdt.launch.coreFileCLaunch"
|
||||
id="org.eclipse.cdt.launch.coreFileCLaunchImage">
|
||||
</launchConfigurationTypeImage>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.debug.ui.launchConfigurationTabGroups">
|
||||
|
@ -48,6 +60,11 @@
|
|||
class="org.eclipse.cdt.launch.internal.ui.LocalCLaunchConfigurationTabGroup"
|
||||
id="org.eclipse.cdt.launch.localClaunchConfigurationTabGroup">
|
||||
</launchConfigurationTabGroup>
|
||||
<launchConfigurationTabGroup
|
||||
type="org.eclipse.cdt.launch.coreFileCLaunch"
|
||||
class="org.eclipse.cdt.launch.internal.ui.CoreFileCLaunchConfigurationTabGroup"
|
||||
id="org.eclipse.cdt.launch.voreFileCLaunchTabGroup">
|
||||
</launchConfigurationTabGroup>
|
||||
</extension>
|
||||
|
||||
</plugin>
|
||||
|
|
|
@ -5,7 +5,10 @@
|
|||
package org.eclipse.cdt.launch;
|
||||
|
||||
import java.io.File;
|
||||
import java.text.DateFormat;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
@ -13,16 +16,34 @@ import java.util.Map.Entry;
|
|||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
|
||||
import org.eclipse.cdt.debug.core.CDebugModel;
|
||||
import org.eclipse.cdt.debug.core.ICDebugConfiguration;
|
||||
import org.eclipse.cdt.debug.core.ICDebugger;
|
||||
import org.eclipse.cdt.debug.core.cdi.CDIException;
|
||||
import org.eclipse.cdt.debug.core.cdi.ICDISession;
|
||||
import org.eclipse.cdt.debug.core.cdi.model.ICDITarget;
|
||||
import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.core.runtime.QualifiedName;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.debug.core.DebugPlugin;
|
||||
import org.eclipse.debug.core.ILaunch;
|
||||
import org.eclipse.debug.core.ILaunchConfiguration;
|
||||
import org.eclipse.debug.core.IStatusHandler;
|
||||
import org.eclipse.debug.core.model.ILaunchConfigurationDelegate;
|
||||
import org.eclipse.debug.core.model.IProcess;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.swt.widgets.FileDialog;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
abstract public class AbstractCLaunchDelegate implements ILaunchConfigurationDelegate {
|
||||
|
||||
|
@ -139,6 +160,46 @@ abstract public class AbstractCLaunchDelegate implements ILaunchConfigurationDel
|
|||
return res;
|
||||
}
|
||||
|
||||
protected ICDebugConfiguration getDebugConfig(ILaunchConfiguration config) throws CoreException {
|
||||
ICDebugConfiguration dbgCfg = null;
|
||||
try {
|
||||
dbgCfg =
|
||||
CDebugCorePlugin.getDefault().getDebugConfiguration(
|
||||
config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID, ""));
|
||||
}
|
||||
catch (CoreException e) {
|
||||
IStatus status =
|
||||
new Status(
|
||||
IStatus.ERROR,
|
||||
LaunchUIPlugin.getUniqueIdentifier(),
|
||||
ICDTLaunchConfigurationConstants.ERR_DEBUGGER_NOT_INSTALLED,
|
||||
"CDT Debubger not installed",
|
||||
e);
|
||||
IStatusHandler handler = DebugPlugin.getDefault().getStatusHandler(status);
|
||||
|
||||
if (handler != null) {
|
||||
Object result = handler.handleStatus(status, this);
|
||||
if (result instanceof String) {
|
||||
// this could return the new debugger id to use?
|
||||
}
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
return dbgCfg;
|
||||
}
|
||||
|
||||
protected String renderTargetLabel(ICDebugConfiguration debugConfig) {
|
||||
String format = "{0} ({1})";
|
||||
String timestamp = DateFormat.getInstance().format(new Date(System.currentTimeMillis()));
|
||||
return MessageFormat.format(format, new String[] { debugConfig.getName(), timestamp });
|
||||
}
|
||||
|
||||
protected String renderProcessLabel(String commandLine) {
|
||||
String format = "{0} ({1})";
|
||||
String timestamp = DateFormat.getInstance().format(new Date(System.currentTimeMillis()));
|
||||
return MessageFormat.format(format, new String[] { commandLine, timestamp });
|
||||
}
|
||||
|
||||
private static class ArgumentParser {
|
||||
private String fArgs;
|
||||
private int fIndex = 0;
|
||||
|
|
|
@ -0,0 +1,120 @@
|
|||
package org.eclipse.cdt.launch.internal;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.Date;
|
||||
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.debug.core.CDebugModel;
|
||||
import org.eclipse.cdt.debug.core.ICDebugConfiguration;
|
||||
import org.eclipse.cdt.debug.core.ICDebugger;
|
||||
import org.eclipse.cdt.debug.core.cdi.CDIException;
|
||||
import org.eclipse.cdt.debug.core.cdi.ICDISession;
|
||||
import org.eclipse.cdt.debug.core.cdi.model.ICDITarget;
|
||||
import org.eclipse.cdt.launch.AbstractCLaunchDelegate;
|
||||
import org.eclipse.cdt.launch.ICDTLaunchConfigurationConstants;
|
||||
import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.core.runtime.QualifiedName;
|
||||
import org.eclipse.debug.core.DebugPlugin;
|
||||
import org.eclipse.debug.core.ILaunch;
|
||||
import org.eclipse.debug.core.ILaunchConfiguration;
|
||||
import org.eclipse.debug.core.model.IProcess;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.swt.widgets.FileDialog;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
/**
|
||||
* Insert the type's description here.
|
||||
* @see ILaunchConfigurationDelegate
|
||||
*/
|
||||
public class CoreFileLaunchDelegate extends AbstractCLaunchDelegate {
|
||||
|
||||
|
||||
public void launch(ILaunchConfiguration config, String mode, ILaunch launch, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
|
||||
if (monitor == null) {
|
||||
monitor = new NullProgressMonitor();
|
||||
}
|
||||
|
||||
monitor.beginTask("Launching Local C Application", IProgressMonitor.UNKNOWN);
|
||||
// check for cancellation
|
||||
if (monitor.isCanceled()) {
|
||||
return;
|
||||
}
|
||||
ICProject cproject = getCProject(config);
|
||||
IPath projectPath = ((IProject) cproject.getResource()).getFile(getProgramName(config)).getLocation();
|
||||
|
||||
ICDebugConfiguration debugConfig = getDebugConfig(config);
|
||||
IFile exe = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(projectPath);
|
||||
ICDISession dsession = null;
|
||||
|
||||
IPath corefile = getCoreFilePath((IProject)cproject.getResource());
|
||||
if ( corefile == null ) {
|
||||
abort("No Corefile selected", null, ICDTLaunchConfigurationConstants.ERR_NO_COREFILE);
|
||||
}
|
||||
try {
|
||||
dsession = debugConfig.getDebugger().createCoreSession(config, exe, corefile);
|
||||
}
|
||||
catch (CDIException e) {
|
||||
abort( "Failed Launching CDI Debugger", e, ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR);
|
||||
}
|
||||
|
||||
ICDITarget dtarget = dsession.getTargets()[0];
|
||||
Process process = dtarget.getProcess();
|
||||
|
||||
IProcess iprocess =
|
||||
DebugPlugin.newProcess(launch, process, renderProcessLabel(projectPath.toOSString()));
|
||||
CDebugModel.newDebugTarget(
|
||||
launch,
|
||||
dsession.getTargets()[0],
|
||||
renderTargetLabel(debugConfig),
|
||||
iprocess,
|
||||
exe.getProject(),
|
||||
true,
|
||||
false,
|
||||
true);
|
||||
}
|
||||
|
||||
private IPath getCoreFilePath(final IProject project) {
|
||||
final Shell shell = LaunchUIPlugin.getShell();
|
||||
final String res[] = { null };
|
||||
if (shell == null)
|
||||
return null;
|
||||
Display display = shell.getDisplay();
|
||||
display.syncExec(new Runnable() {
|
||||
public void run() {
|
||||
FileDialog dialog = new FileDialog(shell);
|
||||
dialog.setText("Select Corefile");
|
||||
|
||||
String initPath = null;
|
||||
try {
|
||||
initPath = project.getPersistentProperty(new QualifiedName(LaunchUIPlugin.getUniqueIdentifier(), "SavePath"));
|
||||
}
|
||||
catch (CoreException e) {
|
||||
}
|
||||
if (initPath == null || initPath.equals("")) {
|
||||
initPath = project.getLocation().toString();
|
||||
}
|
||||
dialog.setFilterPath(initPath);
|
||||
res[0] = dialog.open();
|
||||
}
|
||||
});
|
||||
if (res[0] != null) {
|
||||
return new Path(res[0]);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getPluginID() {
|
||||
return LaunchUIPlugin.getUniqueIdentifier();
|
||||
}
|
||||
}
|
|
@ -17,7 +17,6 @@ import org.eclipse.cdt.core.CCorePlugin;
|
|||
import org.eclipse.cdt.core.IProcessInfo;
|
||||
import org.eclipse.cdt.core.IProcessList;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
|
||||
import org.eclipse.cdt.debug.core.CDebugModel;
|
||||
import org.eclipse.cdt.debug.core.ICDebugConfiguration;
|
||||
import org.eclipse.cdt.debug.core.ICDebugger;
|
||||
|
@ -36,8 +35,6 @@ import org.eclipse.core.runtime.IPath;
|
|||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.core.runtime.QualifiedName;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.debug.core.DebugPlugin;
|
||||
import org.eclipse.debug.core.ILaunch;
|
||||
|
@ -46,14 +43,10 @@ import org.eclipse.debug.core.ILaunchManager;
|
|||
import org.eclipse.debug.core.IStatusHandler;
|
||||
import org.eclipse.debug.core.model.IProcess;
|
||||
import org.eclipse.jface.dialogs.MessageDialog;
|
||||
import org.eclipse.jface.viewers.ILabelProvider;
|
||||
import org.eclipse.jface.viewers.LabelProvider;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.swt.widgets.FileDialog;
|
||||
import org.eclipse.swt.widgets.MessageBox;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.ui.dialogs.ElementListSelectionDialog;
|
||||
import org.eclipse.ui.dialogs.ListSelectionDialog;
|
||||
|
||||
/**
|
||||
* Insert the type's description here.
|
||||
|
@ -61,18 +54,6 @@ import org.eclipse.ui.dialogs.ListSelectionDialog;
|
|||
*/
|
||||
public class LocalCLaunchConfigurationDelegate extends AbstractCLaunchDelegate {
|
||||
|
||||
/*
|
||||
protected String renderDebugTarget(ICDISession session) {
|
||||
String format= "{0} at localhost {1}";
|
||||
return MessageFormat.format(format, new String[] { classToRun, String.valueOf(host) });
|
||||
}
|
||||
*/
|
||||
public String renderProcessLabel(String[] commandLine) {
|
||||
String format = "{0} ({1})";
|
||||
String timestamp = DateFormat.getInstance().format(new Date(System.currentTimeMillis()));
|
||||
return MessageFormat.format(format, new String[] { commandLine[0], timestamp });
|
||||
}
|
||||
|
||||
public void launch(ILaunchConfiguration config, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
|
||||
if (monitor == null) {
|
||||
monitor = new NullProgressMonitor();
|
||||
|
@ -89,33 +70,10 @@ public class LocalCLaunchConfigurationDelegate extends AbstractCLaunchDelegate {
|
|||
ArrayList command = new ArrayList(1 + arguments.length);
|
||||
command.add(projectPath.toOSString());
|
||||
command.addAll(Arrays.asList(arguments));
|
||||
String[] commandArray = (String[]) command.toArray(new String[command.size()]);
|
||||
|
||||
if (mode.equals(ILaunchManager.DEBUG_MODE)) {
|
||||
ICDebugConfiguration dbgCfg = null;
|
||||
ICDebugger cdebugger = null;
|
||||
try {
|
||||
dbgCfg =
|
||||
CDebugCorePlugin.getDefault().getDebugConfiguration(
|
||||
config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID, ""));
|
||||
cdebugger = dbgCfg.getDebugger();
|
||||
}
|
||||
catch (CoreException e) {
|
||||
IStatus status =
|
||||
new Status(
|
||||
IStatus.ERROR,
|
||||
LaunchUIPlugin.getUniqueIdentifier(),
|
||||
ICDTLaunchConfigurationConstants.ERR_DEBUGGER_NOT_INSTALLED,
|
||||
"CDT Debubger not installed",
|
||||
e);
|
||||
IStatusHandler handler = DebugPlugin.getDefault().getStatusHandler(status);
|
||||
|
||||
if (handler != null) {
|
||||
Object result = handler.handleStatus(status, this);
|
||||
if (result instanceof String) {
|
||||
}
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
ICDebugConfiguration debugConfig = getDebugConfig(config);
|
||||
IFile exe = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(projectPath);
|
||||
ICDISession dsession = null;
|
||||
try {
|
||||
|
@ -124,21 +82,14 @@ public class LocalCLaunchConfigurationDelegate extends AbstractCLaunchDelegate {
|
|||
ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
|
||||
ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN);
|
||||
if (debugMode.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN)) {
|
||||
dsession = cdebugger.createLaunchSession(config, exe);
|
||||
dsession = debugConfig.getDebugger().createLaunchSession(config, exe);
|
||||
}
|
||||
else if (debugMode.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH)) {
|
||||
int pid = getProcessID();
|
||||
if ( pid == -1 ) {
|
||||
abort("No Process ID selected", null, ICDTLaunchConfigurationConstants.ERR_NO_PROCESSID);
|
||||
}
|
||||
dsession = cdebugger.createAttachSession(config, exe, pid);
|
||||
}
|
||||
else if (debugMode.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_CORE)) {
|
||||
IPath corefile = getCoreFilePath((IProject)cproject.getResource());
|
||||
if ( corefile == null ) {
|
||||
abort("No Corefile selected", null, ICDTLaunchConfigurationConstants.ERR_NO_COREFILE);
|
||||
}
|
||||
dsession = cdebugger.createCoreSession(config, exe, corefile);
|
||||
dsession = debugConfig.getDebugger().createAttachSession(config, exe, pid);
|
||||
}
|
||||
}
|
||||
catch (CDIException e) {
|
||||
|
@ -154,12 +105,12 @@ public class LocalCLaunchConfigurationDelegate extends AbstractCLaunchDelegate {
|
|||
ICDITarget dtarget = dsession.getTargets()[0];
|
||||
Process process = dtarget.getProcess();
|
||||
IProcess iprocess =
|
||||
DebugPlugin.newProcess(launch, process, renderProcessLabel((String[]) command.toArray(new String[command.size()])));
|
||||
DebugPlugin.newProcess(launch, process, renderProcessLabel(commandArray[0]));
|
||||
boolean stopInMain = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, false);
|
||||
CDebugModel.newDebugTarget(
|
||||
launch,
|
||||
dsession.getTargets()[0],
|
||||
dbgCfg.getName(),
|
||||
renderTargetLabel(debugConfig),
|
||||
iprocess,
|
||||
exe.getProject(),
|
||||
true,
|
||||
|
@ -167,44 +118,12 @@ public class LocalCLaunchConfigurationDelegate extends AbstractCLaunchDelegate {
|
|||
stopInMain);
|
||||
}
|
||||
else {
|
||||
String[] commandArray = (String[]) command.toArray(new String[command.size()]);
|
||||
Process process = exec(commandArray, getEnvironmentArray(config), getWorkingDir(config));
|
||||
DebugPlugin.getDefault().newProcess(launch, process, renderProcessLabel(commandArray));
|
||||
DebugPlugin.getDefault().newProcess(launch, process, renderProcessLabel(commandArray[0]));
|
||||
}
|
||||
monitor.done();
|
||||
}
|
||||
|
||||
private IPath getCoreFilePath(final IProject project) {
|
||||
final Shell shell = LaunchUIPlugin.getShell();
|
||||
final String res[] = {null};
|
||||
if ( shell == null )
|
||||
return null;
|
||||
Display display = shell.getDisplay();
|
||||
display.syncExec(new Runnable() {
|
||||
public void run() {
|
||||
FileDialog dialog = new FileDialog( shell );
|
||||
dialog.setText( "Select Corefile" );
|
||||
|
||||
String initPath = null;
|
||||
try {
|
||||
initPath = project.getPersistentProperty(new QualifiedName(LaunchUIPlugin.getUniqueIdentifier(), "SavePath"));
|
||||
}
|
||||
catch (CoreException e) {
|
||||
}
|
||||
if ( initPath == null || initPath.equals("") ) {
|
||||
initPath = project.getLocation().toString();
|
||||
}
|
||||
dialog.setFilterPath( initPath );
|
||||
res[0] = dialog.open();
|
||||
}
|
||||
});
|
||||
if ( res[0] != null ) {
|
||||
return new Path( res[0] );
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private int getProcessID() {
|
||||
final Shell shell = LaunchUIPlugin.getShell();
|
||||
final int pid[] = {-1};
|
||||
|
|
|
@ -0,0 +1,217 @@
|
|||
/*
|
||||
* (c) Copyright QNX Software System Ltd. 2002.
|
||||
* All Rights Reserved.
|
||||
*/
|
||||
package org.eclipse.cdt.launch.internal.ui;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
|
||||
import org.eclipse.cdt.debug.core.ICDebugConfiguration;
|
||||
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
|
||||
import org.eclipse.cdt.launch.ICDTLaunchConfigurationConstants;
|
||||
import org.eclipse.cdt.launch.ui.CLaunchConfigurationTab;
|
||||
import org.eclipse.core.boot.BootLoader;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.debug.core.ILaunchConfiguration;
|
||||
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
|
||||
import org.eclipse.debug.ui.ILaunchConfigurationTab;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.ModifyEvent;
|
||||
import org.eclipse.swt.events.ModifyListener;
|
||||
import org.eclipse.swt.events.SelectionAdapter;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.graphics.Image;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Combo;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Control;
|
||||
import org.eclipse.swt.widgets.Group;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
|
||||
public abstract class AbstractCDebuggerTab extends CLaunchConfigurationTab {
|
||||
|
||||
protected ILaunchConfiguration fLaunchConfiguration;
|
||||
protected ILaunchConfigurationWorkingCopy fWorkingCopy;
|
||||
protected ICDebugConfiguration fCurrentDebugConfig;
|
||||
|
||||
// Dynamic Debugger UI widgets
|
||||
protected ILaunchConfigurationTab fDynamicTab;
|
||||
protected Composite fDynamicTabHolder;
|
||||
|
||||
protected void setDebugConfig(ICDebugConfiguration config) {
|
||||
fCurrentDebugConfig = config;
|
||||
}
|
||||
|
||||
protected ICDebugConfiguration getDebugConfig() {
|
||||
return fCurrentDebugConfig;
|
||||
}
|
||||
|
||||
protected ILaunchConfigurationTab getDynamicTab() {
|
||||
return fDynamicTab;
|
||||
}
|
||||
|
||||
protected void setDynamicTab(ILaunchConfigurationTab tab) {
|
||||
fDynamicTab = tab;
|
||||
}
|
||||
|
||||
protected Composite getDynamicTabHolder() {
|
||||
return fDynamicTabHolder;
|
||||
}
|
||||
|
||||
protected void setDynamicTabHolder(Composite tabHolder) {
|
||||
fDynamicTabHolder = tabHolder;
|
||||
}
|
||||
|
||||
protected ILaunchConfigurationWorkingCopy getLaunchConfigurationWorkingCopy() {
|
||||
return fWorkingCopy;
|
||||
}
|
||||
|
||||
protected void setLaunchConfiguration(ILaunchConfiguration launchConfiguration) {
|
||||
fLaunchConfiguration = launchConfiguration;
|
||||
}
|
||||
|
||||
protected ILaunchConfiguration getLaunchConfiguration() {
|
||||
return fLaunchConfiguration;
|
||||
}
|
||||
|
||||
protected void setLaunchConfigurationWorkingCopy(ILaunchConfigurationWorkingCopy workingCopy) {
|
||||
fWorkingCopy = workingCopy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Overridden here so that any error message in the dynamic UI gets returned.
|
||||
*
|
||||
* @see ILaunchConfigurationTab#getErrorMessage()
|
||||
*/
|
||||
public String getErrorMessage() {
|
||||
ILaunchConfigurationTab tab = getDynamicTab();
|
||||
if ((super.getErrorMessage() != null) || (tab == null)) {
|
||||
return super.getErrorMessage();
|
||||
}
|
||||
else {
|
||||
return tab.getErrorMessage();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Notification that the user changed the selection of the Debugger.
|
||||
*/
|
||||
protected void handleDebuggerChanged() {
|
||||
loadDynamicDebugArea();
|
||||
|
||||
// always set the newly created area with defaults
|
||||
ILaunchConfigurationWorkingCopy wc = getLaunchConfigurationWorkingCopy();
|
||||
if (getDynamicTab() == null) {
|
||||
// remove any debug specfic args from the config
|
||||
if (wc == null) {
|
||||
if (getLaunchConfiguration().isWorkingCopy()) {
|
||||
wc = (ILaunchConfigurationWorkingCopy) getLaunchConfiguration();
|
||||
}
|
||||
}
|
||||
if (wc != null) {
|
||||
wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_SPECIFIC_ATTRS_MAP, (Map) null);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (wc == null) {
|
||||
try {
|
||||
if (getLaunchConfiguration().isWorkingCopy()) {
|
||||
// get a fresh copy to work on
|
||||
wc = ((ILaunchConfigurationWorkingCopy) getLaunchConfiguration()).getOriginal().getWorkingCopy();
|
||||
}
|
||||
else {
|
||||
wc = getLaunchConfiguration().getWorkingCopy();
|
||||
}
|
||||
}
|
||||
catch (CoreException e) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
getDynamicTab().setDefaults(wc);
|
||||
getDynamicTab().initializeFrom(wc);
|
||||
}
|
||||
updateLaunchConfigurationDialog();
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the contributed piece of UI that was registered for the debugger id
|
||||
* of the currently selected debugger.
|
||||
*/
|
||||
protected void loadDynamicDebugArea() {
|
||||
// Dispose of any current child widgets in the tab holder area
|
||||
Control[] children = getDynamicTabHolder().getChildren();
|
||||
for (int i = 0; i < children.length; i++) {
|
||||
children[i].dispose();
|
||||
}
|
||||
|
||||
// Retrieve the dynamic UI for the current Debugger
|
||||
ICDebugConfiguration debugConfig = getConfigForCurrentDebugger();
|
||||
if (debugConfig == null) {
|
||||
setDynamicTab(null);
|
||||
}
|
||||
else {
|
||||
setDynamicTab(CDebugUIPlugin.getDefault().getDebuggerPage(debugConfig.getID()));
|
||||
}
|
||||
setDebugConfig(debugConfig);
|
||||
if (getDynamicTab() == null) {
|
||||
return;
|
||||
}
|
||||
// Ask the dynamic UI to create its Control
|
||||
getDynamicTab().setLaunchConfigurationDialog(getLaunchConfigurationDialog());
|
||||
getDynamicTab().createControl(getDynamicTabHolder());
|
||||
getDynamicTab().getControl().setVisible(true);
|
||||
getDynamicTabHolder().layout(true);
|
||||
}
|
||||
|
||||
abstract protected ICDebugConfiguration getConfigForCurrentDebugger();
|
||||
abstract public void createControl(Composite parent);
|
||||
abstract public String getName();
|
||||
|
||||
public void initializeFrom(ILaunchConfiguration config) {
|
||||
setLaunchConfiguration(config);
|
||||
ILaunchConfigurationTab dynamicTab = getDynamicTab();
|
||||
if (dynamicTab != null) {
|
||||
dynamicTab.initializeFrom(config);
|
||||
}
|
||||
}
|
||||
|
||||
public void performApply(ILaunchConfigurationWorkingCopy config) {
|
||||
if ( getDebugConfig() != null ) {
|
||||
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID, getDebugConfig().getID());
|
||||
ILaunchConfigurationTab dynamicTab = getDynamicTab();
|
||||
if (dynamicTab == null) {
|
||||
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_SPECIFIC_ATTRS_MAP, (Map) null);
|
||||
}
|
||||
else {
|
||||
dynamicTab.performApply(config);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setDefaults(ILaunchConfigurationWorkingCopy config) {
|
||||
setLaunchConfigurationWorkingCopy(config);
|
||||
ILaunchConfigurationTab dynamicTab = getDynamicTab();
|
||||
if (dynamicTab != null) {
|
||||
dynamicTab.setDefaults(config);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isValid(ILaunchConfiguration config) {
|
||||
setErrorMessage(null);
|
||||
setMessage(null);
|
||||
if (getDebugConfig() == null) {
|
||||
setErrorMessage("No debugger avalible");
|
||||
return false;
|
||||
}
|
||||
|
||||
ILaunchConfigurationTab dynamicTab = getDynamicTab();
|
||||
if (dynamicTab != null) {
|
||||
return dynamicTab.isValid(config);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package org.eclipse.cdt.launch.internal.ui;
|
||||
|
||||
import org.eclipse.cdt.launch.ICDTLaunchConfigurationConstants;
|
||||
import org.eclipse.cdt.launch.ui.CMainTab;
|
||||
import org.eclipse.cdt.launch.ui.CorefileDebuggerTab;
|
||||
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
|
||||
import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup;
|
||||
import org.eclipse.debug.ui.CommonTab;
|
||||
import org.eclipse.debug.ui.ILaunchConfigurationDialog;
|
||||
import org.eclipse.debug.ui.ILaunchConfigurationTab;
|
||||
|
||||
/**
|
||||
* Insert the type's description here.
|
||||
* @see AbstractLaunchConfigurationTabGroup
|
||||
*/
|
||||
public class CoreFileCLaunchConfigurationTabGroup extends AbstractLaunchConfigurationTabGroup {
|
||||
|
||||
/**
|
||||
* Insert the method's description here.
|
||||
* @see AbstractLaunchConfigurationTabGroup#createTabs
|
||||
*/
|
||||
public void createTabs(ILaunchConfigurationDialog dialog, String mode) {
|
||||
ILaunchConfigurationTab[] tabs = new ILaunchConfigurationTab[] {
|
||||
new CMainTab(),
|
||||
new CorefileDebuggerTab(),
|
||||
new CommonTab()
|
||||
};
|
||||
setTabs(tabs);
|
||||
}
|
||||
|
||||
public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
|
||||
// This configuration should work for all platforms
|
||||
configuration.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PLATFORM, "*");
|
||||
super.setDefaults(configuration);
|
||||
}
|
||||
|
||||
}
|
|
@ -3,7 +3,6 @@ package org.eclipse.cdt.launch.internal.ui;
|
|||
import org.eclipse.core.runtime.IPluginDescriptor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.debug.internal.ui.DebugUIMessages;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.ui.IWorkbenchPage;
|
||||
import org.eclipse.ui.IWorkbenchWindow;
|
||||
|
|
|
@ -2,12 +2,10 @@ package org.eclipse.cdt.launch.internal.ui;
|
|||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.eclipse.cdt.launch.ICDTLaunchConfigurationConstants;
|
||||
import org.eclipse.cdt.launch.ui.CArgumentsTab;
|
||||
import org.eclipse.cdt.launch.ui.CDebuggerTab;
|
||||
import org.eclipse.cdt.launch.ui.CEnvironmentTab;
|
||||
import org.eclipse.cdt.launch.ui.CMainTab;
|
||||
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
|
||||
import org.eclipse.debug.core.ILaunchManager;
|
||||
import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup;
|
||||
import org.eclipse.debug.ui.CommonTab;
|
||||
|
|
|
@ -6,7 +6,6 @@ package org.eclipse.cdt.launch.ui;
|
|||
*/
|
||||
|
||||
import org.eclipse.cdt.launch.ICDTLaunchConfigurationConstants;
|
||||
import org.eclipse.cdt.launch.internal.ui.CLaunchConfigurationTab;
|
||||
import org.eclipse.cdt.launch.internal.ui.LaunchImages;
|
||||
import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin;
|
||||
import org.eclipse.cdt.launch.internal.ui.WorkingDirectoryBlock;
|
||||
|
|
|
@ -4,16 +4,16 @@
|
|||
*/
|
||||
package org.eclipse.cdt.launch.ui;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
|
||||
import org.eclipse.cdt.debug.core.ICDebugConfiguration;
|
||||
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
|
||||
import org.eclipse.cdt.launch.ICDTLaunchConfigurationConstants;
|
||||
import org.eclipse.cdt.launch.internal.ui.CLaunchConfigurationTab;
|
||||
import org.eclipse.cdt.launch.internal.ui.AbstractCDebuggerTab;
|
||||
import org.eclipse.cdt.launch.internal.ui.LaunchImages;
|
||||
import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin;
|
||||
import org.eclipse.core.boot.BootLoader;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.debug.core.ILaunchConfiguration;
|
||||
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
|
||||
|
@ -33,21 +33,12 @@ import org.eclipse.swt.widgets.Control;
|
|||
import org.eclipse.swt.widgets.Group;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
|
||||
public class CDebuggerTab extends CLaunchConfigurationTab {
|
||||
public class CDebuggerTab extends AbstractCDebuggerTab {
|
||||
protected Combo fDCombo;
|
||||
protected Button fStopInMain;
|
||||
protected Button fAttachButton;
|
||||
protected Button fCoreButton;
|
||||
protected Button fRunButton;
|
||||
|
||||
// Dynamic Debugger UI widgets
|
||||
protected ILaunchConfigurationTab fDynamicTab;
|
||||
protected Composite fDynamicTabHolder;
|
||||
protected ICDebugConfiguration fCurrentDebugConfig;
|
||||
|
||||
protected ILaunchConfigurationWorkingCopy fWorkingCopy;
|
||||
protected ILaunchConfiguration fLaunchConfiguration;
|
||||
|
||||
public void createControl(Composite parent) {
|
||||
GridData gd;
|
||||
|
||||
|
@ -60,11 +51,39 @@ public class CDebuggerTab extends CLaunchConfigurationTab {
|
|||
fDCombo = new Combo(comp, SWT.DROP_DOWN | SWT.READ_ONLY);
|
||||
fDCombo.addModifyListener(new ModifyListener() {
|
||||
public void modifyText(ModifyEvent e) {
|
||||
handleDebuggerComboBoxModified();
|
||||
handleDebuggerChanged();
|
||||
ICDebugConfiguration debugConfig = getConfigForCurrentDebugger();
|
||||
if ( debugConfig != null ) {
|
||||
fRunButton.setEnabled(debugConfig.supportsMode(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN));
|
||||
fRunButton.setSelection(false);
|
||||
fAttachButton.setEnabled(debugConfig.supportsMode(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH));
|
||||
fAttachButton.setSelection(false);
|
||||
try {
|
||||
String mode =
|
||||
getLaunchConfiguration().getAttribute(
|
||||
ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
|
||||
ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN);
|
||||
if (mode.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN) && fRunButton.isEnabled()) {
|
||||
fRunButton.setSelection(true);
|
||||
}
|
||||
else if (mode.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH) && fAttachButton.isEnabled()) {
|
||||
fAttachButton.setSelection(true);
|
||||
}
|
||||
if (fRunButton.getSelection() == true) {
|
||||
fStopInMain.setEnabled(true);
|
||||
}
|
||||
else {
|
||||
fStopInMain.setEnabled(false);
|
||||
}
|
||||
}
|
||||
catch (CoreException ex) {
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Composite radioComp = new Composite(comp, SWT.NONE);
|
||||
GridLayout radioLayout = new GridLayout(3, true);
|
||||
GridLayout radioLayout = new GridLayout(2, true);
|
||||
radioLayout.marginHeight = 0;
|
||||
radioLayout.marginWidth = 0;
|
||||
radioComp.setLayout(radioLayout);
|
||||
|
@ -74,9 +93,10 @@ public class CDebuggerTab extends CLaunchConfigurationTab {
|
|||
fRunButton = createRadioButton(radioComp, "Run program in debugger.");
|
||||
fRunButton.addSelectionListener(new SelectionAdapter() {
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
if ( fRunButton.getSelection() == true ) {
|
||||
if (fRunButton.getSelection() == true) {
|
||||
fStopInMain.setEnabled(true);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
fStopInMain.setEnabled(false);
|
||||
}
|
||||
updateLaunchConfigurationDialog();
|
||||
|
@ -88,12 +108,6 @@ public class CDebuggerTab extends CLaunchConfigurationTab {
|
|||
updateLaunchConfigurationDialog();
|
||||
}
|
||||
});
|
||||
fCoreButton = createRadioButton(radioComp, "View Corefile.");
|
||||
fCoreButton.addSelectionListener(new SelectionAdapter() {
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
updateLaunchConfigurationDialog();
|
||||
}
|
||||
});
|
||||
|
||||
fStopInMain = new Button(comp, SWT.CHECK);
|
||||
fStopInMain.setText("Stop at main() on startup.");
|
||||
|
@ -112,72 +126,10 @@ public class CDebuggerTab extends CLaunchConfigurationTab {
|
|||
gd = new GridData(GridData.FILL_BOTH);
|
||||
gd.horizontalSpan = 2;
|
||||
getDynamicTabHolder().setLayoutData(gd);
|
||||
|
||||
LaunchUIPlugin.setDebugDialogShell(parent.getShell());
|
||||
}
|
||||
|
||||
protected void setDynamicTabHolder(Composite tabHolder) {
|
||||
this.fDynamicTabHolder = tabHolder;
|
||||
}
|
||||
|
||||
protected Composite getDynamicTabHolder() {
|
||||
return fDynamicTabHolder;
|
||||
}
|
||||
|
||||
protected void setDynamicTab(ILaunchConfigurationTab tab) {
|
||||
fDynamicTab = tab;
|
||||
}
|
||||
|
||||
protected ILaunchConfigurationTab getDynamicTab() {
|
||||
return fDynamicTab;
|
||||
}
|
||||
|
||||
protected ICDebugConfiguration getDebugConfig() {
|
||||
return fCurrentDebugConfig;
|
||||
}
|
||||
|
||||
protected void setDebugConfig(ICDebugConfiguration config) {
|
||||
fCurrentDebugConfig = config;
|
||||
}
|
||||
/**
|
||||
* Notification that the user changed the selection in the JRE combo box.
|
||||
*/
|
||||
protected void handleDebuggerComboBoxModified() {
|
||||
loadDynamicDebugArea();
|
||||
|
||||
// always set the newly created area with defaults
|
||||
ILaunchConfigurationWorkingCopy wc = getLaunchConfigurationWorkingCopy();
|
||||
if (getDynamicTab() == null) {
|
||||
// remove any debug specfic args from the config
|
||||
if (wc == null) {
|
||||
if (getLaunchConfiguration().isWorkingCopy()) {
|
||||
wc = (ILaunchConfigurationWorkingCopy) getLaunchConfiguration();
|
||||
}
|
||||
}
|
||||
if (wc != null) {
|
||||
wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_SPECIFIC_ATTRS_MAP, (Map) null);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (wc == null) {
|
||||
try {
|
||||
if (getLaunchConfiguration().isWorkingCopy()) {
|
||||
// get a fresh copy to work on
|
||||
wc = ((ILaunchConfigurationWorkingCopy) getLaunchConfiguration()).getOriginal().getWorkingCopy();
|
||||
}
|
||||
else {
|
||||
wc = getLaunchConfiguration().getWorkingCopy();
|
||||
}
|
||||
}
|
||||
catch (CoreException e) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
getDynamicTab().setDefaults(wc);
|
||||
getDynamicTab().initializeFrom(wc);
|
||||
}
|
||||
updateLaunchConfigurationDialog();
|
||||
}
|
||||
|
||||
protected void loadDebuggerComboBox(ILaunchConfiguration config, String selection) {
|
||||
ICDebugConfiguration[] debugConfigs;
|
||||
String platform = getPlatform(config);
|
||||
|
@ -187,11 +139,11 @@ public class CDebuggerTab extends CLaunchConfigurationTab {
|
|||
int selndx = 0;
|
||||
for (int i = 0; i < debugConfigs.length; i++) {
|
||||
if (debugConfigs[i].supportsMode(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN)
|
||||
|| debugConfigs[i].supportsMode(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH)
|
||||
|| debugConfigs[i].supportsMode(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_CORE)) {
|
||||
|| debugConfigs[i].supportsMode(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH) ) {
|
||||
String supported[] = debugConfigs[i].getPlatforms();
|
||||
boolean isLocal = platform.equals(BootLoader.getOS());
|
||||
for (int j = 0; j < supported.length; j++) {
|
||||
if (supported[j].equals("*") || supported[j].equalsIgnoreCase(platform)) {
|
||||
if (supported[j].equalsIgnoreCase(platform) || (isLocal && supported[j].equalsIgnoreCase("local"))) {
|
||||
fDCombo.add(debugConfigs[i].getName());
|
||||
fDCombo.setData(Integer.toString(x), debugConfigs[i]);
|
||||
if (selection.equals(debugConfigs[i].getID())) {
|
||||
|
@ -208,11 +160,7 @@ public class CDebuggerTab extends CLaunchConfigurationTab {
|
|||
}
|
||||
|
||||
public void setDefaults(ILaunchConfigurationWorkingCopy config) {
|
||||
setLaunchConfigurationWorkingCopy(config);
|
||||
ILaunchConfigurationTab dynamicTab = getDynamicTab();
|
||||
if (dynamicTab != null) {
|
||||
dynamicTab.setDefaults(config);
|
||||
}
|
||||
super.setDefaults(config);
|
||||
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, false);
|
||||
config.setAttribute(
|
||||
ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
|
||||
|
@ -220,16 +168,10 @@ public class CDebuggerTab extends CLaunchConfigurationTab {
|
|||
}
|
||||
|
||||
public void initializeFrom(ILaunchConfiguration config) {
|
||||
String id;
|
||||
|
||||
setLaunchConfiguration(config);
|
||||
super.initializeFrom(config);
|
||||
try {
|
||||
id = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID, "");
|
||||
String id = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID, "");
|
||||
loadDebuggerComboBox(config, id);
|
||||
ILaunchConfigurationTab dynamicTab = getDynamicTab();
|
||||
if (dynamicTab != null) {
|
||||
dynamicTab.initializeFrom(config);
|
||||
}
|
||||
if (config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, false) == true) {
|
||||
fStopInMain.setSelection(true);
|
||||
}
|
||||
|
@ -241,25 +183,13 @@ public class CDebuggerTab extends CLaunchConfigurationTab {
|
|||
|
||||
public void performApply(ILaunchConfigurationWorkingCopy config) {
|
||||
if (isValid(config)) {
|
||||
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID, getDebugConfig().getID());
|
||||
ILaunchConfigurationTab dynamicTab = getDynamicTab();
|
||||
if (dynamicTab == null) {
|
||||
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_SPECIFIC_ATTRS_MAP, (Map) null);
|
||||
}
|
||||
else {
|
||||
dynamicTab.performApply(config);
|
||||
}
|
||||
super.performApply(config);
|
||||
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, false);
|
||||
if (fAttachButton.getSelection() == true) {
|
||||
config.setAttribute(
|
||||
ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
|
||||
ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH);
|
||||
}
|
||||
else if (fCoreButton.getSelection() == true) {
|
||||
config.setAttribute(
|
||||
ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
|
||||
ICDTLaunchConfigurationConstants.DEBUGGER_MODE_CORE);
|
||||
}
|
||||
else {
|
||||
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, fStopInMain.getSelection());
|
||||
config.setAttribute(
|
||||
|
@ -270,22 +200,12 @@ public class CDebuggerTab extends CLaunchConfigurationTab {
|
|||
}
|
||||
|
||||
public boolean isValid(ILaunchConfiguration config) {
|
||||
setErrorMessage(null);
|
||||
setMessage(null);
|
||||
|
||||
if (fDCombo.getSelectionIndex() == -1 || getDebugConfig() == null) {
|
||||
setErrorMessage("No debugger avalible");
|
||||
if (super.isValid(config) == false ) {
|
||||
return false;
|
||||
}
|
||||
if ( !fRunButton.getSelection()
|
||||
&& !fAttachButton.getSelection()
|
||||
&& !fCoreButton.getSelection() ) {
|
||||
setErrorMessage("Select a Debug mode.");
|
||||
return false;
|
||||
}
|
||||
ILaunchConfigurationTab dynamicTab = getDynamicTab();
|
||||
if (dynamicTab != null) {
|
||||
return dynamicTab.isValid(config);
|
||||
if (!fRunButton.getSelection() && !fAttachButton.getSelection()) {
|
||||
setErrorMessage("Select a Debug mode.");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -299,96 +219,6 @@ public class CDebuggerTab extends CLaunchConfigurationTab {
|
|||
return (ICDebugConfiguration) fDCombo.getData(Integer.toString(selectedIndex));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the contributed piece of UI that was registered for the debugger id
|
||||
* of the currently selected debugger.
|
||||
*/
|
||||
protected void loadDynamicDebugArea() {
|
||||
// Dispose of any current child widgets in the tab holder area
|
||||
Control[] children = getDynamicTabHolder().getChildren();
|
||||
for (int i = 0; i < children.length; i++) {
|
||||
children[i].dispose();
|
||||
}
|
||||
|
||||
// Retrieve the dynamic UI for the current Debugger
|
||||
ICDebugConfiguration debugConfig = getConfigForCurrentDebugger();
|
||||
if (debugConfig == null) {
|
||||
setDynamicTab(null);
|
||||
}
|
||||
else {
|
||||
setDynamicTab(CDebugUIPlugin.getDefault().getDebuggerPage(debugConfig.getID()));
|
||||
}
|
||||
setDebugConfig(debugConfig);
|
||||
if (getDynamicTab() == null) {
|
||||
return;
|
||||
}
|
||||
// Ask the dynamic UI to create its Control
|
||||
getDynamicTab().setLaunchConfigurationDialog(getLaunchConfigurationDialog());
|
||||
getDynamicTab().createControl(getDynamicTabHolder());
|
||||
getDynamicTab().getControl().setVisible(true);
|
||||
getDynamicTabHolder().layout(true);
|
||||
|
||||
fRunButton.setEnabled(debugConfig.supportsMode(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN));
|
||||
fRunButton.setSelection(false);
|
||||
fAttachButton.setEnabled(debugConfig.supportsMode(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH));
|
||||
fAttachButton.setSelection(false);
|
||||
fCoreButton.setEnabled(debugConfig.supportsMode(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_CORE));
|
||||
fCoreButton.setSelection(false);
|
||||
try {
|
||||
String mode =
|
||||
getLaunchConfiguration().getAttribute(
|
||||
ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
|
||||
ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN);
|
||||
if (mode.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN) && fRunButton.isEnabled()) {
|
||||
fRunButton.setSelection(true);
|
||||
}
|
||||
else if (mode.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH) && fAttachButton.isEnabled()) {
|
||||
fAttachButton.setSelection(true);
|
||||
}
|
||||
else if (mode.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_CORE) && fCoreButton.isEnabled()) {
|
||||
fCoreButton.setSelection(true);
|
||||
}
|
||||
if ( fRunButton.getSelection() == true ) {
|
||||
fStopInMain.setEnabled(true);
|
||||
} else {
|
||||
fStopInMain.setEnabled(false);
|
||||
}
|
||||
}
|
||||
catch (CoreException e) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Overridden here so that any error message in the dynamic UI gets returned.
|
||||
*
|
||||
* @see ILaunchConfigurationTab#getErrorMessage()
|
||||
*/
|
||||
public String getErrorMessage() {
|
||||
ILaunchConfigurationTab tab = getDynamicTab();
|
||||
if ((super.getErrorMessage() != null) || (tab == null)) {
|
||||
return super.getErrorMessage();
|
||||
}
|
||||
else {
|
||||
return tab.getErrorMessage();
|
||||
}
|
||||
}
|
||||
|
||||
protected void setLaunchConfigurationWorkingCopy(ILaunchConfigurationWorkingCopy workingCopy) {
|
||||
fWorkingCopy = workingCopy;
|
||||
}
|
||||
|
||||
protected ILaunchConfiguration getLaunchConfiguration() {
|
||||
return fLaunchConfiguration;
|
||||
}
|
||||
|
||||
protected void setLaunchConfiguration(ILaunchConfiguration launchConfiguration) {
|
||||
fLaunchConfiguration = launchConfiguration;
|
||||
}
|
||||
|
||||
protected ILaunchConfigurationWorkingCopy getLaunchConfigurationWorkingCopy() {
|
||||
return fWorkingCopy;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return "Debugger";
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@ import java.util.Map;
|
|||
import java.util.Properties;
|
||||
|
||||
import org.eclipse.cdt.launch.ICDTLaunchConfigurationConstants;
|
||||
import org.eclipse.cdt.launch.internal.ui.CLaunchConfigurationTab;
|
||||
import org.eclipse.cdt.launch.internal.ui.LaunchImages;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.debug.core.ILaunchConfiguration;
|
||||
|
|
|
@ -1,15 +1,16 @@
|
|||
package org.eclipse.cdt.launch.internal.ui;
|
||||
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;
|
||||
import org.eclipse.cdt.launch.ICDTLaunchConfigurationConstants;
|
||||
import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin;
|
||||
import org.eclipse.core.boot.BootLoader;
|
||||
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.debug.core.ILaunchConfiguration;
|
||||
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
|
||||
|
@ -32,40 +33,62 @@ public abstract class CLaunchConfigurationTab extends AbstractLaunchConfiguratio
|
|||
*
|
||||
* @return C element context.
|
||||
*/
|
||||
protected ICElement getContext(ILaunchConfigurationWorkingCopy config) throws CoreException {
|
||||
protected ICElement getContext(ILaunchConfiguration config, String platform) {
|
||||
String projectName = null;
|
||||
IWorkbenchPage page = LaunchUIPlugin.getActivePage();
|
||||
if (page != null) {
|
||||
ISelection selection = page.getSelection();
|
||||
if (selection instanceof IStructuredSelection) {
|
||||
IStructuredSelection ss = (IStructuredSelection) selection;
|
||||
if (!ss.isEmpty()) {
|
||||
Object obj = ss.getFirstElement();
|
||||
if (obj instanceof ICElement) {
|
||||
ICDescriptor descriptor =
|
||||
CCorePlugin.getDefault().getCProjectDescription(((ICElement) obj).getCProject().getProject());
|
||||
if (descriptor.getPlatform().equals(getPlatform(config)))
|
||||
return (ICElement) obj;
|
||||
}
|
||||
if (obj instanceof IResource) {
|
||||
ICElement ce = CoreModel.getDefault().create((IResource) obj);
|
||||
if (ce == null) {
|
||||
IProject pro = ((IResource) obj).getProject();
|
||||
ce = CoreModel.getDefault().create(pro);
|
||||
}
|
||||
if (ce != null) {
|
||||
ICDescriptor descriptor =
|
||||
CCorePlugin.getDefault().getCProjectDescription(ce.getCProject().getProject());
|
||||
if (descriptor.getPlatform().equals(getPlatform(config)))
|
||||
return ce;
|
||||
}
|
||||
Object obj = null;
|
||||
try {
|
||||
projectName = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, (String) null);
|
||||
}
|
||||
catch (CoreException e) {
|
||||
}
|
||||
if (projectName != null && !projectName.equals("")) {
|
||||
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
|
||||
ICProject cProject = CCorePlugin.getDefault().getCoreModel().create(project);
|
||||
if (cProject != null && cProject.exists()) {
|
||||
obj = cProject;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (page != null) {
|
||||
ISelection selection = page.getSelection();
|
||||
if (selection instanceof IStructuredSelection) {
|
||||
IStructuredSelection ss = (IStructuredSelection) selection;
|
||||
if (!ss.isEmpty()) {
|
||||
obj = ss.getFirstElement();
|
||||
}
|
||||
}
|
||||
}
|
||||
IEditorPart part = page.getActiveEditor();
|
||||
if (part != null) {
|
||||
IEditorInput input = part.getEditorInput();
|
||||
return (ICElement) input.getAdapter(ICElement.class);
|
||||
}
|
||||
if (obj instanceof IResource) {
|
||||
ICElement ce = CoreModel.getDefault().create((IResource) obj);
|
||||
if (ce == null) {
|
||||
IProject pro = ((IResource) obj).getProject();
|
||||
ce = CoreModel.getDefault().create(pro);
|
||||
}
|
||||
obj = ce;
|
||||
}
|
||||
if (obj instanceof ICElement) {
|
||||
if (platform != null && !platform.equals("*")) {
|
||||
ICDescriptor descriptor;
|
||||
try {
|
||||
descriptor = CCorePlugin.getDefault().getCProjectDescription(((ICElement) obj).getCProject().getProject());
|
||||
}
|
||||
catch (CoreException e) {
|
||||
return null;
|
||||
}
|
||||
if (descriptor.getPlatform().equals(platform)) {
|
||||
return (ICElement) obj;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return (ICElement) obj;
|
||||
}
|
||||
}
|
||||
IEditorPart part = page.getActiveEditor();
|
||||
if (part != null) {
|
||||
IEditorInput input = part.getEditorInput();
|
||||
return (ICElement) input.getAdapter(ICElement.class);
|
||||
}
|
||||
return null;
|
||||
}
|
|
@ -15,11 +15,12 @@ import org.eclipse.cdt.core.model.IBinary;
|
|||
import org.eclipse.cdt.core.model.IBinaryContainer;
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.internal.ui.CContentProvider;
|
||||
import org.eclipse.cdt.internal.ui.CElementLabelProvider;
|
||||
import org.eclipse.cdt.launch.ICDTLaunchConfigurationConstants;
|
||||
import org.eclipse.cdt.launch.internal.ui.CLaunchConfigurationTab;
|
||||
import org.eclipse.cdt.launch.internal.ui.LaunchImages;
|
||||
import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin;
|
||||
import org.eclipse.core.boot.BootLoader;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
@ -40,6 +41,7 @@ import org.eclipse.swt.widgets.Composite;
|
|||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
import org.eclipse.ui.dialogs.ElementListSelectionDialog;
|
||||
import org.eclipse.ui.dialogs.ListSelectionDialog;
|
||||
|
||||
/**
|
||||
* A launch configuration tab that displays and edits project and
|
||||
|
@ -106,6 +108,7 @@ public class CMainTab extends CLaunchConfigurationTab {
|
|||
fProjButton.addSelectionListener(new SelectionAdapter() {
|
||||
public void widgetSelected(SelectionEvent evt) {
|
||||
handleProjectButtonSelected();
|
||||
updateLaunchConfigurationDialog();
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -136,6 +139,7 @@ public class CMainTab extends CLaunchConfigurationTab {
|
|||
fSearchButton.addSelectionListener(new SelectionAdapter() {
|
||||
public void widgetSelected(SelectionEvent evt) {
|
||||
handleSearchButtonSelected();
|
||||
updateLaunchConfigurationDialog();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -194,19 +198,11 @@ public class CMainTab extends CLaunchConfigurationTab {
|
|||
}
|
||||
|
||||
IBinary[] executables = getBinaryFiles(getCProject());
|
||||
|
||||
ILabelProvider labelProvider = new CElementLabelProvider();
|
||||
ElementListSelectionDialog dialog = new ElementListSelectionDialog(getShell(), labelProvider);
|
||||
dialog.setTitle("Program Selection");
|
||||
dialog.setMessage("Choose a &program to run");
|
||||
ElementListSelectionDialog dialog = new ElementListSelectionDialog(getShell(), labelProvider);
|
||||
dialog.setElements(executables);
|
||||
|
||||
/*
|
||||
if (cProject != null) {
|
||||
dialog.setInitialSelections(new Object[] { cProject });
|
||||
}
|
||||
*/
|
||||
|
||||
dialog.setMessage("Choose a &program to run");
|
||||
dialog.setTitle("Program Selection");
|
||||
if (dialog.open() == dialog.OK) {
|
||||
IBinary binary = (IBinary) dialog.getFirstResult();
|
||||
try {
|
||||
|
@ -271,11 +267,14 @@ public class CMainTab extends CLaunchConfigurationTab {
|
|||
protected ICProject[] getCProjects() {
|
||||
ICProject cproject[] = CoreModel.getDefault().getCRoot().getCProjects();
|
||||
ArrayList list = new ArrayList(cproject.length);
|
||||
boolean isLocal = filterPlatform.equals(BootLoader.getOS());
|
||||
|
||||
for (int i = 0; i < cproject.length; i++) {
|
||||
ICDescriptor cdesciptor = null;
|
||||
try {
|
||||
cdesciptor = CCorePlugin.getDefault().getCProjectDescription((IProject) cproject[i].getResource());
|
||||
if (cdesciptor.getPlatform().equals("*") || filterPlatform.equalsIgnoreCase(cdesciptor.getPlatform()) == true) {
|
||||
if (filterPlatform.equals("*") || (isLocal && cdesciptor.getPlatform().equalsIgnoreCase("local"))
|
||||
|| filterPlatform.equalsIgnoreCase(cdesciptor.getPlatform()) == true) {
|
||||
list.add(cproject[i]);
|
||||
}
|
||||
}
|
||||
|
@ -320,7 +319,7 @@ public class CMainTab extends CLaunchConfigurationTab {
|
|||
setErrorMessage("Program not specified");
|
||||
return false;
|
||||
}
|
||||
if ( name.equals(".") || name.equals("..")) {
|
||||
if (name.equals(".") || name.equals("..")) {
|
||||
setErrorMessage("Program does not exist");
|
||||
return false;
|
||||
}
|
||||
|
@ -335,23 +334,18 @@ public class CMainTab extends CLaunchConfigurationTab {
|
|||
* @see ILaunchConfigurationTab#setDefaults(ILaunchConfigurationWorkingCopy)
|
||||
*/
|
||||
public void setDefaults(ILaunchConfigurationWorkingCopy config) {
|
||||
// We set empty attributes for project & program so that when one config is
|
||||
// compared to another, the existence of empty attributes doesn't cause an
|
||||
// incorrect result (the performApply() method can result in empty values
|
||||
// for these attributes being set on a config if there is nothing in the
|
||||
// corresponding text boxes)
|
||||
// plus getContext will use this to base context from if set.
|
||||
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, EMPTY_STRING);
|
||||
ICElement cElement = null;
|
||||
try {
|
||||
cElement = getContext(config);
|
||||
}
|
||||
catch (CoreException e) {
|
||||
}
|
||||
cElement = getContext(config, getPlatform(config));
|
||||
if (cElement != null) {
|
||||
initializeCProject(cElement, config);
|
||||
}
|
||||
else {
|
||||
// We set empty attributes for project & program so that when one config is
|
||||
// compared to another, the existence of empty attributes doesn't cause an
|
||||
// incorrect result (the performApply() method can result in empty values
|
||||
// for these attributes being set on a config if there is nothing in the
|
||||
// corresponding text boxes)
|
||||
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, EMPTY_STRING);
|
||||
}
|
||||
initializeProgramName(cElement, config);
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,170 @@
|
|||
/*
|
||||
* (c) Copyright QNX Software System Ltd. 2002.
|
||||
* All Rights Reserved.
|
||||
*/
|
||||
package org.eclipse.cdt.launch.ui;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.ICDescriptor;
|
||||
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;
|
||||
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.debug.core.ILaunchConfiguration;
|
||||
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.ModifyEvent;
|
||||
import org.eclipse.swt.events.ModifyListener;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Combo;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Group;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
|
||||
public class CorefileDebuggerTab extends AbstractCDebuggerTab {
|
||||
protected Combo fDCombo;
|
||||
|
||||
private boolean initializingComboBox = false;
|
||||
|
||||
public void createControl(Composite parent) {
|
||||
Composite comp = new Composite(parent, SWT.NONE);
|
||||
setControl(comp);
|
||||
GridLayout topLayout = new GridLayout(2, false);
|
||||
comp.setLayout(topLayout);
|
||||
Label dlabel = new Label(comp, SWT.NONE);
|
||||
dlabel.setText("Debugger:");
|
||||
fDCombo = new Combo(comp, SWT.DROP_DOWN | SWT.READ_ONLY);
|
||||
fDCombo.addModifyListener(new ModifyListener() {
|
||||
public void modifyText(ModifyEvent e) {
|
||||
handleDebuggerChanged();
|
||||
}
|
||||
});
|
||||
Group debuggerGroup = new Group(comp, SWT.SHADOW_ETCHED_IN);
|
||||
debuggerGroup.setText("Debugger Options");
|
||||
setDynamicTabHolder(debuggerGroup);
|
||||
GridLayout tabHolderLayout = new GridLayout();
|
||||
tabHolderLayout.marginHeight = 0;
|
||||
tabHolderLayout.marginWidth = 0;
|
||||
tabHolderLayout.numColumns = 1;
|
||||
getDynamicTabHolder().setLayout(tabHolderLayout);
|
||||
GridData gd = new GridData(GridData.FILL_BOTH);
|
||||
gd.horizontalSpan = 2;
|
||||
getDynamicTabHolder().setLayoutData(gd);
|
||||
|
||||
LaunchUIPlugin.setDebugDialogShell(parent.getShell());
|
||||
}
|
||||
|
||||
protected void loadDebuggerComboBox(ILaunchConfiguration config, String selection) {
|
||||
if ( initializingComboBox ) {
|
||||
return;
|
||||
}
|
||||
initializingComboBox = true;
|
||||
ICDebugConfiguration[] debugConfigs;
|
||||
String platform = getPlatform(config);
|
||||
ICElement ce = getContext(config, null);
|
||||
String projectPlatform = "local";
|
||||
if ( ce != null ) {
|
||||
try {
|
||||
ICDescriptor descriptor = CCorePlugin.getDefault().getCProjectDescription(ce.getCProject().getProject());
|
||||
projectPlatform = descriptor.getPlatform();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
fDCombo.removeAll();
|
||||
debugConfigs = CDebugCorePlugin.getDefault().getDebugConfigurations();
|
||||
int x = 0;
|
||||
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"))) {
|
||||
fDCombo.add(debugConfigs[i].getName());
|
||||
fDCombo.setData(Integer.toString(x), debugConfigs[i]);
|
||||
if (selection.equals(debugConfigs[i].getID())) {
|
||||
selndx = x;
|
||||
}
|
||||
x++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( selndx != -1 ) {
|
||||
fDCombo.select(selndx);
|
||||
}
|
||||
fDCombo.getParent().layout(true);
|
||||
initializingComboBox = false;
|
||||
}
|
||||
|
||||
public void initializeFrom(ILaunchConfiguration config) {
|
||||
super.initializeFrom(config);
|
||||
try {
|
||||
String id = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID, "");
|
||||
loadDebuggerComboBox(config, id);
|
||||
}
|
||||
catch (CoreException e) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public void setDefaults(ILaunchConfigurationWorkingCopy config) {
|
||||
super.setDefaults(config);
|
||||
config.setAttribute(
|
||||
ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
|
||||
ICDTLaunchConfigurationConstants.DEBUGGER_MODE_CORE);
|
||||
}
|
||||
|
||||
public boolean isValid(ILaunchConfiguration config) {
|
||||
if ( !validateDebuggerConfig(config) ) {
|
||||
setErrorMessage("No debugger avalible");
|
||||
return false;
|
||||
}
|
||||
return super.isValid(config);
|
||||
}
|
||||
|
||||
private boolean validateDebuggerConfig(ILaunchConfiguration config) {
|
||||
String platform = getPlatform(config);
|
||||
ICElement ce = getContext(config, null);
|
||||
String projectPlatform = "local";
|
||||
if ( ce != null ) {
|
||||
try {
|
||||
ICDescriptor descriptor = CCorePlugin.getDefault().getCProjectDescription(ce.getCProject().getProject());
|
||||
projectPlatform = descriptor.getPlatform();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
ICDebugConfiguration debugConfig = getDebugConfig();
|
||||
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"))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the class that implements <code>ILaunchConfigurationTab</code>
|
||||
* that is registered against the debugger id of the currently selected debugger.
|
||||
*/
|
||||
protected ICDebugConfiguration getConfigForCurrentDebugger() {
|
||||
int selectedIndex = fDCombo.getSelectionIndex();
|
||||
return (ICDebugConfiguration) fDCombo.getData(Integer.toString(selectedIndex));
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return "Debugger";
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue