Skip to content

[Enhancement] Implement Comprehensive Debugging System (Ruchy-Debug-V2) #172

Description

@noahgift

Objective

Replace the limited ruchydbg macro with a comprehensive debugging system for the Ruchy runtime. The current system lacks granular control, structured output, and integration with standard tools.

Features to Implement

1. Structured Logging & Tracing

  • Replace println! based debugging with tracing crate.
  • Implement RUCHY_LOG levels (error, warn, info, debug, trace).
  • Add structured fields (span, file, line) to log events.

2. Interactive Debugger (CLI)

  • Implement a REPL-based debugger (ruchy debug script.ruchy).
  • Commands: step, next, continue, break <line>, inspect <var>.
  • Stack trace printing with source code context.

3. AST & Bytecode Inspection

  • Add --dump-ast flag to visualize the parsed AST (JSON/Graphviz).
  • Add --dump-bytecode flag to see the compiled instructions before execution.
  • Source mapping (Span -> Line/Col) for accurate error reporting.

4. Remote Debugging (DAP) - Future

  • Lay groundwork for Debug Adapter Protocol (DAP) to support VS Code integration.

Implementation Plan

  1. Add tracing and tracing-subscriber dependencies.
  2. Refactor ruchydbg! to use tracing::debug!.
  3. Implement DebugContext struct to track breakpoints and execution state.
  4. Create debug_cmd.rs for the interactive CLI.
  5. Enhance Parser and Compiler to support inspection flags.

Success Criteria

  • Developers can trace execution flow without recompiling.
  • Users can inspect variable state at runtime.
  • AST/Bytecode dumps are available for compiler debugging.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions