nalgebra
nalgebra copied to clipboard
Pretty printing of dynamically-sized vectors and matrices in debuggers
As far as I have seen, there is currently no support for pretty printing of dynamically-sized vectors and matrices in debuggers (at least on the gdb that got launched by default when running Rust tests in Debug in VS code).
I think that such a feature, if feasible, would be very useful to debug code using nalgebra.
That would be neat! How could it be accomplished? AFAIK gdb prettyprinters are python scripts, not sure there's any sensible way nalgebra can bundle such a thing.
Maybe just provide Python scripts in-tree and make sure they're uploaded to crates.io with the crate, so that you can always find the correct prettyprinter for the specific version of nalgebra you're using? Not quite automatic, but with some documentation it should be pretty straightforward for a user to install, at least?
IIRC, for reference, I think Eigen just provides some pretty printers in its git repo.
Huh, for some reason I thought crates.io allowed you to download the crate source directly, but I can't find that now. docs.rs does, but it seems to have limited ability to let you directly download stuff? Maybe not as convenient as I first thought ...
I would be already very happy to have something that requires a little bit of manual install, as long as it is reasonably simple and well documented, compared to not having anything ;-)
Rust 1.71 was released today, and it seems to give us just what we need to make the nalgebra debug experience stellar:
1.71.0 stabilizes support for a new attribute,
#[debug_visualizer(natvis_file = "...")]and#[debug_visualizer(gdb_script_file = "...")], which allows embedding Natviz descriptions and GDB scripts into Rust libraries to improve debugger output when inspecting data structures created by those libraries. Rust itself has packaged similar scripts for some time for the standard library, but this feature makes it possible for library authors to provide a similar experience to end users.
Reference docs for this functionality is also available.
If anyone has time to look into providing embedded pretty printers for nalgebra, that would be much appreciated!