aboutsummaryrefslogtreecommitdiff
path: root/gdb/ada-valprint.c
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2020-04-06 12:59:57 -0600
committerTom Tromey <tromey@adacore.com>2020-04-06 12:59:57 -0600
commit6ee448cc2d0b9337713ecb6bb2e6305b4f504cbc (patch)
treebc6c280d5cb3ad650f3c93b7a5c2455cf66583c7 /gdb/ada-valprint.c
parentdea34e8cc336a80546dac21463583a76e3e5d473 (diff)
downloadgdb-6ee448cc2d0b9337713ecb6bb2e6305b4f504cbc.zip
gdb-6ee448cc2d0b9337713ecb6bb2e6305b4f504cbc.tar.gz
gdb-6ee448cc2d0b9337713ecb6bb2e6305b4f504cbc.tar.bz2
Select variant field when printing variant
When I updated the Ada variant-printing code to be value-based, I neglected a couple of issues. First, print_variant_part must first extract the variant field before finding the active component; second, print_field_values should pass in the field value as the outer value when recursing. This patch fixes both of these issues. gdb/ChangeLog 2020-04-06 Tom Tromey <tromey@adacore.com> * ada-valprint.c (print_variant_part): Extract the variant field. (print_field_values): Use the field as the outer value when recursing. gdb/testsuite/ChangeLog 2020-04-06 Tom Tromey <tromey@adacore.com> * gdb.ada/variant-record/proc.adb: New file. * gdb.ada/variant-record/value.adb: New file. * gdb.ada/variant-record/value.s: New file. * gdb.ada/variant-record.exp: New file.
Diffstat (limited to 'gdb/ada-valprint.c')
-rw-r--r--gdb/ada-valprint.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c
index 2f2375a..2768829 100644
--- a/gdb/ada-valprint.c
+++ b/gdb/ada-valprint.c
@@ -565,7 +565,8 @@ print_variant_part (struct value *value, int field_num,
if (which < 0)
return 0;
- struct value *active_component = value_field (value, which);
+ struct value *variant_field = value_field (value, field_num);
+ struct value *active_component = value_field (variant_field, which);
return print_field_values (active_component, outer_value, stream, recurse,
options, comma_needed, language);
}
@@ -603,8 +604,9 @@ print_field_values (struct value *value, struct value *outer_value,
if (ada_is_wrapper_field (type, i))
{
+ struct value *field_val = value_field (value, i);
comma_needed =
- print_field_values (value_field (value, i), outer_value,
+ print_field_values (field_val, field_val,
stream, recurse, options,
comma_needed, language);
continue;