ndarray icon indicating copy to clipboard operation
ndarray copied to clipboard

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

Open NeLeGo opened this issue 5 months ago • 0 comments
trafficstars

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

NeLeGo avatar Jun 09 '25 15:06 NeLeGo