Support ptype/o in Rust

This adds support for ptype/o to the Rust language code.

By default, the Rust compiler reorders fields to reduce padding.  So,
the Rust language code sorts the fields by offset before printing.
This may yield somewhat odd-looking results, but it is faithful to
"what really happens", and might be useful when doing lower-level
debugging.

The reordering can be disabled using #[repr(c)]; ptype/o might be more
useful in this case.

gdb/ChangeLog
2018-06-26  Tom Tromey  <tom@tromey.com>

	PR rust/22574:
	* typeprint.c (whatis_exp): Allow ptype/o for Rust.
	* rust-lang.c (rust_print_struct_def): Add podata parameter.
	Update.
	(rust_internal_print_type): Add podata parameter.
	(rust_print_type): Update.

gdb/testsuite/ChangeLog
2018-06-26  Tom Tromey  <tom@tromey.com>

	PR rust/22574:
	* gdb.rust/simple.exp (test_one_slice): Add ptype/o tests.
	* gdb.rust/simple.rs (struct SimpleLayout): New.
This commit is contained in:
Tom Tromey
2018-06-08 13:18:25 -06:00
parent e0c547d14a
commit a33ccfc7af
6 changed files with 106 additions and 20 deletions

View File

@ -490,7 +490,8 @@ whatis_exp (const char *exp, int show)
feature. */
if (show > 0
&& (current_language->la_language == language_c
|| current_language->la_language == language_cplus))
|| current_language->la_language == language_cplus
|| current_language->la_language == language_rust))
{
flags.print_offsets = 1;
flags.print_typedefs = 0;