Dogfooding a MIR Debugger

⚓ Rust    📅 2026-06-22    👤 surdeus    👁️ 3      

surdeus

Info

This post is auto-generated from RSS feed The Rust Programming Language Forum - Latest topics. Source: Dogfooding a MIR Debugger

Hi everyone,

I wanted to do a casual share of a MIR debugger I’ve been dogfooding lately. It is built into KMiri, which is a Miri fork specifically tailored for AsterinasOS.

I’m sharing this primarily to spark a discussion about MIR-level debugging tools; please note that the debugger is currently highly specialized and not yet intended for general-purpose use.

The project began as a prototype implemented by alaotach (original PR: rust-lang/miri#4931). Since then, I have heavily refactored the codebase and implemented several new features to meet my development needs.

Currently, it supports the following core functionalities:

1. Code Execution and Flow Control

  • Multi-level Stepping: Supports stepping through individual MIR statements, basic block terminators, or source code lines (Step-over).
  • Bi-directional Execution: Enables both forward execution and backward stepping (Step-back).
  • Execution Metrics: Real-time display of total executed steps and history record counts.
  • Instance Navigation: High-speed jumping to specific function or generic instances via the Instances view for fast code navigation, without preserving debugging state during the jump.

2. Code and Stack Tracing

  • Source-MIR Synchronization: Simultaneously displays Rust source code and its corresponding MIR, highlighting the current execution point in both.
  • Call Stack Trace: Provides a complete hierarchy of the current thread's function calls, including function signatures, file paths, and precise line numbers.

3. Memory and Variable State Inspection

  • Locals Table: Lists all variables within the current scope (MIR indices, names, types, and values), with support for identifying uninit states and memory pointers.
  • Allocations List: Summarizes all active memory allocations, including AllocIDs, base physical addresses (BasePaddr), memory kinds (e.g., Kernel), size, alignment, and exposure status.
  • Output Log: Captures and displays standard output and kernel-level print messages.

4. Borrow Model Visualization (Stacked Borrows)

  • Borrow Stack Visualization: Displays borrow tags (BorTagID) and their positions in the stack (StackIdx) for specific allocations.
  • Permission Monitoring: Shows access permissions for each tag (e.g., Unique, SharedReadOnly, SharedReadWrite).
  • Protected Status Tracking: Identifies borrow tags currently in a "Protected" state.
  • Provenance Tracing: Tracks pointer evolution by recording parent tag IDs (PrevTagID) and retagging information (RetagInfo).
  • Fine-grained Byte Monitoring: Supports inspecting the borrow state of specific byte ranges within a single allocation.

image

image

Disclaimer: The primary purpose of this debugger is to help me better understand MIR interpretation while using Miri to interpret AsterinasOS. While some portions of the implementation involve LLM-generated code, the vast majority of debugger code has been human written and manually verified to ensure it functions as intended. I want to emphasize that this is not a product of "vibe coding"; substantial effort has been put into validating the logic and ensuring the tool's reliability for its specific use case.

1 post - 1 participant

Read full topic

🏷️ Rust_feed