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

Bug 547831 Add ILaunchTargets for GDB Remote

Adds ILaunchTargets for GDB Remote for TCP and Serial Port.
Adds a launch config provider that maps default launch configurations
for the gdb remote launch config types.

Alters the launch attributes by merging in the target attributes
over the launch configuration attributes. This is a no-op of the
target is the Null Target (which has no attributes).

Some string externalization that was missed from previous commits.

Carrying on tradition of ramdonly using Gdb or GDB in our class names :)

Change-Id: Ie8483110f594db593e704adda420ce6b14812dea
This commit is contained in:
Doug Schaefer 2019-05-31 16:43:03 -04:00
parent 4324811b1b
commit 6a27da170f
25 changed files with 824 additions and 19 deletions

View file

@ -226,6 +226,7 @@ Java and all Java-based trademarks are trademarks of Oracle Corporation in the U
<plugin id="org.eclipse.cdt.make.core"/>
<plugin id="org.eclipse.cdt.managedbuilder.core"/>
<plugin id="org.eclipse.cdt.managedbuilder.gnu.ui"/>
<plugin id="org.eclipse.cdt.native.serial"/>
<plugin id="org.eclipse.cdt.ui"/>
<plugin id="org.eclipse.compare"/>
<plugin id="org.eclipse.compare.core"/>

View file

@ -37,3 +37,9 @@ Launch.common.QualifierColon=Qualifier:
Launch.ILaunchable.Interface.Error=An attempt to instantiate an adapter factory for ILaunchable. By API specification this is not allowed. Use hasAdapter() to determine existense.
NewGenericTargetWizard_0=New Generic Target
NewGenericTargetWizardPage.Arch=CPU Architecture:
NewGenericTargetWizardPage.Desc=Enter name and properties for the target.
NewGenericTargetWizardPage.Name=Name:
NewGenericTargetWizardPage.OS=Operating System:
NewGenericTargetWizardPage.Title=Generic Target

View file

@ -15,7 +15,6 @@ import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
import org.eclipse.launchbar.core.target.ILaunchTarget;
import org.eclipse.launchbar.core.target.ILaunchTargetManager;
import org.eclipse.launchbar.core.target.ILaunchTargetWorkingCopy;
import org.eclipse.launchbar.ui.internal.Activator;
import org.eclipse.launchbar.ui.target.LaunchTargetWizard;
public class NewGenericTargetWizard extends LaunchTargetWizard {
@ -23,7 +22,7 @@ public class NewGenericTargetWizard extends LaunchTargetWizard {
private NewGenericTargetWizardPage page;
public NewGenericTargetWizard() {
setWindowTitle("New Generic Target");
setWindowTitle(LaunchMessages.getString("NewGenericTargetWizard_0")); //$NON-NLS-1$
}
@Override
@ -61,10 +60,10 @@ public class NewGenericTargetWizard extends LaunchTargetWizard {
@Override
public void performDelete() {
ILaunchTargetManager manager = Activator.getService(ILaunchTargetManager.class);
ILaunchTargetManager manager = CDebugUIPlugin.getService(ILaunchTargetManager.class);
ILaunchTarget target = getLaunchTarget();
if (target != null) {
manager.removeLaunchTarget(getLaunchTarget());
manager.removeLaunchTarget(target);
}
}

View file

@ -29,8 +29,8 @@ public class NewGenericTargetWizardPage extends WizardPage {
public NewGenericTargetWizardPage(ILaunchTarget launchTarget) {
super(NewGenericTargetWizardPage.class.getName());
setTitle("Generic Target");
setDescription("Enter name and properties for the target.");
setTitle(LaunchMessages.getString("NewGenericTargetWizardPage.Title")); //$NON-NLS-1$
setDescription(LaunchMessages.getString("NewGenericTargetWizardPage.Desc")); //$NON-NLS-1$
this.launchTarget = launchTarget;
}
@ -40,7 +40,7 @@ public class NewGenericTargetWizardPage extends WizardPage {
comp.setLayout(new GridLayout(2, false));
Label label = new Label(comp, SWT.NONE);
label.setText("Name:");
label.setText(LaunchMessages.getString("NewGenericTargetWizardPage.Name")); //$NON-NLS-1$
nameText = new Text(comp, SWT.BORDER);
nameText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
@ -49,7 +49,7 @@ public class NewGenericTargetWizardPage extends WizardPage {
}
label = new Label(comp, SWT.NONE);
label.setText("Operating System:");
label.setText(LaunchMessages.getString("NewGenericTargetWizardPage.OS")); //$NON-NLS-1$
osText = new Text(comp, SWT.BORDER);
osText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
@ -61,7 +61,7 @@ public class NewGenericTargetWizardPage extends WizardPage {
}
label = new Label(comp, SWT.NONE);
label.setText("CPU Architecture:");
label.setText(LaunchMessages.getString("NewGenericTargetWizardPage.Arch")); //$NON-NLS-1$
archText = new Text(comp, SWT.BORDER);
archText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));

View file

@ -26,7 +26,9 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.cdt.launch;bundle-version="6.1.0",
org.eclipse.debug.core,
org.eclipse.core.resources,
org.eclipse.tm.terminal.control;bundle-version="4.0.0"
org.eclipse.tm.terminal.control;bundle-version="4.0.0",
org.eclipse.cdt.native.serial;bundle-version="1.1.100",
org.eclipse.launchbar.ui;bundle-version="2.3.0"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Export-Package: org.eclipse.cdt.dsf.gdb.internal.ui;x-friends:="org.eclipse.cdt.docker.launcher",

Binary file not shown.

After

Width:  |  Height:  |  Size: 189 B

View file

@ -607,4 +607,27 @@
plugin="org.eclipse.cdt.dsf.gdb">
</statusHandler>
</extension>
<extension
point="org.eclipse.launchbar.ui.launchTargetTypeUI">
<launchTargetTypeUI
id="org.eclipse.cdt.dsf.gdb.remoteTCPLaunchTargetType"
labelProvider="org.eclipse.cdt.dsf.gdb.internal.ui.launching.GdbRemoteTargetLabelProvider">
</launchTargetTypeUI>
<wizard2
class="org.eclipse.cdt.dsf.gdb.internal.ui.launching.NewGdbRemoteTCPTargetWizard"
icon="icons/full/obj16/connect.gif"
id="org.eclipse.cdt.dsf.gdb.remoteTCPLaunchTargetType"
name="GDB Remote TCP">
</wizard2>
<launchTargetTypeUI
id="org.eclipse.cdt.dsf.gdb.remoteSerialLaunchTargetType"
labelProvider="org.eclipse.cdt.dsf.gdb.internal.ui.launching.GdbRemoteTargetLabelProvider">
</launchTargetTypeUI>
<wizard2
class="org.eclipse.cdt.dsf.gdb.internal.ui.launching.NewGdbRemoteSerialTargetWizard"
icon="icons/full/obj16/connect.gif"
id="org.eclipse.cdt.dsf.gdb.remoteSerialLaunchTargetType"
name="GDB Remote Serial">
</wizard2>
</extension>
</plugin>

View file

@ -36,6 +36,7 @@ import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.eclipse.ui.preferences.ScopedPreferenceStore;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
/**
* The activator class controls the plug-in life cycle
@ -275,4 +276,11 @@ public class GdbUIPlugin extends AbstractUIPlugin {
reg.put(IGdbUIConstants.IMG_WIZBAN_ADVANCED_TIMEOUT_SETTINGS,
getImageDescriptor("icons/full/wizban/advtosettings_wiz.png")); //$NON-NLS-1$
}
public static <T> T getService(Class<T> service) {
BundleContext context = plugin.getBundle().getBundleContext();
ServiceReference<T> ref = context.getServiceReference(service);
return ref != null ? context.getService(ref) : null;
}
}

View file

@ -0,0 +1,32 @@
/*******************************************************************************
* Copyright (c) 2019 QNX Software Systems and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/
package org.eclipse.cdt.dsf.gdb.internal.ui.launching;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.launchbar.core.target.ILaunchTarget;
import org.eclipse.swt.graphics.Image;
public class GdbRemoteTargetLabelProvider extends LabelProvider {
@Override
public String getText(Object element) {
if (element instanceof ILaunchTarget) {
return ((ILaunchTarget) element).getId();
}
return super.getText(element);
}
@Override
public Image getImage(Object element) {
return LaunchImages.get(LaunchImages.IMG_OBJS_REMOTE);
}
}

View file

@ -50,6 +50,9 @@ public class LaunchImages {
public static String IMG_OBJS_EXEC = NAME_PREFIX + "exec_obj.gif"; //$NON-NLS-1$
public static final ImageDescriptor DESC_OBJS_EXEC = createManaged(T_OBJS, IMG_OBJS_EXEC);
public static final String IMG_OBJS_REMOTE = NAME_PREFIX + "connect.gif"; //$NON-NLS-1$
public static final ImageDescriptor DESC_OBJS_REMOTE = createManaged(T_OBJS, IMG_OBJS_REMOTE);
public static void initialize() {
}

View file

@ -238,6 +238,30 @@ LocalCDILaunchDelegate.7=Core file does not exist or is not readable.
LocalCDILaunchDelegate.8=Error starting process.
LocalCDILaunchDelegate.9=Eclipse runtime does not support working directory.
LocalCDILaunchDelegate.10=Failed to set program arguments, environment or working directory.
NewGDBRemoteSerialTargetWizard_BaudNotANumber=Baud rate must be a number
NewGDBRemoteSerialTargetWizard_BaudRate=Baud rate:
NewGDBRemoteSerialTargetWizard_ConnectionGroup=Connection
NewGDBRemoteSerialTargetWizard_Desc=Enter the connection information for gdb remote connection.
NewGDBRemoteSerialTargetWizard_NameGroup=Target Name
NewGDBRemoteSerialTargetWizard_NoBaudRate=Baud rate must be specified
NewGDBRemoteSerialTargetWizard_NoSerialPort=Serial port must be specified.
NewGDBRemoteSerialTargetWizard_NoTargetName=Target name must be specified
NewGDBRemoteSerialTargetWizard_SameAsSerialPort=Same as serial port
NewGDBRemoteSerialTargetWizard_SerialPort=Serial port:
NewGDBRemoteSerialTargetWizard_TargetName=Target name:
NewGDBRemoteSerialTargetWizard_Title=New GDB Remote over Serial Port target
NewGdbRemoteTCPTargetWizard.ConnectionGroup=Connection
NewGdbRemoteTCPTargetWizard.Desc=Enter the connection information for gdb remote connection.
NewGdbRemoteTCPTargetWizard.HostName=Hostname or IP:
NewGdbRemoteTCPTargetWizard.NameGroup=Target Name
NewGdbRemoteTCPTargetWizard.NoHost=Hostname or IP must be specified
NewGdbRemoteTCPTargetWizard.NoName=Target name must be specified
NewGdbRemoteTCPTargetWizard.NoPort=Port number must be specified
NewGdbRemoteTCPTargetWizard.Port=Port:
NewGdbRemoteTCPTargetWizard.PortNotANumber=Port must be a number
NewGdbRemoteTCPTargetWizard.SameAsHost=Same as hostname
NewGdbRemoteTCPTargetWizard.TargetName=Target Name:
NewGdbRemoteTCPTargetWizard.Title=New GDB Remote over TCP Target
ProcessPrompter.Core=core
ProcessPrompter.Cores=cores

View file

@ -0,0 +1,217 @@
/*******************************************************************************
* Copyright (c) 2019 QNX Software Systems and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/
package org.eclipse.cdt.dsf.gdb.internal.ui.launching;
import java.io.IOException;
import java.util.Arrays;
import org.eclipse.cdt.dsf.gdb.IGDBLaunchConfigurationConstants;
import org.eclipse.cdt.dsf.gdb.internal.ui.GdbUIPlugin;
import org.eclipse.cdt.dsf.gdb.launching.GDBRemoteSerialLaunchTargetProvider;
import org.eclipse.cdt.serial.SerialPort;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.launchbar.core.target.ILaunchTarget;
import org.eclipse.launchbar.core.target.ILaunchTargetManager;
import org.eclipse.launchbar.core.target.ILaunchTargetWorkingCopy;
import org.eclipse.launchbar.ui.target.LaunchTargetWizard;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
public class NewGdbRemoteSerialTargetWizard extends LaunchTargetWizard {
private Button sameAsPortname;
private Text nameText;
private Combo portCombo;
private Text baudText;
private class SerialPage extends WizardPage {
public SerialPage() {
super(NewGdbRemoteTCPTargetWizard.class.getName());
setTitle(LaunchUIMessages.getString("NewGDBRemoteSerialTargetWizard_Title")); //$NON-NLS-1$
setDescription(LaunchUIMessages.getString("NewGDBRemoteSerialTargetWizard_Desc")); //$NON-NLS-1$
}
@Override
public void createControl(Composite parent) {
Composite control = new Composite(parent, SWT.NONE);
control.setLayout(new GridLayout());
// Target name
Group nameGroup = new Group(control, SWT.NONE);
nameGroup.setText(LaunchUIMessages.getString("NewGDBRemoteSerialTargetWizard_NameGroup")); //$NON-NLS-1$
nameGroup.setLayout(new GridLayout(2, false));
nameGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
sameAsPortname = new Button(nameGroup, SWT.CHECK);
sameAsPortname.setText(LaunchUIMessages.getString("NewGDBRemoteSerialTargetWizard_SameAsSerialPort")); //$NON-NLS-1$
GridData gridData = new GridData();
gridData.horizontalSpan = 2;
sameAsPortname.setLayoutData(gridData);
sameAsPortname.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
boolean same = sameAsPortname.getSelection();
if (same) {
nameText.setText(portCombo.getText());
}
nameText.setEnabled(!same);
}
});
sameAsPortname.setSelection(true);
Label nameLabel = new Label(nameGroup, SWT.NONE);
nameLabel.setText(LaunchUIMessages.getString("NewGDBRemoteSerialTargetWizard_TargetName")); //$NON-NLS-1$
nameText = new Text(nameGroup, SWT.BORDER);
nameText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
nameText.setEnabled(false);
nameText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
validatePage();
}
});
// serial port
Group connGroup = new Group(control, SWT.NONE);
connGroup.setText(LaunchUIMessages.getString("NewGDBRemoteSerialTargetWizard_ConnectionGroup")); //$NON-NLS-1$
connGroup.setLayout(new GridLayout(2, false));
connGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
Label portLabel = new Label(connGroup, SWT.NONE);
portLabel.setText(LaunchUIMessages.getString("NewGDBRemoteSerialTargetWizard_SerialPort")); //$NON-NLS-1$
portCombo = new Combo(connGroup, SWT.NONE);
portCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
try {
String[] portNames = SerialPort.list();
for (String portName : portNames) {
portCombo.add(portName);
}
if (portNames.length > 0) {
portCombo.select(0);
nameText.setText(portCombo.getText());
}
} catch (IOException e) {
GdbUIPlugin.log(e);
}
portCombo.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
if (sameAsPortname.getSelection()) {
nameText.setText(portCombo.getText());
}
validatePage();
}
});
Label baudLabel = new Label(connGroup, SWT.NONE);
baudLabel.setText(LaunchUIMessages.getString("NewGDBRemoteSerialTargetWizard_BaudRate")); //$NON-NLS-1$
baudText = new Text(connGroup, SWT.BORDER);
baudText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
baudText.setText("115200"); //$NON-NLS-1$
baudText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
validatePage();
}
});
setControl(control);
validatePage();
}
private void validatePage() {
setPageComplete(false);
String port = portCombo.getText();
if (port.isEmpty()) {
setErrorMessage(LaunchUIMessages.getString("NewGDBRemoteSerialTargetWizard_NoSerialPort")); //$NON-NLS-1$
return;
}
try {
String[] ports = SerialPort.list();
Arrays.sort(ports);
if (Arrays.binarySearch(ports, port) < 0) {
setMessage("Serial port not found on this system", WARNING); //$NON-NLS-1$
} else {
setMessage(null, WARNING);
}
} catch (IOException e) {
setErrorMessage(e.getLocalizedMessage());
return;
}
String baud = baudText.getText();
if (baud.isEmpty()) {
setErrorMessage(LaunchUIMessages.getString("NewGDBRemoteSerialTargetWizard_NoBaudRate")); //$NON-NLS-1$
return;
}
try {
Integer.parseInt(baud);
} catch (NumberFormatException e) {
setErrorMessage(LaunchUIMessages.getString("NewGDBRemoteSerialTargetWizard_BaudNotANumber")); //$NON-NLS-1$
return;
}
if (nameText.getText().isEmpty()) {
setErrorMessage(LaunchUIMessages.getString("NewGDBRemoteSerialTargetWizard_NoTargetName")); //$NON-NLS-1$
return;
}
setErrorMessage(null);
setPageComplete(true);
}
}
@Override
public void addPages() {
super.addPages();
addPage(new SerialPage());
}
@Override
public boolean performFinish() {
ILaunchTargetManager manager = GdbUIPlugin.getService(ILaunchTargetManager.class);
String id = nameText.getText();
ILaunchTarget target = getLaunchTarget();
if (target == null) {
target = manager.addLaunchTarget(GDBRemoteSerialLaunchTargetProvider.TYPE_ID, id);
}
ILaunchTargetWorkingCopy wc = target.getWorkingCopy();
wc.setId(id);
wc.setAttribute(IGDBLaunchConfigurationConstants.ATTR_DEV, portCombo.getText());
wc.setAttribute(IGDBLaunchConfigurationConstants.ATTR_DEV_SPEED, baudText.getText());
wc.save();
return true;
}
}

View file

@ -0,0 +1,197 @@
/*******************************************************************************
* Copyright (c) 2019 QNX Software Systems and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/
package org.eclipse.cdt.dsf.gdb.internal.ui.launching;
import org.eclipse.cdt.dsf.gdb.IGDBLaunchConfigurationConstants;
import org.eclipse.cdt.dsf.gdb.internal.ui.GdbUIPlugin;
import org.eclipse.cdt.dsf.gdb.launching.GDBRemoteTCPLaunchTargetProvider;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.launchbar.core.target.ILaunchTarget;
import org.eclipse.launchbar.core.target.ILaunchTargetManager;
import org.eclipse.launchbar.core.target.ILaunchTargetWorkingCopy;
import org.eclipse.launchbar.ui.target.LaunchTargetWizard;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
public class NewGdbRemoteTCPTargetWizard extends LaunchTargetWizard {
private Button sameAsHostname;
private Text nameText;
private Text hostText;
private Text portText;
private class TCPPage extends WizardPage {
public TCPPage() {
super(NewGdbRemoteTCPTargetWizard.class.getName());
setTitle(LaunchUIMessages.getString("NewGdbRemoteTCPTargetWizard.Title")); //$NON-NLS-1$
setDescription(LaunchUIMessages.getString("NewGdbRemoteTCPTargetWizard.Desc")); //$NON-NLS-1$
}
@Override
public void createControl(Composite parent) {
Composite control = new Composite(parent, SWT.NONE);
control.setLayout(new GridLayout());
// Target name
Group nameGroup = new Group(control, SWT.NONE);
nameGroup.setText(LaunchUIMessages.getString("NewGdbRemoteTCPTargetWizard.NameGroup")); //$NON-NLS-1$
nameGroup.setLayout(new GridLayout(2, false));
nameGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
sameAsHostname = new Button(nameGroup, SWT.CHECK);
sameAsHostname.setText(LaunchUIMessages.getString("NewGdbRemoteTCPTargetWizard.SameAsHost")); //$NON-NLS-1$
GridData gridData = new GridData();
gridData.horizontalSpan = 2;
sameAsHostname.setLayoutData(gridData);
sameAsHostname.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
boolean same = sameAsHostname.getSelection();
if (same) {
nameText.setText(hostText.getText());
}
nameText.setEnabled(!same);
}
});
sameAsHostname.setSelection(true);
Label nameLabel = new Label(nameGroup, SWT.NONE);
nameLabel.setText(LaunchUIMessages.getString("NewGdbRemoteTCPTargetWizard.TargetName")); //$NON-NLS-1$
nameText = new Text(nameGroup, SWT.BORDER);
nameText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
nameText.setEnabled(false);
nameText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
validatePage();
}
});
// host and port
Group connGroup = new Group(control, SWT.NONE);
connGroup.setText(LaunchUIMessages.getString("NewGdbRemoteTCPTargetWizard.ConnectionGroup")); //$NON-NLS-1$
connGroup.setLayout(new GridLayout(4, false));
connGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
Label hostLabel = new Label(connGroup, SWT.NONE);
hostLabel.setText(LaunchUIMessages.getString("NewGdbRemoteTCPTargetWizard.HostName")); //$NON-NLS-1$
hostText = new Text(connGroup, SWT.BORDER);
hostText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
hostText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
if (sameAsHostname.getSelection()) {
nameText.setText(hostText.getText());
}
validatePage();
}
});
Label portLabel = new Label(connGroup, SWT.NONE);
portLabel.setText(LaunchUIMessages.getString("NewGdbRemoteTCPTargetWizard.Port")); //$NON-NLS-1$
portText = new Text(connGroup, SWT.BORDER);
portText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
validatePage();
}
});
setControl(control);
validatePage();
}
private void validatePage() {
setPageComplete(false);
if (hostText.getText().isEmpty()) {
setErrorMessage(LaunchUIMessages.getString("NewGdbRemoteTCPTargetWizard.NoHost")); //$NON-NLS-1$
return;
}
String port = portText.getText();
if (port.isEmpty()) {
setErrorMessage(LaunchUIMessages.getString("NewGdbRemoteTCPTargetWizard.NoPort")); //$NON-NLS-1$
return;
}
try {
Integer.parseInt(port);
} catch (NumberFormatException e) {
setErrorMessage(LaunchUIMessages.getString("NewGdbRemoteTCPTargetWizard.PortNotANumber")); //$NON-NLS-1$
return;
}
if (nameText.getText().isEmpty()) {
setErrorMessage(LaunchUIMessages.getString("NewGdbRemoteTCPTargetWizard.NoName")); //$NON-NLS-1$
return;
}
setErrorMessage(null);
setPageComplete(true);
}
}
@Override
public void addPages() {
super.addPages();
addPage(new TCPPage());
}
@Override
public boolean performFinish() {
ILaunchTargetManager manager = GdbUIPlugin.getService(ILaunchTargetManager.class);
String id = nameText.getText();
ILaunchTarget target = getLaunchTarget();
if (target == null) {
target = manager.addLaunchTarget(GDBRemoteTCPLaunchTargetProvider.TYPE_ID, id);
}
ILaunchTargetWorkingCopy wc = target.getWorkingCopy();
wc.setId(id);
wc.setAttribute(IGDBLaunchConfigurationConstants.ATTR_HOST, hostText.getText());
wc.setAttribute(IGDBLaunchConfigurationConstants.ATTR_PORT, portText.getText());
wc.save();
return true;
}
@Override
public boolean canDelete() {
return true;
}
@Override
public void performDelete() {
ILaunchTargetManager manager = GdbUIPlugin.getService(ILaunchTargetManager.class);
ILaunchTarget target = getLaunchTarget();
if (target != null) {
manager.removeLaunchTarget(target);
}
}
}

View file

@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-Vendor: %providerName
Bundle-SymbolicName: org.eclipse.cdt.dsf.gdb;singleton:=true
Bundle-Version: 5.6.100.qualifier
Bundle-Version: 5.7.0.qualifier
Bundle-Activator: org.eclipse.cdt.dsf.gdb.internal.GdbPlugin
Bundle-Localization: plugin
Require-Bundle: org.eclipse.core.runtime,
@ -16,7 +16,8 @@ Require-Bundle: org.eclipse.core.runtime,
org.eclipse.cdt.gdb;bundle-version="7.0.0",
org.eclipse.core.resources,
org.eclipse.launchbar.core;bundle-version="2.0.0";visibility:=reexport,
org.eclipse.cdt.core.native;bundle-version="[5.10.0,6.0.0)"
org.eclipse.cdt.core.native;bundle-version="[5.10.0,6.0.0)",
org.eclipse.cdt.native.serial;bundle-version="1.1.100"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Export-Package: org.eclipse.cdt.dsf.gdb,

View file

@ -25,3 +25,4 @@ launchDelegate.attach.description=Attach the GDB debugger, integrated using the
launchDelegate.postmortem.name=GDB (DSF) Postmortem Debugger
launchDelegate.postmortem.description=Load an application dump using the GDB debugger integrated using the Debugger Services Framework (DSF).
cdt.dsf.gdb.component.label = CDT GDB Core
coreBuildLocalDebug.name=Core Build Local Debug

View file

@ -17,7 +17,7 @@
id="org.eclipse.cdt.dsf.gdb.launch.remoteCLaunch"
type="org.eclipse.cdt.launch.remoteApplicationLaunchType"
modes="debug"
delegate="org.eclipse.cdt.dsf.gdb.launching.GdbLaunchDelegate"
delegate="org.eclipse.cdt.dsf.gdb.launching.GdbTargetedLaunchDelegate"
name="%launchDelegate.remoteApplication.name"
delegateDescription="%launchDelegate.remoteApplication.description"
sourceLocatorId="org.eclipse.cdt.debug.core.sourceLocator"
@ -91,7 +91,7 @@
delegate="org.eclipse.cdt.dsf.gdb.internal.launching.CoreBuildLocalDebugLaunchDelegate"
id="org.eclipse.cdt.dsf.gdb.coreBuildLocalDebug"
modes="debug"
name="Core Build Local Debug"
name="%coreBuildLocalDebug.name"
sourceLocatorId="org.eclipse.cdt.debug.core.sourceLocator"
sourcePathComputerId="org.eclipse.cdt.debug.core.sourcePathComputer"
type="org.eclipse.cdt.debug.core.localCoreBuildLaunchConfigType">
@ -101,4 +101,29 @@
</modeCombination>
</launchDelegate>
</extension>
<extension
point="org.eclipse.launchbar.core.launchTargetTypes">
<launchTargetType
id="org.eclipse.cdt.dsf.gdb.remoteTCPLaunchTargetType"
provider="org.eclipse.cdt.dsf.gdb.launching.GDBRemoteTCPLaunchTargetProvider">
</launchTargetType>
<launchTargetType
id="org.eclipse.cdt.dsf.gdb.remoteSerialLaunchTargetType"
provider="org.eclipse.cdt.dsf.gdb.launching.GDBRemoteSerialLaunchTargetProvider">
</launchTargetType>
</extension>
<extension
point="org.eclipse.launchbar.core.launchBarContributions">
<descriptorType
class="org.eclipse.cdt.dsf.gdb.internal.launching.GdbRemoteLaunchDescriptorType"
id="org.eclipse.cdt.dsf.gdb.gdbRemotedescriptorType"
priority="10">
</descriptorType>
<configProvider
class="org.eclipse.cdt.dsf.gdb.internal.launching.GdbRemoteLaunchConfigProvider"
descriptorType="org.eclipse.cdt.dsf.gdb.gdbRemotedescriptorType"
priority="10"
supportsNullTarget="true">
</configProvider>
</extension>
</plugin>

View file

@ -35,6 +35,7 @@ import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunch;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
/**
* The activator class controls the plug-in life cycle
@ -209,4 +210,11 @@ public class GdbPlugin extends Plugin {
public static void log(Throwable e) {
log(new Status(IStatus.ERROR, getUniqueIdentifier(), IStatus.ERROR, e.getMessage(), e));
}
public static <T> T getService(Class<T> service) {
BundleContext context = plugin.getBundle().getBundleContext();
ServiceReference<T> ref = context.getServiceReference(service);
return ref != null ? context.getService(ref) : null;
}
}

View file

@ -0,0 +1,42 @@
/*******************************************************************************
* Copyright (c) 2019 QNX Software Systems and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/
package org.eclipse.cdt.dsf.gdb.internal.launching;
import org.eclipse.cdt.dsf.gdb.launching.GDBRemoteSerialLaunchTargetProvider;
import org.eclipse.cdt.dsf.gdb.launching.GDBRemoteTCPLaunchTargetProvider;
import org.eclipse.cdt.dsf.gdb.launching.LaunchUtils;
import org.eclipse.cdt.dsf.gdb.service.SessionType;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.launchbar.core.DefaultLaunchConfigProvider;
import org.eclipse.launchbar.core.DefaultLaunchDescriptor;
import org.eclipse.launchbar.core.ILaunchDescriptor;
import org.eclipse.launchbar.core.target.ILaunchTarget;
public class GdbRemoteLaunchConfigProvider extends DefaultLaunchConfigProvider {
@Override
public boolean supports(ILaunchDescriptor descriptor, ILaunchTarget target) throws CoreException {
if (descriptor instanceof DefaultLaunchDescriptor) {
ILaunchConfiguration config = descriptor.getAdapter(ILaunchConfiguration.class);
if (LaunchUtils.getSessionType(config) != SessionType.REMOTE) {
return false;
}
String targetTypeId = target.getTypeId();
return targetTypeId.equals(GDBRemoteTCPLaunchTargetProvider.TYPE_ID)
|| targetTypeId.equals(GDBRemoteSerialLaunchTargetProvider.TYPE_ID);
}
return false;
}
}

View file

@ -0,0 +1,34 @@
/*******************************************************************************
* Copyright (c) 2019 QNX Software Systems and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/
package org.eclipse.cdt.dsf.gdb.internal.launching;
import org.eclipse.cdt.dsf.gdb.launching.LaunchUtils;
import org.eclipse.cdt.dsf.gdb.service.SessionType;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.launchbar.core.DefaultLaunchDescriptor;
import org.eclipse.launchbar.core.ILaunchDescriptor;
import org.eclipse.launchbar.core.ILaunchDescriptorType;
public class GdbRemoteLaunchDescriptorType implements ILaunchDescriptorType {
@Override
public ILaunchDescriptor getDescriptor(Object launchObject) throws CoreException {
if (launchObject instanceof ILaunchConfiguration) {
ILaunchConfiguration config = (ILaunchConfiguration) launchObject;
if (LaunchUtils.getSessionType(config) == SessionType.REMOTE) {
return new DefaultLaunchDescriptor(this, config);
}
}
return null;
}
}

View file

@ -0,0 +1,51 @@
/*******************************************************************************
* Copyright (c) 2019 QNX Software Systems and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/
package org.eclipse.cdt.dsf.gdb.launching;
import java.io.IOException;
import org.eclipse.cdt.dsf.gdb.IGDBLaunchConfigurationConstants;
import org.eclipse.cdt.serial.SerialPort;
import org.eclipse.launchbar.core.target.ILaunchTarget;
import org.eclipse.launchbar.core.target.ILaunchTargetManager;
import org.eclipse.launchbar.core.target.ILaunchTargetProvider;
import org.eclipse.launchbar.core.target.TargetStatus;
import org.eclipse.launchbar.core.target.TargetStatus.Code;
public class GDBRemoteSerialLaunchTargetProvider implements ILaunchTargetProvider {
public static final String TYPE_ID = "org.eclipse.cdt.dsf.gdb.remoteSerialLaunchTargetType"; //$NON-NLS-1$
@Override
public void init(ILaunchTargetManager targetManager) {
// No automatic targets. Adding all serial ports would be noisy.
}
@Override
public TargetStatus getStatus(ILaunchTarget target) {
String device = target.getAttribute(IGDBLaunchConfigurationConstants.ATTR_DEV, ""); //$NON-NLS-1$
if (device.isEmpty()) {
return new TargetStatus(Code.ERROR, LaunchMessages.getString("GDBRemoteSerialLaunchTargetProvider_NoPort")); //$NON-NLS-1$
}
try {
for (String port : SerialPort.list()) {
if (device.equals(port)) {
return TargetStatus.OK_STATUS;
}
}
return new TargetStatus(Code.ERROR,
String.format(LaunchMessages.getString("GDBRemoteSerialLaunchTargetProvider_NotFound"), device)); //$NON-NLS-1$
} catch (IOException e) {
return new TargetStatus(Code.ERROR, e.getLocalizedMessage());
}
}
}

View file

@ -0,0 +1,32 @@
/*******************************************************************************
* Copyright (c) 2019 QNX Software Systems and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/
package org.eclipse.cdt.dsf.gdb.launching;
import org.eclipse.launchbar.core.target.ILaunchTarget;
import org.eclipse.launchbar.core.target.ILaunchTargetManager;
import org.eclipse.launchbar.core.target.ILaunchTargetProvider;
import org.eclipse.launchbar.core.target.TargetStatus;
public class GDBRemoteTCPLaunchTargetProvider implements ILaunchTargetProvider {
public static final String TYPE_ID = "org.eclipse.cdt.dsf.gdb.remoteTCPLaunchTargetType"; //$NON-NLS-1$
@Override
public void init(ILaunchTargetManager targetManager) {
// There are no autodiscovered launches for this type.
}
@Override
public TargetStatus getStatus(ILaunchTarget target) {
return TargetStatus.OK_STATUS;
}
}

View file

@ -0,0 +1,65 @@
/*******************************************************************************
* Copyright (c) 2019 QNX Software Systems and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/
package org.eclipse.cdt.dsf.gdb.launching;
import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.launchbar.core.target.ILaunchTarget;
import org.eclipse.launchbar.core.target.ILaunchTargetManager;
import org.eclipse.launchbar.core.target.launch.ILaunchConfigurationTargetedDelegate;
import org.eclipse.launchbar.core.target.launch.ITargetedLaunch;
/**
* Launch delegate that adds the ILaunchTarget to the GdbLaunch.
*
* There are other things we could do with this such as make sure the binary we are
* launching matches the cpu architecture and OS of the target, and add the launch
* checks to do the same. For now, though, we are assuming the user knows what they
* are doing when they set this up since it's all manual at this point.
*/
public class GdbTargetedLaunchDelegate extends GdbLaunchDelegate implements ILaunchConfigurationTargetedDelegate {
@Override
public ITargetedLaunch getLaunch(ILaunchConfiguration configuration, String mode, ILaunchTarget target)
throws CoreException {
GdbLaunch launch = (GdbLaunch) super.getLaunch(configuration, mode);
launch.setLaunchTarget(target);
return launch;
}
@Override
public ILaunch getLaunch(ILaunchConfiguration configuration, String mode) throws CoreException {
ILaunchTarget target = GdbPlugin.getService(ILaunchTargetManager.class).getDefaultLaunchTarget(configuration);
return getLaunch(configuration, mode, target);
}
@Override
public boolean buildForLaunch(ILaunchConfiguration configuration, String mode, ILaunchTarget target,
IProgressMonitor monitor) throws CoreException {
return super.buildForLaunch(configuration, mode, monitor);
}
@Override
public boolean finalLaunchCheck(ILaunchConfiguration configuration, String mode, ILaunchTarget target,
IProgressMonitor monitor) throws CoreException {
return super.finalLaunchCheck(configuration, mode, monitor);
}
@Override
public boolean preLaunchCheck(ILaunchConfiguration configuration, String mode, ILaunchTarget target,
IProgressMonitor monitor) throws CoreException {
return super.preLaunchCheck(configuration, mode, monitor);
}
}

View file

@ -147,6 +147,8 @@ GdbLaunchDelegate.0=Launching debugger session
GdbLaunchDelegate.1=Debugging remote C/C++ application
GdbLaunchDelegate.2=Post Mortem Debugging of C/C++ application
GdbLaunchDelegate.3=Debugging local C/C++ application
GDBRemoteSerialLaunchTargetProvider_NoPort=No serial port device specified.
GDBRemoteSerialLaunchTargetProvider_NotFound=Serial port %s not found
WorkingDirectoryBlock.4=Select a &workspace relative working directory:
WorkingDirectoryBlock.7=Select a working directory for the launch configuration:

View file

@ -17,6 +17,7 @@
package org.eclipse.cdt.dsf.gdb.service;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Hashtable;
import java.util.Iterator;
@ -47,6 +48,7 @@ import org.eclipse.cdt.dsf.debug.service.command.ICommand;
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService.ICommandControlDMContext;
import org.eclipse.cdt.dsf.gdb.IGDBLaunchConfigurationConstants;
import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin;
import org.eclipse.cdt.dsf.gdb.launching.GDBRemoteTCPLaunchTargetProvider;
import org.eclipse.cdt.dsf.gdb.service.IGDBTraceControl.ITraceRecordSelectedChangedDMEvent;
import org.eclipse.cdt.dsf.gdb.service.command.IGDBControl;
import org.eclipse.cdt.dsf.mi.service.IMICommandControl;
@ -67,6 +69,8 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.launchbar.core.target.ILaunchTarget;
import org.eclipse.launchbar.core.target.launch.ITargetedLaunch;
import com.ibm.icu.text.MessageFormat;
@ -435,7 +439,7 @@ public class GDBProcesses_7_2 extends GDBProcesses_7_1 implements IMultiTerminat
} else {
super.handleCompleted();
}
};
}
});
return;
}
@ -535,10 +539,21 @@ public class GDBProcesses_7_2 extends GDBProcesses_7_1 implements IMultiTerminat
ILaunch launch = procCtx.getAdapter(ILaunch.class);
assert launch != null;
if (launch != null) {
Map<String, Object> attributes = null;
Map<String, Object> attributes = new HashMap<>();
try {
attributes = launch.getLaunchConfiguration().getAttributes();
attributes.putAll(launch.getLaunchConfiguration().getAttributes());
} catch (CoreException e) {
rm.done(e.getStatus());
return;
}
if (launch instanceof ITargetedLaunch) {
ILaunchTarget target = ((ITargetedLaunch) launch).getLaunchTarget();
if (target != null) {
attributes.putAll(target.getAttributes());
attributes.put(IGDBLaunchConfigurationConstants.ATTR_REMOTE_TCP,
target.getTypeId().equals(GDBRemoteTCPLaunchTargetProvider.TYPE_ID));
}
}
boolean isTcpConnection = CDebugUtils.getAttribute(attributes,

View file

@ -28,6 +28,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
@ -52,10 +53,12 @@ import org.eclipse.cdt.dsf.debug.service.command.ICommandControl;
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService;
import org.eclipse.cdt.dsf.debug.service.command.ICommandResult;
import org.eclipse.cdt.dsf.debug.service.command.ICommandToken;
import org.eclipse.cdt.dsf.gdb.IGDBLaunchConfigurationConstants;
import org.eclipse.cdt.dsf.gdb.IGdbDebugConstants;
import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin;
import org.eclipse.cdt.dsf.gdb.internal.Messages;
import org.eclipse.cdt.dsf.gdb.launching.FinalLaunchSequence;
import org.eclipse.cdt.dsf.gdb.launching.GDBRemoteTCPLaunchTargetProvider;
import org.eclipse.cdt.dsf.gdb.service.IGDBBackend;
import org.eclipse.cdt.dsf.gdb.service.IGDBProcesses;
import org.eclipse.cdt.dsf.gdb.service.command.GdbCommandTimeoutManager.ICommandTimeoutListener;
@ -94,6 +97,8 @@ import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.IStatusHandler;
import org.eclipse.launchbar.core.target.ILaunchTarget;
import org.eclipse.launchbar.core.target.launch.ITargetedLaunch;
import org.osgi.framework.BundleContext;
/**
@ -425,10 +430,22 @@ public class GDBControl extends AbstractMIControl implements IGDBControl {
public void completeInitialization(final RequestMonitor rm) {
// We take the attributes from the launchConfiguration
ILaunch launch = (ILaunch) getSession().getModelAdapter(ILaunch.class);
Map<String, Object> attributes = null;
Map<String, Object> attributes = new HashMap<>();
try {
attributes = launch.getLaunchConfiguration().getAttributes();
attributes.putAll(launch.getLaunchConfiguration().getAttributes());
} catch (CoreException e) {
rm.done(e.getStatus());
return;
}
// And optionally the target
if (launch instanceof ITargetedLaunch) {
ILaunchTarget target = ((ITargetedLaunch) launch).getLaunchTarget();
if (target != null) {
attributes.putAll(target.getAttributes());
attributes.put(IGDBLaunchConfigurationConstants.ATTR_REMOTE_TCP,
target.getTypeId().equals(GDBRemoteTCPLaunchTargetProvider.TYPE_ID));
}
}
// We need a RequestMonitorWithProgress, if we don't have one, we create one.