From 2e780a54f11e730e20ba0974d2ce3d64873d6087 Mon Sep 17 00:00:00 2001 From: Alvaro Sanchez-Leon Date: Mon, 9 Jan 2017 11:42:22 -0500 Subject: [PATCH] Bug 509812 - Unable to interrupt arm remote target, Neon and GDB 7.12 Adding a GDBJtagDSFFinalLaunchSequence_7_12 class to be used when interfacing with GDB 7.12 or higher. A new step is added to the sequence in order to enable async mode, which will allow us to use the new GDBFullCLIConsole Change-Id: I08c382550c6dd8a8567a66169495a9e490c35397 --- .../.settings/.api_filters | 10 +++ .../META-INF/MANIFEST.MF | 2 +- .../pom.xml | 2 +- .../GDBJtagDSFFinalLaunchSequence_7_12.java | 77 +++++++++++++++++++ .../dsf/gdb/service/GDBJtagControl_7_12.java | 36 +++++++++ .../service/GdbJtagDebugServicesFactory.java | 5 +- .../extensions/GDBJtagControl_HEAD.java | 8 +- .../jtagdevice/DefaultGDBJtagDeviceImpl.java | 8 +- 8 files changed, 140 insertions(+), 8 deletions(-) create mode 100644 jtag/org.eclipse.cdt.debug.gdbjtag.core/.settings/.api_filters create mode 100644 jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/GDBJtagDSFFinalLaunchSequence_7_12.java create mode 100644 jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/dsf/gdb/service/GDBJtagControl_7_12.java diff --git a/jtag/org.eclipse.cdt.debug.gdbjtag.core/.settings/.api_filters b/jtag/org.eclipse.cdt.debug.gdbjtag.core/.settings/.api_filters new file mode 100644 index 00000000000..697d2241993 --- /dev/null +++ b/jtag/org.eclipse.cdt.debug.gdbjtag.core/.settings/.api_filters @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/jtag/org.eclipse.cdt.debug.gdbjtag.core/META-INF/MANIFEST.MF b/jtag/org.eclipse.cdt.debug.gdbjtag.core/META-INF/MANIFEST.MF index 6d887cc46e1..9bef93d8361 100644 --- a/jtag/org.eclipse.cdt.debug.gdbjtag.core/META-INF/MANIFEST.MF +++ b/jtag/org.eclipse.cdt.debug.gdbjtag.core/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.cdt.debug.gdbjtag.core;singleton:=true -Bundle-Version: 9.0.0.qualifier +Bundle-Version: 9.1.0.qualifier Bundle-Activator: org.eclipse.cdt.debug.gdbjtag.core.Activator Bundle-Localization: plugin Require-Bundle: org.eclipse.core.runtime, diff --git a/jtag/org.eclipse.cdt.debug.gdbjtag.core/pom.xml b/jtag/org.eclipse.cdt.debug.gdbjtag.core/pom.xml index 349345bba5e..5e30f1740f7 100644 --- a/jtag/org.eclipse.cdt.debug.gdbjtag.core/pom.xml +++ b/jtag/org.eclipse.cdt.debug.gdbjtag.core/pom.xml @@ -11,7 +11,7 @@ ../../pom.xml - 9.0.0-SNAPSHOT + 9.1.0-SNAPSHOT org.eclipse.cdt.debug.gdbjtag.core eclipse-plugin diff --git a/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/GDBJtagDSFFinalLaunchSequence_7_12.java b/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/GDBJtagDSFFinalLaunchSequence_7_12.java new file mode 100644 index 00000000000..f6b05b76138 --- /dev/null +++ b/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/GDBJtagDSFFinalLaunchSequence_7_12.java @@ -0,0 +1,77 @@ +/******************************************************************************* + * Copyright (c) 2017 Ericsson and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ +package org.eclipse.cdt.debug.gdbjtag.core; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor; +import org.eclipse.cdt.dsf.concurrent.RequestMonitor; +import org.eclipse.cdt.dsf.concurrent.RequestMonitorWithProgress; +import org.eclipse.cdt.dsf.mi.service.IMICommandControl; +import org.eclipse.cdt.dsf.mi.service.command.output.MIInfo; +import org.eclipse.cdt.dsf.service.DsfServicesTracker; +import org.eclipse.cdt.dsf.service.DsfSession; + +/** + * Subclass for GDB >= 7.12. + * + * @since 9.1 + */ +public class GDBJtagDSFFinalLaunchSequence_7_12 extends GDBJtagDSFFinalLaunchSequence_7_7 { + public GDBJtagDSFFinalLaunchSequence_7_12(DsfSession session, Map attributes, + RequestMonitorWithProgress rm) { + super(session, attributes, rm); + } + + @Override + protected String[] getExecutionOrder(String group) { + if (GROUP_TOP_LEVEL.equals(group)) { + // Initialize the list with the steps from the base class + List orderList = new ArrayList( + Arrays.asList(super.getExecutionOrder(GROUP_TOP_LEVEL))); + + // Add the new step after we source the gdbinit file to make sure the user + // cannot change this behavior + orderList.add(orderList.indexOf("stepSourceGDBInitFile") + 1, //$NON-NLS-1$ + "stepSetTargetAsync"); //$NON-NLS-1$ + + return orderList.toArray(new String[orderList.size()]); + } + + return super.getExecutionOrder(group); + } + + @Execute + public void stepSetTargetAsync(RequestMonitor rm) { + DsfServicesTracker tracker = new DsfServicesTracker(Activator.getBundleContext(), + getSession().getId()); + IMICommandControl commandControl = tracker.getService(IMICommandControl.class); + tracker.dispose(); + + if (commandControl != null) { + // Use target async when interfacing with GDB 7.12 or higher + // this will allow us to use the new enhanced GDB Full CLI console + commandControl.queueCommand( + commandControl.getCommandFactory().createMIGDBSetTargetAsync(commandControl.getContext(), true), + new DataRequestMonitor(getExecutor(), rm) { + @Override + protected void handleError() { + // We should only be calling this for GDB >= 7.12, + // but just in case, accept errors for older GDBs + rm.done(); + } + }); + } else { + // Should never happen but accept errors in this case + rm.done(); + } + } +} diff --git a/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/dsf/gdb/service/GDBJtagControl_7_12.java b/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/dsf/gdb/service/GDBJtagControl_7_12.java new file mode 100644 index 00000000000..dce0036815b --- /dev/null +++ b/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/dsf/gdb/service/GDBJtagControl_7_12.java @@ -0,0 +1,36 @@ +/******************************************************************************* + * Copyright (c) 2017 Ericsson and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ +package org.eclipse.cdt.debug.gdbjtag.core.dsf.gdb.service; + +import java.util.Map; + +import org.eclipse.cdt.debug.gdbjtag.core.GDBJtagDSFFinalLaunchSequence_7_12; +import org.eclipse.cdt.dsf.concurrent.RequestMonitorWithProgress; +import org.eclipse.cdt.dsf.concurrent.Sequence; +import org.eclipse.cdt.dsf.gdb.service.command.GDBControl_7_12; +import org.eclipse.cdt.dsf.mi.service.command.CommandFactory; +import org.eclipse.cdt.dsf.service.DsfSession; +import org.eclipse.debug.core.ILaunchConfiguration; + +/** + * Jtag control service which selects the Jtag CompleteInitializationSequence. Used for GDB >= 7.12 + * + * @since 9.1 + */ +public class GDBJtagControl_7_12 extends GDBControl_7_12 { + + public GDBJtagControl_7_12(DsfSession session, ILaunchConfiguration config, CommandFactory factory) { + super(session, config, factory); + } + + @Override + protected Sequence getCompleteInitializationSequence(Map attributes, + RequestMonitorWithProgress rm) { + return new GDBJtagDSFFinalLaunchSequence_7_12(getSession(), attributes, rm); + } +} \ No newline at end of file diff --git a/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/dsf/gdb/service/GdbJtagDebugServicesFactory.java b/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/dsf/gdb/service/GdbJtagDebugServicesFactory.java index cd638975c02..29af1414450 100644 --- a/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/dsf/gdb/service/GdbJtagDebugServicesFactory.java +++ b/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/dsf/gdb/service/GdbJtagDebugServicesFactory.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011, 2016 Ericsson and others. + * Copyright (c) 2011, 2017 Ericsson and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -30,6 +30,9 @@ public class GdbJtagDebugServicesFactory extends GdbDebugServicesFactory { @Override protected ICommandControl createCommandControl(DsfSession session, ILaunchConfiguration config) { + if (compareVersionWith(GDB_7_12_VERSION) >= 0) { + return new GDBJtagControl_7_12(session, config, new CommandFactory_6_8()); + } if (compareVersionWith(GDB_7_7_VERSION) >= 0) { return new GDBJtagControl_7_7(session, config, new CommandFactory_6_8()); } diff --git a/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/dsf/gdb/service/extensions/GDBJtagControl_HEAD.java b/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/dsf/gdb/service/extensions/GDBJtagControl_HEAD.java index ad7211098f5..2639810fb62 100644 --- a/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/dsf/gdb/service/extensions/GDBJtagControl_HEAD.java +++ b/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/dsf/gdb/service/extensions/GDBJtagControl_HEAD.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2015 Ericsson and others. + * Copyright (c) 2015, 2017 Ericsson and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -7,7 +7,7 @@ *******************************************************************************/ package org.eclipse.cdt.debug.gdbjtag.core.dsf.gdb.service.extensions; -import org.eclipse.cdt.debug.gdbjtag.core.dsf.gdb.service.GDBJtagControl_7_7; +import org.eclipse.cdt.debug.gdbjtag.core.dsf.gdb.service.GDBJtagControl_7_12; import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService; import org.eclipse.cdt.dsf.gdb.service.GdbDebugServicesFactory; import org.eclipse.cdt.dsf.mi.service.command.CommandFactory; @@ -38,14 +38,14 @@ import org.eclipse.debug.core.ILaunchConfiguration; * * @since 8.5 */ -public class GDBJtagControl_HEAD extends GDBJtagControl_7_7 { +public class GDBJtagControl_HEAD extends GDBJtagControl_7_12 { public GDBJtagControl_HEAD(DsfSession session, ILaunchConfiguration config, CommandFactory factory) { super(session, config, factory); validateGdbVersion(session); } - protected String getMinGDBVersionSupported() { return GdbDebugServicesFactory.GDB_7_7_VERSION; } + protected String getMinGDBVersionSupported() { return GdbDebugServicesFactory.GDB_7_12_VERSION; } protected void validateGdbVersion(DsfSession session) { GdbDebugServicesFactory.validateGdbVersion(session, getMinGDBVersionSupported(), this); diff --git a/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/jtagdevice/DefaultGDBJtagDeviceImpl.java b/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/jtagdevice/DefaultGDBJtagDeviceImpl.java index 8874d5a3384..7063d23fcca 100644 --- a/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/jtagdevice/DefaultGDBJtagDeviceImpl.java +++ b/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/jtagdevice/DefaultGDBJtagDeviceImpl.java @@ -79,7 +79,13 @@ public class DefaultGDBJtagDeviceImpl implements IGDBJtagDevice { */ @Override public void doContinue(Collection commands) { - String cmd = "continue"; //$NON-NLS-1$ + // The CLI version "continue" causes GDB to block and would not be + // able to respond other MI commands, this is a problem + // when running in async mode as it depends on the processing + // of MI commands e.g. to suspend the program. + // Therefore we need to use the MI command version "-exec-continue" + // which does not block GDB. + String cmd = "-exec-continue"; //$NON-NLS-1$ addCmd(commands, cmd); }