1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-30 20:35:38 +02:00

Bug 535163: Use 'reset and halt' command

Change-Id: Icfe5796a33c01208c1fa98cc6357d21c0e83b9ae
Signed-off-by: John Dallaway <john@dallaway.org.uk>
This commit is contained in:
John Dallaway 2019-08-23 15:40:30 +01:00
parent b1f14709b8
commit 49c7ae5f3b
2 changed files with 47 additions and 10 deletions

View file

@ -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<String> 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<String> 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<String> 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<String> resetAndHaltCommands = new ArrayList<>();
fGdbJtagDevice.doResetAndHalt(resetAndHaltCommands);
return doReset && doHalt && (0 == delay) && !resetAndHaltCommands.isEmpty();
}
/**
* Cleanup now that the sequence has been run.
* @since 8.2

View file

@ -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<String> commands);
@ -68,6 +69,20 @@ public interface IGDBJtagDevice {
*/
public void doHalt(Collection<String> 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<String> commands) {
/* override where supported by debugger */
}
/**
* Commands to connect to remote JTAG device
*