forked from Imagelibrary/binutils-gdb
fort_dyn_array: Enable dynamic member types inside a structure.
Fortran supports dynamic types for which bounds, size and location can vary during their lifetime. As a result of the dynamic behaviour, they have to be resolved at every query. This patch will resolve the type of a structure field when it is dynamic. 2016-04-26 Bernhard Heckel <bernhard.heckel@intel.com> 2016-04-26 Keven Boell <keven.boell@intel.com> Before: (gdb) print threev%ivla(1) Cannot access memory at address 0x3 (gdb) print threev%ivla(5) no such vector element After: (gdb) print threev%ivla(1) $9 = 1 (gdb) print threev%ivla(5) $10 = 42 gdb/Changelog: * NEWS: Add new supported features for fortran. * gdbtypes.c (remove_dyn_prop): New. (resolve_dynamic_struct): Keep type length for fortran structs. * gdbtypes.h: Forward declaration of new function. * value.c (value_address): Return dynamic resolved location of a value. (set_value_component_location): Adjust the value address for single value prints. (value_primitive_field): Support value types with a dynamic location. (set_internalvar): Remove dynamic location property of internal variables. gdb/testsuite/Changelog: * gdb.fortran/vla-type.f90: New file. * gdb.fortran/vla-type.exp: New file.
This commit is contained in:
@@ -2064,7 +2064,9 @@ resolve_dynamic_struct (struct type *type,
|
||||
|
||||
pinfo.type = check_typedef (TYPE_FIELD_TYPE (type, i));
|
||||
pinfo.valaddr = addr_stack->valaddr;
|
||||
pinfo.addr = addr_stack->addr;
|
||||
pinfo.addr
|
||||
= (addr_stack->addr
|
||||
+ (TYPE_FIELD_BITPOS (resolved_type, i) / TARGET_CHAR_BIT));
|
||||
pinfo.next = addr_stack;
|
||||
|
||||
TYPE_FIELD_TYPE (resolved_type, i)
|
||||
@@ -2090,8 +2092,13 @@ resolve_dynamic_struct (struct type *type,
|
||||
resolved_type_bit_length = new_bit_length;
|
||||
}
|
||||
|
||||
TYPE_LENGTH (resolved_type)
|
||||
= (resolved_type_bit_length + TARGET_CHAR_BIT - 1) / TARGET_CHAR_BIT;
|
||||
/* The length of a type won't change for fortran, but it does for C and Ada.
|
||||
For fortran the size of dynamic fields might change over time but not the
|
||||
type length of the structure. If we adapt it, we run into problems
|
||||
when calculating the element offset for arrays of structs. */
|
||||
if (current_language->la_language != language_fortran)
|
||||
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. */
|
||||
@@ -2224,6 +2231,37 @@ add_dyn_prop (enum dynamic_prop_node_kind prop_kind, struct dynamic_prop prop,
|
||||
TYPE_DYN_PROP_LIST (type) = temp;
|
||||
}
|
||||
|
||||
/* Remove dynamic property from TYPE in case it exists. */
|
||||
|
||||
void
|
||||
remove_dyn_prop (enum dynamic_prop_node_kind prop_kind,
|
||||
struct type *type)
|
||||
{
|
||||
struct dynamic_prop_list *prev_node, *curr_node;
|
||||
|
||||
curr_node = TYPE_DYN_PROP_LIST (type);
|
||||
prev_node = NULL;
|
||||
|
||||
while (NULL != curr_node)
|
||||
{
|
||||
if (curr_node->prop_kind == prop_kind)
|
||||
{
|
||||
/* Update the linked list but don't free anything.
|
||||
The property was allocated on objstack and it is not known
|
||||
if we are on top of it. Nevertheless, everything is released
|
||||
when the complete objstack is freed. */
|
||||
if (NULL == prev_node)
|
||||
TYPE_DYN_PROP_LIST (type) = curr_node->next;
|
||||
else
|
||||
prev_node->next = curr_node->next;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
prev_node = curr_node;
|
||||
curr_node = curr_node->next;
|
||||
}
|
||||
}
|
||||
|
||||
/* Find the real type of TYPE. This function returns the real type,
|
||||
after removing all layers of typedefs, and completing opaque or stub
|
||||
|
||||
Reference in New Issue
Block a user