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

[310129] GDB (DSF) Hardware Debugging Launcher ignores startup initialization commands

This commit is contained in:
John Cortell 2010-04-22 22:38:27 +00:00
parent 86490a11d7
commit 1df371b516

View file

@ -69,11 +69,24 @@ import org.eclipse.debug.core.ILaunchConfiguration;
*/
public class GDBJtagDSFFinalLaunchSequence extends Sequence {
Step[] fSteps = new Step[] {
/** utility method; cuts down on clutter */
private void queueCommands(List<String> commands, RequestMonitor rm) {
if (commands.size() > 0) {
fCommandControl.queueCommand(
new CLICommand<MIInfo>(fCommandControl.getContext(), composeCommand(commands)),
new DataRequestMonitor<MIInfo>(getExecutor(), rm));
}
else {
rm.done();
}
}
private Step[] fSteps = new Step[] {
/*
* Create the service tracker for later use
*/
new Step() { @Override
new Step() {
@Override
public void execute(RequestMonitor requestMonitor) {
fTracker = new DsfServicesTracker(Activator.getBundleContext(), fLaunch.getSession().getId());
requestMonitor.done();
@ -87,7 +100,8 @@ public class GDBJtagDSFFinalLaunchSequence extends Sequence {
/*
* Fetch the GDBBackend service for later use
*/
new Step() { @Override
new Step() {
@Override
public void execute(RequestMonitor requestMonitor) {
fGDBBackend = fTracker.getService(IGDBBackend.class);
if (fGDBBackend == null) {
@ -99,7 +113,8 @@ public class GDBJtagDSFFinalLaunchSequence extends Sequence {
/*
* Fetch the control service for later use
*/
new Step() { @Override
new Step() {
@Override
public void execute(RequestMonitor requestMonitor) {
fCommandControl = fTracker.getService(IGDBControl.class);
if (fCommandControl == null) {
@ -113,7 +128,8 @@ public class GDBJtagDSFFinalLaunchSequence extends Sequence {
/*
* Fetch the process service for later use
*/
new Step() { @Override
new Step() {
@Override
public void execute(RequestMonitor requestMonitor) {
fProcService = fTracker.getService(IMIProcesses.class);
if (fProcService == null) {
@ -125,7 +141,8 @@ public class GDBJtagDSFFinalLaunchSequence extends Sequence {
/*
* Source the gdbinit file specified in the launch
*/
new Step() { @Override
new Step() {
@Override
public void execute(final RequestMonitor requestMonitor) {
try {
final String gdbinitFile = fGDBBackend.getGDBInitFile();
@ -157,7 +174,8 @@ public class GDBJtagDSFFinalLaunchSequence extends Sequence {
/*
* Specify the arguments to the executable file
*/
new Step() { @Override
new Step() {
@Override
public void execute(final RequestMonitor requestMonitor) {
try {
String args = fGDBBackend.getProgramArguments();
@ -177,7 +195,8 @@ public class GDBJtagDSFFinalLaunchSequence extends Sequence {
/*
* Specify GDB's working directory
*/
new Step() { @Override
new Step() {
@Override
public void execute(final RequestMonitor requestMonitor) {
IPath dir = null;
try {
@ -199,7 +218,8 @@ public class GDBJtagDSFFinalLaunchSequence extends Sequence {
/*
* Specify environment variables if needed
*/
new Step() { @Override
new Step() {
@Override
public void execute(final RequestMonitor requestMonitor) {
boolean clear = false;
Properties properties = new Properties();
@ -221,7 +241,8 @@ public class GDBJtagDSFFinalLaunchSequence extends Sequence {
/*
* Enable non-stop mode if necessary
*/
new Step() { @Override
new Step() {
@Override
public void execute(final RequestMonitor requestMonitor) {
boolean isNonStop = false;
try {
@ -259,7 +280,7 @@ public class GDBJtagDSFFinalLaunchSequence extends Sequence {
/*
* Tell GDB to automatically load or not the shared library symbols
*/
new Step() { @Override
new Step() {
public void execute(RequestMonitor requestMonitor) {
try {
boolean autolib = fLaunch.getLaunchConfiguration().getAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_AUTO_SOLIB,
@ -275,7 +296,8 @@ public class GDBJtagDSFFinalLaunchSequence extends Sequence {
/*
* Set the shared library paths
*/
new Step() { @Override
new Step() {
@Override
public void execute(final RequestMonitor requestMonitor) {
try {
List<String> p = fGDBBackend.getSharedLibraryPaths();
@ -310,7 +332,8 @@ public class GDBJtagDSFFinalLaunchSequence extends Sequence {
/*
* Setup the source paths
*/
new Step() { @Override
new Step() {
@Override
public void execute(RequestMonitor requestMonitor) {
CSourceLookup sourceLookup = fTracker.getService(CSourceLookup.class);
CSourceLookupDirector locator = (CSourceLookupDirector)fLaunch.getSourceLocator();
@ -325,9 +348,6 @@ public class GDBJtagDSFFinalLaunchSequence extends Sequence {
* Retrieve the JTag device
*/
new Step() {
/* (non-Javadoc)
* @see org.eclipse.cdt.dsf.concurrent.Sequence.Step#execute(org.eclipse.cdt.dsf.concurrent.RequestMonitor)
*/
@Override
public void execute(RequestMonitor rm) {
Exception exception = null;
@ -343,15 +363,11 @@ public class GDBJtagDSFFinalLaunchSequence extends Sequence {
rm.setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, -1, "Cannot get Jtag device", exception)); //$NON-NLS-1$
}
rm.done();
}
},
}},
/*
* Hook up to remote target
*/
new Step() {
/* (non-Javadoc)
* @see org.eclipse.cdt.dsf.concurrent.Sequence.Step#execute(org.eclipse.cdt.dsf.concurrent.RequestMonitor)
*/
@Override
public void execute(RequestMonitor rm) {
ILaunchConfiguration config = fLaunch.getLaunchConfiguration();
@ -359,11 +375,9 @@ public class GDBJtagDSFFinalLaunchSequence extends Sequence {
if (config.getAttribute(IGDBJtagConstants.ATTR_USE_REMOTE_TARGET, IGDBJtagConstants.DEFAULT_USE_REMOTE_TARGET)) {
String ipAddress = config.getAttribute(IGDBJtagConstants.ATTR_IP_ADDRESS, IGDBJtagConstants.DEFAULT_IP_ADDRESS);
int portNumber = config.getAttribute(IGDBJtagConstants.ATTR_PORT_NUMBER, IGDBJtagConstants.DEFAULT_PORT_NUMBER);
ArrayList<String> commands = new ArrayList<String>();
List<String> commands = new ArrayList<String>();
fGdbJtagDevice.doRemote(ipAddress, portNumber, commands);
fCommandControl.queueCommand(
new CLICommand<MIInfo>(fCommandControl.getContext(), composeCommand(commands)),
new DataRequestMonitor<MIInfo>(getExecutor(), rm));
queueCommands(commands, rm);
} else {
rm.done();
}
@ -371,25 +385,19 @@ public class GDBJtagDSFFinalLaunchSequence extends Sequence {
rm.setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, -1, "Cannot connect to remote target", e)); //$NON-NLS-1$
rm.done();
}
}
},
}},
/*
* Run device-specific code to reset the board
*/
new Step() {
/* (non-Javadoc)
* @see org.eclipse.cdt.dsf.concurrent.Sequence.Step#execute(org.eclipse.cdt.dsf.concurrent.RequestMonitor)
*/
@Override
public void execute(RequestMonitor rm) {
ILaunchConfiguration config = fLaunch.getLaunchConfiguration();
try {
if (config.getAttribute(IGDBJtagConstants.ATTR_DO_RESET, true)) {
ArrayList<String> commands = new ArrayList<String>();
List<String> commands = new ArrayList<String>();
fGdbJtagDevice.doReset(commands);
fCommandControl.queueCommand(
new CLICommand<MIInfo>(fCommandControl.getContext(), composeCommand(commands)),
new DataRequestMonitor<MIInfo>(getExecutor(), rm));
queueCommands(commands, rm);
} else {
rm.done();
}
@ -397,48 +405,36 @@ public class GDBJtagDSFFinalLaunchSequence extends Sequence {
rm.setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, -1, "Cannot reset the remote target", e)); //$NON-NLS-1$
rm.done();
}
}
},
}},
/*
* Run device-specific code to delay the startup
*/
new Step() {
/* (non-Javadoc)
* @see org.eclipse.cdt.dsf.concurrent.Sequence.Step#execute(org.eclipse.cdt.dsf.concurrent.RequestMonitor)
*/
@Override
public void execute(RequestMonitor rm) {
ILaunchConfiguration config = fLaunch.getLaunchConfiguration();
int defaultDelay = fGdbJtagDevice.getDefaultDelay();
try {
ArrayList<String> commands = new ArrayList<String>();
List<String> commands = new ArrayList<String>();
fGdbJtagDevice.doDelay(config.getAttribute(IGDBJtagConstants.ATTR_DELAY, defaultDelay), commands);
fCommandControl.queueCommand(
new CLICommand<MIInfo>(fCommandControl.getContext(), composeCommand(commands)),
new DataRequestMonitor<MIInfo>(getExecutor(), rm));
queueCommands(commands, rm);
} catch (CoreException e) {
rm.setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, -1, "Cannot delay the remote target", e)); //$NON-NLS-1$
rm.done();
}
}
},
}},
/*
* Run device-specific code to halt the board
*/
new Step() {
/* (non-Javadoc)
* @see org.eclipse.cdt.dsf.concurrent.Sequence.Step#execute(org.eclipse.cdt.dsf.concurrent.RequestMonitor)
*/
@Override
public void execute(RequestMonitor rm) {
ILaunchConfiguration config = fLaunch.getLaunchConfiguration();
try {
if (config.getAttribute(IGDBJtagConstants.ATTR_DO_HALT, true)) {
ArrayList<String> commands = new ArrayList<String>();
List<String> commands = new ArrayList<String>();
fGdbJtagDevice.doHalt(commands);
fCommandControl.queueCommand(
new CLICommand<MIInfo>(fCommandControl.getContext(), composeCommand(commands)),
new DataRequestMonitor<MIInfo>(getExecutor(), rm));
queueCommands(commands, rm);
} else {
rm.done();
}
@ -446,15 +442,11 @@ public class GDBJtagDSFFinalLaunchSequence extends Sequence {
rm.setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, -1, "Cannot halt the remote target", e)); //$NON-NLS-1$
rm.done();
}
}
},
}},
/*
* Execute any user defined init commands
*/
new Step() {
/* (non-Javadoc)
* @see org.eclipse.cdt.dsf.concurrent.Sequence.Step#execute(org.eclipse.cdt.dsf.concurrent.RequestMonitor)
*/
@Override
public void execute(RequestMonitor rm) {
ILaunchConfiguration config = fLaunch.getLaunchConfiguration();
@ -474,15 +466,11 @@ public class GDBJtagDSFFinalLaunchSequence extends Sequence {
rm.setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, -1, "Cannot run user defined init commands", e)); //$NON-NLS-1$
rm.done();
}
}
},
}},
/*
* Execute image loading
*/
new Step() {
/* (non-Javadoc)
* @see org.eclipse.cdt.dsf.concurrent.Sequence.Step#execute(org.eclipse.cdt.dsf.concurrent.RequestMonitor)
*/
@Override
public void execute(RequestMonitor rm) {
ILaunchConfiguration config = fLaunch.getLaunchConfiguration();
@ -493,11 +481,9 @@ public class GDBJtagDSFFinalLaunchSequence extends Sequence {
if (imageFileName.length() > 0) {
imageFileName = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(imageFileName).replace("\\", "\\\\"); //$NON-NLS-1$ //$NON-NLS-2$
String imageOffset = (imageFileName.endsWith(".elf")) ? "" : "0x" + config.getAttribute(IGDBJtagConstants.ATTR_IMAGE_OFFSET, ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ArrayList<String> commands = new ArrayList<String>();
List<String> commands = new ArrayList<String>();
fGdbJtagDevice.doLoadImage(imageFileName, imageOffset, commands);
fCommandControl.queueCommand(
new CLICommand<MIInfo>(fCommandControl.getContext(), composeCommand(commands)),
new DataRequestMonitor<MIInfo>(getExecutor(), rm));
queueCommands(commands, rm);
} else {
rm.setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, -1, "Image name cannot be empty", null)); //$NON-NLS-1$
rm.done();
@ -509,15 +495,11 @@ public class GDBJtagDSFFinalLaunchSequence extends Sequence {
rm.setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, -1, "Cannot load image", e)); //$NON-NLS-1$
rm.done();
}
}
},
}},
/*
* Execute symbol loading
*/
new Step() {
/* (non-Javadoc)
* @see org.eclipse.cdt.dsf.concurrent.Sequence.Step#execute(org.eclipse.cdt.dsf.concurrent.RequestMonitor)
*/
@Override
public void execute(RequestMonitor rm) {
ILaunchConfiguration config = fLaunch.getLaunchConfiguration();
@ -528,11 +510,9 @@ public class GDBJtagDSFFinalLaunchSequence extends Sequence {
if (symbolsFileName.length() > 0) {
symbolsFileName = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(symbolsFileName).replace("\\", "\\\\"); //$NON-NLS-1$ //$NON-NLS-2$
String symbolsOffset = "0x" + config.getAttribute(IGDBJtagConstants.ATTR_SYMBOLS_OFFSET, ""); //$NON-NLS-1$ //$NON-NLS-2$
ArrayList<String> commands = new ArrayList<String>();
List<String> commands = new ArrayList<String>();
fGdbJtagDevice.doLoadSymbol(symbolsFileName, symbolsOffset, commands);
fCommandControl.queueCommand(
new CLICommand<MIInfo>(fCommandControl.getContext(), composeCommand(commands)),
new DataRequestMonitor<MIInfo>(getExecutor(), rm));
queueCommands(commands, rm);
} else {
rm.setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, -1, "Symbol name cannot be empty", null)); //$NON-NLS-1$
rm.done();
@ -549,7 +529,8 @@ public class GDBJtagDSFFinalLaunchSequence extends Sequence {
/*
* Start tracking the breakpoints once we know we are connected to the target (necessary for remote debugging)
*/
new Step() { @Override
new Step() {
@Override
public void execute(final RequestMonitor requestMonitor) {
if (fSessionType != SessionType.CORE) {
MIBreakpointsManager bpmService = fTracker.getService(MIBreakpointsManager.class);
@ -564,20 +545,15 @@ public class GDBJtagDSFFinalLaunchSequence extends Sequence {
* Set the program counter
*/
new Step() {
/* (non-Javadoc)
* @see org.eclipse.cdt.dsf.concurrent.Sequence.Step#execute(org.eclipse.cdt.dsf.concurrent.RequestMonitor)
*/
@Override
public void execute(RequestMonitor rm) {
ILaunchConfiguration config = fLaunch.getLaunchConfiguration();
try {
if (config.getAttribute(IGDBJtagConstants.ATTR_SET_PC_REGISTER, IGDBJtagConstants.DEFAULT_SET_PC_REGISTER)) {
String pcRegister = config.getAttribute(IGDBJtagConstants.ATTR_PC_REGISTER, config.getAttribute(IGDBJtagConstants.ATTR_IMAGE_OFFSET, "")); //$NON-NLS-1$
ArrayList<String> commands = new ArrayList<String>();
List<String> commands = new ArrayList<String>();
fGdbJtagDevice.doSetPC(pcRegister, commands);
fCommandControl.queueCommand(
new CLICommand<MIInfo>(fCommandControl.getContext(), composeCommand(commands)),
new DataRequestMonitor<MIInfo>(getExecutor(), rm));
queueCommands(commands, rm);
} else {
rm.done();
}
@ -585,26 +561,20 @@ public class GDBJtagDSFFinalLaunchSequence extends Sequence {
rm.setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, -1, "Cannot set program counter", e)); //$NON-NLS-1$
rm.done();
}
}
},
}},
/*
* Execute the stop script
*/
new Step() {
/* (non-Javadoc)
* @see org.eclipse.cdt.dsf.concurrent.Sequence.Step#execute(org.eclipse.cdt.dsf.concurrent.RequestMonitor)
*/
@Override
public void execute(RequestMonitor rm) {
ILaunchConfiguration config = fLaunch.getLaunchConfiguration();
try {
if (config.getAttribute(IGDBJtagConstants.ATTR_SET_STOP_AT, IGDBJtagConstants.DEFAULT_SET_STOP_AT)) {
String stopAt = config.getAttribute(IGDBJtagConstants.ATTR_STOP_AT, ""); //$NON-NLS-1$
ArrayList<String> commands = new ArrayList<String>();
List<String> commands = new ArrayList<String>();
fGdbJtagDevice.doStopAt(stopAt, commands);
fCommandControl.queueCommand(
new CLICommand<MIInfo>(fCommandControl.getContext(), composeCommand(commands)),
new DataRequestMonitor<MIInfo>(getExecutor(), rm));
queueCommands(commands, rm);
} else {
rm.done();
}
@ -618,19 +588,14 @@ public class GDBJtagDSFFinalLaunchSequence extends Sequence {
* Execute the resume script
*/
new Step() {
/* (non-Javadoc)
* @see org.eclipse.cdt.dsf.concurrent.Sequence.Step#execute(org.eclipse.cdt.dsf.concurrent.RequestMonitor)
*/
@Override
public void execute(RequestMonitor rm) {
ILaunchConfiguration config = fLaunch.getLaunchConfiguration();
try {
if (config.getAttribute(IGDBJtagConstants.ATTR_SET_RESUME, IGDBJtagConstants.DEFAULT_SET_RESUME)) {
ArrayList<String> commands = new ArrayList<String>();
List<String> commands = new ArrayList<String>();
fGdbJtagDevice.doContinue(commands);
fCommandControl.queueCommand(
new CLICommand<MIInfo>(fCommandControl.getContext(), composeCommand(commands)),
new DataRequestMonitor<MIInfo>(getExecutor(), rm));
queueCommands(commands, rm);
} else {
rm.done();
}
@ -638,15 +603,11 @@ public class GDBJtagDSFFinalLaunchSequence extends Sequence {
rm.setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, -1, "Cannot resume the remote target", e)); //$NON-NLS-1$
rm.done();
}
}
},
}},
/*
* Run any user defined commands to start debugging
*/
new Step() {
/* (non-Javadoc)
* @see org.eclipse.cdt.dsf.concurrent.Sequence.Step#execute(org.eclipse.cdt.dsf.concurrent.RequestMonitor)
*/
@Override
public void execute(RequestMonitor rm) {
ILaunchConfiguration config = fLaunch.getLaunchConfiguration();
@ -666,8 +627,7 @@ public class GDBJtagDSFFinalLaunchSequence extends Sequence {
rm.setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, -1, "Cannot run user defined run commands", e)); //$NON-NLS-1$
rm.done();
}
}
},
}},
/*
* Indicate that the Data Model has been filled. This will trigger the Debug view to expand.
@ -678,8 +638,7 @@ public class GDBJtagDSFFinalLaunchSequence extends Sequence {
fLaunch.getSession().dispatchEvent(new DataModelInitializedEvent(fCommandControl.getContext()),
fCommandControl.getProperties());
requestMonitor.done();
}
},
}},
/*
* Cleanup
*/
@ -689,8 +648,7 @@ public class GDBJtagDSFFinalLaunchSequence extends Sequence {
fTracker.dispose();
fTracker = null;
requestMonitor.done();
}
},
}},
};
GdbLaunch fLaunch;