diff --git a/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/GDBJtagDSFFinalLaunchSequence.java b/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/GDBJtagDSFFinalLaunchSequence.java index d87b8dff700..1b05c86f69b 100644 --- a/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/GDBJtagDSFFinalLaunchSequence.java +++ b/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/GDBJtagDSFFinalLaunchSequence.java @@ -69,227 +69,249 @@ import org.eclipse.debug.core.ILaunchConfiguration; */ public class GDBJtagDSFFinalLaunchSequence extends Sequence { - Step[] fSteps = new Step[] { - /* - * Create the service tracker for later use - */ - new Step() { @Override - public void execute(RequestMonitor requestMonitor) { - fTracker = new DsfServicesTracker(Activator.getBundleContext(), fLaunch.getSession().getId()); - requestMonitor.done(); - } - @Override - public void rollBack(RequestMonitor requestMonitor) { - if (fTracker != null) fTracker.dispose(); - fTracker = null; - requestMonitor.done(); - }}, - /* - * Fetch the GDBBackend service for later use - */ - new Step() { @Override - public void execute(RequestMonitor requestMonitor) { - fGDBBackend = fTracker.getService(IGDBBackend.class); - if (fGDBBackend == null) { - requestMonitor.setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, -1, "Cannot obtain GDBBackend service", null)); //$NON-NLS-1$ - } + /** utility method; cuts down on clutter */ + private void queueCommands(List commands, RequestMonitor rm) { + if (commands.size() > 0) { + fCommandControl.queueCommand( + new CLICommand(fCommandControl.getContext(), composeCommand(commands)), + new DataRequestMonitor(getExecutor(), rm)); + } + else { + rm.done(); + } + } - requestMonitor.done(); - }}, - /* - * Fetch the control service for later use - */ - new Step() { @Override - public void execute(RequestMonitor requestMonitor) { - fCommandControl = fTracker.getService(IGDBControl.class); - if (fCommandControl == null) { - requestMonitor.setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, -1, "Cannot obtain control service", null)); //$NON-NLS-1$ - } + private Step[] fSteps = new Step[] { + /* + * Create the service tracker for later use + */ + new Step() { + @Override + public void execute(RequestMonitor requestMonitor) { + fTracker = new DsfServicesTracker(Activator.getBundleContext(), fLaunch.getSession().getId()); + requestMonitor.done(); + } + @Override + public void rollBack(RequestMonitor requestMonitor) { + if (fTracker != null) fTracker.dispose(); + fTracker = null; + requestMonitor.done(); + }}, + /* + * Fetch the GDBBackend service for later use + */ + new Step() { + @Override + public void execute(RequestMonitor requestMonitor) { + fGDBBackend = fTracker.getService(IGDBBackend.class); + if (fGDBBackend == null) { + requestMonitor.setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, -1, "Cannot obtain GDBBackend service", null)); //$NON-NLS-1$ + } - fCommandFactory = fCommandControl.getCommandFactory(); - - requestMonitor.done(); - }}, - /* - * Fetch the process service for later use - */ - new Step() { @Override - public void execute(RequestMonitor requestMonitor) { - fProcService = fTracker.getService(IMIProcesses.class); - if (fProcService == null) { - requestMonitor.setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, -1, "Cannot obtain process service", null)); //$NON-NLS-1$ - } + requestMonitor.done(); + }}, + /* + * Fetch the control service for later use + */ + new Step() { + @Override + public void execute(RequestMonitor requestMonitor) { + fCommandControl = fTracker.getService(IGDBControl.class); + if (fCommandControl == null) { + requestMonitor.setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, -1, "Cannot obtain control service", null)); //$NON-NLS-1$ + } - requestMonitor.done(); - }}, - /* - * Source the gdbinit file specified in the launch - */ - new Step() { @Override - public void execute(final RequestMonitor requestMonitor) { - try { - final String gdbinitFile = fGDBBackend.getGDBInitFile(); - - if (gdbinitFile != null && gdbinitFile.length() > 0) { - fCommandControl.queueCommand( - fCommandFactory.createCLISource(fCommandControl.getContext(), gdbinitFile), - new DataRequestMonitor(getExecutor(), requestMonitor) { - @Override - protected void handleCompleted() { - // If the gdbinitFile is the default, then it may not exist and we - // should not consider this an error. - // If it is not the default, then the user must have specified it and - // we want to warn the user if we can't find it. - if (!gdbinitFile.equals(IGDBLaunchConfigurationConstants.DEBUGGER_GDB_INIT_DEFAULT )) { - requestMonitor.setStatus(getStatus()); - } - requestMonitor.done(); - } - }); - } else { - requestMonitor.done(); - } - } catch (CoreException e) { - requestMonitor.setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, -1, "Cannot get gdbinit option", e)); //$NON-NLS-1$ - requestMonitor.done(); - } - }}, - /* - * Specify the arguments to the executable file - */ - new Step() { @Override - public void execute(final RequestMonitor requestMonitor) { - try { - String args = fGDBBackend.getProgramArguments(); - - if (args != null) { - fCommandControl.queueCommand( - fCommandFactory.createMIGDBSetArgs(fCommandControl.getContext(), args), - new DataRequestMonitor(getExecutor(), requestMonitor)); - } else { - requestMonitor.done(); - } - } catch (CoreException e) { - requestMonitor.setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, -1, "Cannot get inferior arguments", e)); //$NON-NLS-1$ - requestMonitor.done(); - } - }}, - /* - * Specify GDB's working directory - */ - new Step() { @Override - public void execute(final RequestMonitor requestMonitor) { - IPath dir = null; - try { - dir = fGDBBackend.getGDBWorkingDirectory(); - } catch (CoreException e) { - requestMonitor.setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, -1, "Cannot get working directory", e)); //$NON-NLS-1$ - requestMonitor.done(); - return; - } + fCommandFactory = fCommandControl.getCommandFactory(); + + requestMonitor.done(); + }}, + /* + * Fetch the process service for later use + */ + new Step() { + @Override + public void execute(RequestMonitor requestMonitor) { + fProcService = fTracker.getService(IMIProcesses.class); + if (fProcService == null) { + requestMonitor.setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, -1, "Cannot obtain process service", null)); //$NON-NLS-1$ + } - if (dir != null) { - fCommandControl.queueCommand( - fCommandFactory.createMIEnvironmentCD(fCommandControl.getContext(), dir.toPortableString()), - new DataRequestMonitor(getExecutor(), requestMonitor)); - } else { - requestMonitor.done(); - } - }}, - /* - * Specify environment variables if needed - */ - new Step() { @Override - public void execute(final RequestMonitor requestMonitor) { - boolean clear = false; - Properties properties = new Properties(); - try { - clear = fGDBBackend.getClearEnvironment(); - properties = fGDBBackend.getEnvironmentVariables(); - } catch (CoreException e) { - requestMonitor.setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, -1, "Cannot get environment information", e)); //$NON-NLS-1$ - requestMonitor.done(); - return; - } + requestMonitor.done(); + }}, + /* + * Source the gdbinit file specified in the launch + */ + new Step() { + @Override + public void execute(final RequestMonitor requestMonitor) { + try { + final String gdbinitFile = fGDBBackend.getGDBInitFile(); + + if (gdbinitFile != null && gdbinitFile.length() > 0) { + fCommandControl.queueCommand( + fCommandFactory.createCLISource(fCommandControl.getContext(), gdbinitFile), + new DataRequestMonitor(getExecutor(), requestMonitor) { + @Override + protected void handleCompleted() { + // If the gdbinitFile is the default, then it may not exist and we + // should not consider this an error. + // If it is not the default, then the user must have specified it and + // we want to warn the user if we can't find it. + if (!gdbinitFile.equals(IGDBLaunchConfigurationConstants.DEBUGGER_GDB_INIT_DEFAULT )) { + requestMonitor.setStatus(getStatus()); + } + requestMonitor.done(); + } + }); + } else { + requestMonitor.done(); + } + } catch (CoreException e) { + requestMonitor.setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, -1, "Cannot get gdbinit option", e)); //$NON-NLS-1$ + requestMonitor.done(); + } + }}, + /* + * Specify the arguments to the executable file + */ + new Step() { + @Override + public void execute(final RequestMonitor requestMonitor) { + try { + String args = fGDBBackend.getProgramArguments(); + + if (args != null) { + fCommandControl.queueCommand( + fCommandFactory.createMIGDBSetArgs(fCommandControl.getContext(), args), + new DataRequestMonitor(getExecutor(), requestMonitor)); + } else { + requestMonitor.done(); + } + } catch (CoreException e) { + requestMonitor.setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, -1, "Cannot get inferior arguments", e)); //$NON-NLS-1$ + requestMonitor.done(); + } + }}, + /* + * Specify GDB's working directory + */ + new Step() { + @Override + public void execute(final RequestMonitor requestMonitor) { + IPath dir = null; + try { + dir = fGDBBackend.getGDBWorkingDirectory(); + } catch (CoreException e) { + requestMonitor.setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, -1, "Cannot get working directory", e)); //$NON-NLS-1$ + requestMonitor.done(); + return; + } - if (clear == true || properties.size() > 0) { - fCommandControl.setEnvironment(properties, clear, requestMonitor); - } else { - requestMonitor.done(); - } - }}, - /* - * Enable non-stop mode if necessary - */ - new Step() { @Override - public void execute(final RequestMonitor requestMonitor) { - boolean isNonStop = false; - try { - isNonStop = fLaunch.getLaunchConfiguration().getAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_NON_STOP, - IGDBLaunchConfigurationConstants.DEBUGGER_NON_STOP_DEFAULT); - } catch (CoreException e) { - } + if (dir != null) { + fCommandControl.queueCommand( + fCommandFactory.createMIEnvironmentCD(fCommandControl.getContext(), dir.toPortableString()), + new DataRequestMonitor(getExecutor(), requestMonitor)); + } else { + requestMonitor.done(); + } + }}, + /* + * Specify environment variables if needed + */ + new Step() { + @Override + public void execute(final RequestMonitor requestMonitor) { + boolean clear = false; + Properties properties = new Properties(); + try { + clear = fGDBBackend.getClearEnvironment(); + properties = fGDBBackend.getEnvironmentVariables(); + } catch (CoreException e) { + requestMonitor.setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, -1, "Cannot get environment information", e)); //$NON-NLS-1$ + requestMonitor.done(); + return; + } - // GDBs that don't support non-stop don't allow you to set it to false. - // We really should set it to false when GDB supports it though. - // Something to fix later. - if (isNonStop) { - // The raw commands should not be necessary in the official GDB release - fCommandControl.queueCommand( - fCommandFactory.createMIGDBSetTargetAsync(fCommandControl.getContext(), true), - new DataRequestMonitor(getExecutor(), requestMonitor) { - @Override - protected void handleSuccess() { - fCommandControl.queueCommand( - fCommandFactory.createMIGDBSetPagination(fCommandControl.getContext(), false), - new DataRequestMonitor(getExecutor(), requestMonitor) { - @Override - protected void handleSuccess() { - fCommandControl.queueCommand( - fCommandFactory.createMIGDBSetNonStop(fCommandControl.getContext(), true), - new DataRequestMonitor(getExecutor(), requestMonitor)); - } - }); - } - }); - } else { - requestMonitor.done(); - } - }}, - /* - * Tell GDB to automatically load or not the shared library symbols - */ - new Step() { @Override - public void execute(RequestMonitor requestMonitor) { - try { - boolean autolib = fLaunch.getLaunchConfiguration().getAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_AUTO_SOLIB, - IGDBLaunchConfigurationConstants.DEBUGGER_AUTO_SOLIB_DEFAULT); - fCommandControl.queueCommand( - fCommandFactory.createMIGDBSetAutoSolib(fCommandControl.getContext(), autolib), - new DataRequestMonitor(getExecutor(), requestMonitor)); - } catch (CoreException e) { - requestMonitor.setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, -1, "Cannot set shared library option", e)); //$NON-NLS-1$ - requestMonitor.done(); - } - }}, - /* - * Set the shared library paths - */ - new Step() { @Override - public void execute(final RequestMonitor requestMonitor) { - try { - List p = fGDBBackend.getSharedLibraryPaths(); - - if (p.size() > 0) { - String[] paths = p.toArray(new String[p.size()]); - fCommandControl.queueCommand( - fCommandFactory.createMIGDBSetSolibSearchPath(fCommandControl.getContext(), paths), - new DataRequestMonitor(getExecutor(), requestMonitor) { - @Override - protected void handleSuccess() { - // Sysroot is not available in GDB6.6 and will make the launch fail in that case. - // Let's remove it for now - requestMonitor.done(); + if (clear == true || properties.size() > 0) { + fCommandControl.setEnvironment(properties, clear, requestMonitor); + } else { + requestMonitor.done(); + } + }}, + /* + * Enable non-stop mode if necessary + */ + new Step() { + @Override + public void execute(final RequestMonitor requestMonitor) { + boolean isNonStop = false; + try { + isNonStop = fLaunch.getLaunchConfiguration().getAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_NON_STOP, + IGDBLaunchConfigurationConstants.DEBUGGER_NON_STOP_DEFAULT); + } catch (CoreException e) { + } + + // GDBs that don't support non-stop don't allow you to set it to false. + // We really should set it to false when GDB supports it though. + // Something to fix later. + if (isNonStop) { + // The raw commands should not be necessary in the official GDB release + fCommandControl.queueCommand( + fCommandFactory.createMIGDBSetTargetAsync(fCommandControl.getContext(), true), + new DataRequestMonitor(getExecutor(), requestMonitor) { + @Override + protected void handleSuccess() { + fCommandControl.queueCommand( + fCommandFactory.createMIGDBSetPagination(fCommandControl.getContext(), false), + new DataRequestMonitor(getExecutor(), requestMonitor) { + @Override + protected void handleSuccess() { + fCommandControl.queueCommand( + fCommandFactory.createMIGDBSetNonStop(fCommandControl.getContext(), true), + new DataRequestMonitor(getExecutor(), requestMonitor)); + } + }); + } + }); + } else { + requestMonitor.done(); + } + }}, + /* + * Tell GDB to automatically load or not the shared library symbols + */ + new Step() { + public void execute(RequestMonitor requestMonitor) { + try { + boolean autolib = fLaunch.getLaunchConfiguration().getAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_AUTO_SOLIB, + IGDBLaunchConfigurationConstants.DEBUGGER_AUTO_SOLIB_DEFAULT); + fCommandControl.queueCommand( + fCommandFactory.createMIGDBSetAutoSolib(fCommandControl.getContext(), autolib), + new DataRequestMonitor(getExecutor(), requestMonitor)); + } catch (CoreException e) { + requestMonitor.setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, -1, "Cannot set shared library option", e)); //$NON-NLS-1$ + requestMonitor.done(); + } + }}, + /* + * Set the shared library paths + */ + new Step() { + @Override + public void execute(final RequestMonitor requestMonitor) { + try { + List p = fGDBBackend.getSharedLibraryPaths(); + + if (p.size() > 0) { + String[] paths = p.toArray(new String[p.size()]); + fCommandControl.queueCommand( + fCommandFactory.createMIGDBSetSolibSearchPath(fCommandControl.getContext(), paths), + new DataRequestMonitor(getExecutor(), requestMonitor) { + @Override + protected void handleSuccess() { + // Sysroot is not available in GDB6.6 and will make the launch fail in that case. + // Let's remove it for now + requestMonitor.done(); // // If we are able to set the solib-search-path, // // we should disable the sysroot variable, as indicated // // in the GDB documentation. This is to avoid the sysroot @@ -297,400 +319,336 @@ public class GDBJtagDSFFinalLaunchSequence extends Sequence { // fCommandControl.queueCommand( // new MIGDBSetSysroot(fCommandControl.getContext()), // new DataRequestMonitor(getExecutor(), requestMonitor)); - }; - }); - } else { - requestMonitor.done(); - } - } catch (CoreException e) { - requestMonitor.setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, -1, "Cannot set share library paths", e)); //$NON-NLS-1$ - requestMonitor.done(); - } - }}, - /* - * Setup the source paths - */ - new Step() { @Override - public void execute(RequestMonitor requestMonitor) { - CSourceLookup sourceLookup = fTracker.getService(CSourceLookup.class); - CSourceLookupDirector locator = (CSourceLookupDirector)fLaunch.getSourceLocator(); - ISourceLookupDMContext sourceLookupDmc = (ISourceLookupDMContext)fCommandControl.getContext(); + }; + }); + } else { + requestMonitor.done(); + } + } catch (CoreException e) { + requestMonitor.setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, -1, "Cannot set share library paths", e)); //$NON-NLS-1$ + requestMonitor.done(); + } + }}, + /* + * Setup the source paths + */ + new Step() { + @Override + public void execute(RequestMonitor requestMonitor) { + CSourceLookup sourceLookup = fTracker.getService(CSourceLookup.class); + CSourceLookupDirector locator = (CSourceLookupDirector)fLaunch.getSourceLocator(); + ISourceLookupDMContext sourceLookupDmc = (ISourceLookupDMContext)fCommandControl.getContext(); - sourceLookup.setSourceLookupPath(sourceLookupDmc, locator.getSourceContainers(), requestMonitor); - }}, - - // Below steps are specific to JTag hardware debugging - - /* - * 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; - try { - fGdbJtagDevice = getGDBJtagDevice(fLaunch.getLaunchConfiguration()); - } catch (NullPointerException e) { - exception = e; - } catch (CoreException e) { - exception = e; - } - if (fGdbJtagDevice == null) { - // Abort the launch - rm.setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, -1, "Cannot get Jtag device", exception)); //$NON-NLS-1$ - } + sourceLookup.setSourceLookupPath(sourceLookupDmc, locator.getSourceContainers(), requestMonitor); + }}, + + // Below steps are specific to JTag hardware debugging + + /* + * Retrieve the JTag device + */ + new Step() { + @Override + public void execute(RequestMonitor rm) { + Exception exception = null; + try { + fGdbJtagDevice = getGDBJtagDevice(fLaunch.getLaunchConfiguration()); + } catch (NullPointerException e) { + exception = e; + } catch (CoreException e) { + exception = e; + } + if (fGdbJtagDevice == null) { + // Abort the launch + 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() { + @Override + public void execute(RequestMonitor rm) { + ILaunchConfiguration config = fLaunch.getLaunchConfiguration(); + try { + 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); + List commands = new ArrayList(); + fGdbJtagDevice.doRemote(ipAddress, portNumber, commands); + queueCommands(commands, rm); + } else { 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(); - try { - 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 commands = new ArrayList(); - fGdbJtagDevice.doRemote(ipAddress, portNumber, commands); - fCommandControl.queueCommand( - new CLICommand(fCommandControl.getContext(), composeCommand(commands)), - new DataRequestMonitor(getExecutor(), rm)); - } else { - rm.done(); - } - } catch (CoreException e) { - 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 commands = new ArrayList(); - fGdbJtagDevice.doReset(commands); - fCommandControl.queueCommand( - new CLICommand(fCommandControl.getContext(), composeCommand(commands)), - new DataRequestMonitor(getExecutor(), rm)); - } else { - rm.done(); - } - } catch (CoreException e) { - rm.setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, -1, "Cannot reset the remote target", e)); //$NON-NLS-1$ - rm.done(); - } + } catch (CoreException e) { + 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() { + @Override + public void execute(RequestMonitor rm) { + ILaunchConfiguration config = fLaunch.getLaunchConfiguration(); + try { + if (config.getAttribute(IGDBJtagConstants.ATTR_DO_RESET, true)) { + List commands = new ArrayList(); + fGdbJtagDevice.doReset(commands); + queueCommands(commands, rm); + } else { + 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 commands = new ArrayList(); - fGdbJtagDevice.doDelay(config.getAttribute(IGDBJtagConstants.ATTR_DELAY, defaultDelay), commands); - fCommandControl.queueCommand( - new CLICommand(fCommandControl.getContext(), composeCommand(commands)), - new DataRequestMonitor(getExecutor(), 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(); - } + } catch (CoreException e) { + 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() { + @Override + public void execute(RequestMonitor rm) { + ILaunchConfiguration config = fLaunch.getLaunchConfiguration(); + int defaultDelay = fGdbJtagDevice.getDefaultDelay(); + try { + List commands = new ArrayList(); + fGdbJtagDevice.doDelay(config.getAttribute(IGDBJtagConstants.ATTR_DELAY, defaultDelay), commands); + 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() { + @Override + public void execute(RequestMonitor rm) { + ILaunchConfiguration config = fLaunch.getLaunchConfiguration(); + try { + if (config.getAttribute(IGDBJtagConstants.ATTR_DO_HALT, true)) { + List commands = new ArrayList(); + fGdbJtagDevice.doHalt(commands); + queueCommands(commands, rm); + } else { + 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 commands = new ArrayList(); - fGdbJtagDevice.doHalt(commands); - fCommandControl.queueCommand( - new CLICommand(fCommandControl.getContext(), composeCommand(commands)), - new DataRequestMonitor(getExecutor(), rm)); - } else { - rm.done(); - } - } catch (CoreException e) { - rm.setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, -1, "Cannot halt the remote target", e)); //$NON-NLS-1$ - rm.done(); - } + } catch (CoreException e) { + 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() { + @Override + public void execute(RequestMonitor rm) { + ILaunchConfiguration config = fLaunch.getLaunchConfiguration(); + try { + String userCmd = config.getAttribute(IGDBJtagConstants.ATTR_INIT_COMMANDS, ""); //$NON-NLS-1$ + userCmd = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(userCmd); + String[] commands = userCmd.split("\\r?\\n"); //$NON-NLS-1$ + + CountingRequestMonitor crm = new CountingRequestMonitor(getExecutor(), rm); + crm.setDoneCount(commands.length); + for (int i = 0; i < commands.length; ++i) { + fCommandControl.queueCommand( + new CLICommand(fCommandControl.getContext(), commands[i]), + new DataRequestMonitor(getExecutor(), crm)); } - }, - /* - * 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(); - try { - String userCmd = config.getAttribute(IGDBJtagConstants.ATTR_INIT_COMMANDS, ""); //$NON-NLS-1$ - userCmd = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(userCmd); - String[] commands = userCmd.split("\\r?\\n"); //$NON-NLS-1$ - - CountingRequestMonitor crm = new CountingRequestMonitor(getExecutor(), rm); - crm.setDoneCount(commands.length); - for (int i = 0; i < commands.length; ++i) { - fCommandControl.queueCommand( - new CLICommand(fCommandControl.getContext(), commands[i]), - new DataRequestMonitor(getExecutor(), crm)); - } - } catch (CoreException e) { - rm.setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, -1, "Cannot run user defined init commands", e)); //$NON-NLS-1$ - rm.done(); - } + } catch (CoreException e) { + 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() { + @Override + public void execute(RequestMonitor rm) { + ILaunchConfiguration config = fLaunch.getLaunchConfiguration(); + try { + if (config.getAttribute(IGDBJtagConstants.ATTR_LOAD_IMAGE, IGDBJtagConstants.DEFAULT_LOAD_IMAGE)) { + // Escape windows path separator characters TWICE, once for Java and once for GDB. + String imageFileName = config.getAttribute(IGDBJtagConstants.ATTR_IMAGE_FILE_NAME, ""); //$NON-NLS-1$ + 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$ + List commands = new ArrayList(); + fGdbJtagDevice.doLoadImage(imageFileName, imageOffset, commands); + 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(); + } + } else { + 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(); - try { - if (config.getAttribute(IGDBJtagConstants.ATTR_LOAD_IMAGE, IGDBJtagConstants.DEFAULT_LOAD_IMAGE)) { - // Escape windows path separator characters TWICE, once for Java and once for GDB. - String imageFileName = config.getAttribute(IGDBJtagConstants.ATTR_IMAGE_FILE_NAME, ""); //$NON-NLS-1$ - 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 commands = new ArrayList(); - fGdbJtagDevice.doLoadImage(imageFileName, imageOffset, commands); - fCommandControl.queueCommand( - new CLICommand(fCommandControl.getContext(), composeCommand(commands)), - new DataRequestMonitor(getExecutor(), rm)); - } else { - rm.setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, -1, "Image name cannot be empty", null)); //$NON-NLS-1$ - rm.done(); - } - } else { - rm.done(); - } - } catch (CoreException e) { - rm.setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, -1, "Cannot load image", e)); //$NON-NLS-1$ - rm.done(); - } + } catch (CoreException e) { + rm.setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, -1, "Cannot load image", e)); //$NON-NLS-1$ + rm.done(); + } + }}, + /* + * Execute symbol loading + */ + new Step() { + @Override + public void execute(RequestMonitor rm) { + ILaunchConfiguration config = fLaunch.getLaunchConfiguration(); + try { + if (config.getAttribute(IGDBJtagConstants.ATTR_LOAD_SYMBOLS, IGDBJtagConstants.DEFAULT_LOAD_SYMBOLS)) { + // Escape windows path separator characters TWICE, once for Java and once for GDB. + String symbolsFileName = config.getAttribute(IGDBJtagConstants.ATTR_SYMBOLS_FILE_NAME, ""); //$NON-NLS-1$ + 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$ + List commands = new ArrayList(); + fGdbJtagDevice.doLoadSymbol(symbolsFileName, symbolsOffset, commands); + 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(); + } + } else { + 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(); - try { - if (config.getAttribute(IGDBJtagConstants.ATTR_LOAD_SYMBOLS, IGDBJtagConstants.DEFAULT_LOAD_SYMBOLS)) { - // Escape windows path separator characters TWICE, once for Java and once for GDB. - String symbolsFileName = config.getAttribute(IGDBJtagConstants.ATTR_SYMBOLS_FILE_NAME, ""); //$NON-NLS-1$ - 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 commands = new ArrayList(); - fGdbJtagDevice.doLoadSymbol(symbolsFileName, symbolsOffset, commands); - fCommandControl.queueCommand( - new CLICommand(fCommandControl.getContext(), composeCommand(commands)), - new DataRequestMonitor(getExecutor(), rm)); - } else { - rm.setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, -1, "Symbol name cannot be empty", null)); //$NON-NLS-1$ - rm.done(); - } - } else { - rm.done(); - } - } catch (CoreException e) { - rm.setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, -1, "Cannot load symbol", e)); //$NON-NLS-1$ - rm.done(); - } + } catch (CoreException e) { + rm.setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, -1, "Cannot load symbol", e)); //$NON-NLS-1$ + rm.done(); + } + } + }, + /* + * Start tracking the breakpoints once we know we are connected to the target (necessary for remote debugging) + */ + new Step() { + @Override + public void execute(final RequestMonitor requestMonitor) { + if (fSessionType != SessionType.CORE) { + MIBreakpointsManager bpmService = fTracker.getService(MIBreakpointsManager.class); + IBreakpointsTargetDMContext breakpointDmc = (IBreakpointsTargetDMContext)fCommandControl.getContext(); + + bpmService.startTrackingBreakpoints(breakpointDmc, requestMonitor); + } else { + requestMonitor.done(); + } + }}, + /* + * Set the program counter + */ + new Step() { + @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$ + List commands = new ArrayList(); + fGdbJtagDevice.doSetPC(pcRegister, commands); + queueCommands(commands, rm); + } else { + rm.done(); } - }, - /* - * Start tracking the breakpoints once we know we are connected to the target (necessary for remote debugging) - */ - new Step() { @Override - public void execute(final RequestMonitor requestMonitor) { - if (fSessionType != SessionType.CORE) { - MIBreakpointsManager bpmService = fTracker.getService(MIBreakpointsManager.class); - IBreakpointsTargetDMContext breakpointDmc = (IBreakpointsTargetDMContext)fCommandControl.getContext(); + } catch (CoreException e) { + 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() { + @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$ + List commands = new ArrayList(); + fGdbJtagDevice.doStopAt(stopAt, commands); + queueCommands(commands, rm); + } else { + rm.done(); + } + } catch (CoreException e) { + rm.setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, -1, "Cannot run the stop script", e)); //$NON-NLS-1$ + rm.done(); + } + } + }, + /* + * Execute the resume script + */ + new Step() { + @Override + public void execute(RequestMonitor rm) { + ILaunchConfiguration config = fLaunch.getLaunchConfiguration(); + try { + if (config.getAttribute(IGDBJtagConstants.ATTR_SET_RESUME, IGDBJtagConstants.DEFAULT_SET_RESUME)) { + List commands = new ArrayList(); + fGdbJtagDevice.doContinue(commands); + queueCommands(commands, rm); + } else { + rm.done(); + } + } catch (CoreException e) { + 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() { + @Override + public void execute(RequestMonitor rm) { + ILaunchConfiguration config = fLaunch.getLaunchConfiguration(); + try { + String userCmd = config.getAttribute(IGDBJtagConstants.ATTR_RUN_COMMANDS, ""); //$NON-NLS-1$ + userCmd = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(userCmd); + String[] commands = userCmd.split("\\r?\\n"); //$NON-NLS-1$ + + CountingRequestMonitor crm = new CountingRequestMonitor(getExecutor(), rm); + crm.setDoneCount(commands.length); + for (int i = 0; i < commands.length; ++i) { + fCommandControl.queueCommand( + new CLICommand(fCommandControl.getContext(), commands[i]), + new DataRequestMonitor(getExecutor(), crm)); + } + } catch (CoreException e) { + rm.setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, -1, "Cannot run user defined run commands", e)); //$NON-NLS-1$ + rm.done(); + } + }}, - bpmService.startTrackingBreakpoints(breakpointDmc, requestMonitor); - } else { - requestMonitor.done(); - } - }}, - /* - * 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 commands = new ArrayList(); - fGdbJtagDevice.doSetPC(pcRegister, commands); - fCommandControl.queueCommand( - new CLICommand(fCommandControl.getContext(), composeCommand(commands)), - new DataRequestMonitor(getExecutor(), rm)); - } else { - rm.done(); - } - } catch (CoreException e) { - 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 commands = new ArrayList(); - fGdbJtagDevice.doStopAt(stopAt, commands); - fCommandControl.queueCommand( - new CLICommand(fCommandControl.getContext(), composeCommand(commands)), - new DataRequestMonitor(getExecutor(), rm)); - } else { - rm.done(); - } - } catch (CoreException e) { - rm.setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, -1, "Cannot run the stop script", e)); //$NON-NLS-1$ - rm.done(); - } - } - }, - /* - * 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 commands = new ArrayList(); - fGdbJtagDevice.doContinue(commands); - fCommandControl.queueCommand( - new CLICommand(fCommandControl.getContext(), composeCommand(commands)), - new DataRequestMonitor(getExecutor(), rm)); - } else { - rm.done(); - } - } catch (CoreException e) { - 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(); - try { - String userCmd = config.getAttribute(IGDBJtagConstants.ATTR_RUN_COMMANDS, ""); //$NON-NLS-1$ - userCmd = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(userCmd); - String[] commands = userCmd.split("\\r?\\n"); //$NON-NLS-1$ - - CountingRequestMonitor crm = new CountingRequestMonitor(getExecutor(), rm); - crm.setDoneCount(commands.length); - for (int i = 0; i < commands.length; ++i) { - fCommandControl.queueCommand( - new CLICommand(fCommandControl.getContext(), commands[i]), - new DataRequestMonitor(getExecutor(), crm)); - } - } catch (CoreException e) { - 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. - */ - new Step() { - @Override - public void execute(final RequestMonitor requestMonitor) { - fLaunch.getSession().dispatchEvent(new DataModelInitializedEvent(fCommandControl.getContext()), - fCommandControl.getProperties()); - requestMonitor.done(); - } - }, - /* - * Cleanup - */ - new Step() { - @Override - public void execute(final RequestMonitor requestMonitor) { - fTracker.dispose(); - fTracker = null; - requestMonitor.done(); - } - }, + /* + * Indicate that the Data Model has been filled. This will trigger the Debug view to expand. + */ + new Step() { + @Override + public void execute(final RequestMonitor requestMonitor) { + fLaunch.getSession().dispatchEvent(new DataModelInitializedEvent(fCommandControl.getContext()), + fCommandControl.getProperties()); + requestMonitor.done(); + }}, + /* + * Cleanup + */ + new Step() { + @Override + public void execute(final RequestMonitor requestMonitor) { + fTracker.dispose(); + fTracker = null; + requestMonitor.done(); + }}, }; GdbLaunch fLaunch;