Fix Python pretty-printing bug in Rust

An upstream Rust bug notes notes that the Python pretty-printing
feature is broken for values that appear as members of certain types
in Rust.

The bug here is that some of the Rust value-printing code calls
value_print_inner, a method on rust_language.  This bypasses the
common code that calls into Python.

I'm checking this in.

gdb/ChangeLog
2021-05-14  Tom Tromey  <tom@tromey.com>

	* rust-lang.c (rust_language::val_print_struct)
	(rust_language::print_enum): Use common_val_print, not
	value_print_inner.

gdb/testsuite/ChangeLog
2021-05-14  Tom Tromey  <tom@tromey.com>

	* gdb.rust/pp.exp: New file.
	* gdb.rust/pp.py: New file.
	* gdb.rust/pp.rs: New file.
This commit is contained in:
Tom Tromey 2021-05-14 19:54:35 -06:00
parent 2fbe9507bf
commit 887e71588b
6 changed files with 133 additions and 2 deletions

View file

@ -386,7 +386,8 @@ rust_language::val_print_struct
fputs_filtered (": ", stream);
}
value_print_inner (value_field (val, i), stream, recurse + 1, &opts);
common_val_print (value_field (val, i), stream, recurse + 1, &opts,
this);
}
if (options->prettyformat)
@ -464,7 +465,8 @@ rust_language::print_enum (struct value *val, struct ui_file *stream,
styled_string (variable_name_style.style (),
TYPE_FIELD_NAME (variant_type, j)));
value_print_inner (value_field (val, j), stream, recurse + 1, &opts);
common_val_print (value_field (val, j), stream, recurse + 1, &opts,
this);
}
if (is_tuple)