Skip to content
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

Added a pretty printer for &mut slices #34550

Merged
merged 1 commit into from
Jul 4, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/etc/debugger_pretty_printers_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def __classify_struct(self):
return TYPE_KIND_STR_SLICE

# REGULAR SLICE
if (unqualified_type_name.startswith("&[") and
if (unqualified_type_name.startswith(("&[", "&mut [")) and
unqualified_type_name.endswith("]") and
self.__conforms_to_field_layout(SLICE_FIELD_NAMES)):
return TYPE_KIND_SLICE
Expand Down
7 changes: 7 additions & 0 deletions src/test/debuginfo/vec-slices.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@
// gdb-command:print *((int64_t[2]*)('vec_slices::MUT_VECT_SLICE'.data_ptr))
// gdb-check:$15 = {64, 65}

//gdb-command:print mut_slice.length
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, these tests are unnecessary, we just need a test that verifies that printing mut_slice gives properly formatted results.

Copy link
Contributor Author

@nikhilshagri nikhilshagri Jul 3, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But that is done in the second test, right? I looked at the buildbot logs and noticed that's exactly where the build was failing:


---- [debuginfo-gdb] debuginfo-gdb/vec-slices.rs stdout ----

error: line not found in debugger output: $17 = {1, 2, 3, 4, 5}
status: exit code: 0
command: arm-linux-androideabi-gdb -quiet -batch -nx -command=x86_64-unknown-linux-gnu/test/debuginfo-gdb/vec-slices.debugger.script
stdout:
------------------------------------------

Edit:
Also, the output in stderr:

x86_64-unknown-linux-gnu/test/debuginfo-gdb/vec-slices.debugger.script:24: Error in sourced command file:
No symbol "int32_t" in current context.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The second one casts it to an array and tries to print it. That relies on the C pretty printer, not ten Rust one. print slice and print mut_slice should be what we are testing. I don't see the value in the array-cast test for mut slices.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

print mut_slice just shows the data pointer and the array's length. I looked at the pretty-printer's code as well, but I couldn't understand much :P

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, that's what we've been trying to fix here 😄 print mut_slice should show an array, just like print slice

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, these tests aren't run with rust-gdb, it would appear as if rust-gdb doesn't have tests. So remove the test changes and we can land this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the error is occurring due to absence of int32_t, maybe I could change the type to i64, since previous examples have used it, and obviously they have passed all the tests/builds. what do you think?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, that works

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed it.

//gdb-check:$16 = 5
//gdb-command:print *((int64_t[5]*)(mut_slice.data_ptr))
//gdb-check:$17 = {1, 2, 3, 4, 5}


// === LLDB TESTS ==================================================================================

Expand Down Expand Up @@ -106,6 +111,8 @@ fn main() {
MUT_VECT_SLICE = VECT_SLICE;
}

let mut_slice: &mut [i64] = &mut [1, 2, 3, 4, 5];

zzz(); // #break
}

Expand Down