1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-21 21:52:10 +02:00

Bug 535143: Support multiple remote debug protocols

Change-Id: If3362e3742aa05a8577faa217b46c41dcddb792f
This commit is contained in:
John Dallaway 2022-04-21 22:24:30 +01:00
parent a1c02e2cce
commit 90627bfa83
17 changed files with 284 additions and 111 deletions

View file

@ -2,14 +2,14 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.cdt.debug.gdbjtag.core.tests;singleton:=true
Bundle-Version: 1.0.300.qualifier
Bundle-Version: 1.0.400.qualifier
Bundle-Activator: org.eclipse.cdt.debug.gdbjtag.core.tests.Activator
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.cdt.tests.dsf.gdb;bundle-version="2.3.0",
org.junit,
org.eclipse.cdt.debug.core,
org.eclipse.cdt.dsf.gdb,
org.eclipse.cdt.debug.gdbjtag.core;bundle-version="9.2.1",
org.eclipse.cdt.debug.gdbjtag.core;bundle-version="10.6.0",
org.eclipse.cdt.dsf,
org.eclipse.cdt.launch,
org.eclipse.debug.core

View file

@ -21,7 +21,7 @@
<relativePath>../../pom.xml</relativePath>
</parent>
<version>1.0.300-SNAPSHOT</version>
<version>1.0.400-SNAPSHOT</version>
<artifactId>org.eclipse.cdt.debug.gdbjtag.core.tests</artifactId>
<packaging>eclipse-test-plugin</packaging>

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2012, 2018 Ericsson and others.
* Copyright (c) 2012, 2022 Ericsson and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@ -12,7 +12,7 @@
* Marc Khouzam (Ericsson) - Base Implementation
* John Dallaway - GDB JTAG Implementation (bug 538282)
*******************************************************************************/
package org.eclipse.cdt.debug.gdbjtag.core.tests.launch;
package org.eclipse.cdt.debug.gdbjtag.core.tests;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2016, 2018 QNX Software System and others.
* Copyright (c) 2016, 2022 QNX Software System and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@ -12,8 +12,10 @@
* Elena Laskavaia (QNX Software System) - Base API and implementation
* John Dallaway - GDB JTAG implementation (bug 538282)
*******************************************************************************/
package org.eclipse.cdt.debug.gdbjtag.core.tests.launch;
package org.eclipse.cdt.debug.gdbjtag.core.tests;
import org.eclipse.cdt.debug.gdbjtag.core.tests.jtagdevice.GDBJtagDeviceContributionTest;
import org.eclipse.cdt.debug.gdbjtag.core.tests.launch.GDBJtagLaunchTest;
import org.eclipse.cdt.tests.dsf.gdb.framework.BaseParametrizedTestCase;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
@ -21,7 +23,7 @@ import org.junit.runners.Suite;
@SuppressWarnings("restriction")
@RunWith(Suite.class)
@Suite.SuiteClasses({ GDBJtagLaunchTest.class })
@Suite.SuiteClasses({ GDBJtagDeviceContributionTest.class, GDBJtagLaunchTest.class })
public class SuiteGDBJtag {

View file

@ -0,0 +1,41 @@
/*******************************************************************************
* Copyright (c) 2022 John Dallaway 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 - Initial implementation (Bug 535143)
*******************************************************************************/
package org.eclipse.cdt.debug.gdbjtag.core.tests.jtagdevice;
import static org.junit.Assert.assertArrayEquals;
import org.eclipse.cdt.debug.gdbjtag.core.IGDBJtagConnection;
import org.eclipse.cdt.debug.gdbjtag.core.jtagdevice.GDBJtagDeviceContribution;
import org.eclipse.cdt.debug.gdbjtag.core.jtagdevice.GDBJtagDeviceContributionFactory;
import org.junit.Test;
import junit.framework.TestCase;
public class GDBJtagDeviceContributionTest extends TestCase {
private static final String TEST_JTAG_DEVICE_ID = "org.eclipse.cdt.debug.gdbjtag.core.jtagdevice.genericDevice"; //$NON-NLS-1$
private static final String EXPECTED_PROTOCOLS = "remote,extended-remote"; //$NON-NLS-1$
private static final String EXPECTED_DEFAULT_CONNECTION = "localhost:1234"; //$NON-NLS-1$
@Test
public void testGdbJtagDeviceContribution() {
final GDBJtagDeviceContribution contribution = GDBJtagDeviceContributionFactory.getInstance()
.findByDeviceId(TEST_JTAG_DEVICE_ID);
assertNotNull(contribution);
final IGDBJtagConnection device = (IGDBJtagConnection) contribution.getDevice();
assertArrayEquals(EXPECTED_PROTOCOLS.split(","), device.getDeviceProtocols());
assertEquals(EXPECTED_DEFAULT_CONNECTION, device.getDefaultDeviceConnection());
}
}

View file

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<component id="org.eclipse.cdt.debug.gdbjtag.core" version="2">
<resource path="src/org/eclipse/cdt/debug/gdbjtag/core/IGDBJtagConnection.java" type="org.eclipse.cdt.debug.gdbjtag.core.IGDBJtagConnection">
<filter id="404000815">
<message_arguments>
<message_argument value="org.eclipse.cdt.debug.gdbjtag.core.IGDBJtagConnection"/>
<message_argument value="doTarget(String, String, Collection&lt;String&gt;)"/>
</message_arguments>
</filter>
<filter id="404000815">
<message_arguments>
<message_argument value="org.eclipse.cdt.debug.gdbjtag.core.IGDBJtagConnection"/>
<message_argument value="getDeviceProtocols()"/>
</message_arguments>
</filter>
<filter id="404000815">
<message_arguments>
<message_argument value="org.eclipse.cdt.debug.gdbjtag.core.IGDBJtagConnection"/>
<message_argument value="setDeviceProtocols(String[])"/>
</message_arguments>
</filter>
</resource>
</component>

View file

@ -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: 10.5.300.qualifier
Bundle-Version: 10.6.0.qualifier
Bundle-Activator: org.eclipse.cdt.debug.gdbjtag.core.Activator
Bundle-Localization: plugin
Require-Bundle: org.eclipse.core.runtime,

View file

@ -27,63 +27,73 @@
point="org.eclipse.cdt.debug.gdbjtag.core.JTagDevice">
<device
class="org.eclipse.cdt.debug.gdbjtag.core.jtagdevice.GenericDevice"
default_connection="localhost:10000"
default_connection="localhost:1234"
id="org.eclipse.cdt.debug.gdbjtag.core.jtagdevice.genericDevice"
name="%Generic.name">
name="%Generic.name"
protocols="remote,extended-remote">
</device>
<device
class="org.eclipse.cdt.debug.gdbjtag.core.jtagdevice.AbatronBDI2000"
default_connection="bdi2000:2001"
id="org.eclipse.cdt.debug.gdbjtag.core.jtagdevice.AbatronBDI2000"
name="%AbatronBDI2000.name">
name="%AbatronBDI2000.name"
protocols="remote">
</device>
<device
class="org.eclipse.cdt.debug.gdbjtag.core.jtagdevice.MacraigorUsb2Demon"
default_connection="localhost:8888"
id="org.eclipse.cdt.debug.gdbjtag.core.jtagdevice.MacraigorUsb2Demon"
name="%MacraigorUsb2Demon.name">
name="%MacraigorUsb2Demon.name"
protocols="remote">
</device>
<device
class="org.eclipse.cdt.debug.gdbjtag.core.jtagdevice.DefaultGDBJtagConnectionImpl"
default_connection="/dev/com1"
default_connection="COM1"
id="org.eclipse.cdt.debug.gdbjtag.core.jtagdevice.GenericSerial"
name="%GenericSerial.name">
name="%GenericSerial.name"
protocols="remote,extended-remote">
</device>
<device
class="org.eclipse.cdt.debug.gdbjtag.core.jtagdevice.OpenOCDPipe"
default_connection="| openocd --pipe"
id="org.eclipse.cdt.debug.gdbjtag.core.jtagdevice.OpenOCD"
name="%OpenOCDPipe.name">
name="%OpenOCDPipe.name"
protocols="remote">
</device>
<device
class="org.eclipse.cdt.debug.gdbjtag.core.jtagdevice.OpenOCDSocket"
default_connection="localhost:3333"
id="org.eclipse.cdt.debug.gdbjtag.core.jtagdevice.OpenOCDSocket"
name="%OpenOCDSocket.name">
name="%OpenOCDSocket.name"
protocols="remote">
</device>
<device
class="org.eclipse.cdt.debug.gdbjtag.core.jtagdevice.PEMicro"
default_connection="localhost:7224"
id="org.eclipse.cdt.debug.gdbjtag.core.jtagdevice.PEMicro"
name="%PEMicro.name">
name="%PEMicro.name"
protocols="remote">
</device>
<device
class="org.eclipse.cdt.debug.gdbjtag.core.jtagdevice.PyOCD"
default_connection="localhost:3333"
id="org.eclipse.cdt.debug.gdbjtag.core.jtagdevice.PyOCD"
name="%PyOCD.name">
name="%PyOCD.name"
protocols="remote">
</device>
<device
class="org.eclipse.cdt.debug.gdbjtag.core.jtagdevice.SeggerJLink"
default_connection="localhost:2331"
id="org.eclipse.cdt.debug.gdbjtag.core.jtagdevice.SeggerJLink"
name="%SeggerJLink.name">
name="%SeggerJLink.name"
protocols="remote">
</device>
<device
class="org.eclipse.cdt.debug.gdbjtag.core.jtagdevice.STLink"
default_connection="localhost:61234"
id="org.eclipse.cdt.debug.gdbjtag.core.jtagdevice.STLink"
name="%STLink.name">
name="%STLink.name"
protocols="remote">
</device>
</extension>
</plugin>

View file

@ -80,6 +80,13 @@
</documentation>
</annotation>
</attribute>
<attribute name="protocols" type="string">
<annotation>
<documentation>
The comma-separated set of GDB target types (protocols) supported by the JTAG device. If omitted, the &quot;remote&quot; protocol is assumed.
</documentation>
</annotation>
</attribute>
</complexType>
</element>

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2007, 2021 QNX Software Systems and others.
* Copyright (c) 2007, 2022 QNX Software Systems and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@ -26,6 +26,7 @@
* John Dallaway - Eliminate deprecated API (Bug 566462)
* John Dallaway - Set executable file (Bug 457697)
* John Dallaway - Initialize memory data before connecting to target (Bug 575934)
* John Dallaway - Support multiple remote debug protocols (Bug 535143)
*******************************************************************************/
package org.eclipse.cdt.debug.gdbjtag.core;
@ -421,8 +422,10 @@ public class GDBJtagDSFFinalLaunchSequence extends FinalLaunchSequence {
connection = String.format("%s:%d", ipAddress, portNumber); //$NON-NLS-1$
}
}
String protocol = CDebugUtils.getAttribute(getAttributes(), IGDBJtagConstants.ATTR_PROTOCOL,
IGDBJtagConstants.DEFAULT_PROTOCOL);
IGDBJtagConnection device = (IGDBJtagConnection) fGdbJtagDevice;
device.doRemote(connection, commands);
device.doTarget(protocol, connection, commands);
queueCommands(commands, rm);
} else {
rm.done();

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2008-2010 QNX Software Systems and others.
* Copyright (c) 2008, 2022 QNX Software Systems and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@ -14,6 +14,7 @@
* Sage Electronic Engineering, LLC - bug 305943
* - API generalization to become transport-independent (e.g. to
* allow connections via serial ports and pipes).
* John Dallaway - Support multiple remote debug protocols - bug 535143
*******************************************************************************/
package org.eclipse.cdt.debug.gdbjtag.core;
@ -22,25 +23,52 @@ import java.util.Collection;
/**
* Provides device specific debug commands for different hardware
* JTAG devices. See <code>DefaultGDBJtagDeviceImpl</code> for
* the default implementations.
* JTAG devices. See <code>DefaultGDBJtagConnectionImpl</code> for
* the default implementation.
* @since 7.0
*/
public interface IGDBJtagConnection {
/**
* Used during instantiation to set the supported protocol strings from XML
* @param protocols
* the array of supported protocols (default protocol first)
* @since 10.6
*/
default void setDeviceProtocols(String[] protocols) {
// not implemented
}
/**
* Used during instantiation to set the device default connection string from XML
* @param connection A device specific default connection string that GDB understands
* @param connection
* the GDB string describing the default connection to the target
*/
public void setDefaultDeviceConnection(String connection);
/**
* Commands to connect to remote JTAG device
* @param connection defines the gdb string required to establish a connection to the target
* @param commands gdb commands to execute on the remote device (usually the target probe)
* @param connection
* the GDB string describing the connection to the target
* @param commands
* implementation should populate the collection with the gdb
* commands that will connect to the JTAG device using the remote
* protocol, or leave the collection as-is if that operation is
* either unsupported or not applicable
* @deprecated call or override {@link #doTarget(String, String, Collection)} instead
*/
@Deprecated(since = "10.6")
public void doRemote(String connection, Collection<String> commands);
/**
* Supported protocols used by GDB to connect to a device
* @return the array of supported protocols (default protocol first)
* @since 10.6
*/
default String[] getDeviceProtocols() {
return new String[] { "remote" }; //$NON-NLS-1$
}
/**
* Host specific default device name used by GDB to connect to a device
* @return identifier for the remote device. It is up to GDB to figure out how to interpret
@ -48,4 +76,23 @@ public interface IGDBJtagConnection {
*/
public String getDefaultDeviceConnection();
/**
* Commands to connect to remote JTAG device
* @param protocol
* the GDB string describing the communication protocol between host and target
* @param connection
* the GDB string required to establish a connection to the target
* @param commands
* implementation should populate the collection with the gdb
* commands that will connect to the JTAG device, or leave
* the collection as-is if that operation is either unsupported
* or not applicable
* @since 10.6
*/
default void doTarget(String protocol, String connection, Collection<String> commands) {
if ("remote".equals(protocol)) { //$NON-NLS-1$
doRemote(connection, commands);
} // else protocol not supported
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2007 - 2020 QNX Software Systems and others.
* Copyright (c) 2007, 2022 QNX Software Systems and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@ -15,6 +15,7 @@
* Torbjörn Svensson (STMicroelectronics) - Bug 535024
* John Dallaway - Sort JTAG device list, bug 560186
* John Dallaway - Eliminate deprecated API, bug 566462
* John Dallaway - Support multiple remote debug protocols, bug 535143
*******************************************************************************/
package org.eclipse.cdt.debug.gdbjtag.core;
@ -52,6 +53,8 @@ public interface IGDBJtagConstants {
public static final String ATTR_STOP_AT = Activator.PLUGIN_ID + ".stopAt"; //$NON-NLS-1$
public static final String ATTR_SET_RESUME = Activator.PLUGIN_ID + ".setResume"; //$NON-NLS-1$
public static final String ATTR_RUN_COMMANDS = Activator.PLUGIN_ID + ".runCommands"; //$NON-NLS-1$
/** @since 10.6 */
public static final String ATTR_PROTOCOL = Activator.PLUGIN_ID + ".protocol"; //$NON-NLS-1$
/** @since 7.0 */
public static final String ATTR_CONNECTION = Activator.PLUGIN_ID + ".connection"; //$NON-NLS-1$
/** @since 7.0 */
@ -73,6 +76,8 @@ public interface IGDBJtagConstants {
public static final boolean DEFAULT_SET_RESUME = false;
public static final boolean DEFAULT_USE_DEFAULT_RUN = true;
/** @since 10.6 */
public static final String DEFAULT_PROTOCOL = "remote"; //$NON-NLS-1$
/** @since 7.0 */
public static final String DEFAULT_CONNECTION = "unspecified-ip-address:unspecified-port-number"; //$NON-NLS-1$
/** @since 7.0 */

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2010, 2020 Sage Electronic Engineering and others.
* Copyright (c) 2010, 2022 Sage Electronic Engineering and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@ -13,6 +13,7 @@
* - API generalization to become transport-independent (e.g. to
* allow connections via serial ports and pipes).
* John Dallaway - Eliminate deprecated API - bug 566462
* John Dallaway - Support multiple remote debug protocols - bug 535143
*******************************************************************************/
package org.eclipse.cdt.debug.gdbjtag.core.jtagdevice;
@ -26,14 +27,24 @@ import org.eclipse.cdt.debug.gdbjtag.core.IGDBJtagConnection;
*/
public class DefaultGDBJtagConnectionImpl extends DefaultGDBJtagDeviceImpl implements IGDBJtagConnection {
private static final String PROTOCOL_REMOTE = "remote"; //$NON-NLS-1$
private String[] protocols = new String[0];
protected String connection = null;
@Override
public final void setDeviceProtocols(String[] protocols) {
this.protocols = protocols;
}
@Override
public final void setDefaultDeviceConnection(String connection) {
this.connection = connection;
}
/** @deprecated call or override {@link #doTarget(String, String, Collection)} instead */
@Override
@Deprecated(since = "10.6")
public void doRemote(String connection, Collection<String> commands) {
String cmd = ""; //$NON-NLS-1$
if (connection != null) {
@ -47,6 +58,21 @@ public class DefaultGDBJtagConnectionImpl extends DefaultGDBJtagDeviceImpl imple
}
}
@Override
public void doTarget(String protocol, String connection, Collection<String> commands) {
if (PROTOCOL_REMOTE.equals(protocol)) {
doRemote(connection, commands); // use legacy method which may have been overridden
} else if ((connection != null) && (protocol != null)) {
String cmd = String.format("-target-select %s %s", protocol, connection); //$NON-NLS-1$
addCmd(commands, cmd);
}
}
@Override
public String[] getDeviceProtocols() {
return protocols;
}
@Override
public String getDefaultDeviceConnection() {
return connection;

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2008 - 2020 QNX Software Systems and others.
* Copyright (c) 2008, 2022 QNX Software Systems and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@ -15,6 +15,7 @@
* - API generalization to become transport-independent (allow
* connections via serial ports and pipes).
* John Dallaway - Eliminate deprecated API - bug 566462
* John Dallaway - Support multiple remote debug protocols - bug 535143
*******************************************************************************/
package org.eclipse.cdt.debug.gdbjtag.core.jtagdevice;
@ -33,6 +34,7 @@ public class GDBJtagDeviceContribution {
private IGDBJtagDevice device;
private String deviceClassBundleName;
private String deviceDefaultConnection;
private String[] deviceProtocols;
/**
* @return the deviceId
@ -98,6 +100,7 @@ public class GDBJtagDeviceContribution {
try {
o = Platform.getBundle(deviceClassBundleName).loadClass(deviceClassName).getConstructor().newInstance();
if (o instanceof IGDBJtagConnection) {
((IGDBJtagConnection) o).setDeviceProtocols(deviceProtocols);
((IGDBJtagConnection) o).setDefaultDeviceConnection(deviceDefaultConnection);
}
device = (IGDBJtagDevice) o;
@ -110,4 +113,14 @@ public class GDBJtagDeviceContribution {
}
/** @since 10.6 */
public void setDeviceProtocols(String[] protocols) {
deviceProtocols = protocols;
}
/** @since 10.6 */
public String[] getDeviceProtocols() {
return deviceProtocols;
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2008, 2018 QNX Software Systems and others.
* Copyright (c) 2008, 2022 QNX Software Systems and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@ -15,10 +15,12 @@
* - API generalization to become transport-independent (allow
* connections via serial ports and pipes).
* Torbjörn Svensson (STMicroelectronics) - Bug 535024
* John Dallaway - Support multiple remote debug protocols - bug 535143
*******************************************************************************/
package org.eclipse.cdt.debug.gdbjtag.core.jtagdevice;
import java.util.ArrayList;
import java.util.Arrays;
import org.eclipse.cdt.debug.gdbjtag.core.Activator;
import org.eclipse.cdt.debug.gdbjtag.core.IGDBJtagConstants;
@ -60,11 +62,15 @@ public class GDBJtagDeviceContributionFactory {
String className = getRequired(configurationElement, "class"); //$NON-NLS-1$
String connection = getOptional(configurationElement, "default_connection", //$NON-NLS-1$
IGDBJtagConstants.DEFAULT_CONNECTION);
String[] protocols = getOptional(configurationElement, "protocols", //$NON-NLS-1$
IGDBJtagConstants.DEFAULT_PROTOCOL).split(","); //$NON-NLS-1$
GDBJtagDeviceContribution adapter = new GDBJtagDeviceContribution();
adapter.setDeviceId(id);
adapter.setDeviceName(name);
adapter.setDeviceClassName(className);
adapter.setDeviceDefaultConnection(connection);
adapter.setDeviceProtocols(
Arrays.stream(protocols).map(String::trim).filter(s -> !s.isEmpty()).toArray(String[]::new));
adapter.setDeviceClassBundleName(configurationElement.getContributor().getName());
addContribution(adapter);
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2007, 2021 QNX Software Systems and others.
* Copyright (c) 2007, 2022 QNX Software Systems and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@ -23,6 +23,7 @@
* John Dallaway - Sort JTAG device list, bug 560186
* John Dallaway - Eliminate deprecated API, bug 566462
* John Dallaway - Eliminate pixel-level sizing, bug 567662
* John Dallaway - Support multiple remote debug protocols, bug 535143
*******************************************************************************/
package org.eclipse.cdt.debug.gdbjtag.ui;
@ -50,10 +51,11 @@ import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
import org.eclipse.debug.ui.StringVariableSelectionDialog;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.layout.PixelConverter;
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.ComboViewer;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StackLayout;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
@ -82,10 +84,11 @@ public class GDBJtagDSFDebuggerTab extends AbstractLaunchConfigurationTab {
private Text gdbCommand;
private Button useRemote;
private Label jtagDeviceLabel;
private Combo jtagDevice;
private Composite remoteConnectionParameters;
private StackLayout remoteConnectParmsLayout;
private Composite remoteConnectionBox;
private Label protocolLabel;
private ComboViewer protocol;
private Label connectionLabel;
private Text connection;
private String savedJtagDevice;
protected Button fUpdateThreadlistOnSuspend;
@ -205,15 +208,13 @@ public class GDBJtagDSFDebuggerTab extends AbstractLaunchConfigurationTab {
private void createRemoteControl(Composite parent) {
Group group = new Group(parent, SWT.NONE);
GridLayout layout = new GridLayout(2, false);
GridLayout layout = new GridLayout();
group.setLayout(layout);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
group.setLayoutData(gd);
group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
group.setText(Messages.getString("GDBJtagDebuggerTab.remoteGroup_Text")); //$NON-NLS-1$
useRemote = new Button(group, SWT.CHECK);
useRemote.setLayoutData(GridDataFactory.swtDefaults().span(2, 1).create());
useRemote.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
useRemote.setText(Messages.getString("GDBJtagDebuggerTab.useRemote_Text")); //$NON-NLS-1$
useRemote.addSelectionListener(new SelectionAdapter() {
@Override
@ -223,7 +224,16 @@ public class GDBJtagDSFDebuggerTab extends AbstractLaunchConfigurationTab {
}
});
remoteTimeoutEnabled = new Button(group, SWT.CHECK);
Composite comp = new Composite(group, SWT.NONE);
layout = new GridLayout();
layout.numColumns = 2;
layout.marginHeight = 0;
layout.marginLeft = new PixelConverter(group).convertHorizontalDLUsToPixels(8);
layout.marginRight = 0;
comp.setLayout(layout);
comp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
remoteTimeoutEnabled = new Button(comp, SWT.CHECK);
remoteTimeoutEnabled.setText(Messages.getString("GDBJtagDebuggerTab.remoteTimeout")); //$NON-NLS-1$
remoteTimeoutEnabled.setToolTipText(Messages.getString("GDBJtagDebuggerTab.remoteTimeoutTooltip")); //$NON-NLS-1$
remoteTimeoutEnabled.addSelectionListener(new SelectionAdapter() {
@ -233,22 +243,15 @@ public class GDBJtagDSFDebuggerTab extends AbstractLaunchConfigurationTab {
updateLaunchConfigurationDialog();
}
});
remoteTimeoutValue = new Text(group, SWT.BORDER);
gd = new GridData();
gd.widthHint = new PixelConverter(remoteTimeoutValue).convertWidthInCharsToPixels(10);
remoteTimeoutValue.setLayoutData(gd);
remoteTimeoutValue = new Text(comp, SWT.BORDER);
remoteTimeoutValue.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
remoteTimeoutValue.setToolTipText(Messages.getString("GDBJtagDebuggerTab.remoteTimeoutTooltip")); //$NON-NLS-1$
Composite comp = new Composite(group, SWT.NONE);
layout = new GridLayout();
layout.numColumns = 2;
comp.setLayout(layout);
comp.setLayoutData(GridDataFactory.swtDefaults().span(2, 1).grab(true, false).create());
Label label = new Label(comp, SWT.NONE);
label.setText(Messages.getString("GDBJtagDebuggerTab.jtagDeviceLabel")); //$NON-NLS-1$
jtagDeviceLabel = new Label(comp, SWT.NONE);
jtagDeviceLabel.setText(Messages.getString("GDBJtagDebuggerTab.jtagDeviceLabel")); //$NON-NLS-1$
jtagDevice = new Combo(comp, SWT.READ_ONLY | SWT.DROP_DOWN);
jtagDevice.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
GDBJtagDeviceContribution[] availableDevices = GDBJtagDeviceContributionFactory.getInstance()
.getGDBJtagDeviceContribution();
@ -263,58 +266,50 @@ public class GDBJtagDSFDebuggerTab extends AbstractLaunchConfigurationTab {
}
});
remoteConnectionParameters = new Composite(group, SWT.NO_TRIM | SWT.NO_FOCUS);
remoteConnectParmsLayout = new StackLayout();
remoteConnectionParameters.setLayout(remoteConnectParmsLayout);
remoteConnectionParameters.setLayoutData(GridDataFactory.fillDefaults().span(2, 1).create());
protocolLabel = new Label(comp, SWT.NONE);
protocolLabel.setText(Messages.getString("GDBJtagDebuggerTab.protocolLabel")); //$NON-NLS-1$
protocol = new ComboViewer(comp, SWT.READ_ONLY | SWT.DROP_DOWN);
protocol.setContentProvider(new ArrayContentProvider());
protocol.getCombo().setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
//
// Create entry fields for other types of connections
//
{
remoteConnectionBox = new Composite(remoteConnectionParameters, SWT.NO_TRIM | SWT.NO_FOCUS);
layout = new GridLayout();
layout.numColumns = 2;
remoteConnectionBox.setLayout(layout);
remoteConnectionBox.setBackground(remoteConnectionParameters.getParent().getBackground());
label = new Label(remoteConnectionBox, SWT.NONE);
label.setText(Messages.getString("GDBJtagDebuggerTab.connectionLabel")); //$NON-NLS-1$
connection = new Text(remoteConnectionBox, SWT.BORDER);
gd = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
connection.setLayoutData(gd);
}
connectionLabel = new Label(comp, SWT.NONE);
connectionLabel.setText(Messages.getString("GDBJtagDebuggerTab.connectionLabel")); //$NON-NLS-1$
connection = new Text(comp, SWT.BORDER);
connection.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
//
// Add watchers for user data entry
//
connection.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
scheduleUpdateJob(); // provides much better performance for Text listeners
}
});
protocol.getCombo().addListener(SWT.Selection, e -> scheduleUpdateJob());
connection.addListener(SWT.Modify, e -> scheduleUpdateJob());
}
/**
* @param text
*/
protected void updateDeviceIpPort(String selectedDeviceName) {
if (selectedDeviceName.equals(savedJtagDevice)) {
return;
if (!selectedDeviceName.equals(savedJtagDevice)) {
resetTargetParameters(selectedDeviceName);
}
}
private void resetTargetParameters(String deviceName) {
GDBJtagDeviceContribution[] availableDevices = GDBJtagDeviceContributionFactory.getInstance()
.getGDBJtagDeviceContribution();
IGDBJtagDevice selectedDevice = null;
for (int i = 0; i < availableDevices.length; i++) {
String name = availableDevices[i].getDeviceName();
if (name.equals(selectedDeviceName)) {
if (name.equals(deviceName)) {
selectedDevice = availableDevices[i].getDevice();
if (selectedDevice != null) {
if (selectedDevice instanceof IGDBJtagConnection) {
IGDBJtagConnection connectionDevice = (IGDBJtagConnection) selectedDevice;
connection.setText(connectionDevice.getDefaultDeviceConnection());
String[] protocols = connectionDevice.getDeviceProtocols();
protocol.setInput(protocols);
if (0 != protocols.length) {
protocol.setSelection(new StructuredSelection(protocols[0]));
}
}
useRemoteChanged();
updateLaunchConfigurationDialog();
@ -331,24 +326,13 @@ public class GDBJtagDSFDebuggerTab extends AbstractLaunchConfigurationTab {
private void useRemoteChanged() {
boolean enabled = useRemote.getSelection();
remoteTimeoutEnabled.setEnabled(enabled);
remoteTimeoutValue.setEnabled(remoteTimeoutEnabled.getSelection());
remoteTimeoutValue.setEnabled(enabled && remoteTimeoutEnabled.getSelection());
jtagDeviceLabel.setEnabled(enabled);
jtagDevice.setEnabled(enabled);
protocolLabel.setEnabled(enabled);
protocol.getCombo().setEnabled(enabled);
connectionLabel.setEnabled(enabled);
connection.setEnabled(enabled);
GDBJtagDeviceContribution selectedDeviceEntry = GDBJtagDeviceContributionFactory.getInstance()
.findByDeviceName(jtagDevice.getText());
if ((selectedDeviceEntry == null) || (selectedDeviceEntry.getDevice() == null)) {
remoteConnectParmsLayout.topControl = null;
remoteConnectionParameters.layout();
} else {
IGDBJtagDevice device = selectedDeviceEntry.getDevice();
if (device instanceof IGDBJtagConnection) {
remoteConnectParmsLayout.topControl = remoteConnectionBox;
remoteConnectionBox.getParent().layout();
} else {
remoteConnectParmsLayout.topControl = null;
remoteConnectionParameters.layout();
}
}
}
/**
@ -434,28 +418,31 @@ public class GDBJtagDSFDebuggerTab extends AbstractLaunchConfigurationTab {
String storedAddress = ""; //$NON-NLS-1$
int storedPort = -1;
String storedConnection = null;
String storedProtocol = null;
for (int i = 0; i < jtagDevice.getItemCount(); i++) {
if (jtagDevice.getItem(i).equals(savedJtagDevice)) {
storedAddress = configuration.getAttribute(IGDBJtagConstants.ATTR_IP_ADDRESS, ""); //$NON-NLS-1$
storedPort = configuration.getAttribute(IGDBJtagConstants.ATTR_PORT_NUMBER, -1);
storedConnection = configuration.getAttribute(IGDBJtagConstants.ATTR_CONNECTION, (String) null);
storedProtocol = configuration.getAttribute(IGDBJtagConstants.ATTR_PROTOCOL, (String) null);
jtagDevice.select(i);
resetTargetParameters(savedJtagDevice);
break;
}
}
String connectionText = IGDBJtagConstants.DEFAULT_CONNECTION;
if (null != storedProtocol) {
protocol.setSelection(new StructuredSelection(storedProtocol));
}
if (null != storedConnection) { // if a connection URI
try {
connectionText = new URI(storedConnection).getSchemeSpecificPart();
connection.setText(new URI(storedConnection).getSchemeSpecificPart());
} catch (URISyntaxException e) {
Activator.log(e);
}
} else if (storedPort != -1) { // if a legacy address:port
connectionText = String.format("%s:%d", storedAddress, storedPort); //$NON-NLS-1$
connection.setText(String.format("%s:%d", storedAddress, storedPort)); //$NON-NLS-1$
}
connection.setText(connectionText);
}
boolean updateThreadsOnSuspend = configuration.getAttribute(
IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_UPDATE_THREADLIST_ON_SUSPEND,
@ -505,10 +492,12 @@ public class GDBJtagDSFDebuggerTab extends AbstractLaunchConfigurationTab {
if (device instanceof IGDBJtagConnection) {
String conn = connection.getText().trim();
URI uri = new URI("gdb", conn, ""); //$NON-NLS-1$ //$NON-NLS-2$
configuration.setAttribute(IGDBJtagConstants.ATTR_PROTOCOL, protocol.getCombo().getText());
configuration.setAttribute(IGDBJtagConstants.ATTR_CONNECTION, uri.toString());
configuration.removeAttribute(IGDBJtagConstants.ATTR_IP_ADDRESS);
configuration.removeAttribute(IGDBJtagConstants.ATTR_PORT_NUMBER);
} else {
configuration.removeAttribute(IGDBJtagConstants.ATTR_PROTOCOL);
configuration.removeAttribute(IGDBJtagConstants.ATTR_CONNECTION);
}
} catch (URISyntaxException e) {

View file

@ -65,11 +65,12 @@ GDBJtagDebuggerTab.miProtocolLabel=Protocol Version:
GDBJtagDebuggerTab.verboseModeLabel=Verbose console mode
GDBJtagDebuggerTab.remoteGroup_Text=Remote Target
GDBJtagDebuggerTab.useRemote_Text=Use remote target
GDBJtagDebuggerTab.jtagDeviceLabel=JTAG Device:
GDBJtagDebuggerTab.jtagDeviceLabel=Debug server:
GDBJtagDebuggerTab.ipAddressLabel=Host name or IP address:
GDBJtagDebuggerTab.portNumberLabel=Port number:
GDBJtagDebuggerTab.connectionLabel=GDB Connection String:
GDBJtagDebuggerTab.protocolLabel=Protocol:
GDBJtagDebuggerTab.connectionLabel=Connection:
GDBJtagDebuggerTab.update_thread_list_on_suspend=Force thread list update on suspend
GDBJtagDebuggerTab.remoteTimeout=Remote timeout (seconds):
GDBJtagDebuggerTab.remoteTimeout=Timeout (seconds):
GDBJtagDebuggerTab.remoteTimeoutTooltip=Timeout for the remote target to respond. If unchecked, uses GDB default value. See GDB's help for "set remotetimeout num".
GDBJtagDebuggerTab.tabName=Debugger