+2015-05-15 Jerome Guitton <guitton@adacore.com>
+
+ * ada-lang.c (find_parallel_type_by_descriptive_type):
+ Go through typedefs during lookup.
+ (to_fixed_array_type): Add support for non-bit packed arrays
+ as variable-length fields.
+
2015-05-15 Pedro Alves <palves@redhat.com>
Simon Marchi <simon.marchi@ericsson.com>
static struct type *
find_parallel_type_by_descriptive_type (struct type *type, const char *name)
{
- struct type *result;
+ struct type *result, *tmp;
if (ada_ignore_descriptive_types_p)
return NULL;
/* Otherwise, look at the next item on the list, if any. */
if (HAVE_GNAT_AUX_INFO (result))
- result = TYPE_DESCRIPTIVE_TYPE (result);
+ tmp = TYPE_DESCRIPTIVE_TYPE (result);
else
- result = NULL;
+ tmp = NULL;
+
+ /* If not found either, try after having resolved the typedef. */
+ if (tmp != NULL)
+ result = tmp;
+ else
+ {
+ CHECK_TYPEDEF (result);
+ if (HAVE_GNAT_AUX_INFO (result))
+ result = TYPE_DESCRIPTIVE_TYPE (result);
+ else
+ result = NULL;
+ }
}
/* If we didn't find a match, see whether this is a packed array. With
struct type *index_type_desc;
struct type *result;
int constrained_packed_array_p;
+ static const char *xa_suffix = "___XA";
type0 = ada_check_typedef (type0);
if (TYPE_FIXED_INSTANCE (type0))
if (constrained_packed_array_p)
type0 = decode_constrained_packed_array_type (type0);
- index_type_desc = ada_find_parallel_type (type0, "___XA");
+ index_type_desc = ada_find_parallel_type (type0, xa_suffix);
+
+ /* As mentioned in exp_dbug.ads, for non bit-packed arrays an
+ encoding suffixed with 'P' may still be generated. If so,
+ it should be used to find the XA type. */
+
+ if (index_type_desc == NULL)
+ {
+ const char *typename = ada_type_name (type0);
+
+ if (typename != NULL)
+ {
+ const int len = strlen (typename);
+ char *name = (char *) alloca (len + strlen (xa_suffix));
+
+ if (typename[len - 1] == 'P')
+ {
+ strcpy (name, typename);
+ strcpy (name + len - 1, xa_suffix);
+ index_type_desc = ada_find_parallel_type_with_name (type0, name);
+ }
+ }
+ }
+
ada_fixup_array_indexes_type (index_type_desc);
if (index_type_desc != NULL
&& ada_is_redundant_index_type_desc (type0, index_type_desc))
+2015-05-15 Joel Brobecker <brobecker@adacore.com>
+
+ * gdb.ada/byte_packed_arr: New testcase.
+
2015-05-15 Joel Brobecker <brobecker@adacore.com>
* gdb.ada/pckd_neg: New testcase.
--- /dev/null
+# Copyright 2015 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"
+
+if { [skip_ada_tests] } { return -1 }
+
+standard_ada_testfile reprod_main
+
+if {[gdb_compile_ada "${srcfile}" "${binfile}" executable {debug}] != ""} {
+ return -1
+}
+
+clean_restart ${testfile}
+
+set bp_location [gdb_get_line_number "STOP" ${testdir}/reprod.adb]
+runto "reprod.adb:$bp_location"
+
+gdb_test "print broken" \
+ " = \\(len => 1, data => \\(\\(i => 1\\)\\)\\)"
--- /dev/null
+-- Copyright 2015 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/>.
+
+generic
+ type Index_Base_T is range <>;
+ type Component_T is private;
+package Array_List_G is
+
+ subtype Length_T is Index_Base_T range 0 .. Index_Base_T'Last;
+ subtype Index_T is Length_T range 1 .. Length_T'Last;
+
+ type T is array (Index_T range <>) of Component_T;
+ pragma Pack(T);
+
+end Array_List_G;
--- /dev/null
+-- Copyright 2015 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 Reprod is
+
+ procedure Do_Nothing (Broken : Obj_T) is
+ begin
+ null; -- STOP
+ end Do_Nothing;
+end Reprod;
--- /dev/null
+-- Copyright 2015 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 Array_List_G;
+
+package Reprod is
+
+ package Objects is
+ type T is record
+ I : Integer;
+ end record;
+ package List is new Array_List_G (Index_Base_T => Natural,
+ Component_T => T);
+ end Objects;
+
+ type Obj_T (Len : Natural) is record
+ Data : Objects.List.T (1 .. Len);
+ end record;
+
+ type T is access Obj_T;
+
+ procedure Do_Nothing (Broken : Obj_T);
+end Reprod;
--- /dev/null
+-- Copyright 2015 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 Reprod; use Reprod;
+
+procedure Reprod_Main is
+ O : Obj_T (Len => 1);
+begin
+ O.Data := (others => (I => 1));
+ Do_Nothing (O);
+end Reprod_Main;