proc-debug

Crates.ioproc-debug
lib.rsproc-debug
version0.1.5
sourcesrc
created_at2024-10-13 00:22:59.958443
updated_at2024-10-19 09:00:55.097842
descriptionDump proc-macro output for efficient debugging
homepage
repositoryhttps://github.com/yasuo-ozu/proc-debug
max_upload_size
id1406972
size273,121
yozu (yasuo-ozu)

documentation

README

proc-debug crate Latest Version Documentation GitHub Actions

Screenshot

Use proc-debug via CLI (recommended)

$ cargo install --path cargo
...
$ cargo proc-debug --help
Usage: cargo proc-debug [OPTIONS] [KEYWORD]...

Arguments:
  [KEYWORD]...  keywords to filter debugging proc-macros

Options:
  -m, --manifest-path <PATH>  specify the manifest path for this library
  -p, --package <PACKAGE>     debug macros called only from the specified packages
      --lib                   debug macro calls only in this package's library
      --bins                  debug macro calls in all bins
      --bin <NAME>            debug macro calls only in specified binary
      --examples              debug macro calls in all examples
      --example <NAME>        debug macro calls only in specified example
      --tests                 debug macro calls in library tests
      --test <NAME>           debug macro calls only in specified test target
      --benches               debug macro calls in all benches
      --bench <NAME>          debug macro calls only in specified benchmark
  -F, --features <FEATURES>   space or comma separated list of features to activate
      --all-features          activate all available features
      --no-default-features   do not activate the `default` feature
  -v, --version               show version
      --target <TARGET>       check for the target triple
  -P, --path <PATH>           absolute (begins with '::') or partial path to filter debugging
                              proc-macros
      --verbose               do not omit longer outputs
  -h, --help                  Print help

# Run proc-debug in the crate dir, which calls proc macros
$ cargo proc-debug --verbose
👉 input of my_macro_crate::macro (macro/lib.rs:1008)
...
👉 output of my_macro_crate::macro (macro/lib.rs:1008)
...

Use proc-debug as a library

Belief configuration

  • Cargo.toml
#[dependencies]
proc-debug = "0.1"
  • lib.rs
#[proc_macro]
#[proc_debug::proc_debug]
fn my_macro(attr: TokenStream, input: TokenStream) -> TokenStream { .. }
  • show help (--nocapture is important)
$ PROC_DEBUG_FLAGS="--help" cargo build --test <test-name> -- --nocapture
Usage: proc-debug [-a] [-n <not...>] [-p <path...>] [-d <depth>] [-c <count>]
                  [-v] [queries...]

Input for `proc-debug`

Options:
  -a, --all            debug all macros
  -n, --not <not>      hide outputs match
  -p, --path <path>    full or partial path of macro definition
  -d, --depth <depth>  depth to show in macro output
  -c, --count <count>  count to show in display
  -v, --verbose        verbose
  -h, --help           Show this help message and exit.
  • show all dumps (called from <test-name>)
$ PROC_DEBUG_FLAGS="-a" cargo build --test <test-name> -- --nocapture
  • filtered
$ PROC_DEBUG_FLAGS="your_macro_path" cargo build --test <test-name> -- --nocapture
Commit count: 14

cargo fmt