From b29198a8acc4d7e162ccc5b01c2abaa15170aea6 Mon Sep 17 00:00:00 2001 From: ewaterlander Date: Mon, 14 Jul 2025 22:33:20 +0100 Subject: [PATCH] GDB Remote launch targets load attributes when editing. (#1207) * When a GDB Remote TCP or Serial launch target was openend for editing the current attribute values were not shown. * The "name" attribute (which is equal to the id) was not updated in the preferences. --- .../META-INF/MANIFEST.MF | 2 +- .../NewGdbRemoteSerialTargetWizard.java | 48 +++++++++++++------ .../NewGdbRemoteTCPTargetWizard.java | 20 ++++++-- .../META-INF/MANIFEST.MF | 2 +- .../target/LaunchTargetWorkingCopy.java | 3 +- 5 files changed, 54 insertions(+), 21 deletions(-) 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 af7cfe4a751..d92d0ef4cfe 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 @@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-Vendor: %providerName Bundle-SymbolicName: org.eclipse.cdt.dsf.gdb.ui;singleton:=true -Bundle-Version: 2.8.800.qualifier +Bundle-Version: 2.8.900.qualifier Bundle-Activator: org.eclipse.cdt.dsf.gdb.internal.ui.GdbUIPlugin Bundle-Localization: plugin Require-Bundle: org.eclipse.ui;bundle-version="[3.207.200,4)", 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 index 8af8bb01a92..cee63dc0889 100644 --- 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2019 QNX Software Systems and others. + * Copyright (c) 2019, 2025 QNX Software Systems and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -42,6 +42,7 @@ public class NewGdbRemoteSerialTargetWizard extends LaunchTargetWizard { private Text nameText; private Combo portCombo; private Text baudText; + private static final String DEFAULT_BAUD_RATE = "115200"; //$NON-NLS-1$ private class SerialPage extends WizardPage { public SerialPage() { @@ -55,6 +56,28 @@ public class NewGdbRemoteSerialTargetWizard extends LaunchTargetWizard { Composite control = new Composite(parent, SWT.NONE); control.setLayout(new GridLayout()); + String targetName = ""; //$NON-NLS-1$ + String serialPort = ""; //$NON-NLS-1$ + String[] portNames; + String baudRate = DEFAULT_BAUD_RATE; + ILaunchTarget launchTarget = getLaunchTarget(); + try { + portNames = SerialPort.list(); + } catch (IOException e) { + GdbUIPlugin.log(e); + portNames = new String[0]; + } + if (launchTarget == null) { + if (portNames.length > 0) { + targetName = portNames[0]; + serialPort = portNames[0]; + } + } else { + targetName = launchTarget.getId(); + serialPort = launchTarget.getAttribute(IGDBLaunchConfigurationConstants.ATTR_DEV, serialPort); + baudRate = launchTarget.getAttribute(IGDBLaunchConfigurationConstants.ATTR_DEV_SPEED, baudRate); + } + // Target name Group nameGroup = new Group(control, SWT.NONE); @@ -77,14 +100,15 @@ public class NewGdbRemoteSerialTargetWizard extends LaunchTargetWizard { nameText.setEnabled(!same); } }); - sameAsPortname.setSelection(true); + sameAsPortname.setSelection(targetName.equals(serialPort)); Label nameLabel = new Label(nameGroup, SWT.NONE); nameLabel.setText(LaunchUIMessages.getString("NewGDBRemoteSerialTargetWizard_TargetName")); //$NON-NLS-1$ nameText = new Text(nameGroup, SWT.BORDER); + nameText.setText(targetName); nameText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - nameText.setEnabled(false); + nameText.setEnabled(!targetName.equals(serialPort)); nameText.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e) { @@ -105,17 +129,11 @@ public class NewGdbRemoteSerialTargetWizard extends LaunchTargetWizard { 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); + for (String portName : portNames) { + portCombo.add(portName); + } + if (portNames.length > 0) { + portCombo.setText(serialPort); } portCombo.addModifyListener(new ModifyListener() { @@ -133,7 +151,7 @@ public class NewGdbRemoteSerialTargetWizard extends LaunchTargetWizard { baudText = new Text(connGroup, SWT.BORDER); baudText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - baudText.setText("115200"); //$NON-NLS-1$ + baudText.setText(baudRate); baudText.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e) { 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 index 8b25a1cad2a..597e2c34dcc 100644 --- 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2019 QNX Software Systems and others. + * Copyright (c) 2019, 2025 QNX Software Systems and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -50,6 +50,16 @@ public class NewGdbRemoteTCPTargetWizard extends LaunchTargetWizard { Composite control = new Composite(parent, SWT.NONE); control.setLayout(new GridLayout()); + String targetName = ""; //$NON-NLS-1$ + String targetHostName = ""; //$NON-NLS-1$ + String targetPort = ""; //$NON-NLS-1$ + ILaunchTarget launchTarget = getLaunchTarget(); + if (launchTarget != null) { + targetName = launchTarget.getId(); + targetHostName = launchTarget.getAttribute(IGDBLaunchConfigurationConstants.ATTR_HOST, targetHostName); + targetPort = launchTarget.getAttribute(IGDBLaunchConfigurationConstants.ATTR_PORT, targetPort); + } + // Target name Group nameGroup = new Group(control, SWT.NONE); @@ -72,14 +82,15 @@ public class NewGdbRemoteTCPTargetWizard extends LaunchTargetWizard { nameText.setEnabled(!same); } }); - sameAsHostname.setSelection(true); + sameAsHostname.setSelection(targetName.equals(targetHostName)); Label nameLabel = new Label(nameGroup, SWT.NONE); nameLabel.setText(LaunchUIMessages.getString("NewGdbRemoteTCPTargetWizard.TargetName")); //$NON-NLS-1$ nameText = new Text(nameGroup, SWT.BORDER); + nameText.setText(targetName); nameText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - nameText.setEnabled(false); + nameText.setEnabled(!targetName.equals(targetHostName)); nameText.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e) { @@ -98,6 +109,7 @@ public class NewGdbRemoteTCPTargetWizard extends LaunchTargetWizard { hostLabel.setText(LaunchUIMessages.getString("NewGdbRemoteTCPTargetWizard.HostName")); //$NON-NLS-1$ hostText = new Text(connGroup, SWT.BORDER); + hostText.setText(targetHostName); hostText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); hostText.addModifyListener(new ModifyListener() { @Override @@ -113,6 +125,8 @@ public class NewGdbRemoteTCPTargetWizard extends LaunchTargetWizard { portLabel.setText(LaunchUIMessages.getString("NewGdbRemoteTCPTargetWizard.Port")); //$NON-NLS-1$ portText = new Text(connGroup, SWT.BORDER); + portText.setText(targetPort); + portText.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e) { diff --git a/launchbar/org.eclipse.launchbar.core/META-INF/MANIFEST.MF b/launchbar/org.eclipse.launchbar.core/META-INF/MANIFEST.MF index bfb68bf27b6..dd577f9f51e 100644 --- a/launchbar/org.eclipse.launchbar.core/META-INF/MANIFEST.MF +++ b/launchbar/org.eclipse.launchbar.core/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.launchbar.core;singleton:=true -Bundle-Version: 3.0.100 +Bundle-Version: 3.0.200 Bundle-Activator: org.eclipse.launchbar.core.internal.Activator Bundle-Vendor: %providerName Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.33.0,4)", diff --git a/launchbar/org.eclipse.launchbar.core/src/org/eclipse/launchbar/core/internal/target/LaunchTargetWorkingCopy.java b/launchbar/org.eclipse.launchbar.core/src/org/eclipse/launchbar/core/internal/target/LaunchTargetWorkingCopy.java index dd68cb73a03..98e9854b685 100644 --- a/launchbar/org.eclipse.launchbar.core/src/org/eclipse/launchbar/core/internal/target/LaunchTargetWorkingCopy.java +++ b/launchbar/org.eclipse.launchbar.core/src/org/eclipse/launchbar/core/internal/target/LaunchTargetWorkingCopy.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2016 QNX Software Systems and others. + * Copyright (c) 2016, 2025 QNX Software Systems and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -102,6 +102,7 @@ public class LaunchTargetWorkingCopy extends PlatformObject implements ILaunchTa target.attributes.remove(key); } } + target.attributes.put("name", target.getId()); //$NON-NLS-1$ target.attributes.flush(); return target; } catch (BackingStoreException e) {