Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions bundles/com.espressif.idf.debug.gdbjtag.openocd/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -228,14 +228,5 @@
after="org.eclipse.debug.ui.commonTab">
</placement>
</tab>
<tab
class="com.espressif.idf.debug.gdbjtag.openocd.ui.TabDebugger"
group="com.espressif.idf.debug.gdbjtag.openocd.launchConfigurationTabGroup"
id="com.espressif.idf.debug.gdbjtag.openocd.ui.debuggertab"
name="Debugger">
<placement
after="org.eclipse.cdt.cdi.launch.mainTab">
</placement>
</tab>
</extension>
</plugin>
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ public class Activator extends AbstractUIPlugin {
// The plug-in ID
public static final String PLUGIN_ID = "com.espressif.idf.debug.gdbjtag.openocd"; //$NON-NLS-1$
public static final String GDB_SERVER_LAUNCH_TIMEOUT = "fGdbServerLaunchTimeout"; //$NON-NLS-1$
/** Must match {@code plugin.xml} statusHandler code for {@code OpenocdStatusHandler}. */
public static final int OPENOCD_STARTUP_TIMEOUT_STATUS = 5012;

@Override
protected void initializeDefaultPreferences(IPreferenceStore preferenceStore)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,9 @@ public static String[] getGdbServerCommandLineArray(ILaunchConfiguration configu
String fmtTelnetPort = useModernSyntax ? "telnet port %d" : "telnet_port %d"; //$NON-NLS-1$ //$NON-NLS-2$
String fmtTclPort = useModernSyntax ? "tcl port %d" : "tcl_port %d"; //$NON-NLS-1$ //$NON-NLS-2$

int port = PortChecker
.getAvailablePort(DefaultPreferences.GDB_SERVER_GDB_PORT_NUMBER_DEFAULT);

ILaunchConfigurationWorkingCopy configurationWorkingCopy = configuration.getWorkingCopy();
configurationWorkingCopy.setAttribute(IGDBJtagConstants.ATTR_PORT_NUMBER, port);
configurationWorkingCopy.doSave();

int port = configuration.getAttribute(IGDBJtagConstants.ATTR_PORT_NUMBER,
DefaultPreferences.GDB_SERVER_GDB_PORT_NUMBER_DEFAULT);

ILaunchTarget activeLaunchTarget = Activator.getService(ILaunchBarManager.class).getActiveLaunchTarget();
if (activeLaunchTarget != null)
{
Expand All @@ -127,16 +123,14 @@ public static String[] getGdbServerCommandLineArray(ILaunchConfiguration configu
lst.add("-c"); //$NON-NLS-1$
lst.add(String.format(fmtGdbPort, port));

port = PortChecker
.getAvailablePort(configuration.getAttribute(ConfigurationAttributes.GDB_SERVER_TELNET_PORT_NUMBER,
DefaultPreferences.GDB_SERVER_TELNET_PORT_NUMBER_DEFAULT));
port = configuration.getAttribute(ConfigurationAttributes.GDB_SERVER_TELNET_PORT_NUMBER,
DefaultPreferences.GDB_SERVER_TELNET_PORT_NUMBER_DEFAULT);

lst.add("-c"); //$NON-NLS-1$
lst.add(String.format(fmtTelnetPort, port));

port = PortChecker.getAvailablePort(
Integer.parseInt(configuration.getAttribute(ConfigurationAttributes.GDB_SERVER_TCL_PORT_NUMBER,
DefaultPreferences.GDB_SERVER_TCL_PORT_NUMBER_DEFAULT)));
port = Integer.parseInt(configuration.getAttribute(ConfigurationAttributes.GDB_SERVER_TCL_PORT_NUMBER,
DefaultPreferences.GDB_SERVER_TCL_PORT_NUMBER_DEFAULT));

lst.add("-c"); //$NON-NLS-1$
lst.add(String.format(fmtTclPort, port));
Expand Down Expand Up @@ -344,6 +338,27 @@ public static boolean getDoStartGdbClient(ILaunchConfiguration config) throws Co
DefaultPreferences.DO_START_GDB_CLIENT_DEFAULT);
}

/**
* Assigns free OpenOCD ports on an in-memory working copy (no {@code doSave()}).
* Must be called once per launch before the server command line is built.
*/
public static void allocateServerPorts(ILaunchConfigurationWorkingCopy configuration) throws CoreException
{
int gdbPort = PortChecker.getAvailablePort(configuration.getAttribute(IGDBJtagConstants.ATTR_PORT_NUMBER,
DefaultPreferences.GDB_SERVER_GDB_PORT_NUMBER_DEFAULT));
configuration.setAttribute(IGDBJtagConstants.ATTR_PORT_NUMBER, gdbPort);
Comment thread
coderabbitai[bot] marked this conversation as resolved.

int telnetPort = PortChecker.getAvailablePort(configuration.getAttribute(
ConfigurationAttributes.GDB_SERVER_TELNET_PORT_NUMBER,
DefaultPreferences.GDB_SERVER_TELNET_PORT_NUMBER_DEFAULT));
configuration.setAttribute(ConfigurationAttributes.GDB_SERVER_TELNET_PORT_NUMBER, telnetPort);

int tclPort = PortChecker.getAvailablePort(Integer.parseInt(configuration.getAttribute(
ConfigurationAttributes.GDB_SERVER_TCL_PORT_NUMBER,
DefaultPreferences.GDB_SERVER_TCL_PORT_NUMBER_DEFAULT)));
configuration.setAttribute(ConfigurationAttributes.GDB_SERVER_TCL_PORT_NUMBER, String.valueOf(tclPort));
}

// ------------------------------------------------------------------------

private static boolean supportsAdapterUsbCommand(String executablePath)
Expand Down
Loading
Loading