Skip to content

Commit 2c91af0

Browse files
committed
fix(gdb): fixed the port in configuration storage for gdb
1 parent d07c76f commit 2c91af0

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

bundles/com.espressif.idf.core/src/com/espressif/idf/core/util/PortChecker.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
package com.espressif.idf.core.util;
66

77
import java.io.IOException;
8+
import java.net.InetAddress;
89
import java.net.ServerSocket;
910
import java.net.Socket;
1011

@@ -26,7 +27,7 @@ private PortChecker()
2627

2728
public static boolean isPortAvailable(int port)
2829
{
29-
try (ServerSocket serverSocket = new ServerSocket(port))
30+
try (ServerSocket serverSocket = new ServerSocket(port, 50, InetAddress.getByName("127.0.0.1"))) //$NON-NLS-1$
3031
{
3132
serverSocket.setReuseAddress(true);
3233
return true;

bundles/com.espressif.idf.debug.gdbjtag.openocd/src/com/espressif/idf/debug/gdbjtag/openocd/Configuration.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@
1818
import java.util.List;
1919

2020
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
21+
import org.eclipse.cdt.debug.gdbjtag.core.IGDBJtagConstants;
2122
import org.eclipse.cdt.dsf.gdb.IGDBLaunchConfigurationConstants;
2223
import org.eclipse.cdt.dsf.gdb.IGdbDebugPreferenceConstants;
2324
import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin;
2425
import org.eclipse.core.resources.IProject;
2526
import org.eclipse.core.runtime.CoreException;
2627
import org.eclipse.core.runtime.Platform;
2728
import org.eclipse.debug.core.ILaunchConfiguration;
29+
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
2830
import org.eclipse.embedcdt.core.EclipseUtils;
2931
import org.eclipse.embedcdt.core.StringUtils;
3032
import org.eclipse.embedcdt.debug.gdbjtag.core.DebugUtils;
@@ -94,7 +96,11 @@ public static String[] getGdbServerCommandLineArray(ILaunchConfiguration configu
9496

9597
int port = PortChecker
9698
.getAvailablePort(DefaultPreferences.GDB_SERVER_GDB_PORT_NUMBER_DEFAULT);
97-
99+
100+
ILaunchConfigurationWorkingCopy configurationWorkingCopy = configuration.getWorkingCopy();
101+
configurationWorkingCopy.setAttribute(IGDBJtagConstants.ATTR_PORT_NUMBER, port);
102+
configurationWorkingCopy.doSave();
103+
98104
lst.add("-c"); //$NON-NLS-1$
99105
lst.add("gdb_port " + port); //$NON-NLS-1$
100106

bundles/com.espressif.idf.debug.gdbjtag.openocd/src/com/espressif/idf/debug/gdbjtag/openocd/dsf/Launch.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,6 @@ public void initializeServerConsole(IProgressMonitor monitor) throws CoreExcepti
173173

174174
// Add the GDB server process to the launch tree
175175
newProcess = addServerProcess(Configuration.getGdbServerCommandName(fConfig));
176-
newProcess.setAttribute(IProcess.ATTR_CMDLINE, Configuration.getGdbServerCommandLine(fConfig));
177-
178176
monitor.worked(1);
179177
}
180178
}

0 commit comments

Comments
 (0)