piodebuggdb
Debug PlatformIO projects with GDB
TLDR
View documentation for the original command
SYNOPSIS
While primarily invoked by pio debug, piodebuggdb is a Python script that can be directly executed (though not recommended for general users) with various configuration options:
python -m platformio.debug.piodebuggdb [OPTIONS]
or
piodebuggdb [OPTIONS] (if an alias or wrapper is set up)
PARAMETERS
--project-dir <path>
Specifies the path to the PlatformIO project directory.
--environment <env>
Selects the build environment (e.g., board configuration) defined in platformio.ini.
--port <port>
Defines the debug probe's communication port or device path (e.g., JTAG/SWD device).
--interface <interface>
Sets the debugging interface (e.g., swd, jtag).
--build-dir <path>
Indicates the directory where build artifacts (like the firmware executable) are located.
--toolchain-path <path>
Provides the absolute path to the GDB toolchain executable (e.g., arm-none-eabi-gdb).
--exec-path <path>
Specifies the absolute path to the compiled firmware executable file to be debugged.
--extra-args <args>
Allows passing additional, raw arguments directly to the invoked GDB client.
--ignore-debug-init
Prevents piodebuggdb from loading the default PlatformIO debug initialization script for GDB.
--interpreter <interpreter>
Sets the GDB interpreter mode (e.g., mi for machine interface, console for standard TUI).
DESCRIPTION
The piodebuggdb command is an internal Python script within the PlatformIO ecosystem, designed to orchestrate and configure GNU Debugger (GDB) sessions for embedded system development. It acts as a crucial bridge, taking PlatformIO project configuration settings (such as target board, debug probe, build environment, and firmware paths) and translating them into the necessary arguments and commands for a GDB client. While users typically initiate debugging through the higher-level pio debug command, piodebuggdb is the underlying utility responsible for launching GDB with the correct parameters, connecting it to the debug probe's GDB server (e.g., OpenOCD, J-Link GDB Server), and loading the target firmware for debugging on the microcontroller. It streamlines the complex setup process often associated with embedded debugging, providing a consistent interface across diverse hardware.
CAVEATS
This command is an internal implementation detail of PlatformIO. It is not typically run directly by end-users but rather invoked and managed by the pio debug command. Direct invocation requires a deep understanding of PlatformIO's internal structure and GDB configuration. It relies on a correctly configured PlatformIO project, a compatible debug probe, and a running GDB server (which PlatformIO often manages itself).
GDB ORCHESTRATION
piodebuggdb's primary role is to act as an orchestrator for the GDB debugging session. It reads the detailed platformio.ini configuration, determines the correct GDB client executable, the GDB server address, and the target firmware. It then constructs the precise command-line arguments and initialization scripts that GDB needs to connect to the hardware and start debugging.
INTEGRATION WITH IDES
This script is also leveraged by PlatformIO's IDE integrations (e.g., VS Code extension). When a user initiates a debug session from their IDE, the IDE calls pio debug, which in turn utilizes piodebuggdb to set up and launch the GDB process, allowing the IDE to interact with the GDB session seamlessly.
HISTORY
piodebuggdb emerged as part of PlatformIO's continuous efforts to provide a seamless and integrated development experience for embedded systems. Its development has focused on abstracting the complexities of GDB setup, making it easier for developers to get started with debugging microcontrollers across various platforms and debug probes, without manually configuring GDB and its server components. It's a key component in PlatformIO's robust debugging framework, constantly updated to support new hardware and debug features.