+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.
+
2020-04-06 Tom Tromey <tromey@adacore.com>
* sh-nbsd-tdep.c: Include nbsd-tdep.h.
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);
}
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;
+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.
+
2020-04-03 Hannes Domani <ssbssa@yahoo.de>
PR gdb/25325
--- /dev/null
+# Copyright 2020 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+load_lib "ada.exp"
+
+standard_ada_testfile proc
+
+if {[gdb_compile_ada "${srcfile}" "${binfile}" executable debug] != ""} {
+ return -1
+}
+
+clean_restart ${testfile}
+
+set bp_location [gdb_get_line_number "STOP" ${testdir}/proc.adb]
+runto "proc.adb:$bp_location"
+
+gdb_test "print Value.Name(My_Value)" \
+ "= \\(well => yes, name => \"abcdefgh\"\\)"
--- /dev/null
+-- Copyright 2020 Free Software Foundation, Inc.
+--
+-- This program is free software; you can redistribute it and/or modify
+-- it under the terms of the GNU General Public License as published by
+-- the Free Software Foundation; either version 3 of the License, or
+-- (at your option) any later version.
+--
+-- This program is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+-- GNU General Public License for more details.
+--
+-- You should have received a copy of the GNU General Public License
+-- along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+with Value;
+procedure Proc is
+ My_Value : Value.T := Value.Create;
+begin
+ null; -- STOP
+end;
--- /dev/null
+-- Copyright 2020 Free Software Foundation, Inc.
+--
+-- This program is free software; you can redistribute it and/or modify
+-- it under the terms of the GNU General Public License as published by
+-- the Free Software Foundation; either version 3 of the License, or
+-- (at your option) any later version.
+--
+-- This program is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+-- GNU General Public License for more details.
+--
+-- You should have received a copy of the GNU General Public License
+-- along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+package body Value is
+ function Create return T is
+ begin
+ return (One => (Well => Value_Name.No,
+ Unique_Name => (X1 => 1, X2 => 2)),
+ Two => (Well => Value_Name.Yes,
+ Name => "abcdefgh"));
+ end Create;
+
+ function Name (Of_Value : T) return Value_Name.T is
+ begin
+ return Of_Value.Two;
+ end Name;
+
+end Value;
--- /dev/null
+-- Copyright 2020 Free Software Foundation, Inc.
+--
+-- This program is free software; you can redistribute it and/or modify
+-- it under the terms of the GNU General Public License as published by
+-- the Free Software Foundation; either version 3 of the License, or
+-- (at your option) any later version.
+--
+-- This program is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+-- GNU General Public License for more details.
+--
+-- You should have received a copy of the GNU General Public License
+-- along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+package Value is
+ package Value_Name is
+ Length : constant Positive := 8;
+ subtype Name_T is String (1 .. Length);
+
+ type A_Record_T is
+ record
+ X1 : Natural;
+ X2 : Natural;
+ end record;
+
+ type Yes_No_T is (Yes, No);
+ type T (Well : Yes_No_T := Yes) is
+ record
+ case Well is
+ when Yes =>
+ Name : Name_T;
+ when No =>
+ Unique_Name : A_Record_T;
+ end case;
+ end record;
+ end;
+
+ type T is private;
+ function Create return T;
+ function Name (Of_Value : T) return Value_Name.T;
+private
+ type T is
+ record
+ One : Value_Name.T (Well => Value_Name.No);
+ Two : Value_Name.T (Well => Value_Name.Yes);
+ end record;
+end;