-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Fix GDB pretty-printer for tuples and pointers #42278
Conversation
Names of children should not be the same, because GDB uses them to distinguish the children.
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @alexcrichton (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
Thanks for the PR! We’ll periodically check in on it to make sure that @alexcrichton or someone else from the team reviews it soon. |
Some pointers values include additional info, so they can't be parsed with int().
8de9edb
to
167e4b0
Compare
( knows more about debuginfo and pretty printers than I ) This looks great though! |
…ters str() can't handle unicode strings
|
Thanks a lot for the PR, @gentoo90! I would be great if you could add test cases to the |
Hi @michaelwoerister, is there any way to run a single test using the nightly binary build from |
You could try |
Most of the tests are |
You should not need LLDB for the GDB based tests. I assume this is on Linux? What's the GDB version you are using? |
Yes, gentoo linux, gdb 7.12 |
I've found another issue while trying to debug But if I remove |
I just tested with GDB 7.12 on Ubuntu and tests are not ignored for me. If you remove all
Would you mind opening an issue about that? |
A proper way to test tuple field names would be // gdbr-command:interpreter-exec mi2 "-enable-pretty-printing"
// gdbr-check:^done
// gdbr-command:interpreter-exec mi2 "-var-create noPadding8 @ noPadding8"
// gdbr-check:^done,name="noPadding8",numchild="2",value="{...}",type="(i8, u8)",thread-id="1",has_more="0"
// gdbr-command:interpreter-exec mi2 "-var-list-children noPadding8"
// gdbr-check:^done,numchild="2",displayhint="array",children=[child={name="noPadding8.0",exp="0",numchild="0",value="-100",type="i8",thread-id="1"},child={name="noPadding8.1",exp="1",numchild="0",value="100",type="u8",thread-id="1"}],has_more="0" but |
Use a class without children() method for printing empty structs. Presence of this method makes GDB's variable objects interface act like if the struct had children.
Added separate pretty-printer for empty structs, which prints the struct type instead of
Testing against variable objects is impossible again without |
src/test/debuginfo/pretty-std.rs
Outdated
@@ -38,6 +38,9 @@ | |||
// gdbg-check:$6 = None | |||
// gdbr-check:$6 = core::option::Option::None | |||
|
|||
// gdb-command: print some_string | |||
// gdbr-check:$7 = Some = {"IAMA optional string!"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should try making this gdb-check
instead of just gdbr-check
, so both kinds of GDB are tested.
Ping @gentoo90, regarding #42278 (comment). Could you make these regular |
GDB can be built with Python 2 or with Python 3
Sorry for delay.
ahh, so that's why |
No worries. Thanks for continuing to work on this!
Yes, that seems like a likely reason. I'm actually not sure what version of GDB is on our test infrastructure. |
@bors r+ Let's give it a try. |
📌 Commit 63076dd has been approved by |
Fix GDB pretty-printer for tuples and pointers Names of children should not be the same, because GDB uses them to distinguish the children. |Before|After| |---|---| |![tuples_before](https://cloud.githubusercontent.com/assets/1297574/26527639/5d6cf10e-43a0-11e7-9498-abfcddb08055.png)|![tuples_after](https://cloud.githubusercontent.com/assets/1297574/26527655/9699233a-43a0-11e7-83c6-f58f713b51a0.png)| `main.rs` ```rust enum Test { Zero, One(i32), Two(i32, String), Three(i32, String, Vec<String>), } fn main() { let tuple = (1, 2, "Asdfgh"); let zero = Test::Zero; let one = Test::One(10); let two = Test::Two(42, "Qwerty".to_owned()); let three = Test::Three(9000, "Zxcvbn".to_owned(), vec!["lorem".to_owned(), "ipsum".to_owned(), "dolor".to_owned()]); println!(""); // breakpoint here } ``` `launch.json` ```json { "version": "0.2.0", "configurations": [ { "type": "gdb", "request": "launch", "gdbpath": "rust-gdb", "name": "Launch Program", "valuesFormatting": "prettyPrinters", //this requires plugin Native Debug >= 0.20.0 "target": "./target/debug/test_pretty_printers", "cwd": "${workspaceRoot}" } ] } ```
☀️ Test successful - status-appveyor, status-travis |
🎉 |
Names of children should not be the same, because GDB uses them to distinguish the children.
main.rs
launch.json