Created attachment 15423 [details] Error logs Hi there, Recently, I tried building and running Rust 1.76 testsuites on my device, and I encountered a slew of errors when the test runner started to run GDB-related tests. The errors were like this: (see the log file attached). I remember those tests passing before, so I did some digging on GDB, and I found this commit: https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=b0dd661fa16a424f059b1e1d80e779508b1a9a12 that caused this kind of error. I am unsure if this new behaviour is intentional. If it is, how should someone print out the size of a Rust slice in this case? I have also opened a bug report on the Rust upstream: https://github.com/rust-lang/rust/issues/122751, in case GDB cannot do anything to fix this situation (so that Rust upstream can fix their tests instead). Thanks!
If you don't want to run all the tests, you may just check this one: https://raw.githubusercontent.com/rust-lang/rust/e3df96cfda905301fc8514e000f942222c1ab6ad/tests/debuginfo/vec-slices.rs
checked with trunk 20240312 and 20240320
The gdb change was intentional. See bug #30330. There's also a follow-up patch that will land before gdb 15: https://sourceware.org/pipermail/gdb-patches/2024-March/207190.html This patch slightly changes the output in some cases. In fact... let's use this bug to track that patch, to make sure it really does land for 15. > If it is, how should someone print out the size of a Rust slice in this case? I built vec-slices.rs and ran it under a gdb with the patch applied: (gdb) info local mut_slice = &mut [i64] [1, 2, 3, 4, 5] padded_struct = &[vec_slices::AStruct] [ vec_slices::AStruct {x: 10, y: 11, z: 12}, vec_slices::AStruct {x: 13, y: 14, z: 15}] padded_tuple = &[(i32, i16)] [(6, 7), (8, 9)] slice_of_slice = &[i64] [3, 4] multiple = &[i64] [2, 3, 4, 5] singleton = &[i64] [1] empty = &[i64] []
> I built vec-slices.rs and ran it under a gdb with the patch > applied: Thanks for the information! Although I am curious about how to print the length of a slice like using `print slice.length` before? I have also built a GDB with the patch applied; the auto-completion in the interactive mode still completes `.length` in this case: (gdb) p multiple. data_ptr length Is this expected?
(In reply to liushuyu from comment #4) > Although I am curious about how to print the length of a slice like using > `print slice.length` before? You can't, not directly anyway. In Rust you use len() but the Rust compiler doesn't emit enough information for gdb to do calls via traits. > I have also built a GDB with the patch applied; the auto-completion in the > interactive mode still completes `.length` in this case: > > (gdb) p multiple. > data_ptr length > > Is this expected? No, this should have a separate report. The completer still sees the underlying C-like type.
Hello, From what I could understand, Tom is saying that there is no issue in GDB, and so we should be able to close this PR?
I want to land the patch mentioned in comment#3 first.
The master branch has been updated by Tom Tromey <tromey@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=251cedaeb57fe1e0fd28798f476fbee75373bbf4 commit 251cedaeb57fe1e0fd28798f476fbee75373bbf4 Author: Tom Tromey <tromey@adacore.com> Date: Thu Mar 7 12:57:07 2024 -0700 Print type name when printing Rust slice The recent change to how unsized Rust values are printed included a small regression from past behavior. Previously, a slice's type would be printed, like: (gdb) print slice $80 = &[i32] [3] The patch changed this to just (gdb) print slice $80 = [3] This patch restores the previous behavior. Reviewed-By: Simon Marchi <simon.marchi@efficios.com> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30330 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31517
I am going to close this now.