]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit - gdb/ada-lang.c
[Ada] Cache all static structures and reset cache during resolution
authorPierre-Marie de Rodat <derodat@adacore.com>
Mon, 27 Apr 2015 09:06:07 +0000 (11:06 +0200)
committerPierre-Marie de Rodat <derodat@adacore.com>
Mon, 27 Apr 2015 09:06:07 +0000 (11:06 +0200)
commit9e19566105546654ab24b2b58c890fd7e2b9e00c
tree91a95f3e63a840d9139194b0dc597fd5ce39d3e0
parent460efde16c5ce834f03d1a7525e453b508cb43da
[Ada] Cache all static structures and reset cache during resolution

Currently, ada-lang.c:template_to_static_fixed_type (working on
structure types only) caches its result into the unused TYPE_TARGET_TYPE
field. This introduces inconsistencies when the input type is
specialized, for instance during type resolution: the cached static
fixed type is copied along with the original type, but it's no longer
adapted to the copy once the copy is modified:
template_to_static_fixed_type has to compute another static fixed type
for it.

This change first introduces a cache reset during type resolution for
structure types so that this inconsistency does not happen anymore. It
also makes template_to_static_fixed_type smarter with respect to types
that do not need static fixed copies so that less computations is done
in general.

This inconsistency was spotted thanks to code reading, not because of
any sort of failure and we did not manage to exhibit a failure yet, so
no testcase for this.

gdb/ChangeLog:

* ada-lang.c (template_to_static_fixed_type): Return input type
when it is already fixed. Cache the input type itself when not
creating a static fixed copy. Make it explicit that we never
molestate the input type.
* gdbtypes.c (resolve_dynamic_struct): Reset the
TYPE_TARGET_TYPE field for resolved copies.
gdb/ChangeLog
gdb/ada-lang.c
gdb/gdbtypes.c