mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 22:52:11 +02:00
Fix Debug in Container
- on Windows (possibly Mac as well), we can't use the ip of the Container to contact the gdbserver as this address may be hidden from the host behind a VM - instead use the localhost port that the tcp/2345 is mapped to which the Docker machine etc.. forwards back - fix this in ContainerLaunchConfigurationDelegate Change-Id: I9f85bf0d0d9dec183c504ba4fb7adc55d4a038bb
This commit is contained in:
parent
feed18180b
commit
dddc340130
1 changed files with 32 additions and 4 deletions
|
@ -37,6 +37,7 @@ import org.eclipse.debug.core.ILaunchManager;
|
|||
import org.eclipse.debug.core.model.ILaunchConfigurationDelegate;
|
||||
import org.eclipse.linuxtools.docker.core.IDockerContainerInfo;
|
||||
import org.eclipse.linuxtools.docker.core.IDockerNetworkSettings;
|
||||
import org.eclipse.linuxtools.docker.core.IDockerPortBinding;
|
||||
import org.eclipse.linuxtools.docker.ui.launch.ContainerLauncher;
|
||||
import org.eclipse.linuxtools.docker.ui.launch.IContainerLaunchListener;
|
||||
|
||||
|
@ -93,6 +94,14 @@ public class ContainerLaunchConfigurationDelegate extends GdbLaunchDelegate
|
|||
return null;
|
||||
}
|
||||
|
||||
public Map<String, List<IDockerPortBinding>> getPorts() {
|
||||
if (info != null) {
|
||||
IDockerNetworkSettings networkSettings = info.networkSettings();
|
||||
return networkSettings.ports();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public IDockerContainerInfo getContainerInfo() {
|
||||
return info;
|
||||
}
|
||||
|
@ -268,10 +277,29 @@ public class ContainerLaunchConfigurationDelegate extends GdbLaunchDelegate
|
|||
wc.setAttribute(
|
||||
ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
|
||||
IGDBLaunchConfigurationConstants.DEBUGGER_MODE_REMOTE);
|
||||
wc.setAttribute(IGDBLaunchConfigurationConstants.ATTR_HOST,
|
||||
job.getIpAddress());
|
||||
wc.setAttribute(IGDBLaunchConfigurationConstants.ATTR_PORT,
|
||||
gdbserverPortNumber);
|
||||
if (job.getPorts() != null) {
|
||||
Map<String, List<IDockerPortBinding>> hostPorts = job
|
||||
.getPorts();
|
||||
List<IDockerPortBinding> 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,
|
||||
job.getIpAddress());
|
||||
wc.setAttribute(
|
||||
IGDBLaunchConfigurationConstants.ATTR_PORT,
|
||||
gdbserverPortNumber);
|
||||
}
|
||||
wc.doSave();
|
||||
try {
|
||||
super.launch(configuration, mode, launch, monitor);
|
||||
|
|
Loading…
Add table
Reference in a new issue