From ba58db30794051a01844f65b540272ce10ebd0dc Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Tue, 9 Jan 2024 21:00:42 +0200 Subject: [PATCH] Introduced the capability to launch the debug server in a separate process // Resolve #4722 --- HISTORY.rst | 1 + platformio/debug/config/base.py | 11 +++++++---- platformio/debug/config/generic.py | 6 +----- platformio/debug/config/jlink.py | 6 +----- platformio/debug/config/mspdebug.py | 6 +----- platformio/debug/config/qemu.py | 6 +----- platformio/debug/config/renode.py | 6 +----- platformio/debug/process/server.py | 4 +++- 8 files changed, 16 insertions(+), 30 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index bb5770ce..10b09bdb 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -21,6 +21,7 @@ test-driven methodologies, and modern toolchains for unrivaled success. ~~~~~~~~~~~~~~~~~~~ * Added support for Python 3.12 +* Introduced the capability to launch the debug server in a separate process (`issue #4722 `_) * Introduced a warning during the verification of MCU maximum RAM usage, signaling when the allocated RAM surpasses 100% (`issue #4791 `_) * Drastically enhanced the speed of project building when operating in verbose mode (`issue #4783 `_) * Upgraded the build engine to the latest version of SCons (4.6.0) to improve build performance, reliability, and compatibility with other tools and systems (`release notes `__) diff --git a/platformio/debug/config/base.py b/platformio/debug/config/base.py index cb496581..212d00fa 100644 --- a/platformio/debug/config/base.py +++ b/platformio/debug/config/base.py @@ -24,7 +24,9 @@ from platformio.project.options import ProjectOptions class DebugConfigBase: # pylint: disable=too-many-instance-attributes - def __init__(self, platform, project_config, env_name, port=None): + DEFAULT_PORT = None + + def __init__(self, platform, project_config, env_name): self.platform = platform self.project_config = project_config self.env_name = env_name @@ -48,7 +50,6 @@ class DebugConfigBase: # pylint: disable=too-many-instance-attributes self._load_cmds = None self._port = None - self.port = port self.server = self._configure_server() try: @@ -120,8 +121,10 @@ class DebugConfigBase: # pylint: disable=too-many-instance-attributes @property def port(self): return ( - self.env_options.get("debug_port", self.tool_settings.get("port")) - or self._port + self._port + or self.env_options.get("debug_port") + or self.tool_settings.get("port") + or self.DEFAULT_PORT ) @port.setter diff --git a/platformio/debug/config/generic.py b/platformio/debug/config/generic.py index faa5a341..8f066802 100644 --- a/platformio/debug/config/generic.py +++ b/platformio/debug/config/generic.py @@ -16,6 +16,7 @@ from platformio.debug.config.base import DebugConfigBase class GenericDebugConfig(DebugConfigBase): + DEFAULT_PORT = ":3333" GDB_INIT_SCRIPT = """ define pio_reset_halt_target monitor reset halt @@ -31,8 +32,3 @@ $LOAD_CMDS pio_reset_halt_target $INIT_BREAK """ - - def __init__(self, *args, **kwargs): - if "port" not in kwargs: - kwargs["port"] = ":3333" - super().__init__(*args, **kwargs) diff --git a/platformio/debug/config/jlink.py b/platformio/debug/config/jlink.py index a820e0aa..5e4cc9ce 100644 --- a/platformio/debug/config/jlink.py +++ b/platformio/debug/config/jlink.py @@ -16,6 +16,7 @@ from platformio.debug.config.base import DebugConfigBase class JlinkDebugConfig(DebugConfigBase): + DEFAULT_PORT = ":2331" GDB_INIT_SCRIPT = """ define pio_reset_halt_target monitor reset @@ -36,11 +37,6 @@ $LOAD_CMDS $INIT_BREAK """ - def __init__(self, *args, **kwargs): - if "port" not in kwargs: - kwargs["port"] = ":2331" - super().__init__(*args, **kwargs) - @property def server_ready_pattern(self): return super().server_ready_pattern or ("Waiting for GDB connection") diff --git a/platformio/debug/config/mspdebug.py b/platformio/debug/config/mspdebug.py index 7f4d8e1a..aac67416 100644 --- a/platformio/debug/config/mspdebug.py +++ b/platformio/debug/config/mspdebug.py @@ -16,6 +16,7 @@ from platformio.debug.config.base import DebugConfigBase class MspdebugDebugConfig(DebugConfigBase): + DEFAULT_PORT = ":2000" GDB_INIT_SCRIPT = """ define pio_reset_halt_target end @@ -29,8 +30,3 @@ $LOAD_CMDS pio_reset_halt_target $INIT_BREAK """ - - def __init__(self, *args, **kwargs): - if "port" not in kwargs: - kwargs["port"] = ":2000" - super().__init__(*args, **kwargs) diff --git a/platformio/debug/config/qemu.py b/platformio/debug/config/qemu.py index b998c782..b28a5f34 100644 --- a/platformio/debug/config/qemu.py +++ b/platformio/debug/config/qemu.py @@ -16,6 +16,7 @@ from platformio.debug.config.base import DebugConfigBase class QemuDebugConfig(DebugConfigBase): + DEFAULT_PORT = ":1234" GDB_INIT_SCRIPT = """ define pio_reset_halt_target monitor system_reset @@ -30,8 +31,3 @@ $LOAD_CMDS pio_reset_halt_target $INIT_BREAK """ - - def __init__(self, *args, **kwargs): - if "port" not in kwargs: - kwargs["port"] = ":1234" - super().__init__(*args, **kwargs) diff --git a/platformio/debug/config/renode.py b/platformio/debug/config/renode.py index f2f62d66..de7bba48 100644 --- a/platformio/debug/config/renode.py +++ b/platformio/debug/config/renode.py @@ -16,6 +16,7 @@ from platformio.debug.config.base import DebugConfigBase class RenodeDebugConfig(DebugConfigBase): + DEFAULT_PORT = ":3333" GDB_INIT_SCRIPT = """ define pio_reset_halt_target monitor machine Reset @@ -33,11 +34,6 @@ $INIT_BREAK monitor start """ - def __init__(self, *args, **kwargs): - if "port" not in kwargs: - kwargs["port"] = ":3333" - super().__init__(*args, **kwargs) - @property def server_ready_pattern(self): return super().server_ready_pattern or ( diff --git a/platformio/debug/process/server.py b/platformio/debug/process/server.py index 693dfa44..7724ddf7 100644 --- a/platformio/debug/process/server.py +++ b/platformio/debug/process/server.py @@ -62,7 +62,9 @@ class DebugServerProcess(DebugBaseProcess): openocd_pipe_allowed = all( [ - not self.debug_config.env_options.get("debug_port"), + not self.debug_config.env_options.get( + "debug_port", self.debug_config.tool_settings.get("port") + ), "gdb" in self.debug_config.client_executable_path, "openocd" in server_executable, ]