From e8128c791424a344ae38106d25cef8f06c1d1ade Mon Sep 17 00:00:00 2001 From: Jonah Graham Date: Fri, 9 Jun 2023 10:24:19 -0400 Subject: [PATCH] Add ability to customize GDB port when auto-starting gdb server When starting a gdbserver (like openocd) connected to a multi-core SoC the gdb server may open multiple ports. This change allows user to configure which port GDB connect to rather than forcing GDB to connect to the first port. When the ports do not match a warning triangle is displayed which can be clicked on to restore the matching values. When a user changes the "GDB port" in the "Start TYPE locally" section that is reflected in the "Port number" in the "Remote Target" section. Changes to "Port number" in the "Remote Target" which lead to the ports not matching will display the warning triangle. Fixes #569 --- .../debug/gdbjtag/jlink/ui/TabDebugger.java | 96 ++++++++++++------ .../gdbjtag/jlink/ui/messages.properties | 2 + .../debug/gdbjtag/openocd/ui/TabDebugger.java | 99 +++++++++++++------ .../gdbjtag/openocd/ui/messages.properties | 2 + .../debug/gdbjtag/pyocd/ui/TabDebugger.java | 95 ++++++++++++------ .../gdbjtag/pyocd/ui/messages.properties | 2 + .../debug/gdbjtag/qemu/ui/TabDebugger.java | 97 ++++++++++++------ .../debug/gdbjtag/qemu/ui/messages.properties | 2 + 8 files changed, 269 insertions(+), 126 deletions(-) diff --git a/plugins/org.eclipse.embedcdt.debug.gdbjtag.jlink.ui/src/org/eclipse/embedcdt/debug/gdbjtag/jlink/ui/TabDebugger.java b/plugins/org.eclipse.embedcdt.debug.gdbjtag.jlink.ui/src/org/eclipse/embedcdt/debug/gdbjtag/jlink/ui/TabDebugger.java index 7cf8c34d1..adc45cb6c 100644 --- a/plugins/org.eclipse.embedcdt.debug.gdbjtag.jlink.ui/src/org/eclipse/embedcdt/debug/gdbjtag/jlink/ui/TabDebugger.java +++ b/plugins/org.eclipse.embedcdt.debug.gdbjtag.jlink.ui/src/org/eclipse/embedcdt/debug/gdbjtag/jlink/ui/TabDebugger.java @@ -47,6 +47,8 @@ import org.eclipse.embedcdt.internal.debug.gdbjtag.jlink.ui.preferences.GlobalMcuPage; import org.eclipse.embedcdt.internal.debug.gdbjtag.jlink.ui.preferences.WorkspaceMcuPage; import org.eclipse.embedcdt.internal.debug.gdbjtag.jlink.ui.properties.ProjectMcuPage; +import org.eclipse.jface.fieldassist.ControlDecoration; +import org.eclipse.jface.fieldassist.FieldDecorationRegistry; import org.eclipse.jface.window.Window; import org.eclipse.swt.SWT; import org.eclipse.swt.events.ModifyEvent; @@ -95,6 +97,9 @@ public class TabDebugger extends AbstractLaunchConfigurationTab { private Text fTargetIpAddress; private Text fTargetPortNumber; + private ControlDecoration fTargetPortNumberDecoration; + private ControlDecoration fTargetIpAddressDecoration; + private Text fGdbFlashDeviceName; private Button fGdbEndiannessLittle; @@ -698,6 +703,7 @@ public void widgetSelected(SelectionEvent e) { if (fDoStartGdbServer.getSelection()) { fTargetIpAddress.setText(DefaultPreferences.REMOTE_IP_ADDRESS_LOCALHOST); + fTargetPortNumber.setText(fGdbServerGdbPort.getText()); } scheduleUpdateJob(); } @@ -1077,6 +1083,10 @@ private void createRemoteControl(Composite parent) { GridData gd = new GridData(); gd.widthHint = 125; fTargetIpAddress.setLayoutData(gd); + fTargetIpAddressDecoration = new ControlDecoration(fTargetIpAddress, SWT.LEFT | SWT.TOP); + fTargetIpAddressDecoration.setDescriptionText(Messages.getString("DebuggerTab.ipAddressWarningDecoration")); //$NON-NLS-1$ + fTargetIpAddressDecoration.setImage(FieldDecorationRegistry.getDefault() + .getFieldDecoration(FieldDecorationRegistry.DEC_WARNING).getImage()); label = new Label(comp, SWT.NONE); label.setText(Messages.getString("DebuggerTab.portNumberLabel")); //$NON-NLS-1$ @@ -1085,6 +1095,11 @@ private void createRemoteControl(Composite parent) { gd = new GridData(); gd.widthHint = 125; fTargetPortNumber.setLayoutData(gd); + fTargetPortNumberDecoration = new ControlDecoration(fTargetPortNumber, SWT.LEFT | SWT.TOP); + fTargetPortNumberDecoration + .setDescriptionText(Messages.getString("DebuggerTab.portNumberWarningDecoration")); //$NON-NLS-1$ + fTargetPortNumberDecoration.setImage(FieldDecorationRegistry.getDefault() + .getFieldDecoration(FieldDecorationRegistry.DEC_WARNING).getImage()); } // ---- Actions ------------------------------------------------------- @@ -1092,6 +1107,7 @@ private void createRemoteControl(Composite parent) { fTargetIpAddress.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e) { + updateDecorations(); scheduleUpdateJob(); // provides much better performance for // Text listeners } @@ -1106,11 +1122,23 @@ public void verifyText(VerifyEvent e) { fTargetPortNumber.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e) { + updateDecorations(); scheduleUpdateJob(); // provides much better performance for // Text listeners } }); - + fTargetIpAddressDecoration.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + fTargetIpAddress.setText(DefaultPreferences.REMOTE_IP_ADDRESS_DEFAULT); + } + }); + fTargetPortNumberDecoration.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + fTargetPortNumber.setText(fGdbServerGdbPort.getText()); + } + }); } private void updateGdbServerActualPath() { @@ -1175,12 +1203,10 @@ private void doStartGdbServerChanged() { fDoGdbServerAllocateSemihostingConsole.setEnabled(enabled); - // Disable remote target params when the server is started - fTargetIpAddress.setEnabled(!enabled); - fTargetPortNumber.setEnabled(!enabled); - fGdbServerPathLabel.setEnabled(enabled); fLink.setEnabled(enabled); + + updateDecorations(); } private void propagateConnectToRunningChanged() { @@ -1193,6 +1219,24 @@ private void propagateConnectToRunningChanged() { } } + protected void updateDecorations() { + if (fDoStartGdbServer.getSelection()) { + if (DefaultPreferences.REMOTE_IP_ADDRESS_DEFAULT.equals(fTargetIpAddress.getText())) { + fTargetIpAddressDecoration.hide(); + } else { + fTargetIpAddressDecoration.show(); + } + if (fGdbServerGdbPort.getText().equals(fTargetPortNumber.getText())) { + fTargetPortNumberDecoration.hide(); + } else { + fTargetPortNumberDecoration.show(); + } + } else { + fTargetIpAddressDecoration.hide(); + fTargetPortNumberDecoration.hide(); + } + } + @Override public void initializeFrom(ILaunchConfiguration configuration) { @@ -1587,8 +1631,12 @@ else if (DefaultPreferences.ENDIANNESS_BIG.equals(endianness)) { fTargetIpAddress.setText(DefaultPreferences.REMOTE_IP_ADDRESS_DEFAULT); // $NON-NLS-1$ - String portString = Integer.toString(DefaultPreferences.REMOTE_PORT_NUMBER_DEFAULT); // $NON-NLS-1$ - fTargetPortNumber.setText(portString); + if (fDoStartGdbServer.getSelection()) { + fTargetPortNumber.setText(fGdbServerGdbPort.getText()); + } else { + String portString = Integer.toString(DefaultPreferences.REMOTE_PORT_NUMBER_DEFAULT); // $NON-NLS-1$ + fTargetPortNumber.setText(portString); + } // useRemoteChanged(); } @@ -1869,31 +1917,15 @@ public void performApply(ILaunchConfigurationWorkingCopy configuration) { // Remote target { - if (fDoStartGdbServer.getSelection()) { - configuration.setAttribute(IGDBJtagConstants.ATTR_IP_ADDRESS, "localhost"); - - String str = fGdbServerGdbPort.getText().trim(); - if (!str.isEmpty()) { - try { - int port; - port = Integer.parseInt(str); - configuration.setAttribute(IGDBJtagConstants.ATTR_PORT_NUMBER, port); - } catch (NumberFormatException e) { - Activator.log(e); - } - } - } else { - String ip = fTargetIpAddress.getText().trim(); - configuration.setAttribute(IGDBJtagConstants.ATTR_IP_ADDRESS, ip); - - String str = fTargetPortNumber.getText().trim(); - if (!str.isEmpty()) { - try { - int port = Integer.valueOf(str).intValue(); - configuration.setAttribute(IGDBJtagConstants.ATTR_PORT_NUMBER, port); - } catch (NumberFormatException e) { - Activator.log(e); - } + String ip = fTargetIpAddress.getText().trim(); + configuration.setAttribute(IGDBJtagConstants.ATTR_IP_ADDRESS, ip); + String str = fTargetPortNumber.getText().trim(); + if (!str.isEmpty()) { + try { + int port = Integer.valueOf(str).intValue(); + configuration.setAttribute(IGDBJtagConstants.ATTR_PORT_NUMBER, port); + } catch (NumberFormatException e) { + Activator.log(e); } } } diff --git a/plugins/org.eclipse.embedcdt.debug.gdbjtag.jlink.ui/src/org/eclipse/embedcdt/internal/debug/gdbjtag/jlink/ui/messages.properties b/plugins/org.eclipse.embedcdt.debug.gdbjtag.jlink.ui/src/org/eclipse/embedcdt/internal/debug/gdbjtag/jlink/ui/messages.properties index 55ab53216..820467fb1 100644 --- a/plugins/org.eclipse.embedcdt.debug.gdbjtag.jlink.ui/src/org/eclipse/embedcdt/internal/debug/gdbjtag/jlink/ui/messages.properties +++ b/plugins/org.eclipse.embedcdt.debug.gdbjtag.jlink.ui/src/org/eclipse/embedcdt/internal/debug/gdbjtag/jlink/ui/messages.properties @@ -202,7 +202,9 @@ the target. Other useful commands are:\n\ DebuggerTab.remoteGroup_Text=Remote Target DebuggerTab.ipAddressLabel=Host name or IP address: +DebuggerTab.ipAddressWarningDecoration=The supplied value for the Host name or IP address does not match the address the J-Link GDB server is listening on. Click the warning to restore the default. DebuggerTab.portNumberLabel=Port number: +DebuggerTab.portNumberWarningDecoration=The supplied port number does not match the port the J-Link GDB server is listening on. Click the warning to restore the default. DebuggerTab.update_thread_list_on_suspend_Text=Force thread list update on suspend diff --git a/plugins/org.eclipse.embedcdt.debug.gdbjtag.openocd.ui/src/org/eclipse/embedcdt/debug/gdbjtag/openocd/ui/TabDebugger.java b/plugins/org.eclipse.embedcdt.debug.gdbjtag.openocd.ui/src/org/eclipse/embedcdt/debug/gdbjtag/openocd/ui/TabDebugger.java index 29361099f..3da5010db 100644 --- a/plugins/org.eclipse.embedcdt.debug.gdbjtag.openocd.ui/src/org/eclipse/embedcdt/debug/gdbjtag/openocd/ui/TabDebugger.java +++ b/plugins/org.eclipse.embedcdt.debug.gdbjtag.openocd.ui/src/org/eclipse/embedcdt/debug/gdbjtag/openocd/ui/TabDebugger.java @@ -46,6 +46,8 @@ import org.eclipse.embedcdt.internal.debug.gdbjtag.openocd.ui.preferences.GlobalMcuPage; import org.eclipse.embedcdt.internal.debug.gdbjtag.openocd.ui.preferences.WorkspaceMcuPage; import org.eclipse.embedcdt.internal.debug.gdbjtag.openocd.ui.properties.ProjectMcuPage; +import org.eclipse.jface.fieldassist.ControlDecoration; +import org.eclipse.jface.fieldassist.FieldDecorationRegistry; import org.eclipse.jface.window.Window; import org.eclipse.swt.SWT; import org.eclipse.swt.events.ModifyEvent; @@ -107,6 +109,8 @@ public class TabDebugger extends AbstractLaunchConfigurationTab { private Text fTargetIpAddress; private Text fTargetPortNumber; + private ControlDecoration fTargetPortNumberDecoration; + private ControlDecoration fTargetIpAddressDecoration; protected Button fUpdateThreadlistOnSuspend; @@ -392,6 +396,7 @@ public void widgetSelected(SelectionEvent e) { doStartGdbServerChanged(); if (fDoStartGdbServer.getSelection()) { fTargetIpAddress.setText(DefaultPreferences.REMOTE_IP_ADDRESS_LOCALHOST); + fTargetPortNumber.setText(fGdbServerGdbPort.getText()); } scheduleUpdateJob(); } @@ -648,6 +653,10 @@ private void createRemoteControl(Composite parent) { GridData gd = new GridData(); gd.widthHint = 125; fTargetIpAddress.setLayoutData(gd); + fTargetIpAddressDecoration = new ControlDecoration(fTargetIpAddress, SWT.LEFT | SWT.TOP); + fTargetIpAddressDecoration.setDescriptionText(Messages.getString("DebuggerTab.ipAddressWarningDecoration")); //$NON-NLS-1$ + fTargetIpAddressDecoration.setImage(FieldDecorationRegistry.getDefault() + .getFieldDecoration(FieldDecorationRegistry.DEC_WARNING).getImage()); label = new Label(comp, SWT.NONE); label.setText(Messages.getString("DebuggerTab.portNumberLabel")); //$NON-NLS-1$ @@ -656,6 +665,12 @@ private void createRemoteControl(Composite parent) { gd = new GridData(); gd.widthHint = 125; fTargetPortNumber.setLayoutData(gd); + fTargetPortNumberDecoration = new ControlDecoration(fTargetPortNumber, SWT.LEFT | SWT.TOP); + fTargetPortNumberDecoration + .setDescriptionText(Messages.getString("DebuggerTab.portNumberWarningDecoration")); //$NON-NLS-1$ + fTargetPortNumberDecoration.setImage(FieldDecorationRegistry.getDefault() + .getFieldDecoration(FieldDecorationRegistry.DEC_WARNING).getImage()); + } // ---- Actions ------------------------------------------------------- @@ -664,6 +679,7 @@ private void createRemoteControl(Composite parent) { fTargetIpAddress.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e) { + updateDecorations(); scheduleUpdateJob(); // provides much better performance for // Text listeners } @@ -677,10 +693,24 @@ public void verifyText(VerifyEvent e) { fTargetPortNumber.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e) { + updateDecorations(); scheduleUpdateJob(); // provides much better performance for // Text listeners } }); + fTargetIpAddressDecoration.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + fTargetIpAddress.setText(DefaultPreferences.REMOTE_IP_ADDRESS_DEFAULT); + } + }); + fTargetPortNumberDecoration.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + fTargetPortNumber.setText(fGdbServerGdbPort.getText()); + } + }); + } private void updateGdbServerActualPath() { @@ -723,12 +753,10 @@ private void doStartGdbServerChanged() { fDoGdbServerAllocateConsole.setEnabled(enabled); } - // Disable remote target params when the server is started - fTargetIpAddress.setEnabled(!enabled); - fTargetPortNumber.setEnabled(!enabled); - fGdbServerPathLabel.setEnabled(enabled); fLink.setEnabled(enabled); + + updateDecorations(); } private void doStartGdbClientChanged() { @@ -742,6 +770,25 @@ private void doStartGdbClientChanged() { fGdbClientOtherCommands.setEnabled(enabled); } + protected void updateDecorations() { + if (fDoStartGdbServer.getSelection()) { + if (DefaultPreferences.REMOTE_IP_ADDRESS_DEFAULT.equals(fTargetIpAddress.getText())) { + fTargetIpAddressDecoration.hide(); + } else { + fTargetIpAddressDecoration.show(); + } + if (fGdbServerGdbPort.getText().equals(fTargetPortNumber.getText())) { + fTargetPortNumberDecoration.hide(); + } else { + fTargetPortNumberDecoration.show(); + } + } else { + fTargetIpAddressDecoration.hide(); + fTargetPortNumberDecoration.hide(); + } + + } + @Override public void initializeFrom(ILaunchConfiguration configuration) { @@ -912,8 +959,12 @@ public void initializeFromDefaults() { { fTargetIpAddress.setText(DefaultPreferences.REMOTE_IP_ADDRESS_DEFAULT); // $NON-NLS-1$ - String portString = Integer.toString(DefaultPreferences.REMOTE_PORT_NUMBER_DEFAULT); // $NON-NLS-1$ - fTargetPortNumber.setText(portString); + if (fDoStartGdbServer.getSelection()) { + fTargetPortNumber.setText(fGdbServerGdbPort.getText()); + } else { + String portString = Integer.toString(DefaultPreferences.REMOTE_PORT_NUMBER_DEFAULT); // $NON-NLS-1$ + fTargetPortNumber.setText(portString); + } } doStartGdbServerChanged(); @@ -1112,31 +1163,17 @@ public void performApply(ILaunchConfigurationWorkingCopy configuration) { } { - if (fDoStartGdbServer.getSelection()) { - configuration.setAttribute(IGDBJtagConstants.ATTR_IP_ADDRESS, "localhost"); - - String str = fGdbServerGdbPort.getText().trim(); - if (!str.isEmpty()) { - try { - int port; - port = Integer.parseInt(str); - configuration.setAttribute(IGDBJtagConstants.ATTR_PORT_NUMBER, port); - } catch (NumberFormatException e) { - Activator.log(e); - } - } - } else { - String ip = fTargetIpAddress.getText().trim(); - configuration.setAttribute(IGDBJtagConstants.ATTR_IP_ADDRESS, ip); - - String str = fTargetPortNumber.getText().trim(); - if (!str.isEmpty()) { - try { - int port = Integer.valueOf(str).intValue(); - configuration.setAttribute(IGDBJtagConstants.ATTR_PORT_NUMBER, port); - } catch (NumberFormatException e) { - Activator.log(e); - } + + String ip = fTargetIpAddress.getText().trim(); + configuration.setAttribute(IGDBJtagConstants.ATTR_IP_ADDRESS, ip); + + String str = fTargetPortNumber.getText().trim(); + if (!str.isEmpty()) { + try { + int port = Integer.valueOf(str).intValue(); + configuration.setAttribute(IGDBJtagConstants.ATTR_PORT_NUMBER, port); + } catch (NumberFormatException e) { + Activator.log(e); } } } diff --git a/plugins/org.eclipse.embedcdt.debug.gdbjtag.openocd.ui/src/org/eclipse/embedcdt/internal/debug/gdbjtag/openocd/ui/messages.properties b/plugins/org.eclipse.embedcdt.debug.gdbjtag.openocd.ui/src/org/eclipse/embedcdt/internal/debug/gdbjtag/openocd/ui/messages.properties index 05b5839f1..8d81cd11a 100644 --- a/plugins/org.eclipse.embedcdt.debug.gdbjtag.openocd.ui/src/org/eclipse/embedcdt/internal/debug/gdbjtag/openocd/ui/messages.properties +++ b/plugins/org.eclipse.embedcdt.debug.gdbjtag.openocd.ui/src/org/eclipse/embedcdt/internal/debug/gdbjtag/openocd/ui/messages.properties @@ -135,7 +135,9 @@ remotetimeout 20'. DebuggerTab.remoteGroup_Text=Remote Target DebuggerTab.ipAddressLabel=Host name or IP address: +DebuggerTab.ipAddressWarningDecoration=The supplied value for the Host name or IP address does not match the address OpenOCD is listening on. Click the warning to restore the default. DebuggerTab.portNumberLabel=Port number: +DebuggerTab.portNumberWarningDecoration=The supplied port number does not match the port OpenOCD is listening on. Click the warning to restore the default. DebuggerTab.update_thread_list_on_suspend_Text=Force thread list update on suspend diff --git a/plugins/org.eclipse.embedcdt.debug.gdbjtag.pyocd.ui/src/org/eclipse/embedcdt/debug/gdbjtag/pyocd/ui/TabDebugger.java b/plugins/org.eclipse.embedcdt.debug.gdbjtag.pyocd.ui/src/org/eclipse/embedcdt/debug/gdbjtag/pyocd/ui/TabDebugger.java index 560a68592..1030414de 100644 --- a/plugins/org.eclipse.embedcdt.debug.gdbjtag.pyocd.ui/src/org/eclipse/embedcdt/debug/gdbjtag/pyocd/ui/TabDebugger.java +++ b/plugins/org.eclipse.embedcdt.debug.gdbjtag.pyocd.ui/src/org/eclipse/embedcdt/debug/gdbjtag/pyocd/ui/TabDebugger.java @@ -64,6 +64,8 @@ import org.eclipse.embedcdt.internal.debug.gdbjtag.pyocd.ui.preferences.WorkspaceMcuPage; import org.eclipse.embedcdt.internal.debug.gdbjtag.pyocd.ui.properties.ProjectMcuPage; import org.eclipse.embedcdt.ui.SystemUIJob; +import org.eclipse.jface.fieldassist.ControlDecoration; +import org.eclipse.jface.fieldassist.FieldDecorationRegistry; import org.eclipse.jface.window.Window; import org.eclipse.swt.SWT; import org.eclipse.swt.events.ModifyEvent; @@ -119,6 +121,8 @@ public class TabDebugger extends AbstractLaunchConfigurationTab { private Text fTargetIpAddress; private Text fTargetPortNumber; + private ControlDecoration fTargetPortNumberDecoration; + private ControlDecoration fTargetIpAddressDecoration; private Combo fGdbServerProbeId; private Button fGdbServerRefreshProbes; @@ -658,6 +662,7 @@ public void widgetSelected(SelectionEvent e) { doStartGdbServerChanged(); if (fDoStartGdbServer.getSelection()) { fTargetIpAddress.setText(DefaultPreferences.REMOTE_IP_ADDRESS_LOCALHOST); + fTargetPortNumber.setText(fGdbServerGdbPort.getText()); } scheduleUpdateJob(); } @@ -931,6 +936,10 @@ private void createRemoteControl(Composite parent) { GridData gd = new GridData(); gd.widthHint = 125; fTargetIpAddress.setLayoutData(gd); + fTargetIpAddressDecoration = new ControlDecoration(fTargetIpAddress, SWT.LEFT | SWT.TOP); + fTargetIpAddressDecoration.setDescriptionText(Messages.getString("DebuggerTab.ipAddressWarningDecoration")); //$NON-NLS-1$ + fTargetIpAddressDecoration.setImage(FieldDecorationRegistry.getDefault() + .getFieldDecoration(FieldDecorationRegistry.DEC_WARNING).getImage()); label = new Label(comp, SWT.NONE); label.setText(Messages.getString("DebuggerTab.portNumberLabel")); //$NON-NLS-1$ @@ -939,6 +948,11 @@ private void createRemoteControl(Composite parent) { gd = new GridData(); gd.widthHint = 125; fTargetPortNumber.setLayoutData(gd); + fTargetPortNumberDecoration = new ControlDecoration(fTargetPortNumber, SWT.LEFT | SWT.TOP); + fTargetPortNumberDecoration + .setDescriptionText(Messages.getString("DebuggerTab.portNumberWarningDecoration")); //$NON-NLS-1$ + fTargetPortNumberDecoration.setImage(FieldDecorationRegistry.getDefault() + .getFieldDecoration(FieldDecorationRegistry.DEC_WARNING).getImage()); } // ---- Actions ------------------------------------------------------- @@ -947,6 +961,7 @@ private void createRemoteControl(Composite parent) { fTargetIpAddress.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e) { + updateDecorations(); scheduleUpdateJob(); // provides much better performance for // Text listeners } @@ -960,10 +975,24 @@ public void verifyText(VerifyEvent e) { fTargetPortNumber.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e) { + updateDecorations(); scheduleUpdateJob(); // provides much better performance for // Text listeners } }); + fTargetIpAddressDecoration.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + fTargetIpAddress.setText(DefaultPreferences.REMOTE_IP_ADDRESS_DEFAULT); + } + }); + fTargetPortNumberDecoration.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + fTargetPortNumber.setText(fGdbServerGdbPort.getText()); + } + }); + } private void updateGdbServerActualPath() { @@ -1025,12 +1054,10 @@ private void doStartGdbServerChanged() { fDoGdbServerAllocateConsole.setEnabled(enabled); fDoGdbServerAllocateSemihostingConsole.setEnabled(enabled); - // Disable remote target params when the server is started - fTargetIpAddress.setEnabled(!enabled); - fTargetPortNumber.setEnabled(!enabled); - fGdbServerPathLabel.setEnabled(enabled); fLink.setEnabled(enabled); + + updateDecorations(); } private void overrideTargetChanged() { @@ -1480,6 +1507,24 @@ public IStatus runInUIThread(IProgressMonitor monitor) { } } + protected void updateDecorations() { + if (fDoStartGdbServer.getSelection()) { + if (DefaultPreferences.REMOTE_IP_ADDRESS_DEFAULT.equals(fTargetIpAddress.getText())) { + fTargetIpAddressDecoration.hide(); + } else { + fTargetIpAddressDecoration.show(); + } + if (fGdbServerGdbPort.getText().equals(fTargetPortNumber.getText())) { + fTargetPortNumberDecoration.hide(); + } else { + fTargetPortNumberDecoration.show(); + } + } else { + fTargetIpAddressDecoration.hide(); + fTargetPortNumberDecoration.hide(); + } + } + @Override public void initializeFrom(ILaunchConfiguration configuration) { if (Activator.getInstance().isDebugging()) { @@ -1729,8 +1774,12 @@ public void initializeFromDefaults() { { fTargetIpAddress.setText(DefaultPreferences.REMOTE_IP_ADDRESS_DEFAULT); // $NON-NLS-1$ - String portString = Integer.toString(DefaultPreferences.REMOTE_PORT_NUMBER_DEFAULT); // $NON-NLS-1$ - fTargetPortNumber.setText(portString); + if (fDoStartGdbServer.getSelection()) { + fTargetPortNumber.setText(fGdbServerGdbPort.getText()); + } else { + String portString = Integer.toString(DefaultPreferences.REMOTE_PORT_NUMBER_DEFAULT); // $NON-NLS-1$ + fTargetPortNumber.setText(portString); + } } doStartGdbServerChanged(); @@ -1978,31 +2027,15 @@ public void performApply(ILaunchConfigurationWorkingCopy configuration) { } { - if (fDoStartGdbServer.getSelection()) { - configuration.setAttribute(IGDBJtagConstants.ATTR_IP_ADDRESS, "localhost"); - - String str = fGdbServerGdbPort.getText().trim(); - if (!str.isEmpty()) { - try { - int port; - port = Integer.parseInt(str); - configuration.setAttribute(IGDBJtagConstants.ATTR_PORT_NUMBER, port); - } catch (NumberFormatException e) { - Activator.log(e); - } - } - } else { - String ip = fTargetIpAddress.getText().trim(); - configuration.setAttribute(IGDBJtagConstants.ATTR_IP_ADDRESS, ip); - - String str = fTargetPortNumber.getText().trim(); - if (!str.isEmpty()) { - try { - int port = Integer.valueOf(str).intValue(); - configuration.setAttribute(IGDBJtagConstants.ATTR_PORT_NUMBER, port); - } catch (NumberFormatException e) { - Activator.log(e); - } + String ip = fTargetIpAddress.getText().trim(); + configuration.setAttribute(IGDBJtagConstants.ATTR_IP_ADDRESS, ip); + String str = fTargetPortNumber.getText().trim(); + if (!str.isEmpty()) { + try { + int port = Integer.valueOf(str).intValue(); + configuration.setAttribute(IGDBJtagConstants.ATTR_PORT_NUMBER, port); + } catch (NumberFormatException e) { + Activator.log(e); } } } diff --git a/plugins/org.eclipse.embedcdt.debug.gdbjtag.pyocd.ui/src/org/eclipse/embedcdt/internal/debug/gdbjtag/pyocd/ui/messages.properties b/plugins/org.eclipse.embedcdt.debug.gdbjtag.pyocd.ui/src/org/eclipse/embedcdt/internal/debug/gdbjtag/pyocd/ui/messages.properties index 4e7e67abe..1ad406f7d 100644 --- a/plugins/org.eclipse.embedcdt.debug.gdbjtag.pyocd.ui/src/org/eclipse/embedcdt/internal/debug/gdbjtag/pyocd/ui/messages.properties +++ b/plugins/org.eclipse.embedcdt.debug.gdbjtag.pyocd.ui/src/org/eclipse/embedcdt/internal/debug/gdbjtag/pyocd/ui/messages.properties @@ -229,7 +229,9 @@ remotetimeout 20'. DebuggerTab.remoteGroup_Text=Remote Target DebuggerTab.ipAddressLabel=Host name or IP address: +DebuggerTab.ipAddressWarningDecoration=The supplied value for the Host name or IP address does not match the address pyOCD is listening on. Click the warning to restore the default. DebuggerTab.portNumberLabel=Port number: +DebuggerTab.portNumberWarningDecoration=The supplied port number does not match the port pyOCD is listening on. Click the warning to restore the default. DebuggerTab.update_thread_list_on_suspend_Text=Force thread list update on suspend diff --git a/plugins/org.eclipse.embedcdt.debug.gdbjtag.qemu.ui/src/org/eclipse/embedcdt/debug/gdbjtag/qemu/ui/TabDebugger.java b/plugins/org.eclipse.embedcdt.debug.gdbjtag.qemu.ui/src/org/eclipse/embedcdt/debug/gdbjtag/qemu/ui/TabDebugger.java index 199386679..beb782335 100644 --- a/plugins/org.eclipse.embedcdt.debug.gdbjtag.qemu.ui/src/org/eclipse/embedcdt/debug/gdbjtag/qemu/ui/TabDebugger.java +++ b/plugins/org.eclipse.embedcdt.debug.gdbjtag.qemu.ui/src/org/eclipse/embedcdt/debug/gdbjtag/qemu/ui/TabDebugger.java @@ -48,6 +48,8 @@ import org.eclipse.embedcdt.internal.debug.gdbjtag.qemu.ui.preferences.GlobalMcuPage; import org.eclipse.embedcdt.internal.debug.gdbjtag.qemu.ui.preferences.WorkspaceMcuPage; import org.eclipse.embedcdt.internal.debug.gdbjtag.qemu.ui.properties.ProjectMcuPage; +import org.eclipse.jface.fieldassist.ControlDecoration; +import org.eclipse.jface.fieldassist.FieldDecorationRegistry; import org.eclipse.jface.window.Window; import org.eclipse.swt.SWT; import org.eclipse.swt.events.ModifyEvent; @@ -98,6 +100,8 @@ public class TabDebugger extends AbstractLaunchConfigurationTab { private Text fTargetIpAddress; private Text fTargetPortNumber; + private ControlDecoration fTargetPortNumberDecoration; + private ControlDecoration fTargetIpAddressDecoration; private Text fQemuBoardName; private Text fQemuDeviceName; @@ -531,6 +535,7 @@ public void widgetSelected(SelectionEvent e) { doStartGdbServerChanged(); if (fDoStartGdbServer.getSelection()) { fTargetIpAddress.setText(DefaultPreferences.REMOTE_IP_ADDRESS_LOCALHOST); + fTargetPortNumber.setText(fGdbServerGdbPort.getText()); } scheduleUpdateJob(); } @@ -798,6 +803,10 @@ private void createRemoteControl(Composite parent) { GridData gd = new GridData(); gd.widthHint = 125; fTargetIpAddress.setLayoutData(gd); + fTargetIpAddressDecoration = new ControlDecoration(fTargetIpAddress, SWT.LEFT | SWT.TOP); + fTargetIpAddressDecoration.setDescriptionText(Messages.getString("DebuggerTab.ipAddressWarningDecoration")); //$NON-NLS-1$ + fTargetIpAddressDecoration.setImage(FieldDecorationRegistry.getDefault() + .getFieldDecoration(FieldDecorationRegistry.DEC_WARNING).getImage()); label = new Label(comp, SWT.NONE); label.setText(Messages.getString("DebuggerTab.portNumberLabel")); //$NON-NLS-1$ @@ -806,6 +815,12 @@ private void createRemoteControl(Composite parent) { gd = new GridData(); gd.widthHint = 125; fTargetPortNumber.setLayoutData(gd); + fTargetPortNumberDecoration = new ControlDecoration(fTargetPortNumber, SWT.LEFT | SWT.TOP); + fTargetPortNumberDecoration + .setDescriptionText(Messages.getString("DebuggerTab.portNumberWarningDecoration")); //$NON-NLS-1$ + fTargetPortNumberDecoration.setImage(FieldDecorationRegistry.getDefault() + .getFieldDecoration(FieldDecorationRegistry.DEC_WARNING).getImage()); + } // ---- Actions ------------------------------------------------------- @@ -814,6 +829,7 @@ private void createRemoteControl(Composite parent) { fTargetIpAddress.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e) { + updateDecorations(); scheduleUpdateJob(); // provides much better performance for // Text listeners } @@ -827,11 +843,23 @@ public void verifyText(VerifyEvent e) { fTargetPortNumber.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e) { + updateDecorations(); scheduleUpdateJob(); // provides much better performance for // Text listeners } }); - + fTargetIpAddressDecoration.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + fTargetIpAddress.setText(DefaultPreferences.REMOTE_IP_ADDRESS_DEFAULT); + } + }); + fTargetPortNumberDecoration.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + fTargetPortNumber.setText(fGdbServerGdbPort.getText()); + } + }); } private void updateGdbServerActualPath() { @@ -879,14 +907,12 @@ private void doStartGdbServerChanged() { fIsQemuVerbose.setEnabled(enabled); } - // Disable remote target params when the server is started - fTargetIpAddress.setEnabled(!enabled); - fTargetPortNumber.setEnabled(!enabled); - fGdbServerPathLabel.setEnabled(enabled); fLink.setEnabled(enabled); fGdbServerDelay.setEnabled(enabled); + + updateDecorations(); } private void doEnableSemihostingChanged() { @@ -921,6 +947,24 @@ private String getProjectName(ILaunchConfiguration configuration) { return fProjectName; } + protected void updateDecorations() { + if (fDoStartGdbServer.getSelection()) { + if (DefaultPreferences.REMOTE_IP_ADDRESS_DEFAULT.equals(fTargetIpAddress.getText())) { + fTargetIpAddressDecoration.hide(); + } else { + fTargetIpAddressDecoration.show(); + } + if (fGdbServerGdbPort.getText().equals(fTargetPortNumber.getText())) { + fTargetPortNumberDecoration.hide(); + } else { + fTargetPortNumberDecoration.show(); + } + } else { + fTargetIpAddressDecoration.hide(); + fTargetPortNumberDecoration.hide(); + } + } + @Override public void initializeFrom(ILaunchConfiguration configuration) { @@ -1158,8 +1202,12 @@ public void initializeFromDefaults() { { fTargetIpAddress.setText(DefaultPreferences.REMOTE_IP_ADDRESS_DEFAULT); // $NON-NLS-1$ - String portString = Integer.toString(DefaultPreferences.REMOTE_PORT_NUMBER_DEFAULT); // $NON-NLS-1$ - fTargetPortNumber.setText(portString); + if (fDoStartGdbServer.getSelection()) { + fTargetPortNumber.setText(fGdbServerGdbPort.getText()); + } else { + String portString = Integer.toString(DefaultPreferences.REMOTE_PORT_NUMBER_DEFAULT); // $NON-NLS-1$ + fTargetPortNumber.setText(portString); + } } } @@ -1369,31 +1417,16 @@ public void performApply(ILaunchConfigurationWorkingCopy configuration) { } { - if (fDoStartGdbServer.getSelection()) { - configuration.setAttribute(IGDBJtagConstants.ATTR_IP_ADDRESS, "localhost"); - - String str = fGdbServerGdbPort.getText().trim(); - if (!str.isEmpty()) { - try { - int port; - port = Integer.parseInt(str); - configuration.setAttribute(IGDBJtagConstants.ATTR_PORT_NUMBER, port); - } catch (NumberFormatException e) { - Activator.log(e); - } - } - } else { - String ip = fTargetIpAddress.getText().trim(); - configuration.setAttribute(IGDBJtagConstants.ATTR_IP_ADDRESS, ip); - - String str = fTargetPortNumber.getText().trim(); - if (!str.isEmpty()) { - try { - int port = Integer.valueOf(str).intValue(); - configuration.setAttribute(IGDBJtagConstants.ATTR_PORT_NUMBER, port); - } catch (NumberFormatException e) { - Activator.log(e); - } + String ip = fTargetIpAddress.getText().trim(); + configuration.setAttribute(IGDBJtagConstants.ATTR_IP_ADDRESS, ip); + + String str = fTargetPortNumber.getText().trim(); + if (!str.isEmpty()) { + try { + int port = Integer.valueOf(str).intValue(); + configuration.setAttribute(IGDBJtagConstants.ATTR_PORT_NUMBER, port); + } catch (NumberFormatException e) { + Activator.log(e); } } } diff --git a/plugins/org.eclipse.embedcdt.debug.gdbjtag.qemu.ui/src/org/eclipse/embedcdt/internal/debug/gdbjtag/qemu/ui/messages.properties b/plugins/org.eclipse.embedcdt.debug.gdbjtag.qemu.ui/src/org/eclipse/embedcdt/internal/debug/gdbjtag/qemu/ui/messages.properties index 9b39fd74a..c5d466f32 100644 --- a/plugins/org.eclipse.embedcdt.debug.gdbjtag.qemu.ui/src/org/eclipse/embedcdt/internal/debug/gdbjtag/qemu/ui/messages.properties +++ b/plugins/org.eclipse.embedcdt.debug.gdbjtag.qemu.ui/src/org/eclipse/embedcdt/internal/debug/gdbjtag/qemu/ui/messages.properties @@ -161,7 +161,9 @@ remotetimeout 20'. DebuggerTab.remoteGroup_Text=Remote Target DebuggerTab.ipAddressLabel=Host name or IP address: +DebuggerTab.ipAddressWarningDecoration=The supplied value for the Host name or IP address does not match the address QEMU is listening on. Click the warning to restore the default. DebuggerTab.portNumberLabel=Port number: +DebuggerTab.portNumberWarningDecoration=The supplied port number does not match the port QEMU is listening on. Click the warning to restore the default. DebuggerTab.update_thread_list_on_suspend_Text=Force thread list update on suspend