1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-08 02:06:01 +02:00

Bug 305943 Support for transport specific devices, based on patch from Bruce Griffith

This commit is contained in:
Alena Laskavaia 2010-05-06 16:57:16 +00:00
parent 221d891570
commit 9b9fedb9fd
15 changed files with 580 additions and 137 deletions

View file

@ -1,16 +1,21 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<!-- Schema file written by PDE --> <!-- Schema file written by PDE -->
<schema targetNamespace="org.eclipse.cdt.debug.gdbjtag.core"> <schema targetNamespace="org.eclipse.cdt.debug.gdbjtag.core" xmlns="http://www.w3.org/2001/XMLSchema">
<annotation> <annotation>
<appInfo> <appInfo>
<meta.schema plugin="org.eclipse.cdt.debug.gdbjtag.core" id="JTagDevice" name="%JTagDevice.name"/> <meta.schema plugin="org.eclipse.cdt.debug.gdbjtag.core" id="JTagDevice" name="%JTagDevice.name"/>
</appInfo> </appInfo>
<documentation> <documentation>
[Enter description of this extension point.] Jtag device extension point
</documentation> </documentation>
</annotation> </annotation>
<element name="extension"> <element name="extension">
<annotation>
<appInfo>
<meta.element />
</appInfo>
</annotation>
<complexType> <complexType>
<sequence> <sequence>
<element ref="device" minOccurs="1" maxOccurs="unbounded"/> <element ref="device" minOccurs="1" maxOccurs="unbounded"/>
@ -44,27 +49,37 @@
<attribute name="id" type="string" use="required"> <attribute name="id" type="string" use="required">
<annotation> <annotation>
<documentation> <documentation>
Unique if of the jtag device contribution.
</documentation> </documentation>
</annotation> </annotation>
</attribute> </attribute>
<attribute name="name" type="string" use="required"> <attribute name="name" type="string" use="required">
<annotation> <annotation>
<documentation> <documentation>
Name of the JTag device.
</documentation> </documentation>
</annotation> </annotation>
</attribute> </attribute>
<attribute name="class" type="string" use="required"> <attribute name="class" type="string" use="required">
<annotation> <annotation>
<documentation> <documentation>
Class that implements IGDBJtagDevice and provides default commands used by debbuger for various set-up tasks. It is recommended tp extend DefaultGDBJtagConnectionImpl class.
</documentation> </documentation>
<appInfo> <appInfo>
<meta.attribute kind="java" basedOn=":org.eclipse.cdt.debug.gdbjtag.core.jtagdevice.IGDBJtagDevice"/> <meta.attribute kind="java" basedOn=":org.eclipse.cdt.debug.gdbjtag.core.jtagdevice.IGDBJtagDevice"/>
</appInfo> </appInfo>
</annotation> </annotation>
</attribute> </attribute>
<attribute name="default_connection" type="string">
<annotation>
<documentation>
This field can be used to set the default connection string for GDB. It is
not used when the &quot;class&quot; parameter specifies a jtagdevice subclass that
overrides the default implementation of the getDefaultDeviceConnection()
method.
</documentation>
</annotation>
</attribute>
</complexType> </complexType>
</element> </element>
@ -73,7 +88,7 @@
<meta.section type="since"/> <meta.section type="since"/>
</appInfo> </appInfo>
<documentation> <documentation>
[Enter the first release in which this extension point appears.] 5.0
</documentation> </documentation>
</annotation> </annotation>
@ -104,13 +119,5 @@
</documentation> </documentation>
</annotation> </annotation>
<annotation>
<appInfo>
<meta.section type="copyright"/>
</appInfo>
<documentation>
</documentation>
</annotation>
</schema> </schema>

View file

@ -14,6 +14,7 @@ package org.eclipse.cdt.debug.gdbjtag.core;
import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Plugin; import org.eclipse.core.runtime.Plugin;
import org.eclipse.core.runtime.Status;
import org.osgi.framework.BundleContext; import org.osgi.framework.BundleContext;
/** /**
@ -74,5 +75,11 @@ public class Activator extends Plugin {
public static void log(IStatus status) { public static void log(IStatus status) {
getDefault().getLog().log(status); getDefault().getLog().log(status);
} }
/**
* @since 7.0
*/
public static void log(Throwable t) {
getDefault().getLog().log(new Status(Status.ERROR, PLUGIN_ID, t.getMessage(), t));
}
} }

View file

@ -8,6 +8,9 @@
* Contributors: * Contributors:
* Ericsson - initial API and implementation this class is based on * Ericsson - initial API and implementation this class is based on
* QNX Software Systems - Initial implementation for Jtag debugging * QNX Software Systems - Initial implementation for Jtag debugging
* Sage Electronic Engineering, LLC - bug 305943
* - API generalization to become transport-independent (allow
* connections via serial ports and pipes).
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.debug.gdbjtag.core; package org.eclipse.cdt.debug.gdbjtag.core;
@ -16,6 +19,8 @@ package org.eclipse.cdt.debug.gdbjtag.core;
* *
*/ */
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Iterator; import java.util.Iterator;
@ -373,10 +378,17 @@ public class GDBJtagDSFFinalLaunchSequence extends Sequence {
ILaunchConfiguration config = fLaunch.getLaunchConfiguration(); ILaunchConfiguration config = fLaunch.getLaunchConfiguration();
try { try {
if (config.getAttribute(IGDBJtagConstants.ATTR_USE_REMOTE_TARGET, IGDBJtagConstants.DEFAULT_USE_REMOTE_TARGET)) { if (config.getAttribute(IGDBJtagConstants.ATTR_USE_REMOTE_TARGET, IGDBJtagConstants.DEFAULT_USE_REMOTE_TARGET)) {
String ipAddress = config.getAttribute(IGDBJtagConstants.ATTR_IP_ADDRESS, IGDBJtagConstants.DEFAULT_IP_ADDRESS);
int portNumber = config.getAttribute(IGDBJtagConstants.ATTR_PORT_NUMBER, IGDBJtagConstants.DEFAULT_PORT_NUMBER);
List<String> commands = new ArrayList<String>(); List<String> commands = new ArrayList<String>();
if (fGdbJtagDevice instanceof IGDBJtagConnection) {
URI uri = new URI(config.getAttribute(IGDBJtagConstants.ATTR_IP_ADDRESS, ""));
IGDBJtagConnection device = (IGDBJtagConnection)fGdbJtagDevice;
device.doRemote(uri.getSchemeSpecificPart(), commands);
} else {
// Handle legacy network device contributions that don't understand URIs
String ipAddress = config.getAttribute(IGDBJtagConstants.ATTR_IP_ADDRESS, "");
int portNumber = config.getAttribute(IGDBJtagConstants.ATTR_PORT_NUMBER, 0);
fGdbJtagDevice.doRemote(ipAddress, portNumber, commands); fGdbJtagDevice.doRemote(ipAddress, portNumber, commands);
}
queueCommands(commands, rm); queueCommands(commands, rm);
} else { } else {
rm.done(); rm.done();
@ -384,6 +396,9 @@ public class GDBJtagDSFFinalLaunchSequence extends Sequence {
} catch (CoreException e) { } catch (CoreException e) {
rm.setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, -1, "Cannot connect to remote target", e)); //$NON-NLS-1$ rm.setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, -1, "Cannot connect to remote target", e)); //$NON-NLS-1$
rm.done(); rm.done();
} catch (URISyntaxException e) {
rm.setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, -1, "Invalid remote target connection syntax", e)); //$NON-NLS-1$
rm.done();
} }
}}, }},
/* /*

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2007 - 2008 QNX Software Systems and others. * Copyright (c) 2007 - 2010 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -9,11 +9,16 @@
* Doug Schaefer, Adrian Petrescu - QNX Software Systems - Initial API and implementation * Doug Schaefer, Adrian Petrescu - QNX Software Systems - Initial API and implementation
* Andy Jin - Hardware debugging UI improvements, bug 229946 * Andy Jin - Hardware debugging UI improvements, bug 229946
* Peter Vidler - Monitor support (progress and cancellation) bug 242699 * Peter Vidler - Monitor support (progress and cancellation) bug 242699
* Bruce Griffith, Sage Electronic Engineering, LLC - bug 305943
* - API generalization to become transport-independent (allow
* connections via serial ports and pipes).
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.debug.gdbjtag.core; package org.eclipse.cdt.debug.gdbjtag.core;
import java.io.File; import java.io.File;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -118,9 +123,19 @@ public class GDBJtagDebugger extends AbstractGDBCDIDebugger {
boolean useRemote = config.getAttribute(IGDBJtagConstants.ATTR_USE_REMOTE_TARGET, IGDBJtagConstants.DEFAULT_USE_REMOTE_TARGET); boolean useRemote = config.getAttribute(IGDBJtagConstants.ATTR_USE_REMOTE_TARGET, IGDBJtagConstants.DEFAULT_USE_REMOTE_TARGET);
if (useRemote) { if (useRemote) {
submonitor.subTask(Messages.getString("GDBJtagDebugger.2")); //$NON-NLS-1$ submonitor.subTask(Messages.getString("GDBJtagDebugger.2")); //$NON-NLS-1$
String ipAddress = config.getAttribute(IGDBJtagConstants.ATTR_IP_ADDRESS, IGDBJtagConstants.DEFAULT_IP_ADDRESS); try {
int portNumber = config.getAttribute(IGDBJtagConstants.ATTR_PORT_NUMBER, IGDBJtagConstants.DEFAULT_PORT_NUMBER); if (gdbJtagDevice instanceof IGDBJtagConnection) {
URI connection = new URI(config.getAttribute(IGDBJtagConstants.ATTR_CONNECTION, "")); //$NON-NLS-1$
IGDBJtagConnection device = (IGDBJtagConnection)gdbJtagDevice;
device.doRemote(connection.getSchemeSpecificPart(), commands);
} else {
String ipAddress = config.getAttribute(IGDBJtagConstants.ATTR_IP_ADDRESS, ""); //$NON-NLS-1$
int portNumber = config.getAttribute(IGDBJtagConstants.ATTR_PORT_NUMBER, 0);
gdbJtagDevice.doRemote(ipAddress, portNumber, commands); gdbJtagDevice.doRemote(ipAddress, portNumber, commands);
}
} catch (URISyntaxException e) {
throw new OperationCanceledException();
}
executeGDBScript(getGDBScript(commands), miSession, submonitor.newChild(10)); executeGDBScript(getGDBScript(commands), miSession, submonitor.newChild(10));
if (submonitor.isCanceled()) { if (submonitor.isCanceled()) {
throw new OperationCanceledException(); throw new OperationCanceledException();

View file

@ -0,0 +1,48 @@
/*******************************************************************************
* Copyright (c) 2008-2010 QNX Software Systems 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
*
* Contributors:
* QNX Software Systems - Initial API and implementation
* Andy Jin - Hardware debugging UI improvements, bug 229946
* Sage Electronic Engineering, LLC - bug 305943
* - API generalization to become transport-independent (e.g. to
* allow connections via serial ports and pipes).
*******************************************************************************/
package org.eclipse.cdt.debug.gdbjtag.core;
import java.util.Collection;
/**
* Provides device specific debug commands for different hardware
* JTAG devices. See <code>DefaultGDBJtagDeviceImpl</code> for
* the default implementations.
* @since 7.0
*/
public interface IGDBJtagConnection {
/**
* Used during instantiation to set the device default connection string from XML
* @param connection A device specific default connection string that GDB understands
*/
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)
*/
public void doRemote(String connection, Collection<String> commands);
/**
* 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
* the connection string (e.g /dev/COM1, 127.0.0.1:8888, etc.)
*/
public String getDefaultDeviceConnection();
}

View file

@ -23,13 +23,18 @@ public interface IGDBJtagConstants {
// Debugger // Debugger
public static final String ATTR_USE_REMOTE_TARGET = Activator.PLUGIN_ID + ".useRemoteTarget"; //$NON-NLS-1$ public static final String ATTR_USE_REMOTE_TARGET = Activator.PLUGIN_ID + ".useRemoteTarget"; //$NON-NLS-1$
public static final String ATTR_IP_ADDRESS = Activator.PLUGIN_ID + ".ipAddress"; //$NON-NLS-1$ public static final String ATTR_IP_ADDRESS = Activator.PLUGIN_ID + ".ipAddress"; //$NON-NLS-1$
/** @since 7.0 */
public static final String ATTR_CONNECTION = Activator.PLUGIN_ID + ".connection"; //$NON-NLS-1$
public static final String ATTR_PORT_NUMBER = Activator.PLUGIN_ID + ".portNumber"; //$NON-NLS-1$ public static final String ATTR_PORT_NUMBER = Activator.PLUGIN_ID + ".portNumber"; //$NON-NLS-1$
public static final String ATTR_JTAG_DEVICE = Activator.PLUGIN_ID + ".jtagDevice"; //$NON-NLS-1$ public static final String ATTR_JTAG_DEVICE = Activator.PLUGIN_ID + ".jtagDevice"; //$NON-NLS-1$
public static final boolean DEFAULT_USE_REMOTE_TARGET = true; public static final boolean DEFAULT_USE_REMOTE_TARGET = true;
public static final String DEFAULT_IP_ADDRESS = "localhost"; //$NON-NLS-1$ public static final String DEFAULT_IP_ADDRESS = "localhost"; //$NON-NLS-1$
public static final int DEFAULT_PORT_NUMBER = 10000; public static final int DEFAULT_PORT_NUMBER = 10000;
/**
* @since 7.0
*/
public static final String DEFAULT_CONNECTION = "localhost:10000"; //$NON-NLS-1$
// Startup // Startup
public static final String ATTR_INIT_COMMANDS = Activator.PLUGIN_ID + ".initCommands"; //$NON-NLS-1$ public static final String ATTR_INIT_COMMANDS = Activator.PLUGIN_ID + ".initCommands"; //$NON-NLS-1$
public static final String ATTR_DELAY = Activator.PLUGIN_ID + ".delay"; //$NON-NLS-1$ public static final String ATTR_DELAY = Activator.PLUGIN_ID + ".delay"; //$NON-NLS-1$

View file

@ -0,0 +1,60 @@
/*******************************************************************************
* Copyright (c) 2010 Sage Electronic Engineering 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
*
* Contributors:
* Bruce Griffith,Sage Electronic Engineering, LLC - bug 305943
* - API generalization to become transport-independent (e.g. to
* allow connections via serial ports and pipes).
*******************************************************************************/
package org.eclipse.cdt.debug.gdbjtag.core.jtagdevice;
import java.util.Collection;
import org.eclipse.cdt.debug.gdbjtag.core.IGDBJtagConnection;
/**
* @since 7.0
*/
public class DefaultGDBJtagConnectionImpl extends DefaultGDBJtagDeviceImpl implements IGDBJtagConnection {
protected String connection = null;
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.gdbjtag.core.jtagdevice.IGDBJtagDevice#doDelay(int, java.util.Collection)
*/
public final void setDefaultDeviceConnection(String connection) {
this.connection = connection;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.gdbjtag.core.jtagdevice.IGDBJtagDevice#doRemote(java.lang.String, java.util.Collection)
*/
public void doRemote(String connection, Collection<String> commands) {
String cmd = ""; //$NON-NLS-1$
if (connection != null) {
cmd = "target remote " + connection; //$NON-NLS-1$
addCmd(commands, cmd);
}
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.gdbjtag.core.jtagdevice.IGDBJtagDevice#getDefaultDeviceConnection()
*/
public String getDefaultDeviceConnection() {
return connection;
}
public String getDefaultIpAddress() {
throw new UnsupportedOperationException();
}
public String getDefaultPortNumber() {
throw new UnsupportedOperationException();
}
}

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2008 QNX Software Systems and others. * Copyright (c) 2008 - 2010 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -8,10 +8,14 @@
* Contributors: * Contributors:
* QNX Software Systems - Initial API and implementation * QNX Software Systems - Initial API and implementation
* Andy Jin - Hardware debugging UI improvements, bug 229946 * Andy Jin - Hardware debugging UI improvements, bug 229946
* Bruce Griffith, Sage Electronic Engineering, LLC - bug 305943
* - API generalization to become transport-independent (allow
* connections via serial ports and pipes).
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.debug.gdbjtag.core.jtagdevice; package org.eclipse.cdt.debug.gdbjtag.core.jtagdevice;
import org.eclipse.cdt.debug.gdbjtag.core.Activator; import org.eclipse.cdt.debug.gdbjtag.core.Activator;
import org.eclipse.cdt.debug.gdbjtag.core.IGDBJtagConnection;
import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.Status;
@ -24,6 +28,7 @@ public class GDBJtagDeviceContribution {
private String deviceClassName; private String deviceClassName;
private IGDBJtagDevice device; private IGDBJtagDevice device;
private String deviceClassBundleName; private String deviceClassBundleName;
private String deviceDefaultConnection;
/** /**
* @return the deviceId * @return the deviceId
@ -75,29 +80,29 @@ public class GDBJtagDeviceContribution {
this.deviceClassBundleName = deviceClassBundleName; this.deviceClassBundleName = deviceClassBundleName;
} }
/**
* @since 7.0
*/
public void setDeviceDefaultConnection(String connection) {
this.deviceDefaultConnection = connection;
}
public IGDBJtagDevice getDevice() throws NullPointerException { public IGDBJtagDevice getDevice() throws NullPointerException {
if (device != null) if (device != null) return device;
return device;
Object o = null; Object o = null;
try { try {
o = Platform.getBundle(deviceClassBundleName).loadClass(deviceClassName).newInstance(); o = Platform.getBundle(deviceClassBundleName).loadClass(deviceClassName).newInstance();
} catch (InstantiationException e) { if (o instanceof IGDBJtagConnection) {
Activator.log(new Status(IStatus.ERROR, Activator.getUniqueIdentifier(), ((IGDBJtagConnection) o).setDefaultDeviceConnection(deviceDefaultConnection);
DebugPlugin.INTERNAL_ERROR, "Error instantiating "
+ getDeviceClassName() + " class", null));
throw new NullPointerException();
} catch (IllegalAccessException e) {
Activator.log(new Status(IStatus.ERROR, Activator.getUniqueIdentifier(),
DebugPlugin.INTERNAL_ERROR, "Error instantiating "
+ getDeviceClassName() + " class", null));
throw new NullPointerException();
} catch (ClassNotFoundException e) {
Activator.log(new Status(IStatus.ERROR, Activator.getUniqueIdentifier(),
DebugPlugin.INTERNAL_ERROR, "Error instantiating "
+ getDeviceClassName() + " class", null));
throw new NullPointerException();
} }
return device = (IGDBJtagDevice) o; device = (IGDBJtagDevice) o;
return device;
} catch (Exception e) {
Activator.log(new Status(IStatus.ERROR, Activator.getUniqueIdentifier(), DebugPlugin.INTERNAL_ERROR,
"Error instantiating " + getDeviceClassName() + " class", e)); //$NON-NLS-1$ //$NON-NLS-2$
return null;
}
} }
} }

View file

@ -8,12 +8,16 @@
* Contributors: * Contributors:
* QNX Software Systems - Initial API and implementation * QNX Software Systems - Initial API and implementation
* Andy Jin - Hardware debugging UI improvements, bug 229946 * Andy Jin - Hardware debugging UI improvements, bug 229946
* Bruce Griffith, Sage Electronic Engineering, LLC - bug 305943
* - API generalization to become transport-independent (allow
* connections via serial ports and pipes).
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.debug.gdbjtag.core.jtagdevice; package org.eclipse.cdt.debug.gdbjtag.core.jtagdevice;
import java.util.ArrayList; import java.util.ArrayList;
import org.eclipse.cdt.debug.gdbjtag.core.Activator; import org.eclipse.cdt.debug.gdbjtag.core.Activator;
import org.eclipse.cdt.debug.gdbjtag.core.IGDBJtagConstants;
import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtensionPoint; import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.IStatus;
@ -22,19 +26,19 @@ import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.DebugPlugin;
public class GDBJtagDeviceContributionFactory { public class GDBJtagDeviceContributionFactory {
private static final String EXTENSION_POINT_NAME = "JTagDevice"; private static final String EXTENSION_POINT_NAME = "JTagDevice"; //$NON-NLS-1$
private static final String MAIN_ELEMENT = "device"; private static final String MAIN_ELEMENT = "device"; //$NON-NLS-1$
private static GDBJtagDeviceContributionFactory instance; private static GDBJtagDeviceContributionFactory instance;
protected ArrayList contributions; protected ArrayList<GDBJtagDeviceContribution> contributions;
private GDBJtagDeviceContributionFactory() { private GDBJtagDeviceContributionFactory() {
contributions = new ArrayList(); contributions = new ArrayList<GDBJtagDeviceContribution>();
loadSubtypeContributions(); loadSubtypeContributions();
} }
public GDBJtagDeviceContribution[] getGDBJtagDeviceContribution() { public GDBJtagDeviceContribution[] getGDBJtagDeviceContribution() {
return (GDBJtagDeviceContribution[]) contributions.toArray( return contributions.toArray(
new GDBJtagDeviceContribution[contributions.size()]); new GDBJtagDeviceContribution[contributions.size()]);
} }
@ -48,13 +52,15 @@ public class GDBJtagDeviceContributionFactory {
for (int i = 0; i < elements.length; i++) { for (int i = 0; i < elements.length; i++) {
IConfigurationElement configurationElement = elements[i]; IConfigurationElement configurationElement = elements[i];
if (configurationElement.getName().equals(MAIN_ELEMENT)) { if (configurationElement.getName().equals(MAIN_ELEMENT)) {
String id = getRequired(configurationElement, "id"); String id = getRequired(configurationElement, "id"); //$NON-NLS-1$
String name = getRequired(configurationElement, "name"); String name = getRequired(configurationElement, "name"); //$NON-NLS-1$
String className = getRequired(configurationElement, "class"); String className = getRequired(configurationElement, "class"); //$NON-NLS-1$
String connection = getOptional(configurationElement, "default_connection", IGDBJtagConstants.DEFAULT_CONNECTION); //$NON-NLS-1$
GDBJtagDeviceContribution adapter = new GDBJtagDeviceContribution(); GDBJtagDeviceContribution adapter = new GDBJtagDeviceContribution();
adapter.setDeviceId(id); adapter.setDeviceId(id);
adapter.setDeviceName(name); adapter.setDeviceName(name);
adapter.setDeviceClassName(className); adapter.setDeviceClassName(className);
adapter.setDeviceDefaultConnection(connection);
adapter.setDeviceClassBundleName(configurationElement.getContributor().getName()); adapter.setDeviceClassBundleName(configurationElement.getContributor().getName());
addContribution(adapter); addContribution(adapter);
} }
@ -83,4 +89,9 @@ public class GDBJtagDeviceContributionFactory {
return elementValue; return elementValue;
} }
private static String getOptional(IConfigurationElement configurationElement, String name, String defaultValue) {
String elementValue = configurationElement.getAttribute(name);
return (elementValue != null) ? elementValue : defaultValue;
}
} }

View file

@ -54,7 +54,7 @@ public interface IGDBJtagDevice {
* @param ip host name of IP address of JTAG device * @param ip host name of IP address of JTAG device
* @param port TCP socket port number of JTAG device * @param port TCP socket port number of JTAG device
* @param commands remote connection commands * @param commands remote connection commands
* @deprecated use @see IGDBJtagConnection#doRemote
*/ */
public void doRemote(String ip, int port, Collection<String> commands); public void doRemote(String ip, int port, Collection<String> commands);
@ -97,14 +97,14 @@ public interface IGDBJtagDevice {
/** /**
* Device specific default hostname of IP address * Device specific default hostname of IP address
* @return default hostname of IP address * @return default hostname of IP address
* @deprecated use @see IGDBJtagConnection#getDetaultDeviceConnection
*/ */
public String getDefaultIpAddress(); public String getDefaultIpAddress();
/** /**
* Device specific default port number * Device specific default port number
* @return default port number * @return default port number
* @deprecated use @see IGDBJtagConnection#getDetaultDeviceConnection
*/ */
public String getDefaultPortNumber(); public String getDefaultPortNumber();

View file

@ -1,5 +1,5 @@
############################################################################### ###############################################################################
# Copyright (c) 2007, 2009 QNX Software Systems and others. # Copyright (c) 2007-2010 QNX Software Systems and others.
# All rights reserved. This program and the accompanying materials # All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0 # are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at # which accompanies this distribution, and is available at
@ -8,13 +8,19 @@
# Contributors: # Contributors:
# QNX Software Systems - initial API and implementation # QNX Software Systems - initial API and implementation
# IBM Corporation # IBM Corporation
# Andy Jin (QNX) - Added DSF debugging, bug 248593
# Bruce Griffith,Sage Electronic Engineering, LLC - bug 305943
# - API generalization to become transport-independent (e.g. to
# allow connections via serial ports and pipes).
############################################################################### ###############################################################################
pluginName=Eclipse GDB Hardware Debug UI Plug-in pluginName=Eclipse GDB Hardware Debug UI Plug-in
providerName=Eclipse CDT providerName=Eclipse CDT
AbatronBDI2000.name=Abatron BDI2000 AbatronBDI2000.name=Abatron BDI2000
MacraigorUsb2Demon.name=Macraigor USB2Demon MacraigorUsb2Demon.name=Macraigor USB2Demon
Generic.name=Generic GenericSerial.name=Generic Serial
OpenOCDPipe.name=OpenOCD (via pipe)
Generic.name=Generic TCP/IP
launchtab.cmaintab.name=Main launchtab.cmaintab.name=Main
launchtab.debuggertab.name=Debugger launchtab.debuggertab.name=Debugger

View file

@ -39,6 +39,24 @@
name="%MacraigorUsb2Demon.name"> name="%MacraigorUsb2Demon.name">
</device> </device>
</extension> </extension>
<extension
point="org.eclipse.cdt.debug.gdbjtag.core.JTagDevice">
<device
class="org.eclipse.cdt.debug.gdbjtag.core.jtagdevice.DefaultGDBJtagConnectionImpl"
default_connection="/dev/com1"
id="org.eclipse.cdt.debug.gdbjtag.core.jtagdevice.GenericSerial"
name="%GenericSerial.name">
</device>
</extension>
<extension
point="org.eclipse.cdt.debug.gdbjtag.core.JTagDevice">
<device
class="org.eclipse.cdt.debug.gdbjtag.core.jtagdevice.DefaultGDBJtagConnectionImpl"
default_connection="| openocd --pipe"
id="org.eclipse.cdt.debug.gdbjtag.core.jtagdevice.OpenOCD"
name="%OpenOCDPipe.name">
</device>
</extension>
<extension <extension
point="org.eclipse.debug.ui.launchConfigurationTabs"> point="org.eclipse.debug.ui.launchConfigurationTabs">
<tab <tab

View file

@ -6,13 +6,25 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* QNX Software Systems - Initial implementation * QNX Software Systems - Initial API and implementation
*******************************************************************************/ * Andy Jin - Hardware debugging UI improvements, bug 229946
* Anna Dushistova(MontaVista) - bug 241279
* - Hardware Debugging: Host name or ip address not saving in
* the debug configuration
* Andy Jin (QNX) - Added DSF debugging, bug 248593
* Bruce Griffith,Sage Electronic Engineering, LLC - bug 305943
* - API generalization to become transport-independent (e.g. to
* allow connections via serial ports and pipes).
*******************************************************************************/
package org.eclipse.cdt.debug.gdbjtag.ui; package org.eclipse.cdt.debug.gdbjtag.ui;
import java.io.File; import java.io.File;
import java.net.URI;
import java.net.URISyntaxException;
import org.eclipse.cdt.debug.gdbjtag.core.Activator; import org.eclipse.cdt.debug.gdbjtag.core.Activator;
import org.eclipse.cdt.debug.gdbjtag.core.IGDBJtagConnection;
import org.eclipse.cdt.debug.gdbjtag.core.IGDBJtagConstants; import org.eclipse.cdt.debug.gdbjtag.core.IGDBJtagConstants;
import org.eclipse.cdt.debug.gdbjtag.core.jtagdevice.GDBJtagDeviceContribution; import org.eclipse.cdt.debug.gdbjtag.core.jtagdevice.GDBJtagDeviceContribution;
import org.eclipse.cdt.debug.gdbjtag.core.jtagdevice.GDBJtagDeviceContributionFactory; import org.eclipse.cdt.debug.gdbjtag.core.jtagdevice.GDBJtagDeviceContributionFactory;
@ -29,6 +41,7 @@ import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
import org.eclipse.debug.ui.StringVariableSelectionDialog; import org.eclipse.debug.ui.StringVariableSelectionDialog;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.ScrolledComposite; import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.custom.StackLayout;
import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionAdapter;
@ -57,9 +70,14 @@ public class GDBJtagDSFDebuggerTab extends AbstractLaunchConfigurationTab {
private Text gdbCommand; private Text gdbCommand;
private Button useRemote; private Button useRemote;
private Combo jtagDevice;
private Composite remoteConnectionParameters;
private StackLayout remoteConnectParmsLayout;
private Composite remoteTcpipBox;
private Text ipAddress; private Text ipAddress;
private Text portNumber; private Text portNumber;
private Combo jtagDevice; private Composite remoteConnectionBox;
private Text connection;
private String savedJtagDevice; private String savedJtagDevice;
protected Button fUpdateThreadlistOnSuspend; protected Button fUpdateThreadlistOnSuspend;
@ -195,7 +213,6 @@ public class GDBJtagDSFDebuggerTab extends AbstractLaunchConfigurationTab {
jtagDevice.add(availableDevices[i].getDeviceName()); jtagDevice.add(availableDevices[i].getDeviceName());
} }
jtagDevice.select(0);
jtagDevice.addModifyListener(new ModifyListener() { jtagDevice.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) { public void modifyText(ModifyEvent e) {
updateDeviceIpPort(jtagDevice.getText()); updateDeviceIpPort(jtagDevice.getText());
@ -203,24 +220,64 @@ public class GDBJtagDSFDebuggerTab extends AbstractLaunchConfigurationTab {
} }
}); });
label = new Label(comp, SWT.NONE); remoteConnectionParameters = new Composite(group, SWT.NO_TRIM | SWT.NO_FOCUS);
label.setText(Messages.getString("GDBJtagDebuggerTab.ipAddressLabel")); remoteConnectParmsLayout = new StackLayout();
ipAddress = new Text(comp, SWT.BORDER); remoteConnectionParameters.setLayout(remoteConnectParmsLayout);
//
// Create entry fields for TCP/IP connections
//
{
remoteTcpipBox = new Composite(remoteConnectionParameters, SWT.NO_TRIM | SWT.NO_FOCUS);
layout = new GridLayout();
layout.numColumns = 2;
remoteTcpipBox.setLayout(layout);
remoteTcpipBox.setBackground(remoteConnectionParameters.getParent().getBackground());
label = new Label(remoteTcpipBox, SWT.NONE);
label.setText(Messages.getString("GDBJtagDebuggerTab.ipAddressLabel")); //$NON-NLS-1$
ipAddress = new Text(remoteTcpipBox, SWT.BORDER);
gd = new GridData(); gd = new GridData();
gd.widthHint = 100; gd.widthHint = 125;
ipAddress.setLayoutData(gd); ipAddress.setLayoutData(gd);
label = new Label(remoteTcpipBox, SWT.NONE);
label.setText(Messages.getString("GDBJtagDebuggerTab.portNumberLabel")); //$NON-NLS-1$
portNumber = new Text(remoteTcpipBox, SWT.BORDER);
gd = new GridData();
gd.widthHint = 125;
portNumber.setLayoutData(gd);
}
//
// 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();
gd.widthHint = 125;
connection.setLayoutData(gd);
}
//
// Add watchers for user data entry
//
ipAddress.addModifyListener(new ModifyListener() { ipAddress.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) { public void modifyText(ModifyEvent e) {
updateLaunchConfigurationDialog(); updateLaunchConfigurationDialog();
} }
}); });
label = new Label(comp, SWT.NONE);
label.setText(Messages.getString("GDBJtagDebuggerTab.portNumberLabel"));
portNumber = new Text(comp, SWT.BORDER);
gd = new GridData();
gd.widthHint = 100;
portNumber.setLayoutData(gd);
portNumber.addVerifyListener(new VerifyListener() { portNumber.addVerifyListener(new VerifyListener() {
public void verifyText(VerifyEvent e) { public void verifyText(VerifyEvent e) {
e.doit = Character.isDigit(e.character) || Character.isISOControl(e.character); e.doit = Character.isDigit(e.character) || Character.isISOControl(e.character);
@ -231,6 +288,12 @@ public class GDBJtagDSFDebuggerTab extends AbstractLaunchConfigurationTab {
updateLaunchConfigurationDialog(); updateLaunchConfigurationDialog();
} }
}); });
connection.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
updateLaunchConfigurationDialog();
}
});
} }
/** /**
@ -246,10 +309,14 @@ public class GDBJtagDSFDebuggerTab extends AbstractLaunchConfigurationTab {
if (name.equals(selectedDeviceName)) { if (name.equals(selectedDeviceName)) {
selectedDevice = availableDevices[i].getDevice(); selectedDevice = availableDevices[i].getDevice();
if (selectedDevice != null) { if (selectedDevice != null) {
String ip = selectedDevice.getDefaultIpAddress(); if (selectedDevice instanceof IGDBJtagConnection) {
ipAddress.setText(ip); IGDBJtagConnection connectionDevice = (IGDBJtagConnection)selectedDevice;
String port = selectedDevice.getDefaultPortNumber(); connection.setText(connectionDevice.getDefaultDeviceConnection());
portNumber.setText(port); } else {
ipAddress.setText(selectedDevice.getDefaultIpAddress());
portNumber.setText(selectedDevice.getDefaultPortNumber());
}
useRemoteChanged();
updateLaunchConfigurationDialog(); updateLaunchConfigurationDialog();
break; break;
} }
@ -262,6 +329,31 @@ public class GDBJtagDSFDebuggerTab extends AbstractLaunchConfigurationTab {
jtagDevice.setEnabled(enabled); jtagDevice.setEnabled(enabled);
ipAddress.setEnabled(enabled); ipAddress.setEnabled(enabled);
portNumber.setEnabled(enabled); portNumber.setEnabled(enabled);
connection.setEnabled(enabled);
GDBJtagDeviceContribution selectedDeviceEntry = findJtagDeviceByName(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 = remoteTcpipBox;
remoteTcpipBox.getParent().layout();
}
}
}
private GDBJtagDeviceContribution findJtagDeviceByName(String name) {
GDBJtagDeviceContribution[] availableDevices = GDBJtagDeviceContributionFactory.getInstance().getGDBJtagDeviceContribution();
for (GDBJtagDeviceContribution device : availableDevices) {
if (device.getDeviceName().equals(name)) {
return device;
}
}
return null;
} }
public void initializeFrom(ILaunchConfiguration configuration) { public void initializeFrom(ILaunchConfiguration configuration) {
@ -273,25 +365,45 @@ public class GDBJtagDSFDebuggerTab extends AbstractLaunchConfigurationTab {
boolean useRemoteAttr = configuration.getAttribute(IGDBJtagConstants.ATTR_USE_REMOTE_TARGET, boolean useRemoteAttr = configuration.getAttribute(IGDBJtagConstants.ATTR_USE_REMOTE_TARGET,
IGDBJtagConstants.DEFAULT_USE_REMOTE_TARGET); IGDBJtagConstants.DEFAULT_USE_REMOTE_TARGET);
useRemote.setSelection(useRemoteAttr); useRemote.setSelection(useRemoteAttr);
useRemoteChanged();
String ipAddressAttr = configuration.getAttribute(IGDBJtagConstants.ATTR_IP_ADDRESS,
IGDBJtagConstants.DEFAULT_IP_ADDRESS);
ipAddress.setText(ipAddressAttr);
int portNumberAttr = configuration.getAttribute(IGDBJtagConstants.ATTR_PORT_NUMBER,
IGDBJtagConstants.DEFAULT_PORT_NUMBER);
portNumber.setText(String.valueOf(portNumberAttr));
savedJtagDevice = configuration.getAttribute(IGDBJtagConstants.ATTR_JTAG_DEVICE, ""); savedJtagDevice = configuration.getAttribute(IGDBJtagConstants.ATTR_JTAG_DEVICE, "");
if (savedJtagDevice.isEmpty()) {
jtagDevice.select(0);
} else {
String storedAddress = ""; //$NON-NLS-1$
int storedPort = 0;
String storedConnection = ""; //$NON-NLS-1$
for (int i = 0; i < jtagDevice.getItemCount(); i++) { for (int i = 0; i < jtagDevice.getItemCount(); i++) {
if (jtagDevice.getItem(i).equals(savedJtagDevice)) { if (jtagDevice.getItem(i).equals(savedJtagDevice)) {
storedAddress = configuration.getAttribute(IGDBJtagConstants.ATTR_IP_ADDRESS, ""); //$NON-NLS-1$
storedPort = configuration.getAttribute(IGDBJtagConstants.ATTR_PORT_NUMBER, 0);
storedConnection = configuration.getAttribute(IGDBJtagConstants.ATTR_CONNECTION, ""); //$NON-NLS-1$
jtagDevice.select(i); jtagDevice.select(i);
break;
}
}
if (storedConnection!=null) {
try {
connection.setText(new URI(storedConnection).getSchemeSpecificPart());
} catch (URISyntaxException e) {
Activator.log(e);
}
}
if (storedAddress!=null)
{
// Treat as legacy network probe
ipAddress.setText(storedAddress);
String portString = (0<storedPort)&&(storedPort<=65535) ? Integer.valueOf(storedPort).toString() : ""; //$NON-NLS-1$
portNumber.setText(portString);
} }
} }
boolean updateThreadsOnSuspend = configuration.getAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_UPDATE_THREADLIST_ON_SUSPEND, boolean updateThreadsOnSuspend = configuration.getAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_UPDATE_THREADLIST_ON_SUSPEND,
IGDBLaunchConfigurationConstants.DEBUGGER_UPDATE_THREADLIST_ON_SUSPEND_DEFAULT); IGDBLaunchConfigurationConstants.DEBUGGER_UPDATE_THREADLIST_ON_SUSPEND_DEFAULT);
fUpdateThreadlistOnSuspend.setSelection(updateThreadsOnSuspend); fUpdateThreadlistOnSuspend.setSelection(updateThreadsOnSuspend);
useRemoteChanged();
} catch (CoreException e) { } catch (CoreException e) {
Activator.getDefault().getLog().log(e.getStatus()); Activator.getDefault().getLog().log(e.getStatus());
} }
@ -312,12 +424,24 @@ public class GDBJtagDSFDebuggerTab extends AbstractLaunchConfigurationTab {
savedJtagDevice = jtagDevice.getText(); savedJtagDevice = jtagDevice.getText();
configuration.setAttribute(IGDBJtagConstants.ATTR_JTAG_DEVICE, savedJtagDevice); configuration.setAttribute(IGDBJtagConstants.ATTR_JTAG_DEVICE, savedJtagDevice);
configuration.setAttribute(IGDBJtagConstants.ATTR_USE_REMOTE_TARGET, useRemote.getSelection()); configuration.setAttribute(IGDBJtagConstants.ATTR_USE_REMOTE_TARGET, useRemote.getSelection());
configuration.setAttribute(IGDBJtagConstants.ATTR_IP_ADDRESS, ipAddress.getText().trim()); if (!savedJtagDevice.isEmpty()) {
try { try {
configuration.setAttribute(IGDBJtagConstants.ATTR_PORT_NUMBER, Integer IGDBJtagDevice device = findJtagDeviceByName(jtagDevice.getText()).getDevice();
.parseInt(portNumber.getText().trim())); 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_CONNECTION, uri.toString());
} else {
String ip = ipAddress.getText().trim();
configuration.setAttribute(IGDBJtagConstants.ATTR_IP_ADDRESS, ip);
int port = Integer.valueOf(portNumber.getText().trim()).intValue();
configuration.setAttribute(IGDBJtagConstants.ATTR_PORT_NUMBER, port);
}
} catch (URISyntaxException e) {
Activator.log(e);
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
configuration.setAttribute(IGDBJtagConstants.ATTR_PORT_NUMBER, 0); Activator.log(e);
}
} }
configuration.setAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_UPDATE_THREADLIST_ON_SUSPEND, configuration.setAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_UPDATE_THREADLIST_ON_SUSPEND,
fUpdateThreadlistOnSuspend.getSelection()); fUpdateThreadlistOnSuspend.getSelection());
@ -334,8 +458,6 @@ public class GDBJtagDSFDebuggerTab extends AbstractLaunchConfigurationTab {
IMILaunchConfigurationConstants.DEBUGGER_VERBOSE_MODE_DEFAULT); IMILaunchConfigurationConstants.DEBUGGER_VERBOSE_MODE_DEFAULT);
configuration.setAttribute(IGDBJtagConstants.ATTR_USE_REMOTE_TARGET, configuration.setAttribute(IGDBJtagConstants.ATTR_USE_REMOTE_TARGET,
IGDBJtagConstants.DEFAULT_USE_REMOTE_TARGET); IGDBJtagConstants.DEFAULT_USE_REMOTE_TARGET);
configuration.setAttribute(IGDBJtagConstants.ATTR_IP_ADDRESS, IGDBJtagConstants.DEFAULT_IP_ADDRESS);
configuration.setAttribute(IGDBJtagConstants.ATTR_PORT_NUMBER, IGDBJtagConstants.DEFAULT_PORT_NUMBER);
configuration.setAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_UPDATE_THREADLIST_ON_SUSPEND, configuration.setAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_UPDATE_THREADLIST_ON_SUSPEND,
IGDBLaunchConfigurationConstants.DEBUGGER_UPDATE_THREADLIST_ON_SUSPEND_DEFAULT); IGDBLaunchConfigurationConstants.DEBUGGER_UPDATE_THREADLIST_ON_SUSPEND_DEFAULT);
} }

View file

@ -8,15 +8,23 @@
* Contributors: * Contributors:
* QNX Software Systems - Initial API and implementation * QNX Software Systems - Initial API and implementation
* Andy Jin - Hardware debugging UI improvements, bug 229946 * Andy Jin - Hardware debugging UI improvements, bug 229946
* Anna Dushistova(MontaVista) - Hardware Debugging: Host name or ip address not saving in the debug configuration, bug 241279 * Anna Dushistova(MontaVista) - bug 241279
* - Hardware Debugging: Host name or ip address not saving in
* the debug configuration
* Andy Jin (QNX) - Added DSF debugging, bug 248593 * Andy Jin (QNX) - Added DSF debugging, bug 248593
*******************************************************************************/ * Bruce Griffith, Sage Electronic Engineering, LLC - bug 305943
* - API generalization to become transport-independent (e.g. to
* allow connections via serial ports and pipes).
*******************************************************************************/
package org.eclipse.cdt.debug.gdbjtag.ui; package org.eclipse.cdt.debug.gdbjtag.ui;
import java.io.File; import java.io.File;
import java.net.URI;
import java.net.URISyntaxException;
import org.eclipse.cdt.debug.gdbjtag.core.Activator; import org.eclipse.cdt.debug.gdbjtag.core.Activator;
import org.eclipse.cdt.debug.gdbjtag.core.IGDBJtagConnection;
import org.eclipse.cdt.debug.gdbjtag.core.IGDBJtagConstants; import org.eclipse.cdt.debug.gdbjtag.core.IGDBJtagConstants;
import org.eclipse.cdt.debug.gdbjtag.core.jtagdevice.GDBJtagDeviceContribution; import org.eclipse.cdt.debug.gdbjtag.core.jtagdevice.GDBJtagDeviceContribution;
import org.eclipse.cdt.debug.gdbjtag.core.jtagdevice.GDBJtagDeviceContributionFactory; import org.eclipse.cdt.debug.gdbjtag.core.jtagdevice.GDBJtagDeviceContributionFactory;
@ -33,6 +41,7 @@ import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
import org.eclipse.debug.ui.StringVariableSelectionDialog; import org.eclipse.debug.ui.StringVariableSelectionDialog;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.ScrolledComposite; import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.custom.StackLayout;
import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionAdapter;
@ -66,9 +75,14 @@ public class GDBJtagDebuggerTab extends AbstractLaunchConfigurationTab {
private Combo miProtocol; private Combo miProtocol;
private Button verboseMode; private Button verboseMode;
private Button useRemote; private Button useRemote;
private Combo jtagDevice;
private Composite remoteConnectionParameters;
private StackLayout remoteConnectParmsLayout;
private Composite remoteTcpipBox;
private Text ipAddress; private Text ipAddress;
private Text portNumber; private Text portNumber;
private Combo jtagDevice; private Composite remoteConnectionBox;
private Text connection;
private String savedJtagDevice; private String savedJtagDevice;
@ -268,7 +282,6 @@ public class GDBJtagDebuggerTab extends AbstractLaunchConfigurationTab {
jtagDevice.add(availableDevices[i].getDeviceName()); jtagDevice.add(availableDevices[i].getDeviceName());
} }
jtagDevice.select(0);
jtagDevice.addModifyListener(new ModifyListener() { jtagDevice.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) { public void modifyText(ModifyEvent e) {
updateDeviceIpPort(jtagDevice.getText()); updateDeviceIpPort(jtagDevice.getText());
@ -276,24 +289,64 @@ public class GDBJtagDebuggerTab extends AbstractLaunchConfigurationTab {
} }
}); });
label = new Label(comp, SWT.NONE); remoteConnectionParameters = new Composite(group, SWT.NO_TRIM | SWT.NO_FOCUS);
label.setText(Messages.getString("GDBJtagDebuggerTab.ipAddressLabel")); remoteConnectParmsLayout = new StackLayout();
ipAddress = new Text(comp, SWT.BORDER); remoteConnectionParameters.setLayout(remoteConnectParmsLayout);
//
// Create entry fields for TCP/IP connections
//
{
remoteTcpipBox = new Composite(remoteConnectionParameters, SWT.NO_TRIM | SWT.NO_FOCUS);
layout = new GridLayout();
layout.numColumns = 2;
remoteTcpipBox.setLayout(layout);
remoteTcpipBox.setBackground(remoteConnectionParameters.getParent().getBackground());
label = new Label(remoteTcpipBox, SWT.NONE);
label.setText(Messages.getString("GDBJtagDebuggerTab.ipAddressLabel")); //$NON-NLS-1$
ipAddress = new Text(remoteTcpipBox, SWT.BORDER);
gd = new GridData(); gd = new GridData();
gd.widthHint = 100; gd.widthHint = 125;
ipAddress.setLayoutData(gd); ipAddress.setLayoutData(gd);
label = new Label(remoteTcpipBox, SWT.NONE);
label.setText(Messages.getString("GDBJtagDebuggerTab.portNumberLabel")); //$NON-NLS-1$
portNumber = new Text(remoteTcpipBox, SWT.BORDER);
gd = new GridData();
gd.widthHint = 125;
portNumber.setLayoutData(gd);
}
//
// 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();
gd.widthHint = 125;
connection.setLayoutData(gd);
}
//
// Add watchers for user data entry
//
ipAddress.addModifyListener(new ModifyListener() { ipAddress.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) { public void modifyText(ModifyEvent e) {
updateLaunchConfigurationDialog(); updateLaunchConfigurationDialog();
} }
}); });
label = new Label(comp, SWT.NONE);
label.setText(Messages.getString("GDBJtagDebuggerTab.portNumberLabel"));
portNumber = new Text(comp, SWT.BORDER);
gd = new GridData();
gd.widthHint = 100;
portNumber.setLayoutData(gd);
portNumber.addVerifyListener(new VerifyListener() { portNumber.addVerifyListener(new VerifyListener() {
public void verifyText(VerifyEvent e) { public void verifyText(VerifyEvent e) {
e.doit = Character.isDigit(e.character) || Character.isISOControl(e.character); e.doit = Character.isDigit(e.character) || Character.isISOControl(e.character);
@ -304,6 +357,12 @@ public class GDBJtagDebuggerTab extends AbstractLaunchConfigurationTab {
updateLaunchConfigurationDialog(); updateLaunchConfigurationDialog();
} }
}); });
connection.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
updateLaunchConfigurationDialog();
}
});
} }
/** /**
@ -321,10 +380,14 @@ public class GDBJtagDebuggerTab extends AbstractLaunchConfigurationTab {
if (name.equals(selectedDeviceName)) { if (name.equals(selectedDeviceName)) {
selectedDevice = availableDevices[i].getDevice(); selectedDevice = availableDevices[i].getDevice();
if (selectedDevice != null) { if (selectedDevice != null) {
String ip = selectedDevice.getDefaultIpAddress(); if (selectedDevice instanceof IGDBJtagConnection) {
ipAddress.setText(ip); IGDBJtagConnection connectionDevice = (IGDBJtagConnection)selectedDevice;
String port = selectedDevice.getDefaultPortNumber(); connection.setText(connectionDevice.getDefaultDeviceConnection());
portNumber.setText(port); } else {
ipAddress.setText(selectedDevice.getDefaultIpAddress());
portNumber.setText(selectedDevice.getDefaultPortNumber());
}
useRemoteChanged();
updateLaunchConfigurationDialog(); updateLaunchConfigurationDialog();
break; break;
} }
@ -337,6 +400,31 @@ public class GDBJtagDebuggerTab extends AbstractLaunchConfigurationTab {
jtagDevice.setEnabled(enabled); jtagDevice.setEnabled(enabled);
ipAddress.setEnabled(enabled); ipAddress.setEnabled(enabled);
portNumber.setEnabled(enabled); portNumber.setEnabled(enabled);
connection.setEnabled(enabled);
GDBJtagDeviceContribution selectedDeviceEntry = findJtagDeviceByName(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 = remoteTcpipBox;
remoteTcpipBox.getParent().layout();
}
}
}
private GDBJtagDeviceContribution findJtagDeviceByName(String name) {
GDBJtagDeviceContribution[] availableDevices = GDBJtagDeviceContributionFactory.getInstance().getGDBJtagDeviceContribution();
for (GDBJtagDeviceContribution device : availableDevices) {
if (device.getDeviceName().equals(name)) {
return device;
}
}
return null;
} }
public void initializeFrom(ILaunchConfiguration configuration) { public void initializeFrom(ILaunchConfiguration configuration) {
@ -370,16 +458,37 @@ public class GDBJtagDebuggerTab extends AbstractLaunchConfigurationTab {
useRemote.setSelection(useRemoteAttr); useRemote.setSelection(useRemoteAttr);
useRemoteChanged(); useRemoteChanged();
String ipAddressAttr = configuration.getAttribute(IGDBJtagConstants.ATTR_IP_ADDRESS, IGDBJtagConstants.DEFAULT_IP_ADDRESS); savedJtagDevice = configuration.getAttribute(IGDBJtagConstants.ATTR_JTAG_DEVICE, ""); //$NON-NLS-1$
ipAddress.setText(ipAddressAttr); if (savedJtagDevice.isEmpty()) {
jtagDevice.select(0);
} else {
String storedAddress = ""; //$NON-NLS-1$
int storedPort = 0;
String storedConnection = ""; //$NON-NLS-1$
int portNumberAttr = configuration.getAttribute(IGDBJtagConstants.ATTR_PORT_NUMBER, IGDBJtagConstants.DEFAULT_PORT_NUMBER);
portNumber.setText(String.valueOf(portNumberAttr));
savedJtagDevice = configuration.getAttribute(IGDBJtagConstants.ATTR_JTAG_DEVICE, "");
for (int i = 0; i < jtagDevice.getItemCount(); i++) { for (int i = 0; i < jtagDevice.getItemCount(); i++) {
if (jtagDevice.getItem(i).equals(savedJtagDevice)) { if (jtagDevice.getItem(i).equals(savedJtagDevice)) {
storedAddress = configuration.getAttribute(IGDBJtagConstants.ATTR_IP_ADDRESS, ""); //$NON-NLS-1$
storedPort = configuration.getAttribute(IGDBJtagConstants.ATTR_PORT_NUMBER, 0);
storedConnection = configuration.getAttribute(IGDBJtagConstants.ATTR_CONNECTION, ""); //$NON-NLS-1$
jtagDevice.select(i); jtagDevice.select(i);
break;
}
}
if (storedConnection!=null) {
try {
connection.setText(new URI(storedConnection).getSchemeSpecificPart());
} catch (URISyntaxException e) {
Activator.log(e);
}
}
if (storedAddress!=null)
{
// Treat as legacy network probe
ipAddress.setText(storedAddress);
String portString = (0<storedPort)&&(storedPort<=65535) ? Integer.valueOf(storedPort).toString() : ""; //$NON-NLS-1$
portNumber.setText(portString);
} }
} }
} catch (CoreException e) { } catch (CoreException e) {
@ -405,11 +514,24 @@ public class GDBJtagDebuggerTab extends AbstractLaunchConfigurationTab {
savedJtagDevice = jtagDevice.getText(); savedJtagDevice = jtagDevice.getText();
configuration.setAttribute(IGDBJtagConstants.ATTR_JTAG_DEVICE, savedJtagDevice); configuration.setAttribute(IGDBJtagConstants.ATTR_JTAG_DEVICE, savedJtagDevice);
configuration.setAttribute(IGDBJtagConstants.ATTR_USE_REMOTE_TARGET, useRemote.getSelection()); configuration.setAttribute(IGDBJtagConstants.ATTR_USE_REMOTE_TARGET, useRemote.getSelection());
configuration.setAttribute(IGDBJtagConstants.ATTR_IP_ADDRESS, ipAddress.getText().trim()); if (!savedJtagDevice.isEmpty()) {
try { try {
configuration.setAttribute(IGDBJtagConstants.ATTR_PORT_NUMBER, Integer.parseInt(portNumber.getText().trim())); IGDBJtagDevice device = findJtagDeviceByName(jtagDevice.getText()).getDevice();
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_CONNECTION, uri.toString());
} else {
String ip = ipAddress.getText().trim();
configuration.setAttribute(IGDBJtagConstants.ATTR_IP_ADDRESS, ip);
int port = Integer.valueOf(portNumber.getText().trim()).intValue();
configuration.setAttribute(IGDBJtagConstants.ATTR_PORT_NUMBER, port);
}
} catch (URISyntaxException e) {
Activator.log(e);
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
configuration.setAttribute(IGDBJtagConstants.ATTR_PORT_NUMBER, 0); Activator.log(e);
}
} }
} }
@ -421,8 +543,6 @@ public class GDBJtagDebuggerTab extends AbstractLaunchConfigurationTab {
configuration.setAttribute(IMILaunchConfigurationConstants.ATTR_DEBUGGER_PROTOCOL, defDesc.getMIVersions()[0]); configuration.setAttribute(IMILaunchConfigurationConstants.ATTR_DEBUGGER_PROTOCOL, defDesc.getMIVersions()[0]);
configuration.setAttribute(IMILaunchConfigurationConstants.ATTR_DEBUGGER_VERBOSE_MODE, IMILaunchConfigurationConstants.DEBUGGER_VERBOSE_MODE_DEFAULT); configuration.setAttribute(IMILaunchConfigurationConstants.ATTR_DEBUGGER_VERBOSE_MODE, IMILaunchConfigurationConstants.DEBUGGER_VERBOSE_MODE_DEFAULT);
configuration.setAttribute(IGDBJtagConstants.ATTR_USE_REMOTE_TARGET, IGDBJtagConstants.DEFAULT_USE_REMOTE_TARGET); configuration.setAttribute(IGDBJtagConstants.ATTR_USE_REMOTE_TARGET, IGDBJtagConstants.DEFAULT_USE_REMOTE_TARGET);
configuration.setAttribute(IGDBJtagConstants.ATTR_IP_ADDRESS, IGDBJtagConstants.DEFAULT_IP_ADDRESS);
configuration.setAttribute(IGDBJtagConstants.ATTR_PORT_NUMBER, IGDBJtagConstants.DEFAULT_PORT_NUMBER);
} }
} }

View file

@ -1,5 +1,5 @@
############################################################################### ###############################################################################
# Copyright (c) 2008 QNX Software Systems and others. # Copyright (c) 2008-2010 QNX Software Systems and others.
# All rights reserved. This program and the accompanying materials # All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0 # are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at # which accompanies this distribution, and is available at
@ -7,6 +7,9 @@
# #
# Contributors: # Contributors:
# QNX Software Systems - initial API and implementation # QNX Software Systems - initial API and implementation
# Bruce Griffith,Sage Electronic Engineering, LLC - bug 305943
# - API generalization to become transport-independent (e.g. to
# allow connections via serial ports and pipes).
############################################################################### ###############################################################################
GDBJtagStartupTab.initGroup_Text=Initialization Commands GDBJtagStartupTab.initGroup_Text=Initialization Commands
@ -58,4 +61,5 @@ GDBJtagDebuggerTab.useRemote_Text=Use remote target
GDBJtagDebuggerTab.jtagDeviceLabel=JTAG Device: GDBJtagDebuggerTab.jtagDeviceLabel=JTAG Device:
GDBJtagDebuggerTab.ipAddressLabel=Host name or IP address: GDBJtagDebuggerTab.ipAddressLabel=Host name or IP address:
GDBJtagDebuggerTab.portNumberLabel=Port number: GDBJtagDebuggerTab.portNumberLabel=Port number:
GDBJtagDebuggerTab.connectionLabel=GDB Connection String:
GDBJtagDebuggerTab.update_thread_list_on_suspend=Force thread list update on suspend GDBJtagDebuggerTab.update_thread_list_on_suspend=Force thread list update on suspend