Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Sep 3, 2025

This PR implements a new GDB Machine Interface (MI) adapter that provides local debugging capabilities using GDB's structured MI protocol, complementing the existing remote-only GDB RSP adapter.

Key Features

Local Debugging Support: Unlike the existing GdbAdapter which only supports remote connections, the new GdbMiAdapter provides full local process execution via Execute() and ExecuteWithArgs() methods.

Structured Communication: Uses GDB's Machine Interface protocol instead of raw Remote Serial Protocol packets, providing better parsing, error handling, and structured responses.

System Integration: Automatically detects system GDB installations with fallback support for bundled GDB executables. Validates MI support and provides clear error messages when requirements aren't met.

Cross-Platform Support: Includes comprehensive process management for Windows, macOS, and Linux with proper pipe handling and process lifecycle management.

Implementation

The adapter is implemented as:

  • GdbMiAdapter: Main adapter class inheriting from DebugAdapter with full MI protocol support
  • GdbMiAdapterType: Adapter type class with system validation and capability detection
  • Automatic Registration: Appears as "GDB MI (Local)" in the debugger adapter selection

Architecture

Binary Ninja UI ←→ GdbMiAdapter ←→ System GDB (--interpreter=mi) ←→ Target Process
                        ↓
                   Bundled gdbserver (for enhanced features)

Changes Made

  • New Files: core/adapters/gdbmiadapter.{h,cpp} with complete MI implementation
  • Build Integration: Updated CMakeLists.txt to include new adapter and properly bundle gdbserver
  • Registration: Modified core/debugger.cpp to initialize the new adapter type

Differences from Existing GdbAdapter

Feature GdbAdapter (RSP) GdbMiAdapter (MI)
Protocol Remote Serial Protocol Machine Interface
Local Execution ❌ Remote only ✅ Full local support
Communication Raw packets ✅ Structured responses
Requirements gdbserver bundle System GDB + gdbserver

The implementation provides comprehensive debugging capabilities including breakpoints, stepping operations, memory access, register management, and reverse debugging support through GDB's rich MI interface.

Fixes #170.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@Copilot Copilot AI changed the title [WIP] Add a GDB machine interface adapter Add GDB Machine Interface adapter for local debugging Sep 3, 2025
@Copilot Copilot AI requested a review from xusheng6 September 3, 2025 10:29
Copilot finished work on behalf of xusheng6 September 3, 2025 10:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a GDB machine interface adapter
3 participants