Improve debugger visualization for `ndarray` arrays using `#[debugger_visualizer]`

Open
#1,519 0 comments 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
python, rust
Domain
devtools

Research direction

Start by reviewing discussions in issues #827 and #366, then read the Rust Reference debugger attribute documentation and the Rust Compiler Development Guide section on supported debuggers. Evaluate whether embedding Python pretty-printers and .natvis files with #[debugger_visualizer] is feasible for ndarray arrays. Done means a decided approach for official debugger visualization support.

Written by the indexing model from the issue text.

Description

This issue has been discussed in #827 and #366, but it remains partially unresolved.

Problem and Previous solution

When debugging ndarray arrays in VSCode, their display is often not human-readable:

image

However, with this custom formatter.py file (along with some additional configuration), the display becomes much more readable:

image

(This solution was originally provided by @MartinRJDagleish in this comment)

More Discussion

The #[debugger_visualizer] attribute has been stabalized in Rust 1.71.0 for 2 years, which can be used to embed a debugger visualizer file into the debug information. This means we can write pretty-printer files (Python script, for GDB and LLDB) and .natvis files (for Windbg) for ndarray arrays, and embed them into the Rust code using the attribute, to provide official support for debugger visualization of ndarray arrays.

I'm not sure whether it is a feasible approach, but I'm glad to have a discussion.

Relevant Links

Dominant language
Rust
Stars
4.3k
Forks
391
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from rust-ndarray/ndarray

All issues in rust-ndarray/ndarray

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.