Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upConsider having special debugger pretty printers/handling for Unique/Shared/NonZero #29392
Comments
huonw
added
the
A-debuginfo
label
Oct 27, 2015
This comment has been minimized.
This comment has been minimized.
|
Filtering out NonZero and Unique in the pretty printers should be doable I think. We already have special handling for Vec<> and String, for example. Changing how GDB parses and evaluates expressions is a different thing though. There may be some way to make this work, but doing it cleanly involves going into GDB's rather messy C internals, as far as I know. As a side note: It seems that LLDB is starting to support language plugins. A real Rust plugin would make it possible to support all of the above and a lot more |
This comment has been minimized.
This comment has been minimized.
|
OK, unfortunately this turns out to be way harder to do in GDB than expected. Due to how GDB's pretty printing API is structured, it's not possible filter out intermediate data structure nesting levels (like a NonZero field) without this level still leaving some kind of artifact in the rendered string:
At least the above is the best thing I managed and I tried various different approaches. The only way to get arround this problem is to have pretty printers for every type, even primitive ones. But then one loses the ability to influence how these are printed. E.g. one can't force integers to be printed as hexadecimals anymore, as can be done with |
brson
added
I-wishlist
P-low
labels
Apr 4, 2017
This comment has been minimized.
This comment has been minimized.
|
I looked at this today. Upstream output is more or less the same, just more clear that pointer points to a tuple.
Dereferencing still needs a lot of typing, but it's now Rust syntax at least:
For |
huonw commentedOct 27, 2015
A debugger is particularly useful for diagnosing problems in unsafe code, and these types appear reasonably often there. Currently they're printed in a rather ugly way:
Compiling with
rustc -g unique.rsand usingrust-gdb uniqueto break on thedrop(f)line allows one to printf:Pretty much the only thing that's even slightly interesting there is the
0x7fffffffdef8and maybe theunique::Bar, the layers ofNonZeroandPhantomDataare just noise. (And even the raw address is pretty useless, and the type is often obvious from context.)Also, the only way to examine what the pointer points to is to do a pile of field accesses, like:
In the best case, it'd be great if
*f.ptrcould work. (Also,f.ptr.pointer.__0[x]being writtenf.ptr[x], for when theUniqueis representing an array.)(I guess there may be other standard library types to consider in a similar context: making
rust-gdbhandle them even more nicely.)