aboutsummaryrefslogtreecommitdiff
path: root/gdb/gdbtypes.c
diff options
context:
space:
mode:
authorPierre-Marie de Rodat <derodat@adacore.com>2015-04-27 11:06:07 +0200
committerPierre-Marie de Rodat <derodat@adacore.com>2015-04-27 11:06:07 +0200
commit9e19566105546654ab24b2b58c890fd7e2b9e00c (patch)
tree91a95f3e63a840d9139194b0dc597fd5ce39d3e0 /gdb/gdbtypes.c
parent460efde16c5ce834f03d1a7525e453b508cb43da (diff)
downloadfsf-binutils-gdb-9e19566105546654ab24b2b58c890fd7e2b9e00c.zip
fsf-binutils-gdb-9e19566105546654ab24b2b58c890fd7e2b9e00c.tar.gz
fsf-binutils-gdb-9e19566105546654ab24b2b58c890fd7e2b9e00c.tar.bz2
[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.
Diffstat (limited to 'gdb/gdbtypes.c')
-rw-r--r--gdb/gdbtypes.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index 103b4e2..b2e1177 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -2013,6 +2013,10 @@ resolve_dynamic_struct (struct type *type,
TYPE_LENGTH (resolved_type)
= (resolved_type_bit_length + TARGET_CHAR_BIT - 1) / TARGET_CHAR_BIT;
+ /* The Ada language uses this field as a cache for static fixed types: reset
+ it as RESOLVED_TYPE must have its own static fixed type. */
+ TYPE_TARGET_TYPE (resolved_type) = NULL;
+
return resolved_type;
}