gdb and rr Debugging
The gdb-mcp server exposes GDB and rr debugging capabilities as structured tools, enabling an AI assistant to fully control and inspect program execution.
Session Management
start_session— launch a new GDB process, optionally loading a binary, arguments, and working directorystop_session— kill a session and free its resourceslist_sessions— view all running sessions, their kind (gdborrr-replay), and status
Time-Travel Debugging (rr)
rr_record— capture a full deterministic execution trace, returning atrace_dirstart_replay_session— replay a recorded trace to enable reverse executionreverse-continue— run backwards to the previous breakpoint or watchpointreverse-step— step backwards one line/instruction, entering callsreverse-next— step backwards one line/instruction, skipping callsreverse-finish— run backwards to where the current function was called
Execution Control
run— start or restart the inferior programcontinue_exec— resume execution from a stopstep/next— step forward into or over the next source line/instructionfinish— run until the current function returnsuntil— run forward to a specific locationinterrupt— send SIGINT to unblock a running session
Breakpoints & Watchpoints
breakpoint— break at a function, file:line, or address, with optional conditions and temporary flagdelete_breakpoints— remove one or all breakpointswatch— stop on write, read, or any access to an expression/memory location
Thread Management
list_threads— show all threads and their current locationselect_thread— switch to a specific thread
Stack Frame Navigation
backtrace— show the full call stackselect_frame— jump to a specific frame by numberup/down— move toward the caller or innermost frame
Inspection & Introspection
context— full snapshot of current frame, arguments, locals, and source after any stoplist_variables— show local variables and/or function argumentsprint— evaluate and print any GDB expression with optional formattingexamine— dump memory at an address with configurable format and unit sizeinfo_registers— display CPU register values (all or specific)list_source— show source code around the current position or a given locationdisassemble— disassemble a function or address range, optionally interleaved with source
Generic Commands
exec_command— execute any arbitrary GDB command and return its outputbatch_commands— run a sequence of GDB commands in one round-trip to reduce latency
gdb-mcp
MCP server that exposes GDB debugging as tools. An AI assistant can set breakpoints, run programs, step through code, inspect variables and memory, and examine registers — all via structured tool calls.
Reverse debugging with rr is also supported.
Requirements
Related MCP server: MCP Server GDB
Installation
uv tool install git+https://github.com/schuay/gdb-mcp.gitThis installs a gdb-mcp command into an isolated environment and puts a
shim on your $PATH. Upgrade later with:
uv tool upgrade gdb-mcpInstall and configure Gemini CLI
curl -fsSL https://raw.githubusercontent.com/schuay/gdb-mcp/main/install-gemini.sh | bashThis installs the tool and adds the server to ~/.gemini/settings.json.
Requires jq.
Tools
Session management
Tool | Description |
| Spawn a GDB process, optionally loading a binary |
| Kill a session and free its resources |
| Show all active sessions with idle time and kind ( |
Time-travel debugging (rr)
rr records a full execution trace and replays it deterministically, enabling reverse-execution (reverse-continue, reverse-step, etc.).
Tool | Description |
| Record a program execution; returns |
| Start an rr replay session; accepts |
A replay session works with all standard tools, plus dedicated reverse-execution tools:
Tool | Description |
| Run backwards to the previous breakpoint or watchpoint |
| Step backwards one source line or instruction (enters calls) |
| Step backwards one source line or instruction (skips calls) |
| Run backwards to where the current function was called |
Typical workflow:
rr_record("/path/to/binary", args=["--flag"])
→ { "trace_dir": "/home/user/.local/share/rr/binary-0", ... }
start_replay_session(trace_dir="/home/user/.local/share/rr/binary-0")
→ { "session_id": "a1b2c3d4", ... }
# Now use the session_id with any tool: breakpoint, run, reverse-continue, etc.Execution control
Execution tools block until the inferior stops (breakpoint, signal, exit, or
timeout). While blocked, use interrupt to send SIGINT and unblock.
Tool | GDB command | Description |
|
| Start or restart the inferior |
|
| Continue after a stop |
|
| Step into next line or instruction |
|
| Step over next line or instruction |
|
| Run until current function returns |
|
| Run until a specific location (skip loops) |
| SIGINT | Interrupt a running inferior |
Breakpoints and watchpoints
Tool | GDB command | Description |
|
| Set a breakpoint (supports conditions) |
|
| Delete one or all breakpoints |
|
| Stop when an expression is written, read, or accessed |
Threads
Tool | GDB command | Description |
|
| List all threads with their current location |
|
| Switch to a specific thread |
Stack frames
Tool | GDB command | Description |
|
| Show the full call stack |
|
| Select a frame by number |
|
| Move up toward the caller |
|
| Move down toward the innermost frame |
Inspection
Tool | GDB command | Description |
| frame + info args + info locals + list | Full snapshot of current location, arguments, locals, and source — call this after every stop |
|
| Variables in the current frame |
|
| Evaluate and print a GDB expression |
|
| Examine memory at an address |
|
| Show CPU register values |
|
| Show source code around the current position |
|
| Disassemble a function or address range |
Generic
Tool | Description |
| Run any GDB command and return its output |
| Run a list of commands sequentially (fewer round-trips) |
exec_command handles execution commands correctly: advance, jump,
signal, and return all block until the inferior stops, just like the named
tools do.
Notes
GDB plugins such as pwndbg or GEF work if installed, but their custom
prompts ((pwndbg), gef>) will break session startup. Either avoid them or
force the standard prompt in .gdbinit:
set prompt (gdb)Timeout behaviour: if an execution command times out, the session is in an
indeterminate state. Call interrupt to stop the inferior, wait for the
blocked tool call to return, then resume normally. When in doubt, stop_session
start_sessiongives a clean slate.
Available Tools
34 toolsbacktraceB
Show the call stack (GDB 'backtrace' / 'bt').
limit: maximum number of frames to show (omit for full stack).
Inputs: session_id (required), limit. Returns: result
batch_commandsA
Execute a list of GDB commands sequentially and return each output.
Useful to avoid multiple round-trips, e.g.: ["file /bin/ls", "break main", "run -la"] stop_on_error: halt the batch on the first GdbError (default: continue).
Inputs: commands (required), session_id (required), timeout, stop_on_error. Returns: result
breakpointA
Set a breakpoint at a location. Triggers in both directions in rr replay sessions.
location: function name, file:line, or *address e.g. "main", "foo.c:42", "*0x401234", "MyClass::method" condition: optional expression that must be true to trigger — e.g. "x > 5" temporary: if True, the breakpoint auto-deletes after its first hit
Inputs: location (required), session_id (required), condition, temporary. Returns: result
contextA
Return a full snapshot of the current debugging context.
Combines the most commonly needed post-stop information into one call:
Current frame: function, file, and line number
Function arguments
Local variables
Source listing around the current line
Call this immediately after any stop event (breakpoint hit, step, interrupt) to orient yourself before deciding on the next action.
Note: this resets GDB's internal source-listing position to the current PC, which cancels any forward scrolling done by previous list_source calls.
Inputs: session_id (required). Returns: result
continue_execA
Continue forward execution from the current stop. Blocks until the program stops again.
rr replay sessions: use reverse-continue to run backwards instead.
Inputs: session_id (required), timeout. Returns: result
delete_breakpointsA
Delete one breakpoint or all breakpoints (GDB 'delete').
number: breakpoint number to delete; omit to delete all breakpoints.
Inputs: session_id (required), number. Returns: result
disassembleA
Disassemble code (GDB 'disassemble').
location: function name, *address, or "start,end" address range. Omit to disassemble the current function. with_source: if True, interleave C source lines with assembly (/s flag).
Inputs: session_id (required), location, with_source. Returns: result
downA
Move down the call stack toward the innermost frame (GDB 'down').
count: number of frames to move down (default 1).
Inputs: session_id (required), count. Returns: result
examineA
Examine memory at an address (GDB 'x').
address: GDB expression for the target address: "&var", "0x601020", "$rsp" count: number of units to display fmt: x=hex, d=decimal, i=instruction, s=string, c=char, o=octal, t=binary unit: b=byte(1B), h=halfword(2B), w=word(4B), g=giant(8B)
Example: examine("$rsp", count=8, fmt="x", unit="g") → x/8xg $rsp (8 giant-word hex dump of the stack)
Inputs: address (required), session_id (required), fmt, unit, +1 more. Returns: result
exec_commandA
Execute any GDB command and return its output. Escape hatch for commands without a dedicated tool.
Useful examples: info breakpoints — list all breakpoints set var x = 5 — modify a variable thread apply all bt — backtrace every thread catch syscall / catch throw advance location — run to a specific location in the current frame source /path/to/script.gdb attach PID core-file /path/to/core
IMPORTANT — any command that resumes the inferior (run, continue, step, next, finish, until, advance, jump, signal, return, and the rr reverse-* variants) will BLOCK until the inferior stops again. Output includes the stop reason, e.g.: [Stopped: breakpoint-hit, in main, at foo.c:10] Use the interrupt tool to unblock a running session.
Inputs: command (required), session_id (required), timeout. Returns: result
finishA
Run forward until the current function returns, then show the return value. Blocks until stopped.
rr replay sessions: use reverse-finish to run backwards to the call site instead.
Inputs: session_id (required), timeout. Returns: result
info_registersA
Show CPU register values (GDB 'info registers').
register: specific register name (e.g. "rax", "eip"), or omit for all general-purpose registers.
Inputs: session_id (required), register. Returns: result
interruptA
Interrupt a running inferior by sending SIGINT.
Use when run, continue_exec, or a reverse-* tool is blocking because the program has not stopped yet. The blocked call returns with the stop output.
Inputs: session_id (required).
list_sessionsA
List all active sessions. Each entry includes id, kind ("gdb" or "rr-replay"), and alive status.
Inputs: no named parameters.
list_sourceA
List source code (GDB 'list' / 'l').
location: function name, file:line, or omit to list around the current position. Call repeatedly with no location to scroll forward.
Inputs: session_id (required), location. Returns: result
list_threadsB
List all threads in the inferior with their current location (GDB 'info threads').
Inputs: session_id (required). Returns: result
list_variablesA
Show variables in the current stack frame (GDB 'info locals' / 'info args').
scope: "locals" — local variables only (default) "args" — function arguments only "all" — both locals and arguments
Inputs: session_id (required), scope. Returns: result
nextA
Step forward over the next source line or machine instruction. Does not enter called functions.
Use step to enter calls instead. count: number of steps (default 1) instruction: if True, step over one machine instruction instead of one source line rr replay sessions: use reverse-next to step backwards.
Inputs: session_id (required), count, instruction. Returns: result
printB
Print/evaluate a GDB expression (GDB 'print' / 'p').
expression: any GDB expression — variable, cast, function call, etc. fmt: optional output format: x=hex, d=decimal, o=octal, t=binary, f=float, s=string, c=char, a=address e.g. fmt="x" → "print /x expression"
Inputs: expression (required), session_id (required), fmt. Returns: result
reverse-continueA
[rr only] Run backwards until a breakpoint or watchpoint is hit. Blocks until stopped.
Requires an rr replay session created with start_replay_session. The reverse counterpart of continue_exec: resumes execution in reverse through previously executed code.
Inputs: session_id (required), timeout. Returns: result
reverse-finishA
[rr only] Run backwards until just before the current function was called. Blocks until stopped.
Requires an rr replay session created with start_replay_session. The reverse counterpart of finish: where finish runs forward to the return, reverse-finish runs backward to the call site.
Inputs: session_id (required), timeout. Returns: result
reverse-nextA
[rr only] Step backwards over the previous source line or machine instruction. Blocks until stopped.
Requires an rr replay session created with start_replay_session. The reverse counterpart of next: does not enter called functions when going backwards. Use reverse-step to step backwards into calls. count: number of steps (default 1) instruction: if True, step back one machine instruction instead of one source line
Inputs: session_id (required), count, instruction. Returns: result
reverse-stepA
[rr only] Step backwards into the previous source line or machine instruction. Blocks until stopped.
Requires an rr replay session created with start_replay_session. The reverse counterpart of step: enters called functions when going backwards. Use reverse-next to step backwards without entering calls. count: number of steps (default 1) instruction: if True, step back one machine instruction instead of one source line
Inputs: session_id (required), count, instruction. Returns: result
rr_recordA
Record a full program execution with rr for time-travel debugging. Step 1 of the rr workflow.
Runs the program to completion and captures a deterministic trace. Returns trace_dir, which is passed to start_replay_session to begin debugging. Crashes and non-zero exit codes are normal and recorded as part of the trace — they do not indicate failure. The program's stdin is not available during recording.
binary: path to the executable to record args: command-line arguments for the binary cwd: working directory (defaults to current directory) timeout: maximum seconds to wait for the program to finish (default 5 min)
Inputs: binary (required), cwd, args, timeout.
runA
Start or restart the inferior program. Blocks until it stops (breakpoint, signal, or exit).
In an rr replay session, run restarts from the very beginning of the recording. Pass args to override arguments set at session creation.
Inputs: session_id (required), args, timeout. Returns: result
select_frameA
Select a stack frame by number (GDB 'frame N').
Frame 0 is the innermost (current) frame; use backtrace to see frame numbers. After selecting a frame, inspection commands (print, info locals, list_source) operate in that frame's context.
Inputs: frame (required), session_id (required). Returns: result
select_threadA
Switch to a specific thread (GDB 'thread N').
Use list_threads to see thread IDs. After switching, stack and local variable commands operate on the selected thread.
Inputs: thread_id (required), session_id (required). Returns: result
start_replay_sessionA
Start an rr replay session for time-travel debugging. Step 2 of the rr workflow.
Call rr_record first to produce a trace, then call this tool. The returned session_id works with all standard tools (breakpoint, run, continue_exec, step, backtrace, print, …). In addition, four reverse-execution tools let you run the program backwards: reverse-continue — run backwards to the previous breakpoint or watchpoint reverse-step — step backwards one source line or instruction (enters calls) reverse-next — step backwards one source line or instruction (skips calls) reverse-finish — run backwards to where the current function was called Breakpoints and watchpoints trigger in both directions.
trace_dir: trace directory from rr_record; omit to replay the most recent recording cwd: working directory for rr (defaults to current directory)
Inputs: cwd, trace_dir.
start_sessionA
Start a new GDB debug session. Returns session_id required by all other tools.
For time-travel (record/replay) debugging use rr_record + start_replay_session instead.
binary: path to the executable (can also be set later via exec_command("file /path")) args: command-line arguments passed to the inferior when run is called cwd: working directory for GDB (defaults to current directory)
Inputs: cwd, args, binary.
stepA
Step forward into the next source line or machine instruction. Enters called functions.
Use next to step over calls instead. count: number of steps (default 1) instruction: if True, step one machine instruction instead of one source line rr replay sessions: use reverse-step to step backwards.
Inputs: session_id (required), count, instruction. Returns: result
stop_sessionA
Stop and clean up a GDB session (kills the GDB process).
Inputs: session_id (required).
untilA
Run forward until a specific location is reached. Blocks until stopped.
Skips over loops and blocks of code without setting a temporary breakpoint. location: file:line, function name, or *address — e.g. "foo.c:42", "cleanup", "*0x401234"
Inputs: location (required), session_id (required), timeout. Returns: result
upB
Move up the call stack toward the caller (GDB 'up').
count: number of frames to move up (default 1).
Inputs: session_id (required), count. Returns: result
watchA
Set a watchpoint that stops execution when an expression changes (GDB 'watch').
Watchpoints detect when data changes, not where execution reaches. Useful for tracking memory corruption, unexpected variable mutations, etc.
expression: any GDB expression — variable, memory location, dereferenced pointer e.g. "x", "buf[4]", "*0x601020", "obj->field" mode: "write" — stop when expression is written (default, GDB 'watch') "read" — stop when expression is read (GDB 'rwatch') "access" — stop on any read or write (GDB 'awatch')
Inputs: expression (required), session_id (required), mode. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 34 tools
Each tool has a distinct purpose clearly described. For example, step and next are separated by whether they enter function calls, and reverse tools are clearly prefixed. There is minimal overlap; batch_commands and exec_command serve different needs (sequential vs. single command).
All tools use consistent snake_case verb_noun or verb phrase patterns. Reverse tools follow a uniform 'reverse-verb' naming. No mixed conventions like camelCase or inconsistent verb styles.
34 tools is on the high end but appropriate for the comprehensive domain of GDB and rr debugging. Each tool covers a specific aspect without redundancy. The count feels slightly heavy but earns a high score due to the scope of the server.
The tool set covers all major debugging workflows: session management, breakpoints, stepping (forward/reverse, source/instruction), stack navigation, memory inspection, registers, source listing, variables, watchpoints, and escape hatch. rr tools include recording, replay, and all reverse stepping variants, leaving no obvious gaps.
Related MCP Connectors
Live browser debugging for AI assistants — DOM, console, network via MCP.
MCP server for your apps' tools and custom tools, plus hosted AI agents and approval-gated workflows
Agent Replay Debugger MCP — record every agent step + deterministic replay. Step-debugger for
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
Related MCP Servers
- AlicenseBqualityDmaintenanceProvides GDB debugging functionality for use with Claude or other AI assistants, allowing users to manage debugging sessions, set breakpoints, examine variables, and execute GDB commands through natural language.16135 npm161MIT
- AlicenseNot gradedqualityDmaintenanceA GDB/MI protocol server based on the MCP protocol, providing remote application debugging capabilities.68MIT
- AlicenseNot gradedqualityDmaintenanceAn MCP server that provides programmatic access to the GNU Debugger (GDB), enabling AI models to interact with GDB through natural language for debugging tasks.9Apache 2.0
- AlicenseCqualityBmaintenanceEnables LLM clients to interact with the GNU Debugger (GDB) for comprehensive debugging and binary analysis. It provides a wide range of tools for program execution control, memory examination, stack analysis, and disassembly.1374GPL 3.0