From 4c50b40f53125c49ba0567738084808f311ea4c6 Mon Sep 17 00:00:00 2001 From: Jeff Johnston Date: Wed, 23 May 2018 19:15:17 -0400 Subject: [PATCH] Bug 535014 - cannot debug in a container - add check for network ports coming back empty for a Container launch and if so, fall-back to use the ip address of the Container for the remote host Change-Id: I83d68a10e2dc92f7d0f27bb9dec304388594b4a3 --- .../ContainerLaunchConfigurationDelegate.java | 27 +++++++++---------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/launch/org.eclipse.cdt.docker.launcher/src/org/eclipse/cdt/internal/docker/launcher/ContainerLaunchConfigurationDelegate.java b/launch/org.eclipse.cdt.docker.launcher/src/org/eclipse/cdt/internal/docker/launcher/ContainerLaunchConfigurationDelegate.java index f52cdea7a51..f9a93fec138 100644 --- a/launch/org.eclipse.cdt.docker.launcher/src/org/eclipse/cdt/internal/docker/launcher/ContainerLaunchConfigurationDelegate.java +++ b/launch/org.eclipse.cdt.docker.launcher/src/org/eclipse/cdt/internal/docker/launcher/ContainerLaunchConfigurationDelegate.java @@ -392,21 +392,20 @@ public class ContainerLaunchConfigurationDelegate extends GdbLaunchDelegate wc.setAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE, IGDBLaunchConfigurationConstants.DEBUGGER_MODE_REMOTE); + Map> hostPorts = new HashMap<>(); if (job.getPorts() != null && isLocalConnection) { - Map> hostPorts = job - .getPorts(); - List bindingList = hostPorts - .get(gdbserverPortNumber + "/tcp"); //$NON-NLS-1$ - if (bindingList != null && !bindingList.isEmpty()) { - IDockerPortBinding firstBinding = bindingList - .get(0); - wc.setAttribute( - IGDBLaunchConfigurationConstants.ATTR_HOST, - "localhost"); //$NON-NLS-1$ - wc.setAttribute( - IGDBLaunchConfigurationConstants.ATTR_PORT, - firstBinding.hostPort()); - } + hostPorts = job.getPorts(); + } + List bindingList = hostPorts + .get(gdbserverPortNumber + "/tcp"); //$NON-NLS-1$ + if (bindingList != null && !bindingList.isEmpty()) { + IDockerPortBinding firstBinding = bindingList.get(0); + wc.setAttribute( + IGDBLaunchConfigurationConstants.ATTR_HOST, + "localhost"); //$NON-NLS-1$ + wc.setAttribute( + IGDBLaunchConfigurationConstants.ATTR_PORT, + firstBinding.hostPort()); } else { wc.setAttribute( IGDBLaunchConfigurationConstants.ATTR_HOST,