gdb_start_session
Start a GDB debugging session for executable, core dump, or custom commands. Detects missing debug symbols and other warnings, returning a session ID for further debugging tools.
Instructions
Start a new GDB debugging session. Can load an executable, core dump, or run custom initialization commands. Automatically detects and reports important warnings such as: missing debug symbols (not compiled with -g), file not found, or invalid executable. Check the 'warnings' field in the response for critical issues that may affect debugging. Available parameters: program (executable path), args (program arguments), core (core dump path - uses --core flag for proper symbol resolution), init_commands (GDB commands to run after loading), env (environment variables), gdb_path (GDB binary path), working_dir (directory to run program from). IMPORTANT for core dump debugging: Set 'sysroot' and 'solib-search-path' AFTER loading the core (either via 'core' parameter or 'core-file' init_command) for symbols to resolve correctly. Returns a session_id integer that must be passed to all other GDB tools.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| program | No | Path to executable to debug | |
| args | No | Command-line arguments for the program | |
| init_commands | No | GDB commands to run on startup (e.g., 'core-file /path/to/core', 'set sysroot /path') | |
| env | No | Environment variables to set for the debugged program (e.g., {'LD_LIBRARY_PATH': '/custom/libs'}) | |
| gdb_path | No | Path to GDB executable (default: from GDB_PATH env var or 'gdb') | |
| working_dir | No | Working directory to use when starting GDB. Use this when debugging programs that need to be run from a specific directory, or when the program expects to find files (config, data, etc.) relative to its working directory. GDB will be started in this directory, then the original directory is restored. Example: If debugging a server that loads config from './config.json', set working_dir to the server's directory. | |
| core | No | Path to core dump file for post-mortem debugging. When specified, GDB is started with --core flag which properly initializes symbol resolution. IMPORTANT: When using a sysroot with core dumps, set sysroot AFTER the core is loaded (either via this parameter or core-file command) for symbols to resolve correctly. |