From 4ebb82d8b2f02e925ee5e29b22a7803fb8ef7fd2 Mon Sep 17 00:00:00 2001 From: John Dallaway Date: Fri, 23 Aug 2019 19:45:13 +0100 Subject: [PATCH] Bug 535163: Use 'reset and halt' command (DAP) Change-Id: Id5ec90a062a203933a2756d0a2f71ce36d00daf8 Signed-off-by: John Dallaway --- .../dap/gdbjtag/DapGdbJtagLaunchDelegate.java | 39 +++++++++++++++---- 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/jtag/org.eclipse.cdt.debug.dap.gdbjtag/src/org/eclipse/cdt/debug/dap/gdbjtag/DapGdbJtagLaunchDelegate.java b/jtag/org.eclipse.cdt.debug.dap.gdbjtag/src/org/eclipse/cdt/debug/dap/gdbjtag/DapGdbJtagLaunchDelegate.java index a5baf797d51..176ffac929f 100644 --- a/jtag/org.eclipse.cdt.debug.dap.gdbjtag/src/org/eclipse/cdt/debug/dap/gdbjtag/DapGdbJtagLaunchDelegate.java +++ b/jtag/org.eclipse.cdt.debug.dap.gdbjtag/src/org/eclipse/cdt/debug/dap/gdbjtag/DapGdbJtagLaunchDelegate.java @@ -1,3 +1,16 @@ +/******************************************************************************* + * Copyright (c) 2019 Kichwa Coders and others. + * + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * John Dallaway - Use 'reset and halt' command (Bug 535163) + *******************************************************************************/ package org.eclipse.cdt.debug.dap.gdbjtag; import java.net.URI; @@ -222,26 +235,38 @@ public class DapGdbJtagLaunchDelegate extends DapLaunchDelegate { private void addInitCommands(Map params, IGDBJtagDevice jtagDevice, Map attributes) throws CoreException { + boolean doReset = CDebugUtils.getAttribute(attributes, IGDBJtagConstants.ATTR_DO_RESET, + IGDBJtagConstants.DEFAULT_DO_RESET); + boolean doHalt = CDebugUtils.getAttribute(attributes, IGDBJtagConstants.ATTR_DO_HALT, + IGDBJtagConstants.DEFAULT_DO_HALT); + int defaultDelay = jtagDevice.getDefaultDelay(); + int delay = CDebugUtils.getAttribute(attributes, IGDBJtagConstants.ATTR_DELAY, defaultDelay); + List resetAndHaltCommands = new ArrayList<>(); + jtagDevice.doResetAndHalt(resetAndHaltCommands); + boolean useResetAndHalt = doReset && doHalt && (0 == delay) && !resetAndHaltCommands.isEmpty(); + List commands = new ArrayList<>(); - if (CDebugUtils.getAttribute(attributes, IGDBJtagConstants.ATTR_DO_RESET, IGDBJtagConstants.DEFAULT_DO_RESET)) { + if (doReset) { int size = commands.size(); - jtagDevice.doReset(commands); + if (useResetAndHalt) { + commands.addAll(resetAndHaltCommands); + } else { + jtagDevice.doReset(commands); + } if (size == commands.size()) { throw newCoreException( String.format("Reset command not defined for device '%s'", getGDBJtagDeviceName(attributes))); } } - if (CDebugUtils.getAttribute(attributes, IGDBJtagConstants.ATTR_DO_RESET, IGDBJtagConstants.DEFAULT_DO_RESET)) { - int defaultDelay = jtagDevice.getDefaultDelay(); - int delay = CDebugUtils.getAttribute(attributes, IGDBJtagConstants.ATTR_DELAY, defaultDelay); + if (doReset && (0 != delay)) { int size = commands.size(); jtagDevice.doDelay(delay, commands); - if (size == commands.size() && (delay != 0)) { + if (size == commands.size()) { throw newCoreException( String.format("Delay command not defined for device '%s'", getGDBJtagDeviceName(attributes))); } } - if (CDebugUtils.getAttribute(attributes, IGDBJtagConstants.ATTR_DO_HALT, IGDBJtagConstants.DEFAULT_DO_HALT)) { + if (doHalt && !useResetAndHalt) { int size = commands.size(); jtagDevice.doHalt(commands); if (size == commands.size()) {