DWARF: add a language hook to override types in debugging information
authorpmderodat <pmderodat@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 17 Dec 2015 14:09:45 +0000 (14:09 +0000)
committerpmderodat <pmderodat@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 17 Dec 2015 14:09:45 +0000 (14:09 +0000)
commitdb3c183a4446aaf27626517ed6ba6042e233a3f1
tree1954e1f36ee22fe1453b3126d1e77a2db664d746
parentb20f41dd0c51e02bbe209ecf87ed37722984b673
DWARF: add a language hook to override types in debugging information

Many artificial types are introduced by GNAT in order to satisfy
constraints in GCC's internal trees or to generate optimal code.  These
hide original types from sources and miss useful information in the
debugging information or add noise to it and make debugging confusing.
This change introduces a new language hook to give a chance to
front-ends to restore the source types in the debugging information.

This change also enhance the array descriptor language hook to handle
array-wide bit/byte stride.  Some arrays may contain dynamically-sized
objects.  Debuggers need for these a hint to know the size allocated for
each element, hence the need for the array-wide bit/byte stride.

The Ada front-end is enhanced to take advantage of both hooks when
-fgnat-encodings=minimal, in order to keep compatibility with GDB.

gcc/ada/ChangeLog:

* gcc-interface/ada-tree.h (struct lang_type): Rename the t
field as t1 and add a t2 one.
(get_lang_specific): New.
(GET_TYPE_LANG_SPECIFIC): Refactor to use get_lang_specific.
(SET_TYPE_LANG_SPECIFIC): Likewise.
(GET_TYPE_LANG_SPECIFIC2): New macro.
(SET_TYPE_LANG_SPECIFIC2): New macro.
(TYPE_DEBUG_TYPE): New macro.
(SET_TYPE_DEBUG_TYPE): New macro.
* gcc-interface/decl.c (gnat_to_gnu_entity): When
-fgnat-encodings=minimal, set padding types' debug type to the
padded one (i.e. strip ___PAD GNAT encodings) and set
constrained record subtypes's debug type to the base type.
* gcc-interface/misc.c (gnat_print_type): Print debug types.
(gnat_get_debug_type): New.
(gnat_get_array_descr_info): When -fgnat-encodings=minimal, set
a byte stride for arrays that contain a type whose debug type
has variable length.
(LANG_HOOKS_GET_DEBUG_TYPE): Redefine macro to implement the
debug type language hook.
* gcc-interface/utils.c (maybe_pad_type): When
-fgnat-encodings=minimal, set padding types' debug type to the
padded one.  Restore XVZ variables creation when
-fgnat-encodings-minimal and use them to hold padding types'
byte size.  For library-level padding types, share this variable
across translation units.  Tag XVZ variables as artificial.

gcc/ChangeLog:

* langhooks.h (struct lang_hooks_for_types): Add a
get_debug_type field.
* langhooks-def.h (LANG_HOOKS_GET_DEBUG_TYPE): New macro.
(LANG_HOOKS_FOR_TYPES_INITIALIZER): Initialize the
get_debug_type field.
* dwarf2out.h (struct array_descr_info): Add an array-wide
stride field.
* dwarf2out.c (modified_type_die): Invoke the get_debug_type
language hook, process its result instead, if any.
(gen_descr_array_type_die): Add array-wide stride processing.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@231763 138bc75d-0d04-0410-961f-82ee72b054a4
gcc/ChangeLog
gcc/ada/ChangeLog
gcc/ada/gcc-interface/ada-tree.h
gcc/ada/gcc-interface/decl.c
gcc/ada/gcc-interface/misc.c
gcc/ada/gcc-interface/utils.c
gcc/dwarf2out.c
gcc/dwarf2out.h
gcc/langhooks-def.h
gcc/langhooks.h