From 44f17a1865c800e79ba4051cb5d00a05d7966c72 Mon Sep 17 00:00:00 2001 From: John Moule Date: Tue, 21 Nov 2023 10:47:03 +0000 Subject: [PATCH] Allows launch config to override launch target connection type When launching a GDB debug session using the Launch Bar and a Launch Target, now the launch takes into account a REMOTE_TCP value in the launch configuration before considering the type of the Launch Target. Improves the change submitted in: Bug 547881 - Allow targets to set ATTR_REMOTE_TCP Fixes issue #622 --- .../cdt/dsf/gdb/service/command/GDBControl.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) 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 16c45b0a9b5..3ccc8573d2f 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 @@ -439,16 +439,19 @@ public void completeInitialization(final RequestMonitor rm) { } // And optionally the target - if (launch instanceof ITargetedLaunch) { - ILaunchTarget target = ((ITargetedLaunch) launch).getLaunchTarget(); + if (launch instanceof ITargetedLaunch targettedLaunch) { + ILaunchTarget target = targettedLaunch.getLaunchTarget(); if (target != null) { attributes.putAll(target.getAttributes()); String tcp = target.getAttribute(IGDBLaunchConfigurationConstants.ATTR_REMOTE_TCP, ""); //$NON-NLS-1$ if (!tcp.isEmpty()) { attributes.put(IGDBLaunchConfigurationConstants.ATTR_REMOTE_TCP, Boolean.parseBoolean(tcp)); } else { - attributes.put(IGDBLaunchConfigurationConstants.ATTR_REMOTE_TCP, - target.getTypeId().equals(GDBRemoteTCPLaunchTargetProvider.TYPE_ID)); + // If the launch config attrs don't contain a REMOTE_TCP value then check the launch target attrs + if (!attributes.containsKey(IGDBLaunchConfigurationConstants.ATTR_REMOTE_TCP)) { + attributes.put(IGDBLaunchConfigurationConstants.ATTR_REMOTE_TCP, + target.getTypeId().equals(GDBRemoteTCPLaunchTargetProvider.TYPE_ID)); + } } } } @@ -689,7 +692,7 @@ protected void doRegisterStep(final RequestMonitor requestMonitor) { getSession().addServiceEventListener(GDBControl.this, null); register(new String[] { ICommandControl.class.getName(), ICommandControlService.class.getName(), IMICommandControl.class.getName(), AbstractMIControl.class.getName(), IGDBControl.class.getName() }, - new Hashtable()); + new Hashtable<>()); getSession().dispatchEvent(new GDBControlInitializedDMEvent(getContext()), getProperties()); requestMonitor.done(); }