1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-13 19:25:38 +02:00

use new debugger configuartion page extension

added AbstractCLaunchTAb
This commit is contained in:
David Inglis 2002-08-15 14:43:02 +00:00
parent 54f5b7dadf
commit 6a2a614989
8 changed files with 306 additions and 242 deletions

View file

@ -8,6 +8,7 @@
<classpathentry kind="src" path="/org.eclipse.cdt.core"/>
<classpathentry kind="src" path="/org.eclipse.cdt.ui"/>
<classpathentry kind="src" path="/org.eclipse.cdt.debug.core"/>
<classpathentry kind="src" path="/org.eclipse.cdt.debug.ui"/>
<classpathentry kind="src" path="/org.eclipse.core.runtime"/>
<classpathentry kind="src" path="/org.eclipse.core.boot"/>
<classpathentry kind="var" path="JRE_LIB" rootpath="JRE_SRCROOT" sourcepath="JRE_SRC"/>

View file

@ -5,6 +5,7 @@
<projects>
<project>org.eclipse.cdt.core</project>
<project>org.eclipse.cdt.debug.core</project>
<project>org.eclipse.cdt.debug.ui</project>
<project>org.eclipse.cdt.ui</project>
<project>org.eclipse.core.boot</project>
<project>org.eclipse.core.resources</project>

View file

@ -17,6 +17,7 @@
<import plugin="org.eclipse.cdt.core"/>
<import plugin="org.eclipse.cdt.ui"/>
<import plugin="org.eclipse.cdt.debug.core"/>
<import plugin="org.eclipse.cdt.debug.ui"/>
</requires>

View file

@ -0,0 +1,212 @@
/*
* (c) Copyright QNX Software System Ltd. 2002.
* All Rights Reserved.
*/
package org.eclipse.cdt.launch;
import java.io.File;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Map;
import java.util.Properties;
import java.util.Map.Entry;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.model.ILaunchConfigurationDelegate;
abstract public class AbstractCLaunchDelegate implements ILaunchConfigurationDelegate {
abstract public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException;
protected String[] getEnvironmentArray(ILaunchConfiguration config) {
// Map env = configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ENVIROMENT_MAP, (Map) null);
// TODO create env array;
return null;
}
protected Properties getEnvironmentProperty(ILaunchConfiguration config) {
Properties prop = new Properties();
Map env = null;
try {
env = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ENVIROMENT_MAP, (Map) null);
}
catch (CoreException e) {
}
if ( env == null )
return prop;
Iterator entries = env.entrySet().iterator();
Entry entry;
while( entries.hasNext() ) {
entry = (Entry) entries.next();
prop.setProperty((String)entry.getKey(), (String)entry.getValue());
}
return prop;
}
protected File getWorkingDir(ILaunchConfiguration config) throws CoreException {
String path = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, (String)null);
if (path == null) {
return null;
}
File dir = new File(path);
if (!dir.isDirectory()) {
abort("Specified working directory does not exist or is not a directory", null, ICDTLaunchConfigurationConstants.ERR_WORKING_DIRECTORY_DOES_NOT_EXIST);
}
return dir;
}
/**
* Throws a core exception with an error status object built from
* the given message, lower level exception, and error code.
*
* @param message the status message
* @param exception lower level exception associated with the
* error, or <code>null</code> if none
* @param code error code
*/
protected void abort(String message, Throwable exception, int code) throws CoreException {
throw new CoreException(new Status(IStatus.ERROR, LaunchUIPlugin.getUniqueIdentifier(), code, message, exception));
}
public ICProject getCProject(ILaunchConfiguration configuration) throws CoreException {
String projectName = getProjectName(configuration);
if (projectName != null) {
projectName = projectName.trim();
if (projectName.length() > 0) {
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
ICProject cProject = CCorePlugin.getDefault().getCoreModel().create(project);
if (cProject != null && cProject.exists()) {
return cProject;
}
}
}
return null;
}
public String getProjectName(ILaunchConfiguration configuration) throws CoreException {
return configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, (String)null);
}
public String getProgramName(ILaunchConfiguration configuration) throws CoreException {
return configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, (String)null);
}
/**
* Returns the program arguments as a String.
*
* @return the program arguments as a String
*/
public String getProgramArguments(ILaunchConfiguration config) throws CoreException {
return config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, (String)null);
}
/**
* Returns the program arguments as an array of individual arguments.
*
* @return the program arguments as an array of individual arguments
*/
public String[] getProgramArgumentsArray(ILaunchConfiguration config) throws CoreException {
return parseArguments(getProgramArguments(config));
}
private static String[] parseArguments(String args) {
if (args == null)
return new String[0];
ArgumentParser parser= new ArgumentParser(args);
String[] res= parser.parseArguments();
return res;
}
private static class ArgumentParser {
private String fArgs;
private int fIndex= 0;
private int ch= -1;
public ArgumentParser(String args) {
fArgs= args;
}
public String[] parseArguments() {
ArrayList v= new ArrayList();
ch= getNext();
while (ch > 0) {
while (Character.isWhitespace((char)ch))
ch= getNext();
if (ch == '"') {
v.add(parseString());
} else {
v.add(parseToken());
}
}
String[] result= new String[v.size()];
v.toArray(result);
return result;
}
private int getNext() {
if (fIndex < fArgs.length())
return fArgs.charAt(fIndex++);
return -1;
}
private String parseString() {
StringBuffer buf= new StringBuffer();
ch= getNext();
while (ch > 0 && ch != '"') {
if (ch == '\\') {
ch= getNext();
if (ch != '"') { // Only escape double quotes
buf.append('\\');
}
}
if (ch > 0) {
buf.append((char)ch);
ch= getNext();
}
}
ch= getNext();
return buf.toString();
}
private String parseToken() {
StringBuffer buf= new StringBuffer();
while (ch > 0 && !Character.isWhitespace((char)ch)) {
if (ch == '\\') {
ch= getNext();
if (ch > 0) {
if (ch != '"') { // Only escape double quotes
buf.append('\\');
}
buf.append((char)ch);
ch= getNext();
} else if (ch == -1) { // Don't lose a trailing backslash
buf.append('\\');
}
} else if (ch == '"') {
buf.append(parseString());
} else {
buf.append((char)ch);
ch= getNext();
}
}
return buf.toString();
}
}
}

View file

@ -54,18 +54,22 @@ public interface ICDTLaunchConfigurationConstants {
* Launch configuration attribute key. The value is the debugger id
* used when launching a C/C++ application for debug.
*/
public static final String ATTR_CDT_DEBUGGER_ID = LaunchUIPlugin.getUniqueIdentifier() + ".CDT_DEBUGGER"; //$NON-NLS-1$
public static final String ATTR_DEBUGGER_ID = LaunchUIPlugin.getUniqueIdentifier() + ".DEBUGGER_ID"; //$NON-NLS-1$
/**
* Launch configuration attribute key. The value is the platform string of the launch configuration
*/
public static final String ATTR_CDT_PLATFORM = LaunchUIPlugin.getUniqueIdentifier() + ".CDT_PLATFFORM"; //$NON-NLS-1$
public static final String ATTR_PLATFORM = LaunchUIPlugin.getUniqueIdentifier() + ".PLATFFORM"; //$NON-NLS-1$
/**
* Launch configuration attribute key. The value is the platform string of the launch configuration
*/
public static final String ATTR_DEBUGGER_SPECIFIC_ATTRS_MAP = LaunchUIPlugin.getUniqueIdentifier() + ".CDT_DEBUGGER_SPECIFIC_ATTRS_MAP"; //$NON-NLS-1$
public static final String ATTR_DEBUGGER_SPECIFIC_ATTRS_MAP = LaunchUIPlugin.getUniqueIdentifier() + ".DEBUGGER_SPECIFIC_ATTRS_MAP"; //$NON-NLS-1$
/**
* Launch configuration attribute key. The value is the platform string of the launch configuration
*/
public static final String ATTR_DEBUGGER_STOP_AT_MAIN = LaunchUIPlugin.getUniqueIdentifier() + ".DEBUGGER_STOP_AT_MAIN"; //$NON-NLS-1$
/**
* Status code indicating that the Eclipse runtime does not support
* launching a program with a working directory. This feature is only

View file

@ -13,19 +13,17 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Properties;
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.ICDebuggerManager;
import org.eclipse.cdt.debug.core.cdi.CDIException;
import org.eclipse.cdt.debug.core.cdi.ICDIRuntimeOptions;
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;
@ -36,46 +34,33 @@ 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.Platform;
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.ILaunchManager;
import org.eclipse.debug.core.IStatusHandler;
import org.eclipse.debug.core.model.ILaunchConfigurationDelegate;
import org.eclipse.debug.core.model.IProcess;
/**
* Insert the type's description here.
* @see ILaunchConfigurationDelegate
*/
public class LocalCLaunchConfigurationDelegate implements ILaunchConfigurationDelegate {
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) });
return "session -- TODO";
/*
protected String renderDebugTarget(ICDISession session) {
String format= "{0} at localhost {1}";
return MessageFormat.format(format, new String[] { classToRun, String.valueOf(host) });
}
public static String renderProcessLabel(String[] commandLine) {
*/
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 });
}
protected static String renderCommandLine(String[] commandLine) {
if (commandLine.length < 1)
return "";
StringBuffer buf= new StringBuffer(commandLine[0]);
for (int i= 1; i < commandLine.length; i++) {
buf.append(' ');
buf.append(commandLine[i]);
}
return buf.toString();
}
public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
public void launch(ILaunchConfiguration config, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
if (monitor == null) {
monitor = new NullProgressMonitor();
}
@ -85,19 +70,18 @@ public class LocalCLaunchConfigurationDelegate implements ILaunchConfigurationDe
if (monitor.isCanceled()) {
return;
}
ICProject cproject = getCProject(configuration);
IPath projectPath = Platform.getLocation().append(cproject.getResource().getFullPath());
projectPath = projectPath.append(getProgramName(configuration));
String arguments[] = getProgramArgumentsArray(configuration);
ICProject cproject = getCProject(config);
IPath projectPath = ((IProject)cproject.getResource()).getFile(getProgramName(config)).getLocation();
String arguments[] = getProgramArgumentsArray(config);
ArrayList command = new ArrayList(1+arguments.length);
command.add(projectPath.toOSString());
command.addAll(Arrays.asList(arguments));
if (mode.equals(ILaunchManager.DEBUG_MODE)) {
ICDebuggerManager dbgmanager = CDebugCorePlugin.getDefault().getDebuggerManager();
ICDebugger cdebugger = null;
ICDebugConfiguration dbgCfg = CDebugCorePlugin.getDefault().getDebugConfiguration(config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID, ""));
ICDebugger cdebugger = null;
try {
cdebugger = dbgmanager.createDebugger(configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_CDT_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);
@ -113,67 +97,32 @@ public class LocalCLaunchConfigurationDelegate implements ILaunchConfigurationDe
IFile exe = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(projectPath);
ICDISession dsession = null;
try {
dsession = cdebugger.createLaunchSession(configuration, exe);
dsession = cdebugger.createLaunchSession(config, exe);
}
catch (CDIException e) {
IStatus status = new Status(0, LaunchUIPlugin.getUniqueIdentifier(), ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR,"CDI Error", e);
throw new CoreException(status);
}
ICDIRuntimeOptions opt = dsession.getRuntimeOptions();
opt.setArguments(configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, ""));
File wd = getWorkingDir(configuration);
opt.setArguments(config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, ""));
File wd = getWorkingDir(config);
if ( wd != null ) {
opt.setWorkingDirectory(wd.toString());
}
opt.setEnvironment(getEnvironmentProperty(configuration));
opt.setEnvironment(getEnvironmentProperty(config));
ICDITarget dtarget = dsession.getTargets()[0];
Process process = dtarget.getProcess();
IProcess iprocess = DebugPlugin.newProcess(launch, process, renderProcessLabel((String [])command.toArray(new String[command.size()])));
CDebugModel.newDebugTarget(launch, dsession.getTargets()[0], renderDebugTarget(dsession), iprocess, true, false, false );
boolean stopInMain = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, false);
CDebugModel.newDebugTarget(launch, dsession.getTargets()[0], dbgCfg.getName(), iprocess, true, false, stopInMain );
}
else {
Process process = exec((String [])command.toArray(new String[command.size()]), getEnvironmentArray(configuration), getWorkingDir(configuration));
Process process = exec((String [])command.toArray(new String[command.size()]), getEnvironmentArray(config), getWorkingDir(config));
DebugPlugin.getDefault().newProcess(launch, process, "label");
}
monitor.done();
}
private String[] getEnvironmentArray(ILaunchConfiguration configuration) {
// Map env = configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ENVIROMENT_MAP, (Map) null);
// TODO create env array;
return null;
}
private Properties getEnvironmentProperty(ILaunchConfiguration configuration) {
// Map env = configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ENVIROMENT_MAP, (Map) null);
return new Properties();
}
protected File getWorkingDir(ILaunchConfiguration config) throws CoreException {
String path = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, (String)null);
if (path == null) {
return null;
}
File dir = new File(path);
if (!dir.isDirectory()) {
abort("Specified working directory does not exist or is not a directory", null, ICDTLaunchConfigurationConstants.ERR_WORKING_DIRECTORY_DOES_NOT_EXIST);
}
return dir;
}
/**
* Throws a core exception with an error status object built from
* the given message, lower level exception, and error code.
*
* @param message the status message
* @param exception lower level exception associated with the
* error, or <code>null</code> if none
* @param code error code
*/
protected void abort(String message, Throwable exception, int code) throws CoreException {
throw new CoreException(new Status(IStatus.ERROR, LaunchUIPlugin.getUniqueIdentifier(), code, message, exception));
}
/**
* Performs a runtime exec on the given command line in the context
@ -220,130 +169,4 @@ public class LocalCLaunchConfigurationDelegate implements ILaunchConfigurationDe
}
return p;
}
public ICProject getCProject(ILaunchConfiguration configuration) throws CoreException {
String projectName = getCProjectName(configuration);
if (projectName != null) {
projectName = projectName.trim();
if (projectName.length() > 0) {
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
ICProject cProject = CCorePlugin.getDefault().getCoreModel().create(project);
if (cProject != null && cProject.exists()) {
return cProject;
}
}
}
return null;
}
public String getCProjectName(ILaunchConfiguration configuration) throws CoreException {
return configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, (String)null);
}
public String getProgramName(ILaunchConfiguration configuration) throws CoreException {
return configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, (String)null);
}
/**
* Returns the program arguments as an array of individual arguments.
*
* @return the program arguments as an array of individual arguments
*/
public String[] getProgramArgumentsArray(ILaunchConfiguration configuration) throws CoreException {
String args = configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, (String)null);
return parseArguments(args);
}
private static class ArgumentParser {
private String fArgs;
private int fIndex= 0;
private int ch= -1;
public ArgumentParser(String args) {
fArgs= args;
}
public String[] parseArguments() {
List v= new ArrayList();
ch= getNext();
while (ch > 0) {
while (Character.isWhitespace((char)ch))
ch= getNext();
if (ch == '"') {
v.add(parseString());
} else {
v.add(parseToken());
}
}
String[] result= new String[v.size()];
v.toArray(result);
return result;
}
private int getNext() {
if (fIndex < fArgs.length())
return fArgs.charAt(fIndex++);
return -1;
}
private String parseString() {
StringBuffer buf= new StringBuffer();
ch= getNext();
while (ch > 0 && ch != '"') {
if (ch == '\\') {
ch= getNext();
if (ch != '"') { // Only escape double quotes
buf.append('\\');
}
}
if (ch > 0) {
buf.append((char)ch);
ch= getNext();
}
}
ch= getNext();
return buf.toString();
}
private String parseToken() {
StringBuffer buf= new StringBuffer();
while (ch > 0 && !Character.isWhitespace((char)ch)) {
if (ch == '\\') {
ch= getNext();
if (ch > 0) {
if (ch != '"') { // Only escape double quotes
buf.append('\\');
}
buf.append((char)ch);
ch= getNext();
} else if (ch == -1) { // Don't lose a trailing backslash
buf.append('\\');
}
} else if (ch == '"') {
buf.append(parseString());
} else {
buf.append((char)ch);
ch= getNext();
}
}
return buf.toString();
}
}
private static String[] parseArguments(String args) {
if (args == null)
return new String[0];
ArgumentParser parser= new ArgumentParser(args);
String[] res= parser.parseArguments();
return res;
}
}

View file

@ -83,6 +83,6 @@ public abstract class CLaunchConfigurationTab extends AbstractLaunchConfiguratio
protected String getPlatform(ILaunchConfiguration config) throws CoreException {
String platform = BootLoader.getOS();
return config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_CDT_PLATFORM, platform);
return config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PLATFORM, platform);
}
}

View file

@ -9,7 +9,8 @@ import java.util.Map;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
import org.eclipse.cdt.debug.core.ICDebuggerInfo;
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.LaunchImages;
@ -25,6 +26,7 @@ import org.eclipse.swt.events.SelectionListener;
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;
@ -35,6 +37,7 @@ public class CDebuggerTab extends CLaunchConfigurationTab {
ArrayList fDinfo;
int fDindex;
Combo fDlist;
Button stopInMain;
// Dynamic Debugger UI widgets
protected ILaunchConfigurationTab fDynamicTab;
@ -42,13 +45,11 @@ public class CDebuggerTab extends CLaunchConfigurationTab {
protected ILaunchConfigurationWorkingCopy fWorkingCopy;
protected ILaunchConfiguration fLaunchConfiguration;
public void createControl(Composite parent) {
Composite comp= new Composite(parent, SWT.NONE);
setControl(comp);
GridLayout topLayout = new GridLayout(2, false);
GridLayout topLayout = new GridLayout(3, false);
comp.setLayout(topLayout);
Label dlabel = new Label(comp, SWT.NONE);
dlabel.setText("Debugger:");
@ -58,9 +59,15 @@ public class CDebuggerTab extends CLaunchConfigurationTab {
handleDebuggerComboBoxModified();
}
});
stopInMain = new Button(comp, SWT.CHECK);
stopInMain.setText("Stop at main() on startup.");
GridData gd = new GridData();
gd.grabExcessHorizontalSpace = true;
gd.horizontalAlignment = GridData.HORIZONTAL_ALIGN_END;
stopInMain.setLayoutData(gd);
Group debuggerGroup = new Group(comp, SWT.SHADOW_ETCHED_IN);
GridData gd = new GridData(GridData.FILL_BOTH);
gd.horizontalSpan = 2;
gd = new GridData(GridData.FILL_BOTH);
gd.horizontalSpan = 3;
debuggerGroup.setLayoutData(gd);
debuggerGroup.setText("Debugger Options");
setDynamicTabHolder(new Composite(debuggerGroup, SWT.NONE));
@ -71,7 +78,6 @@ public class CDebuggerTab extends CLaunchConfigurationTab {
getDynamicTabHolder().setLayout(tabHolderLayout);
gd = new GridData(GridData.FILL_BOTH);
getDynamicTabHolder().setLayoutData(gd);
}
protected void setDynamicTabHolder(Composite tabHolder) {
@ -100,7 +106,7 @@ public class CDebuggerTab extends CLaunchConfigurationTab {
// always set the newly created area with defaults
ILaunchConfigurationWorkingCopy wc = getLaunchConfigurationWorkingCopy();
if (getDynamicTab() == null) {
// remove any VM specfic args from the config
// remove any debug specfic args from the config
if (wc == null) {
if (getLaunchConfiguration().isWorkingCopy()) {
wc = (ILaunchConfigurationWorkingCopy)getLaunchConfiguration();
@ -130,28 +136,37 @@ public class CDebuggerTab extends CLaunchConfigurationTab {
}
protected void loadDebuggerComboBox(ILaunchConfiguration config) {
ICDebuggerInfo[] debuggerInfo = null;
if ( fDinfo != null ) {
fDinfo.clear();
}
fDlist.removeAll();
ICDebugConfiguration[] debugConfigs;
String platform;
try {
debuggerInfo = CDebugCorePlugin.getDefault().getDebuggerManager().queryDebuggers(getPlatform(config));
platform = getPlatform(config);
}
catch (CoreException e) {
return;
}
fDinfo = new ArrayList(debuggerInfo.length);
for( int i = 0; i < debuggerInfo.length; i++ ) {
fDinfo.add(debuggerInfo[i]);
fDlist.add(debuggerInfo[i].getName());
if ( fDinfo != null ) {
fDinfo.clear();
}
fDlist.removeAll();
debugConfigs = CDebugCorePlugin.getDefault().getDebugConfigurations();
fDinfo = new ArrayList(debugConfigs.length);
for( int i = 0; i < debugConfigs.length; i++ ) {
String supported[] = debugConfigs[i].getPlatforms();
for( int j = 0; j < supported.length; j++ ) {
if (supported[j].equals("*") || supported[j].equalsIgnoreCase(platform)) {
fDinfo.add(debugConfigs[i]);
fDlist.add(debugConfigs[i].getName());
break;
}
}
}
fDlist.getParent().layout();
}
protected void setSelection(String id) {
for (int i = 0; i < fDinfo.size(); i++ ) {
ICDebuggerInfo dinfo = (ICDebuggerInfo) fDinfo.get(i);
if ( dinfo != null && dinfo.getID().equals(id) ) {
ICDebugConfiguration debugConfig = (ICDebugConfiguration) fDinfo.get(i);
if ( debugConfig != null && debugConfig.getID().equals(id) ) {
fDlist.select(i);
return;
}
@ -162,16 +177,17 @@ public class CDebuggerTab extends CLaunchConfigurationTab {
setLaunchConfigurationWorkingCopy(config);
loadDebuggerComboBox(config);
if ( fDinfo.size() > 0 ) {
ICDebuggerInfo info = (ICDebuggerInfo) fDinfo.get(0);
if ( info != null ) {
setSelection(info.getID());
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_CDT_DEBUGGER_ID, info.getID());
ICDebugConfiguration dbgCfg = (ICDebugConfiguration) fDinfo.get(0);
if ( dbgCfg != null ) {
setSelection(dbgCfg.getID());
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID, dbgCfg.getID());
}
}
ILaunchConfigurationTab dynamicTab = getDynamicTab();
if (dynamicTab != null) {
dynamicTab.setDefaults(config);
}
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, false);
}
public void initializeFrom(ILaunchConfiguration config) {
@ -179,29 +195,32 @@ public class CDebuggerTab extends CLaunchConfigurationTab {
setLaunchConfiguration(config);
loadDebuggerComboBox(config);
try {
id = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_CDT_DEBUGGER_ID, "");
id = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID, "");
setSelection(id);
ILaunchConfigurationTab dynamicTab = getDynamicTab();
if (dynamicTab != null) {
dynamicTab.initializeFrom(config);
}
if ( config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, false) == true ) {
stopInMain.setSelection(true);
}
}
catch (CoreException e) {
return;
}
setSelection(id);
ILaunchConfigurationTab dynamicTab = getDynamicTab();
if (dynamicTab != null) {
dynamicTab.initializeFrom(config);
}
}
public void performApply(ILaunchConfigurationWorkingCopy config) {
if ( isValid(config) ) {
ICDebuggerInfo dinfo = (ICDebuggerInfo)fDinfo.get(fDlist.getSelectionIndex());
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_CDT_DEBUGGER_ID, dinfo.getID() );
ICDebugConfiguration dbgCfg = (ICDebugConfiguration)fDinfo.get(fDlist.getSelectionIndex());
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID, dbgCfg.getID() );
ILaunchConfigurationTab dynamicTab = getDynamicTab();
if (dynamicTab == null) {
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_SPECIFIC_ATTRS_MAP, (Map)null);
} else {
dynamicTab.performApply(config);
}
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, stopInMain.getSelection());
}
}
@ -223,18 +242,20 @@ public class CDebuggerTab extends CLaunchConfigurationTab {
/**
* Return the class that implements <code>ILaunchConfigurationTab</code>
* that is registered against the install type of the currently selected VM.
* that is registered against the debugger id of the currently selected debugger.
*/
protected ILaunchConfigurationTab getTabForCurrentDebugger() {
int selectedIndex = fDlist.getSelectionIndex();
if (selectedIndex > 0) {
ICDebugConfiguration dbgCfg = (ICDebugConfiguration) fDinfo.get(selectedIndex);
return CDebugUIPlugin.getDefault().getDebuggerPage(dbgCfg.getID());
}
return null;
}
/**
* Show the contributed piece of UI that was registered for the install type
* of the currently selected VM.
* 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
@ -243,7 +264,7 @@ public class CDebuggerTab extends CLaunchConfigurationTab {
children[i].dispose();
}
// Retrieve the dynamic UI for the current JRE
// Retrieve the dynamic UI for the current Debugger
setDynamicTab(getTabForCurrentDebugger());
if (getDynamicTab() == null) {
return;
@ -252,7 +273,8 @@ public class CDebuggerTab extends CLaunchConfigurationTab {
// Ask the dynamic UI to create its Control
getDynamicTab().setLaunchConfigurationDialog(getLaunchConfigurationDialog());
getDynamicTab().createControl(getDynamicTabHolder());
getDynamicTabHolder().layout();
getDynamicTab().getControl().setVisible(true);
getDynamicTabHolder().layout(true);
}
/**