From 6a27da170ff212875e529870131e87aa431cfe5f Mon Sep 17 00:00:00 2001 From: Doug Schaefer Date: Fri, 31 May 2019 16:43:03 -0400 Subject: [PATCH] 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 --- .../debug.product | 1 + .../ui/launch/LaunchMessages.properties | 6 + .../ui/launch/NewGenericTargetWizard.java | 7 +- .../ui/launch/NewGenericTargetWizardPage.java | 10 +- .../META-INF/MANIFEST.MF | 4 +- .../icons/full/obj16/connect.gif | Bin 0 -> 189 bytes dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/plugin.xml | 23 ++ .../cdt/dsf/gdb/internal/ui/GdbUIPlugin.java | 8 + .../GdbRemoteTargetLabelProvider.java | 32 +++ .../internal/ui/launching/LaunchImages.java | 3 + .../ui/launching/LaunchUIMessages.properties | 24 ++ .../NewGdbRemoteSerialTargetWizard.java | 217 ++++++++++++++++++ .../NewGdbRemoteTCPTargetWizard.java | 197 ++++++++++++++++ .../META-INF/MANIFEST.MF | 5 +- .../org.eclipse.cdt.dsf.gdb/plugin.properties | 1 + dsf-gdb/org.eclipse.cdt.dsf.gdb/plugin.xml | 29 ++- .../cdt/dsf/gdb/internal/GdbPlugin.java | 8 + .../GdbRemoteLaunchConfigProvider.java | 42 ++++ .../GdbRemoteLaunchDescriptorType.java | 34 +++ .../GDBRemoteSerialLaunchTargetProvider.java | 51 ++++ .../GDBRemoteTCPLaunchTargetProvider.java | 32 +++ .../launching/GdbTargetedLaunchDelegate.java | 65 ++++++ .../gdb/launching/LaunchMessages.properties | 2 + .../cdt/dsf/gdb/service/GDBProcesses_7_2.java | 21 +- .../dsf/gdb/service/command/GDBControl.java | 21 +- 25 files changed, 824 insertions(+), 19 deletions(-) create mode 100755 dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/icons/full/obj16/connect.gif create mode 100644 dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/GdbRemoteTargetLabelProvider.java create mode 100644 dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/NewGdbRemoteSerialTargetWizard.java create mode 100644 dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/NewGdbRemoteTCPTargetWizard.java create mode 100644 dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/launching/GdbRemoteLaunchConfigProvider.java create mode 100644 dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/launching/GdbRemoteLaunchDescriptorType.java create mode 100644 dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/GDBRemoteSerialLaunchTargetProvider.java create mode 100644 dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/GDBRemoteTCPLaunchTargetProvider.java create mode 100644 dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/GdbTargetedLaunchDelegate.java diff --git a/debug/org.eclipse.cdt.debug.application.product/debug.product b/debug/org.eclipse.cdt.debug.application.product/debug.product index bad7089943d..0b7c6d4e87a 100644 --- a/debug/org.eclipse.cdt.debug.application.product/debug.product +++ b/debug/org.eclipse.cdt.debug.application.product/debug.product @@ -226,6 +226,7 @@ Java and all Java-based trademarks are trademarks of Oracle Corporation in the U + diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/LaunchMessages.properties b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/LaunchMessages.properties index e8ce5e4aa49..1308970bbed 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/LaunchMessages.properties +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/LaunchMessages.properties @@ -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 diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/NewGenericTargetWizard.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/NewGenericTargetWizard.java index cd7fc623a2b..d87250367d1 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/NewGenericTargetWizard.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/NewGenericTargetWizard.java @@ -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); } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/NewGenericTargetWizardPage.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/NewGenericTargetWizardPage.java index 03bac89a531..1505126f847 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/NewGenericTargetWizardPage.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/NewGenericTargetWizardPage.java @@ -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)); diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/META-INF/MANIFEST.MF b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/META-INF/MANIFEST.MF index edeeaddf009..c37b595367c 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/META-INF/MANIFEST.MF +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/META-INF/MANIFEST.MF @@ -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", diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/icons/full/obj16/connect.gif b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/icons/full/obj16/connect.gif new file mode 100755 index 0000000000000000000000000000000000000000..866ad33825010a87df311a4d9468dc73303f6935 GIT binary patch literal 189 zcmZ?wbhEHb6krfwc+A1TV9UVZ%D~XT5E&WCu$qBkKLf)(hF6cJ{^J0O|3saOQWHy3 zQxwWGOEMHfGEx=XJ$(Zh6o0ZXaxw5T=r8~Q$Z!Uhzz-)qSMRM*QsGnxT~OGP*c7aw z#LO;Y;Lypqo7bt&%e0zD*D2vRvs|BUi$;m{Kep4I6AnoIF}vt~a!Ss{v<-(=eGLfY Tuw=|SyxPZo<_;NQMh0sDv;9kC literal 0 HcmV?d00001 diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/plugin.xml b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/plugin.xml index 16ca680837c..75ae7454c99 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/plugin.xml +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/plugin.xml @@ -607,4 +607,27 @@ plugin="org.eclipse.cdt.dsf.gdb"> + + + + + + + + + + diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbUIPlugin.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbUIPlugin.java index 1bc7d8fdb00..6520f9c888b 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbUIPlugin.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbUIPlugin.java @@ -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 getService(Class service) { + BundleContext context = plugin.getBundle().getBundleContext(); + ServiceReference ref = context.getServiceReference(service); + return ref != null ? context.getService(ref) : null; + } + } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/GdbRemoteTargetLabelProvider.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/GdbRemoteTargetLabelProvider.java new file mode 100644 index 00000000000..f59b0b08777 --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/GdbRemoteTargetLabelProvider.java @@ -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); + } + +} diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/LaunchImages.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/LaunchImages.java index 3102a08e011..0c74bf6611c 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/LaunchImages.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/LaunchImages.java @@ -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() { } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/LaunchUIMessages.properties b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/LaunchUIMessages.properties index f511805dc5d..80164ffcc54 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/LaunchUIMessages.properties +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/LaunchUIMessages.properties @@ -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 diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/NewGdbRemoteSerialTargetWizard.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/NewGdbRemoteSerialTargetWizard.java new file mode 100644 index 00000000000..8af8bb01a92 --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/NewGdbRemoteSerialTargetWizard.java @@ -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; + } + +} diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/NewGdbRemoteTCPTargetWizard.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/NewGdbRemoteTCPTargetWizard.java new file mode 100644 index 00000000000..8b25a1cad2a --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/NewGdbRemoteTCPTargetWizard.java @@ -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); + } + } + +} diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/META-INF/MANIFEST.MF b/dsf-gdb/org.eclipse.cdt.dsf.gdb/META-INF/MANIFEST.MF index aec9fbef1f9..90a14a44145 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/META-INF/MANIFEST.MF +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/META-INF/MANIFEST.MF @@ -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, diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/plugin.properties b/dsf-gdb/org.eclipse.cdt.dsf.gdb/plugin.properties index 81803f92b47..6c296d4fa2e 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/plugin.properties +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/plugin.properties @@ -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 diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/plugin.xml b/dsf-gdb/org.eclipse.cdt.dsf.gdb/plugin.xml index ea9c3a68a7c..c7061339fec 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/plugin.xml +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/plugin.xml @@ -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 @@ + + + + + + + + + + + + diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/GdbPlugin.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/GdbPlugin.java index b3adb14e7a8..9b79416996b 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/GdbPlugin.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/GdbPlugin.java @@ -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 getService(Class service) { + BundleContext context = plugin.getBundle().getBundleContext(); + ServiceReference ref = context.getServiceReference(service); + return ref != null ? context.getService(ref) : null; + } + } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/launching/GdbRemoteLaunchConfigProvider.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/launching/GdbRemoteLaunchConfigProvider.java new file mode 100644 index 00000000000..9d639b947df --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/launching/GdbRemoteLaunchConfigProvider.java @@ -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; + } + +} diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/launching/GdbRemoteLaunchDescriptorType.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/launching/GdbRemoteLaunchDescriptorType.java new file mode 100644 index 00000000000..97fa5318582 --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/launching/GdbRemoteLaunchDescriptorType.java @@ -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; + } + +} diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/GDBRemoteSerialLaunchTargetProvider.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/GDBRemoteSerialLaunchTargetProvider.java new file mode 100644 index 00000000000..331dae14b3b --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/GDBRemoteSerialLaunchTargetProvider.java @@ -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()); + } + } + +} diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/GDBRemoteTCPLaunchTargetProvider.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/GDBRemoteTCPLaunchTargetProvider.java new file mode 100644 index 00000000000..1823fc2fd39 --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/GDBRemoteTCPLaunchTargetProvider.java @@ -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; + } + +} diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/GdbTargetedLaunchDelegate.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/GdbTargetedLaunchDelegate.java new file mode 100644 index 00000000000..76caa8c00c0 --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/GdbTargetedLaunchDelegate.java @@ -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); + } + +} diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/LaunchMessages.properties b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/LaunchMessages.properties index 4b3c9c0cdf7..17952d59e59 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/LaunchMessages.properties +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/LaunchMessages.properties @@ -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: diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBProcesses_7_2.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBProcesses_7_2.java index 7abc6db0a06..d1ce72b90d9 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBProcesses_7_2.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBProcesses_7_2.java @@ -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 attributes = null; + Map 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, diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GDBControl.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GDBControl.java index c456c372d1d..590e71bbe4b 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GDBControl.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GDBControl.java @@ -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 attributes = null; + Map 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.