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 4e1761704dc..59f169e6ed8 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 @@ -22,6 +22,7 @@ * John Dallaway - Test for reset/delay/halt command not defined (Bug 361881) * Torbjörn Svensson (STMicroelectronics) - Bug 535024 * John Dallaway - Report download progress (Bug 543149) + * John Dallaway - Use 'reset and halt' command (Bug 535163) *******************************************************************************/ package org.eclipse.cdt.debug.gdbjtag.core; @@ -412,7 +413,11 @@ public class GDBJtagDSFFinalLaunchSequence extends FinalLaunchSequence { if (CDebugUtils.getAttribute(getAttributes(), IGDBJtagConstants.ATTR_DO_RESET, IGDBJtagConstants.DEFAULT_DO_RESET)) { List commands = new ArrayList<>(); - fGdbJtagDevice.doReset(commands); + if (useResetAndHalt()) { + fGdbJtagDevice.doResetAndHalt(commands); + } else { + fGdbJtagDevice.doReset(commands); + } if (commands.isEmpty()) { setError(String.format(Messages.getString("GDBJtagDebugger.reset_not_defined"), getGDBJtagDeviceName()), //$NON-NLS-1$ rm); @@ -437,9 +442,11 @@ public class GDBJtagDSFFinalLaunchSequence extends FinalLaunchSequence { List commands = new ArrayList<>(); int delay = CDebugUtils.getAttribute(getAttributes(), IGDBJtagConstants.ATTR_DELAY, defaultDelay); fGdbJtagDevice.doDelay(delay, commands); - if (commands.isEmpty() && (delay != 0)) { - setError(String.format(Messages.getString("GDBJtagDebugger.delay_not_defined"), getGDBJtagDeviceName()), //$NON-NLS-1$ - rm); + if (0 == delay) { + rm.done(); + } else if (commands.isEmpty()) { + setError(String.format(Messages.getString("GDBJtagDebugger.delay_not_defined"), //$NON-NLS-1$ + getGDBJtagDeviceName()), rm); } else { queueCommands(commands, rm); } @@ -454,7 +461,7 @@ public class GDBJtagDSFFinalLaunchSequence extends FinalLaunchSequence { /** @since 8.2 */ @Execute public void stepHaltBoard(final RequestMonitor rm) { - if (CDebugUtils.getAttribute(getAttributes(), IGDBJtagConstants.ATTR_DO_HALT, + if (!useResetAndHalt() && CDebugUtils.getAttribute(getAttributes(), IGDBJtagConstants.ATTR_DO_HALT, IGDBJtagConstants.DEFAULT_DO_HALT)) { List commands = new ArrayList<>(); fGdbJtagDevice.doHalt(commands); @@ -772,6 +779,21 @@ public class GDBJtagDSFFinalLaunchSequence extends FinalLaunchSequence { return sb.toString(); } + /** + * Determine if reset and halt should be issued as one command + */ + private boolean useResetAndHalt() { + final boolean doReset = CDebugUtils.getAttribute(getAttributes(), IGDBJtagConstants.ATTR_DO_RESET, + IGDBJtagConstants.DEFAULT_DO_RESET); + final boolean doHalt = CDebugUtils.getAttribute(getAttributes(), IGDBJtagConstants.ATTR_DO_HALT, + IGDBJtagConstants.DEFAULT_DO_HALT); + final int defaultDelay = fGdbJtagDevice.getDefaultDelay(); + final int delay = CDebugUtils.getAttribute(getAttributes(), IGDBJtagConstants.ATTR_DELAY, defaultDelay); + final List resetAndHaltCommands = new ArrayList<>(); + fGdbJtagDevice.doResetAndHalt(resetAndHaltCommands); + return doReset && doHalt && (0 == delay) && !resetAndHaltCommands.isEmpty(); + } + /** * Cleanup now that the sequence has been run. * @since 8.2 diff --git a/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/jtagdevice/IGDBJtagDevice.java b/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/jtagdevice/IGDBJtagDevice.java index c854cee390b..461b2528d8a 100644 --- a/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/jtagdevice/IGDBJtagDevice.java +++ b/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/jtagdevice/IGDBJtagDevice.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2012 QNX Software Systems and others. + * Copyright (c) 2008, 2019 QNX Software Systems and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -11,6 +11,7 @@ * Contributors: * QNX Software Systems - Initial API and implementation * Andy Jin - Hardware debugging UI improvements, bug 229946 + * John Dallaway - Support 'reset and halt' command, bug 535163 *******************************************************************************/ package org.eclipse.cdt.debug.gdbjtag.core.jtagdevice; @@ -26,13 +27,13 @@ import java.util.Collection; public interface IGDBJtagDevice { /** - * Device reset command + * Device reset and run commands * * @param commands * implementation should populate the collection with the gdb - * commands that will reset the device, or leave the collection - * as-is if that operation is either unsupported or not - * applicable + * commands that will reset the device and let it run, or leave + * the collection as-is if that operation is either unsupported + * or not applicable */ public void doReset(Collection commands); @@ -68,6 +69,20 @@ public interface IGDBJtagDevice { */ public void doHalt(Collection commands); + /** + * Device reset and immediate halt as a single command + * + * @param commands + * implementation should populate the collection with the + * single gdb command that will reset and halt the target, or + * leave the collection as-is if that operation is either + * unsupported or not applicable + * @since 9.3 + */ + default void doResetAndHalt(Collection commands) { + /* override where supported by debugger */ + } + /** * Commands to connect to remote JTAG device *