Skip to content

gdb

GDB Debugger Support

This directory provides integration for controlling the GNU Debugger (GDB) using voice commands. It allows users to execute common debugging tasks—such as stepping through code, managing breakpoints, inspecting memory, and examining registers—directly within a Linux terminal interface.

The GDB implementation is structured around three key components:

  • Global Activation Management: Global commands to toggle the availability of the GDB context.
  • Generic Debugger Interface: Implementations of standardized debugger actions (such as stepping and execution control) mapped to GDB-specific syntaxes.
  • Command Voice Map: GDB-specific commands for fine-grained debugging, memory inspection (hexdumps), display rules, and thread/inferior management.

How It Works

GDB voice support operates on a toggleable tag model to prevent command collisions in standard terminal sessions.

+------------------+                   +---------------+
| gdb_global.talon | --(Voice Command)-->|    gdb.py     |
+------------------+                   +---------------+
                                               |
                                        (Sets/Clears Tag)
                                               v
+------------------+                   +---------------+
| gdb_active.talon | <--(Checks Tag)---|   user.gdb    |
+------------------+                   +---------------+

1. Global State Management

The GDB commands are restricted so that they do not accidentally trigger during standard command-line usage.

  • gdb_global.talon declares the global voice triggers [enable] debug mode and disable debug mode.
  • These triggers call user.gdb_enable() and user.gdb_disable() respectively.
  • The Python file gdb.py defines these actions, dynamically adding or removing the user.gdb tag to the global context (ctx_global).

2. Standardized Debugger Actions

The Python backend in gdb.py binds standard Talon debugger operations to GDB commands. This is executed under the ctx_gdb_enabled context, which becomes active only when the user.gdb tag is present.

It implements abstract actions from the user.debugger namespace:

  • Execution Control: Maps operations like debugger_step_into() to stepi\n, debugger_step_over_line() to next\n, and debugger_continue() to c\n.
  • Breakpoint Management: Translates standard actions such as adding, clearing, and disabling breakpoints (e.g., debugger_clear_all_breakpoints() becomes d br\n).
  • Hardware and Register Access: Powers commands to display and set registers (e.g., debugger_show_registers() maps to info registers\n).

3. GDB-Specific Command Mapping

The file gdb_active.talon activates when the user is running a Linux terminal and has enabled the user.gdb tag. It overrides and introduces a wide array of debugging shortcuts:

  • Memory Hexdumping: Quickly formats memory examination commands. For example, saying "hex dump <number> quad words" generates x/{number}gx. It also provides rapid actions to dump addresses stored in the system clipboard or currently highlighted on the screen.
  • Data Inspections: Shortcuts for printing variables, displaying strings, and formatting output in hexadecimal format (e.g. p/x).
  • Execution & Multi-Process Control: Commands to manage fork follow modes (set follow-fork-mode child/parent), manage detach behaviors, and handle multiple inferiors ("resume from inferior <number>").
  • Display & Backtracing: Utility scripts to configure list sizes, display assembly instructions at the program counter (display /i $pc), view local variables, and check active threads.