介绍 Rudy:用于 Rust 调试信息的工具链

  • July 9, 2025 (1mo ago):

    • rudy is Rust-specific debuginfo tooling. By default, cargo build invokes rustc with -g and outputs debug info with the binary. On MacOS and Linux, rustc emits DWARF debugging info.
    • rudy consists of rudy-dwarf for directly interacting with DWARF info and rudy-db for a higher-level interface. Its two main goals are to improve Rust debugging with lldb via rudy-lldb and build foundational tooling.
  • Rudy LLDB:

    • rudy-lldb is a small application using rudy-db to provide an extension for lldb. It works by adding the Python client to ~/.lldbinit, connecting to a locally-running server over TCP, and using rudy-db to query and forward information.
    • It extends lldb with Rust-specific functionality, understands Rust types and their memory layouts, and differentiates between functions, methods, and trait implementations.
  • Rudy Dwarf:

    • rudy-dwarf is a "medium-level" library for interacting with DWARF info, sitting above gimli. It provides indexes for fast lookups, parser combinators for extracting data, and a visitor trait.
    • The parser is based on the Parser trait, which takes a salsa database and a Die (an opaque wrapper around an offset) and parses the DWARF info. Parser combinators like all are used to combine multiple parsers.
    • For example, complex Rust types like enums can be parsed using reusable components, and parser combinators make it easy to build custom functionality.
  • Using Salsa:

    • The project initially aimed to build a Rust-specific debugger but was split into rudy. salsa is used for incremental computation and caching in rudy-dwarf and rudy-db.
    • On MacOS, rudy-db computes indexes quickly for small projects (20-30ms) and larger projects (1-2s). Individual operations are fast after indexing (around 1ms for small, 10ms for large).
    • There are improvements to be made, especially on Linux where indexing the entire binary upfront is expensive. A follow-up post is planned to discuss the use of salsa in more detail.
  • Digression: Why do we need better debugging tooling for Rust?:

    • The author has used Rust for over 10 years and only used interactive debuggers for stack overflows. Print debugging can be a trap, and it would be helpful to have an interactive debugger to query the system state.
    • rudy aims to make lldb debugging a viable option and provide foundational tooling for the next generation of debug tooling.
阅读 9
0 条评论