-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rust-lldb: add a pretty printer for &mut slices #30232
Comments
Seems like it should be easy to fix: rust/src/etc/debugger_pretty_printers_common.py Lines 142 to 145 in aad4e56
|
Is this still an issue? |
Yes; #30249 was closed without merging the changes. |
Does this issue appear for gdb as well? If yes, then I can try to fix it, since I have a linux machine. EDIT: I looked at the closed PR, and noticed that a test was failing on a Mac. Hmm....so maybe this one isn't for me then:expressionless: |
@cynicaldevil actually, this failure is due to an issue in the common code (debugger_pretty_printers_common.py), where it classifies things as TYPE_CODE_SLICE. So the bug should appear in gdb as well. I'm right now using gdb on a mac in an esoteric setup so I haven't gotten rust-gdb working again and can't verify, but you can try it out and try to fix it :) |
@tromey What is your opinion on slice pretty-printing? Right now in gdb we don't pretty-print slices much, but we could. However, without indexing support hiding the data pointer can be counterproductive in case it is a slice of complicated structs. The same goes for Vec and String -- should we encode knowledge of the internals in GDB itself and handle both pretty printing and indexing? Or leave pretty printing up to Rust's pretty printers? Right now in general there is significant overlap between what rust-gdb does and what trunk gdb does; I'm wondering if the goal is to eliminate rust-gdb pretty printing entirely; and perhaps package convenience functions like |
(Willing to help anyone who wants to work on this) |
@Manishearth oh that's good. I am willing to try my hand at this then. |
First check that this is indeed a bug in gdb; I haven't yet checked locally 😄 . I'm just guessing by looking at the code. |
I confirmed that the bug is present in gdb as well, here's the output:
Also, the pretty-print output of
Doesn't seem like this is the desired output. Also, I noticed that the lldb output mentions |
Does it pretty-print an |
Make sure you (GDB trunk does print the type name, btw) |
damn, I used the normal gdb. I read some 'debugging rust' tutorials and they didn't mention anything about this. I will try it out using the rustc version then. |
(btw, feel free to ping me on #rust-tools (or any other Rust IRC channel) for a more realtime discussion) |
My view has been that types that are part of the language should be handled directly by gdb, while types from a library should be handled by pretty-printers; with It wasn't clear to me how gdb ought to print slices, so I left that alone. It's easy to change this; if you can tell me what it should do, I can implement it. Slice indexing ought to work already. So, given this approach, there's still a useful role for
|
Just like an array, really, prefixed by
Not sure what you mean here? Why do we need to look for rustc?
Well, two more:
It seems like logically Vec/String handling should go in rust-gdb, since rust-gdb evolves with the stdlib (unlike gdb, which evolves independently). I do not like having rust-gdb continue existing; but I guess having a tiny rust-gdb with handling for string/vec and My main concern was indexing, but if you think it's possible to expose enough info to gdb python for this to work, I guess that's okay too. |
We shouldn't close this, once #34550 lands we need a test for lldb too |
Added a pretty printer for &mut slices Fixes #30232 I have added a test which checks for correctness in gdb, but I need some help to do the same for lldb. r? @Manishearth
Pretty printer for
&mut
slices doesn't work.I tried this code:
In rust-lldb
p a
should print:Instead, it prints:
Meta
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: