aboutsummaryrefslogtreecommitdiff
path: root/gdb/rust-lang.c
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2020-02-22 10:02:42 -0700
committerTom Tromey <tom@tromey.com>2020-02-22 10:12:52 -0700
commit3f0cbb04d0fbb0923f2972efa95a4c767592860b (patch)
tree2cb2b5e19021553e6ba40a7497e30f39f45fa6d0 /gdb/rust-lang.c
parent7b3c27152b5695177a2cd5adc0d7b0255f99aca0 (diff)
downloadgdb-3f0cbb04d0fbb0923f2972efa95a4c767592860b.zip
gdb-3f0cbb04d0fbb0923f2972efa95a4c767592860b.tar.gz
gdb-3f0cbb04d0fbb0923f2972efa95a4c767592860b.tar.bz2
Style field names in "print"
This changes gdb to use the "variable" style when printing field names. I've added new tests for C and Rust, but not other languages. I chose "variable" because that seemed most straightforward. However, another option would be to introduce a new "field" style. Similarly, this patch uses the variable style for enumerator constants -- but again, a new style could be used if that's preferred. gdb/ChangeLog 2020-02-22 Tom Tromey <tom@tromey.com> * valprint.c (generic_val_print_enum_1) (val_print_type_code_flags): Style member names. * rust-lang.c (val_print_struct, rust_print_enum) (rust_print_struct_def, rust_internal_print_type): Style member names. * p-valprint.c (pascal_object_print_value_fields): Style member names. Only call fprintf_symbol_filtered for static members. * m2-typeprint.c (m2_record_fields, m2_enum): Style member names. * f-valprint.c (f_val_print): Style member names. * f-typeprint.c (f_type_print_base): Style member names. * cp-valprint.c (cp_print_value_fields): Style member names. Only call fprintf_symbol_filtered for static members. (cp_print_class_member): Style member names. * c-typeprint.c (c_print_type_1, c_type_print_base_1): Style member names. * ada-valprint.c (ada_print_scalar): Style enum names. (ada_val_print_enum): Likewise. * ada-typeprint.c (print_enum_type): Style enum names. gdb/testsuite/ChangeLog 2020-02-22 Tom Tromey <tom@tromey.com> * gdb.rust/rust-style.rs: New file. * gdb.rust/rust-style.exp: New file. * gdb.base/style.exp: Test structure printing. * gdb.base/style.c (struct some_struct): New type. (enum etype): New type. (struct_value): New global. Change-Id: I070e1293c6cc830c9ea916af8243410aa384e944
Diffstat (limited to 'gdb/rust-lang.c')
-rw-r--r--gdb/rust-lang.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c
index 18dc6a5..fc48e34 100644
--- a/gdb/rust-lang.c
+++ b/gdb/rust-lang.c
@@ -436,7 +436,8 @@ val_print_struct (struct type *type, int embedded_offset,
if (!is_tuple && !is_tuple_struct)
{
- fputs_filtered (TYPE_FIELD_NAME (type, i), stream);
+ fputs_styled (TYPE_FIELD_NAME (type, i),
+ variable_name_style.style (), stream);
fputs_filtered (": ", stream);
}
@@ -515,8 +516,9 @@ rust_print_enum (struct type *type, int embedded_offset,
first_field = false;
if (!is_tuple)
- fprintf_filtered (stream, "%s: ",
- TYPE_FIELD_NAME (variant_type, j));
+ fprintf_filtered (stream, "%ps: ",
+ styled_string (variable_name_style.style (),
+ TYPE_FIELD_NAME (variant_type, j)));
val_print (TYPE_FIELD_TYPE (variant_type, j),
(embedded_offset
@@ -792,9 +794,12 @@ rust_print_struct_def (struct type *type, const char *varstring,
if (!for_rust_enum || flags->print_offsets)
print_spaces_filtered (level + 2, stream);
if (is_enum)
- fputs_filtered (TYPE_FIELD_NAME (type, i), stream);
+ fputs_styled (TYPE_FIELD_NAME (type, i), variable_name_style.style (),
+ stream);
else if (!is_tuple_struct)
- fprintf_filtered (stream, "%s: ", TYPE_FIELD_NAME (type, i));
+ fprintf_filtered (stream, "%ps: ",
+ styled_string (variable_name_style.style (),
+ TYPE_FIELD_NAME (type, i)));
rust_internal_print_type (TYPE_FIELD_TYPE (type, i), NULL,
stream, (is_enum ? show : show - 1),
@@ -943,7 +948,9 @@ rust_internal_print_type (struct type *type, const char *varstring,
&& name[len] == ':'
&& name[len + 1] == ':')
name += len + 2;
- fprintfi_filtered (level + 2, stream, "%s,\n", name);
+ fprintfi_filtered (level + 2, stream, "%ps,\n",
+ styled_string (variable_name_style.style (),
+ name));
}
fputs_filtered ("}", stream);