mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
First GDB JTAG session running.
This commit is contained in:
parent
9b08755795
commit
28af2813bf
7 changed files with 164 additions and 106 deletions
|
@ -58,6 +58,11 @@ public class MISession extends Observable {
|
|||
*/
|
||||
public final static int CORE = 2;
|
||||
|
||||
/**
|
||||
* Timeout value for a very long time.
|
||||
*/
|
||||
public final static int FOREVER = Integer.MAX_VALUE;
|
||||
|
||||
boolean terminated;
|
||||
boolean useInterpreterExecConsole;
|
||||
boolean verboseMode = false;
|
||||
|
|
|
@ -10,6 +10,7 @@ Require-Bundle: org.eclipse.core.runtime,
|
|||
org.eclipse.cdt.launch,
|
||||
org.eclipse.cdt.debug.core,
|
||||
org.eclipse.cdt.debug.mi.core,
|
||||
org.eclipse.cdt.core
|
||||
org.eclipse.cdt.core,
|
||||
org.eclipse.core.variables
|
||||
Eclipse-LazyStart: true
|
||||
Export-Package: org.eclipse.cdt.debug.gdbjtag.core
|
||||
|
|
|
@ -14,6 +14,8 @@ package org.eclipse.cdt.debug.gdbjtag.core;
|
|||
import java.io.File;
|
||||
|
||||
import org.eclipse.cdt.core.IBinaryParser.IBinaryObject;
|
||||
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
|
||||
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
|
||||
import org.eclipse.cdt.debug.core.cdi.ICDISession;
|
||||
import org.eclipse.cdt.debug.core.cdi.model.ICDITarget;
|
||||
import org.eclipse.cdt.debug.mi.core.AbstractGDBCDIDebugger;
|
||||
|
@ -22,11 +24,18 @@ import org.eclipse.cdt.debug.mi.core.MIPlugin;
|
|||
import org.eclipse.cdt.debug.mi.core.MISession;
|
||||
import org.eclipse.cdt.debug.mi.core.cdi.Session;
|
||||
import org.eclipse.cdt.debug.mi.core.cdi.model.Target;
|
||||
import org.eclipse.cdt.debug.mi.core.command.CLICommand;
|
||||
import org.eclipse.cdt.debug.mi.core.command.CommandFactory;
|
||||
import org.eclipse.cdt.debug.mi.core.command.MIGDBSetNewConsole;
|
||||
import org.eclipse.cdt.debug.mi.core.command.MITargetDownload;
|
||||
import org.eclipse.cdt.debug.mi.core.command.MITargetSelect;
|
||||
import org.eclipse.cdt.debug.mi.core.output.MIInfo;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.MultiStatus;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.core.variables.VariablesPlugin;
|
||||
import org.eclipse.debug.core.ILaunch;
|
||||
import org.eclipse.debug.core.ILaunchConfiguration;
|
||||
|
||||
|
@ -58,14 +67,14 @@ public class GDBJtagDebugger extends AbstractGDBCDIDebugger {
|
|||
if (targets.length == 0 || !(targets[0] instanceof Target))
|
||||
return ; // TODO should raise an exception
|
||||
MISession miSession = ((Target)targets[0]).getMISession();
|
||||
getMISession( session );
|
||||
getMISession(session);
|
||||
CommandFactory factory = miSession.getCommandFactory();
|
||||
try {
|
||||
MIGDBSetNewConsole newConsole = factory.createMIGDBSetNewConsole();
|
||||
miSession.postCommand( newConsole );
|
||||
miSession.postCommand(newConsole);
|
||||
MIInfo info = newConsole.getMIInfo();
|
||||
if ( info == null ) {
|
||||
throw new MIException( MIPlugin.getResourceString( "src.common.No_answer" ) ); //$NON-NLS-1$
|
||||
if (info == null) {
|
||||
throw new MIException(MIPlugin.getResourceString("src.common.No_answer")); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
catch( MIException e ) {
|
||||
|
@ -73,9 +82,48 @@ public class GDBJtagDebugger extends AbstractGDBCDIDebugger {
|
|||
// on GNU/Linux the new-console is an error.
|
||||
}
|
||||
|
||||
// TODO execute init script
|
||||
// hook up to remote target
|
||||
boolean useRemote = config.getAttribute(IGDBJtagConstants.ATTR_USE_REMOTE_TARGET, IGDBJtagConstants.DEFAULT_USE_REMOTE_TARGET);
|
||||
if (useRemote) {
|
||||
try {
|
||||
monitor.beginTask("Connecting to remote", 1);
|
||||
String ipAddress = config.getAttribute(IGDBJtagConstants.ATTR_IP_ADDRESS, IGDBJtagConstants.DEFAULT_IP_ADDRESS);
|
||||
int portNumber = config.getAttribute(IGDBJtagConstants.ATTR_PORT_NUMBER, IGDBJtagConstants.DEFAULT_PORT_NUMBER);
|
||||
String address = ipAddress + ":" + String.valueOf(portNumber);
|
||||
MITargetSelect targetSelect = factory.createMITargetSelect(new String[] { "remote", address });
|
||||
miSession.postCommand(targetSelect);
|
||||
MIInfo info = targetSelect.getMIInfo();
|
||||
if (info == null) {
|
||||
throw new MIException(MIPlugin.getResourceString("src.common.No_answer")); //$NON-NLS-1$
|
||||
}
|
||||
} catch (MIException e) {
|
||||
// TODO dunno...
|
||||
}
|
||||
}
|
||||
|
||||
// execute init script
|
||||
monitor.beginTask("Executing init commands", 1);
|
||||
executeGDBScript(config, IGDBJtagConstants.ATTR_INIT_COMMANDS, miSession);
|
||||
|
||||
// TODO execute load
|
||||
// execute load
|
||||
boolean doLoad = config.getAttribute(IGDBJtagConstants.ATTR_LOAD_IMAGE, IGDBJtagConstants.DEFAULT_LOAD_IMAGE);
|
||||
if (doLoad) {
|
||||
String imageFileName = config.getAttribute(IGDBJtagConstants.ATTR_IMAGE_FILE_NAME, "");
|
||||
if (imageFileName.length() > 0) {
|
||||
try {
|
||||
monitor.beginTask("Loading image", 1);
|
||||
imageFileName = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(imageFileName);
|
||||
MITargetDownload download = factory.createMITargetDownload(imageFileName);
|
||||
miSession.postCommand(download, MISession.FOREVER);
|
||||
MIInfo info = download.getMIInfo();
|
||||
if (info == null) {
|
||||
throw new MIException(MIPlugin.getResourceString("src.common.No_answer")); //$NON-NLS-1$
|
||||
}
|
||||
} catch (MIException e) {
|
||||
// TODO dunno...
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected MISession getMISession(Session session) {
|
||||
|
@ -85,15 +133,47 @@ public class GDBJtagDebugger extends AbstractGDBCDIDebugger {
|
|||
return ((Target)targets[0]).getMISession();
|
||||
}
|
||||
|
||||
public void doRunSession(ILaunch launch, ICDISession session, IProgressMonitor monitor) {
|
||||
public void doRunSession(ILaunch launch, ICDISession session, IProgressMonitor monitor) throws CoreException {
|
||||
ILaunchConfiguration config = launch.getLaunchConfiguration();
|
||||
ICDITarget[] targets = session.getTargets();
|
||||
if ( targets.length == 0 || !(targets[0] instanceof Target) )
|
||||
return;
|
||||
MISession miSession = ((Target)targets[0]).getMISession();
|
||||
CommandFactory factory = miSession.getCommandFactory();
|
||||
|
||||
// TODO execute run script
|
||||
// execute run script
|
||||
monitor.beginTask("Executing run commands", 1);
|
||||
executeGDBScript(config, IGDBJtagConstants.ATTR_RUN_COMMANDS, miSession);
|
||||
}
|
||||
|
||||
private void executeGDBScript(ILaunchConfiguration configuration, String attribute,
|
||||
MISession miSession) throws CoreException {
|
||||
// Try to execute any extrac comand
|
||||
String script = configuration.getAttribute(attribute, ""); //$NON-NLS-1$
|
||||
script = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(script);
|
||||
String[] commands = script.split("\\r?\\n");
|
||||
for (int j = 0; j < commands.length; ++j) {
|
||||
try {
|
||||
CLICommand cli = new CLICommand(commands[j]);
|
||||
miSession.postCommand(cli, MISession.FOREVER);
|
||||
MIInfo info = cli.getMIInfo();
|
||||
if (info == null) {
|
||||
throw new MIException("Timeout"); //$NON-NLS-1$
|
||||
}
|
||||
} catch (MIException e) {
|
||||
MultiStatus status = new MultiStatus(
|
||||
Activator.PLUGIN_ID,
|
||||
ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR,
|
||||
"Failed command", e);
|
||||
status
|
||||
.add(new Status(
|
||||
IStatus.ERROR,
|
||||
Activator.PLUGIN_ID,
|
||||
ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR,
|
||||
e == null ? "" : e.getLocalizedMessage(), //$NON-NLS-1$
|
||||
e));
|
||||
CDebugCorePlugin.log(status);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ import org.eclipse.cdt.launch.AbstractCLaunchDelegate;
|
|||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.SubMonitor;
|
||||
import org.eclipse.debug.core.DebugPlugin;
|
||||
import org.eclipse.debug.core.ILaunch;
|
||||
import org.eclipse.debug.core.ILaunchConfiguration;
|
||||
|
@ -41,56 +42,48 @@ public class GDBJtagLaunchConfigurationDelegate extends AbstractCLaunchDelegate
|
|||
|
||||
public void launch(ILaunchConfiguration configuration, String mode,
|
||||
ILaunch launch, IProgressMonitor monitor) throws CoreException {
|
||||
try {
|
||||
// set the default source locator if required
|
||||
setDefaultSourceLocator(launch, configuration);
|
||||
SubMonitor submonitor = SubMonitor.convert(monitor, 2);
|
||||
// set the default source locator if required
|
||||
setDefaultSourceLocator(launch, configuration);
|
||||
|
||||
if (mode.equals(ILaunchManager.DEBUG_MODE)) {
|
||||
GDBJtagDebugger debugger = new GDBJtagDebugger();
|
||||
ICProject project = verifyCProject(configuration);
|
||||
IPath exePath = verifyProgramPath(configuration);
|
||||
File exeFile = exePath != null ? exePath.toFile() : null;
|
||||
ICDISession session = debugger.createSession(launch, exeFile, monitor);
|
||||
IBinaryObject exeBinary = null;
|
||||
if ( exePath != null ) {
|
||||
exeBinary = verifyBinary(project, exePath);
|
||||
}
|
||||
boolean defaultRun = configuration.getAttribute(GDBJtagConstants.ATTR_USE_DEFAULT_RUN, GDBJtagConstants.DEFAULT_USE_DEFAULT_RUN);
|
||||
|
||||
try {
|
||||
monitor.worked(1);
|
||||
|
||||
// create the Launch targets/processes for eclipse.
|
||||
ICDITarget[] targets = session.getTargets();
|
||||
for( int i = 0; i < targets.length; i++ ) {
|
||||
Process process = targets[i].getProcess();
|
||||
IProcess iprocess = null;
|
||||
if ( process != null ) {
|
||||
iprocess = DebugPlugin.newProcess(launch, process, renderProcessLabel(exePath.toOSString()),
|
||||
getDefaultProcessMap() );
|
||||
}
|
||||
CDIDebugModel.newDebugTarget(launch, project.getProject(), targets[i],
|
||||
renderProcessLabel("GDB Hardware Debugger"), iprocess, exeBinary, true, false, defaultRun);
|
||||
}
|
||||
|
||||
if (!defaultRun)
|
||||
debugger.doRunSession(launch, session, monitor);
|
||||
} catch (CoreException e) {
|
||||
try {
|
||||
session.terminate();
|
||||
} catch (CDIException e1) {
|
||||
// ignore
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
} else {
|
||||
cancel("TargetConfiguration not supported",
|
||||
ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR);
|
||||
if (mode.equals(ILaunchManager.DEBUG_MODE)) {
|
||||
GDBJtagDebugger debugger = new GDBJtagDebugger();
|
||||
ICProject project = verifyCProject(configuration);
|
||||
IPath exePath = verifyProgramPath(configuration);
|
||||
File exeFile = exePath != null ? exePath.toFile() : null;
|
||||
ICDISession session = debugger.createSession(launch, exeFile, submonitor.newChild(1));
|
||||
IBinaryObject exeBinary = null;
|
||||
if ( exePath != null ) {
|
||||
exeBinary = verifyBinary(project, exePath);
|
||||
}
|
||||
} finally {
|
||||
monitor.done();
|
||||
|
||||
try {
|
||||
// create the Launch targets/processes for eclipse.
|
||||
ICDITarget[] targets = session.getTargets();
|
||||
for( int i = 0; i < targets.length; i++ ) {
|
||||
Process process = targets[i].getProcess();
|
||||
IProcess iprocess = null;
|
||||
if ( process != null ) {
|
||||
iprocess = DebugPlugin.newProcess(launch, process, renderProcessLabel(exePath.toOSString()),
|
||||
getDefaultProcessMap() );
|
||||
}
|
||||
CDIDebugModel.newDebugTarget(launch, project.getProject(), targets[i],
|
||||
renderProcessLabel("GDB Hardware Debugger"), iprocess, exeBinary, true, false, false);
|
||||
}
|
||||
|
||||
debugger.doRunSession(launch, session, submonitor.newChild(1));
|
||||
} catch (CoreException e) {
|
||||
try {
|
||||
session.terminate();
|
||||
} catch (CDIException e1) {
|
||||
// ignore
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
} else {
|
||||
cancel("TargetConfiguration not supported",
|
||||
ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ package org.eclipse.cdt.debug.gdbjtag.core;
|
|||
* @author Doug Schaefer
|
||||
*
|
||||
*/
|
||||
public class GDBJtagConstants {
|
||||
public interface IGDBJtagConstants {
|
||||
|
||||
public static final String DEBUGGER_ID = "org.eclipse.cdt.debug.mi.core.CDebuggerNew"; //$NON-NLS-1$
|
||||
|
||||
|
@ -32,7 +32,6 @@ public class GDBJtagConstants {
|
|||
public static final String ATTR_INIT_COMMANDS = Activator.PLUGIN_ID + ".initCommands"; //$NON-NLS-1$
|
||||
public static final String ATTR_LOAD_IMAGE = Activator.PLUGIN_ID + ".loadImage"; //$NON-NLS-1$
|
||||
public static final String ATTR_IMAGE_FILE_NAME = Activator.PLUGIN_ID + ".imageFileName"; //$NON-NLS-1$
|
||||
public static final String ATTR_USE_DEFAULT_RUN = Activator.PLUGIN_ID + ".useDefaultRun"; //$NON-NLS-1$
|
||||
public static final String ATTR_RUN_COMMANDS = Activator.PLUGIN_ID + ".runCommands"; //$NON-NLS-1$
|
||||
|
||||
public static final boolean DEFAULT_LOAD_IMAGE = false;
|
|
@ -13,7 +13,7 @@ package org.eclipse.cdt.debug.gdbjtag.ui;
|
|||
|
||||
import java.io.File;
|
||||
|
||||
import org.eclipse.cdt.debug.gdbjtag.core.GDBJtagConstants;
|
||||
import org.eclipse.cdt.debug.gdbjtag.core.IGDBJtagConstants;
|
||||
import org.eclipse.cdt.debug.mi.core.IMILaunchConfigurationConstants;
|
||||
import org.eclipse.cdt.debug.mi.core.MIPlugin;
|
||||
import org.eclipse.cdt.debug.mi.core.command.factories.CommandFactoryDescriptor;
|
||||
|
@ -205,7 +205,7 @@ public class GDBJtagDebuggerTab extends AbstractLaunchConfigurationTab {
|
|||
|
||||
// Get the command sets
|
||||
CommandFactoryManager cfManager = MIPlugin.getDefault().getCommandFactoryManager();
|
||||
cfDescs = cfManager.getDescriptors(GDBJtagConstants.DEBUGGER_ID);
|
||||
cfDescs = cfManager.getDescriptors(IGDBJtagConstants.DEBUGGER_ID);
|
||||
for (int i = 0; i < cfDescs.length; ++i) {
|
||||
commandFactory.add(cfDescs[i].getName());
|
||||
}
|
||||
|
@ -329,7 +329,7 @@ public class GDBJtagDebuggerTab extends AbstractLaunchConfigurationTab {
|
|||
gdbinitFile.setText(gdbinitFileAttr);
|
||||
|
||||
CommandFactoryManager cfManager = MIPlugin.getDefault().getCommandFactoryManager();
|
||||
CommandFactoryDescriptor defDesc = cfManager.getDefaultDescriptor(GDBJtagConstants.DEBUGGER_ID);
|
||||
CommandFactoryDescriptor defDesc = cfManager.getDefaultDescriptor(IGDBJtagConstants.DEBUGGER_ID);
|
||||
String commandFactoryAttr = configuration.getAttribute(IMILaunchConfigurationConstants.ATTR_DEBUGGER_COMMAND_FACTORY, defDesc.getName());
|
||||
int cfid = 0;
|
||||
for (int i = 0; i < cfDescs.length; ++i)
|
||||
|
@ -349,14 +349,14 @@ public class GDBJtagDebuggerTab extends AbstractLaunchConfigurationTab {
|
|||
boolean verboseModeAttr = configuration.getAttribute(IMILaunchConfigurationConstants.ATTR_DEBUGGER_VERBOSE_MODE, IMILaunchConfigurationConstants.DEBUGGER_VERBOSE_MODE_DEFAULT);
|
||||
verboseMode.setSelection(verboseModeAttr);
|
||||
|
||||
boolean useRemoteAttr = configuration.getAttribute(GDBJtagConstants.ATTR_USE_REMOTE_TARGET, GDBJtagConstants.DEFAULT_USE_REMOTE_TARGET);
|
||||
boolean useRemoteAttr = configuration.getAttribute(IGDBJtagConstants.ATTR_USE_REMOTE_TARGET, IGDBJtagConstants.DEFAULT_USE_REMOTE_TARGET);
|
||||
useRemote.setSelection(useRemoteAttr);
|
||||
useRemoteChanged();
|
||||
|
||||
String ipAddressAttr = configuration.getAttribute(GDBJtagConstants.ATTR_IP_ADDRESS, GDBJtagConstants.DEFAULT_IP_ADDRESS);
|
||||
String ipAddressAttr = configuration.getAttribute(IGDBJtagConstants.ATTR_IP_ADDRESS, IGDBJtagConstants.DEFAULT_IP_ADDRESS);
|
||||
ipAddress.setText(ipAddressAttr);
|
||||
|
||||
int portNumberAttr = configuration.getAttribute(GDBJtagConstants.ATTR_PORT_NUMBER, GDBJtagConstants.DEFAULT_PORT_NUMBER);
|
||||
int portNumberAttr = configuration.getAttribute(IGDBJtagConstants.ATTR_PORT_NUMBER, IGDBJtagConstants.DEFAULT_PORT_NUMBER);
|
||||
portNumber.setText(String.valueOf(portNumberAttr));
|
||||
} catch (CoreException e) {
|
||||
Activator.getDefault().getLog().log(e.getStatus());
|
||||
|
@ -372,12 +372,12 @@ public class GDBJtagDebuggerTab extends AbstractLaunchConfigurationTab {
|
|||
|
||||
configuration.setAttribute(IMILaunchConfigurationConstants.ATTR_DEBUGGER_VERBOSE_MODE, verboseMode.getSelection());
|
||||
|
||||
configuration.setAttribute(GDBJtagConstants.ATTR_USE_REMOTE_TARGET, useRemote.getSelection());
|
||||
configuration.setAttribute(GDBJtagConstants.ATTR_IP_ADDRESS, ipAddress.getText().trim());
|
||||
configuration.setAttribute(IGDBJtagConstants.ATTR_USE_REMOTE_TARGET, useRemote.getSelection());
|
||||
configuration.setAttribute(IGDBJtagConstants.ATTR_IP_ADDRESS, ipAddress.getText().trim());
|
||||
try {
|
||||
configuration.setAttribute(GDBJtagConstants.ATTR_PORT_NUMBER, Integer.parseInt(portNumber.getText().trim()));
|
||||
configuration.setAttribute(IGDBJtagConstants.ATTR_PORT_NUMBER, Integer.parseInt(portNumber.getText().trim()));
|
||||
} catch (NumberFormatException e) {
|
||||
configuration.setAttribute(GDBJtagConstants.ATTR_PORT_NUMBER, 0);
|
||||
configuration.setAttribute(IGDBJtagConstants.ATTR_PORT_NUMBER, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -386,15 +386,15 @@ public class GDBJtagDebuggerTab extends AbstractLaunchConfigurationTab {
|
|||
configuration.setAttribute(IMILaunchConfigurationConstants.ATTR_GDB_INIT, IMILaunchConfigurationConstants.DEBUGGER_GDB_INIT_DEFAULT);
|
||||
|
||||
CommandFactoryManager cfManager = MIPlugin.getDefault().getCommandFactoryManager();
|
||||
CommandFactoryDescriptor defDesc = cfManager.getDefaultDescriptor(GDBJtagConstants.DEBUGGER_ID);
|
||||
CommandFactoryDescriptor defDesc = cfManager.getDefaultDescriptor(IGDBJtagConstants.DEBUGGER_ID);
|
||||
configuration.setAttribute(IMILaunchConfigurationConstants.ATTR_DEBUGGER_COMMAND_FACTORY, defDesc.getName());
|
||||
configuration.setAttribute(IMILaunchConfigurationConstants.ATTR_DEBUGGER_PROTOCOL, defDesc.getMIVersions()[0]);
|
||||
|
||||
configuration.setAttribute(IMILaunchConfigurationConstants.ATTR_DEBUGGER_VERBOSE_MODE, IMILaunchConfigurationConstants.DEBUGGER_VERBOSE_MODE_DEFAULT);
|
||||
|
||||
configuration.setAttribute(GDBJtagConstants.ATTR_USE_REMOTE_TARGET, GDBJtagConstants.DEFAULT_USE_REMOTE_TARGET);
|
||||
configuration.setAttribute(GDBJtagConstants.ATTR_IP_ADDRESS, GDBJtagConstants.DEFAULT_IP_ADDRESS);
|
||||
configuration.setAttribute(GDBJtagConstants.ATTR_PORT_NUMBER, GDBJtagConstants.DEFAULT_PORT_NUMBER);
|
||||
configuration.setAttribute(IGDBJtagConstants.ATTR_USE_REMOTE_TARGET, IGDBJtagConstants.DEFAULT_USE_REMOTE_TARGET);
|
||||
configuration.setAttribute(IGDBJtagConstants.ATTR_IP_ADDRESS, IGDBJtagConstants.DEFAULT_IP_ADDRESS);
|
||||
configuration.setAttribute(IGDBJtagConstants.ATTR_PORT_NUMBER, IGDBJtagConstants.DEFAULT_PORT_NUMBER);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ package org.eclipse.cdt.debug.gdbjtag.ui;
|
|||
|
||||
import java.io.File;
|
||||
|
||||
import org.eclipse.cdt.debug.gdbjtag.core.GDBJtagConstants;
|
||||
import org.eclipse.cdt.debug.gdbjtag.core.IGDBJtagConstants;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.debug.core.ILaunchConfiguration;
|
||||
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
|
||||
|
@ -46,7 +46,6 @@ public class GDBJtagStartupTab extends AbstractLaunchConfigurationTab {
|
|||
Text imageFileName;
|
||||
Button imageFileBrowse;
|
||||
Button imageFileVariables;
|
||||
Button defaultRun;
|
||||
Text runCommands;
|
||||
Button runCommandVariables;
|
||||
|
||||
|
@ -192,15 +191,6 @@ public class GDBJtagStartupTab extends AbstractLaunchConfigurationTab {
|
|||
group.setLayoutData(gd);
|
||||
group.setText("Run Commands");
|
||||
|
||||
defaultRun = new Button(group, SWT.CHECK);
|
||||
defaultRun.setText("Use default run command");
|
||||
defaultRun.addSelectionListener(new SelectionAdapter() {
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
defaultRunChanged();
|
||||
updateLaunchConfigurationDialog();
|
||||
}
|
||||
});
|
||||
|
||||
runCommands = new Text(group, SWT.MULTI | SWT.WRAP | SWT.BORDER | SWT.V_SCROLL);
|
||||
gd = new GridData(GridData.FILL_BOTH);
|
||||
gd.heightHint = 100;
|
||||
|
@ -222,40 +212,30 @@ public class GDBJtagStartupTab extends AbstractLaunchConfigurationTab {
|
|||
});
|
||||
}
|
||||
|
||||
private void defaultRunChanged() {
|
||||
boolean enabled = !defaultRun.getSelection();
|
||||
runCommands.setEnabled(enabled);
|
||||
runCommandVariables.setEnabled(enabled);
|
||||
}
|
||||
|
||||
public void initializeFrom(ILaunchConfiguration configuration) {
|
||||
try {
|
||||
initCommands.setText(configuration.getAttribute(GDBJtagConstants.ATTR_INIT_COMMANDS, "")); //$NON-NLS-1$
|
||||
loadImage.setSelection(configuration.getAttribute(GDBJtagConstants.ATTR_LOAD_IMAGE, GDBJtagConstants.DEFAULT_LOAD_IMAGE));
|
||||
initCommands.setText(configuration.getAttribute(IGDBJtagConstants.ATTR_INIT_COMMANDS, "")); //$NON-NLS-1$
|
||||
loadImage.setSelection(configuration.getAttribute(IGDBJtagConstants.ATTR_LOAD_IMAGE, IGDBJtagConstants.DEFAULT_LOAD_IMAGE));
|
||||
loadImageChanged();
|
||||
imageFileName.setText(configuration.getAttribute(GDBJtagConstants.ATTR_IMAGE_FILE_NAME, "")); //$NON-NLS-1$
|
||||
defaultRun.setSelection(configuration.getAttribute(GDBJtagConstants.ATTR_USE_DEFAULT_RUN, GDBJtagConstants.DEFAULT_USE_DEFAULT_RUN));
|
||||
defaultRunChanged();
|
||||
runCommands.setText(configuration.getAttribute(GDBJtagConstants.ATTR_RUN_COMMANDS, "")); //$NON-NLS-1$)
|
||||
imageFileName.setText(configuration.getAttribute(IGDBJtagConstants.ATTR_IMAGE_FILE_NAME, "")); //$NON-NLS-1$
|
||||
runCommands.setText(configuration.getAttribute(IGDBJtagConstants.ATTR_RUN_COMMANDS, "")); //$NON-NLS-1$)
|
||||
} catch (CoreException e) {
|
||||
Activator.getDefault().getLog().log(e.getStatus());
|
||||
}
|
||||
}
|
||||
|
||||
public void performApply(ILaunchConfigurationWorkingCopy configuration) {
|
||||
configuration.setAttribute(GDBJtagConstants.ATTR_INIT_COMMANDS, initCommands.getText());
|
||||
configuration.setAttribute(GDBJtagConstants.ATTR_LOAD_IMAGE, loadImage.getSelection());
|
||||
configuration.setAttribute(GDBJtagConstants.ATTR_IMAGE_FILE_NAME, imageFileName.getText().trim());
|
||||
configuration.setAttribute(GDBJtagConstants.ATTR_USE_DEFAULT_RUN, defaultRun.getSelection());
|
||||
configuration.setAttribute(GDBJtagConstants.ATTR_RUN_COMMANDS, runCommands.getText());
|
||||
configuration.setAttribute(IGDBJtagConstants.ATTR_INIT_COMMANDS, initCommands.getText());
|
||||
configuration.setAttribute(IGDBJtagConstants.ATTR_LOAD_IMAGE, loadImage.getSelection());
|
||||
configuration.setAttribute(IGDBJtagConstants.ATTR_IMAGE_FILE_NAME, imageFileName.getText().trim());
|
||||
configuration.setAttribute(IGDBJtagConstants.ATTR_RUN_COMMANDS, runCommands.getText());
|
||||
}
|
||||
|
||||
public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
|
||||
configuration.setAttribute(GDBJtagConstants.ATTR_INIT_COMMANDS, ""); //$NON-NLS-1$
|
||||
configuration.setAttribute(GDBJtagConstants.ATTR_LOAD_IMAGE, GDBJtagConstants.DEFAULT_LOAD_IMAGE);
|
||||
configuration.setAttribute(GDBJtagConstants.ATTR_IMAGE_FILE_NAME, ""); //$NON-NLS-1$
|
||||
configuration.setAttribute(GDBJtagConstants.ATTR_USE_DEFAULT_RUN, true);
|
||||
configuration.setAttribute(GDBJtagConstants.ATTR_RUN_COMMANDS, ""); //$NON-NLS-1$
|
||||
configuration.setAttribute(IGDBJtagConstants.ATTR_INIT_COMMANDS, ""); //$NON-NLS-1$
|
||||
configuration.setAttribute(IGDBJtagConstants.ATTR_LOAD_IMAGE, IGDBJtagConstants.DEFAULT_LOAD_IMAGE);
|
||||
configuration.setAttribute(IGDBJtagConstants.ATTR_IMAGE_FILE_NAME, ""); //$NON-NLS-1$
|
||||
configuration.setAttribute(IGDBJtagConstants.ATTR_RUN_COMMANDS, ""); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue