Skip to main content
Glama
gdb and rr Debugging

gdb and rr Debugging

by schuay

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

  • Python 3.12+

  • uv

  • GDB on $PATH

  • rr on $PATH (optional — only needed for rr_record / start_replay_session)

Related MCP server: MCP Server GDB

Installation

uv tool install git+https://github.com/schuay/gdb-mcp.git

This installs a gdb-mcp command into an isolated environment and puts a shim on your $PATH. Upgrade later with:

uv tool upgrade gdb-mcp

Install and configure Gemini CLI

curl -fsSL https://raw.githubusercontent.com/schuay/gdb-mcp/main/install-gemini.sh | bash

This installs the tool and adds the server to ~/.gemini/settings.json. Requires jq.

Tools

Session management

Tool

Description

start_session

Spawn a GDB process, optionally loading a binary

stop_session

Kill a session and free its resources

list_sessions

Show all active sessions with idle time and kind (gdb / rr-replay)

Time-travel debugging (rr)

rr records a full execution trace and replays it deterministically, enabling reverse-execution (reverse-continue, reverse-step, etc.).

Tool

Description

rr_record

Record a program execution; returns trace_dir for later replay

start_replay_session

Start an rr replay session; accepts trace_dir from rr_record, or omit to replay the latest recording

A replay session works with all standard tools, plus dedicated reverse-execution tools:

Tool

Description

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

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

run

run

Start or restart the inferior

continue_exec

continue

Continue after a stop

step

step / stepi

Step into next line or instruction

next

next / nexti

Step over next line or instruction

finish

finish

Run until current function returns

until

until

Run until a specific location (skip loops)

interrupt

SIGINT

Interrupt a running inferior

Breakpoints and watchpoints

Tool

GDB command

Description

breakpoint

break / tbreak

Set a breakpoint (supports conditions)

delete_breakpoints

delete

Delete one or all breakpoints

watch

watch / rwatch / awatch

Stop when an expression is written, read, or accessed

Threads

Tool

GDB command

Description

list_threads

info threads

List all threads with their current location

select_thread

thread N

Switch to a specific thread

Stack frames

Tool

GDB command

Description

backtrace

backtrace

Show the full call stack

select_frame

frame N

Select a frame by number

up

up

Move up toward the caller

down

down

Move down toward the innermost frame

Inspection

Tool

GDB command

Description

context

frame + info args + info locals + list

Full snapshot of current location, arguments, locals, and source — call this after every stop

list_variables

info locals / info args

Variables in the current frame

print

print

Evaluate and print a GDB expression

examine

x

Examine memory at an address

info_registers

info registers

Show CPU register values

list_source

list

Show source code around the current position

disassemble

disassemble

Disassemble a function or address range

Generic

Tool

Description

exec_command

Run any GDB command and return its output

batch_commands

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_session gives a clean slate.

Available Tools

34 tools
backtraceB

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

    A4/5.0

    Scored across 34 tools

    Disambiguation5/5

    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).

    Naming Consistency5/5

    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.

    Tool Count4/5

    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.

    Completeness5/5

    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

    Related MCP Servers

    • A
      license
      B
      quality
      D
      maintenance
      Provides 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.
      16
      135 npm
      161
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      An MCP server that provides programmatic access to the GNU Debugger (GDB), enabling AI models to interact with GDB through natural language for debugging tasks.
      9
      Apache 2.0
    • A
      license
      C
      quality
      B
      maintenance
      Enables 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.
      13
      74
      GPL 3.0