axon-debug
axon-debug
Section titled βaxon-debugβDebugging tools for the Axon programming language β GDB and LLDB pretty printers, crash symbolicators, and profiling helpers.
Features
Section titled βFeaturesβ- GDB Pretty Printers β Human-readable display of Axon types (
Option,Result,String,Vec,Map) in GDB - LLDB Type Formatters β Equivalent type summary/synthetic providers for LLDB
- Crash Symbolicator (
axon-sym) β Parse crash traces and resolve addresses to source file:line; supports free-form traces, explicit addresses, and structured JSON crash reports - C Bindings Generator (
axon-bindgen) β Generate Axon.axsextern declarations from C header files - Performance Benchmarks (
tools/bench.py) β Micro-benchmarks for addr2line and bindgen with CI thresholds - Memory Profiler (
tools/memprof.py) β Heap allocation tracker + leak detector (issue #34) - CPU Profiler (
tools/cpu.py) β Sampling CPU profiler with hot-spot aggregation (issue #122) - Panic Handler (
tools/panic_hook.py) β Structured panic reporter with category classification (issue #120) - DAP Server (
tools/dap.py) β Minimal Debug Adapter Protocol server for editors like VS Code and Cursor (issue #123) - MCP Server (
tools/mcp.py) β Model Context Protocol server (stdio / JSON-RPC 2.0) exposing 7 debug tools β addr2line, crash decode, memprof + CPU summaries, ownership, replay inspect, launch plan β to AI agents like Claude Code and Cursor (issue #127)
Supported Types
Section titled βSupported Typesβ| Axon Type | GDB Display | LLDB Display |
|---|---|---|
Option | Some(42) / None | Some(42) / None |
Result | Ok(val) / Err(e) | Ok(val) / Err(e) |
String | "hello world" | "hello world" |
Vec | Vec(len=3, cap=8) [0]=1 [1]=2 [2]=3 | Vec(len=3, cap=8) |
Map | Map(string, len=2, cap=4) | Map(string, len=2, cap=4) |
Sum / Enum | Tag::Variant(data) | Tag::Variant(data) |
Tuple | (1, "hello", 3.14) | (1, "hello", 3.14) |
Installation
Section titled βInstallationβFor full per-platform install instructions (Homebrew, apt, winget, manual, dev), see docs/INSTALL.md.
Quick Start
Section titled βQuick Startβ# macOS / Linux (one-time, auto-detects GDB and/or LLDB):git clone https://git.catalystgroup.tech/labs/axon/axon-debug.gitcd axon-debug./install.sh
# Verify:./install.sh --check # show status./install.sh --verify # actually load printers in debuggerOther install paths
Section titled βOther install pathsβ| Platform | Command |
|---|---|
| macOS | brew install axon-debug (after tap; see packaging/homebrew/) |
| Ubuntu/Debian | sudo dpkg -i axon-debug_*_all.deb (build with packaging/debian/build-deb.sh) |
| Windows | winget install catalystgroup.axon-debug (manifest in packaging/winget/) |
| Any (release) | Download tarball from Releases + run ./install.sh |
$ gdb ./my_axon_program(gdb) break main(gdb) run(gdb) print my_option$1 = Some(42)(gdb) print my_result$2 = Ok("success")(gdb) print my_string$3 = "hello world"$ lldb ./my_axon_program(lldb) breakpoint set --name main(lldb) run(lldb) frame variable my_option(axon::Option) my_option = Some(42)(lldb) frame variable my_result(axon::Result) my_result = Ok("success")Crash Symbolication (axon-sym / tools/addr2line.py)
Section titled βCrash Symbolication (axon-sym / tools/addr2line.py)βaxon-sym resolves hex addresses in crash traces to source file:line pairs. It works in three modes:
Mode 1 β Free-form text / piped trace:
my_program 2>&1 | python3 tools/addr2line.py ./my_programpython3 tools/addr2line.py ./my_program crash.logpython3 tools/addr2line.py ./my_program 0x1234 0x5678Mode 2 β JSON crash report (--crash-file):
When an Axon program crashes, axon_panic_handler() in libaxon_rt.a writes a structured crash.json to ~/.axon/crashes/. The --crash-file mode symbolicates the full stack:
# Use binary_path embedded in the crash report (most common):python3 tools/addr2line.py --crash-file ~/.axon/crashes/2026-06-20T03-26-21Z.json
# Override binary path if missing from report:python3 tools/addr2line.py --crash-file crash.json --binary ./my_program
# Machine-readable JSON output (for Sentry pipelines):python3 tools/addr2line.py --crash-file crash.json --output json > symbolized.json
# Text output with per-frame detail:python3 tools/addr2line.py --crash-file crash.json --output textSee docs/CRASH_REPORTS.md for the full crash.json schema and storage location documentation.
Project Structure
Section titled βProject Structureβaxon-debug/βββ gdb/β βββ __init__.py # GDB auto-load package initβ βββ axon_printers.py # GDB pretty printers (Option, Result, String, Vec, Map)βββ lldb/β βββ axon_formatters.py # LLDB type formatters + synthetic children providersβββ tools/β βββ addr2line.py # Crash trace symbolicator (free-form + JSON crash reports)β βββ bindgen.py # C header β Axon .axs extern generatorβ βββ aggregate_metrics.py # JUnit + coverage.json β public/metrics.jsonβ βββ run_tests.sh # Canonical test runner (JUnit + coverage)β βββ bench.py # Performance micro-benchmarks (addr2line + bindgen)β βββ dap.py # Debug Adapter Protocol server (stdio/TCP)β βββ mcp.py # Model Context Protocol server (stdio/JSON-RPC, 7 debug tools)β βββ remove_blocks.py # Strip axon-debug version blocks from init filesβββ tests/β βββ fixtures/β β βββ basic_types.axs # Test fixture (i32, i64, bool)β β βββ crash_test.c # C test binary for addr2line end-to-end testsβ βββ conftest.py # Shared pytest fixturesβ βββ test_printers.py # Printer unit tests (no debugger needed)β βββ test_lldb_formatters.py # LLDB provider interface + parity testsβ βββ test_basic_types.py # GDB integration testsβ βββ test_bindgen.py # bindgen CLI testsβ βββ test_addr2line.py # addr2line unit + end-to-end testsβ βββ test_mcp.py # MCP server tests (handshake, schema, 7 tools)β βββ test_bench.py # bench.py smoke testsβββ docs/β βββ INSTALL.md # Full per-platform install guideβ βββ CRASH_REPORTS.md # crash.json schema and storageβ βββ tools.md # tools/ directory referenceβ βββ dap.md # Debug Adapter Protocol server guideβ βββ mcp.md # Model Context Protocol server guideβ βββ FORMATTERS.md # GDB/LLDB formatter architectureβ βββ CI.md # CI pipeline and metrics infrastructureβββ public/β βββ metrics.json # GitLab Pages metrics (deployed by CI)βββ requirements.txt # Python dependenciesβββ .gitlab-ci.yml # CI pipelineβββ install.sh # GDB/LLDB installer with idempotency + versioningβββ CONTRIBUTING.md # Contributor guide (start here!)βββ README.mdRunning Tests
Section titled βRunning TestsβUsing the canonical runner (recommended)
Section titled βUsing the canonical runner (recommended)βtools/run_tests.sh # full suite with JUnit + coveragetools/run_tests.sh --no-cov # skip coverage (faster)tools/run_tests.sh --keep-results # keep results.xml / coverage filestools/run_tests.sh tests/test_printers.py # single filetools/run_tests.sh --help # show all flagsUsing pytest directly
Section titled βUsing pytest directlyβpytest tests/ -v # all testspytest tests/test_printers.py -v # unit tests only (no GDB/LLDB required)pytest tests/test_basic_types.py -v # GDB integration testsGDB tests auto-skip on macOS (outdated GDB). LLDB tests require an LLVM-based lldb (default on macOS).
Running benchmarks
Section titled βRunning benchmarksβpython3 tools/bench.py # writes benchmarks.jsonBenchmarks measure addr2line (10/100/1000 frames) and bindgen (10/50/100 declarations) wall-clock time.
Development
Section titled βDevelopmentβPrerequisites
Section titled βPrerequisitesβ- Python 3.8+
- GDB 10+ (with Python support) and/or LLDB 12+
- Axon compiler (for building test fixtures)
- For addr2line end-to-end tests:
binutils(addr2line) and a C compiler (cc)
pip install -r requirements.txtLinting
Section titled βLintingβruff check gdb/ tools/ tests/ lldb/Recent Changes
Section titled βRecent Changesβ| MR | Summary |
|---|---|
| #127 | tools/mcp.py β Model Context Protocol server exposing 7 debug tools over stdio (see docs/mcp.md, CHANGELOG.md) |
| #123 | tools/dap.py β minimal Debug Adapter Protocol server (see docs/dap.md) |
| !12 | tests/test_bench.py β coverage fix for benchmark tests |
| !11 | tools/bench.py β performance micro-benchmarks for addr2line + bindgen, CI threshold |
| !10 | Coverage threshold gate (23%) added to CI |
| !9 | Metrics pipeline: run_tests.sh, aggregate_metrics.py, GitLab Pages deployment |
| !8 | addr2line.py --crash-file JSON mode, docs/CRASH_REPORTS.md |
| !7 | install.sh rewrite: idempotency, versioning, --verify flag |
Related
Section titled βRelatedβ- axon-lang β The Axon compiler
- axon-std β Axon standard library
- axon-db β Database driver library
License
Section titled βLicenseβSee LICENSE for details.