vla: add dynamic lower bound support.

This patch creates infrastructure for the Fortran dynamic
array (VLA) support.

2013-10-24  Keven Boell  <keven.boell@intel.com>
            Sanimir Agovic  <sanimir.agovic@intel.com>

	* dwarf2read.c (read_subrange_type): Add storage
	of dwarf block for low bound aligned with high
	bound implementation.

Change-Id: If66f8cd3c2cc1c099cbf4e2d0419a71319f0b7ab
Signed-off-by: Keven Boell <keven.boell@intel.com>
vla: restructure dynamic type detection/resolving.

The purpose of this patch is to restructure the type
detection and resolving for dynamic types as pre-work
for Fortran dynamic array (VLA) support. Moved data
location resolving out of array specific code as it can
be used in Fortran dynamic strings as well.
Added dynamic resolving of values for field types to
support dynamic types in Fortran types/structs.

2013-10-24  Keven Boell  <keven.boell@intel.com>
            Sanimir Agovic  <sanimir.agovic@intel.com>

	* gdbtypes.c (is_dynamic_type): Add type detection
	for fields and follow pointers only in the C99 case
	as this is not required in Fortran.
	(resolve_dynamic_bounds): Rename to
	resolve_dynamic_values. Restructured code as pre-work
	for Fortran dynamic array support (VLA).

Change-Id: Ibce653120e65b5ebfabce75d8758b380980b6973
Signed-off-by: Keven Boell <keven.boell@intel.com>
vla: introduce allocated/associated flags

Fortran 90 provide types whose values may be dynamically
allocated or associated with a variable under explicit
program control. The purpose of this commit is to read
allocated/associated DWARF tags and store them to the
main_type.

2013-10-24  Keven Boell  <keven.boell@intel.com>
            Sanimir Agovic  <sanimir.agovic@intel.com>

	* dwarf2read.c (set_die_type): Add reading of
	allocated/associated flags.
	* gdbtypes.h (struct main_type): Add allocated/
	associated dwarf2_prop attributes.
	(TYPE_ALLOCATED_PROP): New macro.
	(TYPE_ASSOCIATED_PROP): New macro.
	(TYPE_NOT_ALLOCATED): New macro.
	(TYPE_NOT_ASSOCIATED): New macro.

Change-Id: I10776237cbdbab2185036c56501bf95c222652e1
Signed-off-by: Keven Boell <keven.boell@intel.com>
vla: make Fortran dynamic arrays functional.

This patch enables GDB to print the value of a dynamic
array (VLA) if allocated/associated in Fortran. If not the
allocation status will be printed to the command line.

(gdb) p vla_not_allocated
$1 = <not allocated>

(gdb) p vla_allocated
$1 = (1, 2, 3)

The patch covers various locations where the allocation/
association status makes sense to print.

2013-10-25  Keven Boell  <keven.boell@intel.com>
            Sanimir Agovic  <sanimir.agovic@intel.com>

	* dwarf2loc.c (dwarf2_address_data_valid): New
	function.
	* dwarf2loc.h (dwarf2_address_data_valid): New
	function.
	* f-typeprint.c (f_print_type): Print allocation/
	association status.
	(f_type_print_varspec_suffix): Print allocation/
	association status for &-operator usages.
	* gdbtypes.c (get_type_length): Return 0 if a
	type is not allocated or associated.
	(is_dynamic_type): Extend dynamic type detection
	with allocated/associated.
	(resolve_dynamic_values): Add resolving of allocated/
	associated attributes.
	(copy_type_recursive): Deep copy allocated/associated
	attributes.
	* valarith.c (value_subscripted_rvalue): Print allocated/
	associated status when indexing a VLA.
	* valprint.c (valprint_check_validity): Print allocated/
	associated status.
	(val_print_not_allocated): New function.
	(val_print_not_associated): New function.
	* valprint.h (val_print_not_allocated): New function.
	(val_print_not_associated): New function.
	* value.c (set_value_component_location): Adjust the value
	address for single value prints.

Change-Id: Iccf66d115f4f91242fb52b7ba92fc92e2761d109
Signed-off-by: Keven Boell <keven.boell@intel.com>
vla: make field selection work with vla

In Fortran vla are pointers to arrays. Thus a
type only contains a pointer to such array and
we need to re-read the field to retrieve the
correct vla.

old (wrong value):
(gdb) p type_var%vla(14)
$1 = 1

new (correct value):
(gdb) p type_var%vla(14)
$1 = 42

2013-10-25  Sanimir Agovic  <sanimir.agovic@intel.com>
            Keven Boell  <keven.boell@intel.com>

	* value.c (value_primitive_field): Re-evaluate
	field value to get the actual value.

Change-Id: Ic0aaec47a9f99cc87a61a81ef308ff196911184d
Signed-off-by: Keven Boell <keven.boell@intel.com>
vla: reconstruct value to compute bounds of target type

Printing a pointer to an array, gdb tries to print the
target type including its bounds. To follow this
semantic with vla, this patch re-constructs the value to
resolve the bounds of the target type.

2013-10-25  Sanimir Agovic  <sanimir.agovic@intel.com>
            Keven Boell  <keven.boell@intel.com>

	* typeprint.c (whatis_exp): Re-construct value to
	compute bounds of target type.
	* c-valprint.c (c_value_print): Re-construct value
	to compute bounds of target type.

testsuite/gdb.base/:

	* vla-multi.exp: Replace regex to grep for concrete
	length instead of "dynamic length".

Change-Id: I77905ba6d72aa2a0106dc722149f749bfb18a5e0
Signed-off-by: Keven Boell <keven.boell@intel.com>
vla: use value constructor instead of raw-buffer manipulation

Instead of pre-computing indices into a fortran array re-use
the value_* interfaces to subscript a fortran array.

2013-10-25  Sanimir Agovic  <sanimir.agovic@intel.com>
            Keven Boell  <keven.boell@intel.com>

	* f-valprint.c (f77_create_arrayprint_offset_tbl): Remove
	function.
	(F77_DIM_SIZE, F77_DIM_OFFSET): Remove macro.
	(f77_print_array_1): Use value_subscript to subscript a
	value array.
	(f77_print_array): Remove call to f77_create_arrayprint_offset_tbl.
	(f_val_print): Use value_field to construct a field value.

Change-Id: I51cdb1dbdd0d3a818e45b00418bd3bc867fb5646
Signed-off-by: Keven Boell <keven.boell@intel.com>
vla: get dynamic array corner cases to work

This patch does not overwrite the value type in
case it is a dynamic type. For dynamic types GDB
resolved its dynamic values in a copy of the type.
The call to deprecated_set_value_type overwrites the
resolved type with the original type, which breaks
pointer to Fortran types, which contain a dynamic array.

Old:
(gdb) print &vla1
(PTR TO -> ( real(kind=4) (23959136:23959184))) 0x7fffffffd490

New:
(gdb) print &vla1
(PTR TO -> ( real(kind=4) (5))) 0x7fffffffd490

2013-10-31  Keven Boell  <keven.boell@intel.com>
            Sanimir Agovic  <sanimir.agovic@intel.com>

	* value.c (readjust_indirect_value_type): Add
	check for dynamic types.

Change-Id: I5c996e35586abc68f66221e08ede28b8cbeb6c45
Signed-off-by: Keven Boell <keven.boell@intel.com>
vla: changed string length semantic.

This patch changes the semantic of the Dwarf string length
attribute to reflect the standard. This serves as pre-work
to get variable strings in Fortran work.

2013-10-25  Keven Boell  <keven.boell@intel.com>
            Sanimir Agovic  <sanimir.agovic@intel.com>

	* dwarf2read.c (read_tag_string_type): changed
	semantic of DW_AT_string_length to be able to
	handle Dwarf blocks as well. Support for
	DW_AT_byte_length added to get correct length
	if specified in combination with
	DW_AT_string_length.
	* dwarf2read.c (attr_to_locexprbaton): added
	functionality to add Dwarf operators to baton
	data attribute.

Change-Id: I9a8de4491afe5854dec9f764337d336058b9c55c
Signed-off-by: Keven Boell <keven.boell@intel.com>
vla: get Fortran dynamic strings working.

This patch enables the correct calculation of dynamic
string length.

Old:
(gdb) p my_dyn_string
$1 = (PTR TO -> ( character*23959136 )) 0x605fc0

New:
(gdb) p my_dyn_string
$1 = (PTR TO -> ( character*10 )) 0x605fc0

2013-08-23  Keven Boell  <keven.boell@intel.com>
            Sanimir Agovic  <sanimir.agovic@intel.com>

	* gdbtypes.c (resolve_dynamic_values): Add string
	conditions.
	(is_dynamic_type): Follow pointer if detected a
	string type, as Fortran strings are represented
	as pointers to strings internally.

Change-Id: If73f7ba0b4d502e70a4444a782c50818fac3fa67
Signed-off-by: Keven Boell <keven.boell@intel.com>
vla: add stride support fortran arrays.

2013-11-05  Sanimir Agovic  <sanimir.agovic@intel.com>
            Keven Boell  <keven.boell@intel.com>

	* dwarf2read.c (read_subrange_type):
	* gdbtypes.c (create_range_type_1): Add stride parameter.
	(create_range_type): Pass default stride parameter.
	(resolve_dynamic_values_1): Evaluate stride baton.
	* gdbtypes.h (TYPE_BYTE_STRIDE): New macro.
	(TYPE_BYTE_STRIDE_BLOCK): New macro.
	(TYPE_BYTE_STRIDE_LOCLIST): New macro.
	(TYPE_BYTE_STRIDE_KIND): New macro.
	(create_range_type_1): Add stride parameter.
	* valarith.c (value_subscripted_rvalue): Use stride.

Change-Id: Ia6482a1f45748adece6e3cf45c6be975587b2435
Signed-off-by: Keven Boell <keven.boell@intel.com>
test: basic tests for dynamic array evaluations in Fortran.

Tests ensure that values of Fortran dynamic arrays
can be evaluated correctly in various ways and states.

2013-10-28  Keven Boell  <keven.boell@intel.com>
            Sanimir Agovic  <sanimir.agovic@intel.com>

testsuite/gdb.fortran/:

	* vla.f90: New file.
	* vla-value.exp: New file.

Change-Id: I16b75446390dfc19f16991f9da80ebfed8785b8d
Signed-off-by: Keven Boell <keven.boell@intel.com>
test: evaluate Fortran dynamic arrays of types.

Tests ensure that dynamic arrays of various Fortran
datatypes can be evaluated correctly.

2013-10-28  Keven Boell  <keven.boell@intel.com>
            Sanimir Agovic  <sanimir.agovic@intel.com>

testsuite/gdb.fortran/:

	* vla-type.exp: New file.
	* vla-type.f90: New file.

Change-Id: I1f6569333f24e3944c2f785b5392a1bcffa01421
Signed-off-by: Keven Boell <keven.boell@intel.com>
test: evaluate dynamic arrays using Fortran primitives.

Tests ensure that Fortran primitives can be evaluated
correctly when used as a dynamic array.

2013-10-28  Keven Boell  <keven.boell@intel.com>
            Sanimir Agovic  <sanimir.agovic@intel.com>

testsuite/gdb.fortran/:

	* vla-datatypes.f90: New file.
	* vla-datatypes.exp: New file.

Change-Id: I384e8d4ea966fd4122208ac55aa2fc84de0a5ace
Signed-off-by: Keven Boell <keven.boell@intel.com>
test: dynamic arrays passed to subroutines.

Tests dynamic arrays passed to subroutines and handled
in different ways inside the routine.

2013-10-28  Keven Boell  <keven.boell@intel.com>
            Sanimir Agovic  <sanimir.agovic@intel.com>

testsuite/gdb.fortran/:

	* vla-sub.f90: New file.
	* vla-ptype-sub.exp: New file.
	* vla-value-sub-arbitrary.exp: New file.
	* vla-value-sub-finish.exp: New file.
	* vla-value-sub.exp: New file.

Change-Id: Ibb04ab15d35ccb0c4be050defb2763be7e9c69d1
Signed-off-by: Keven Boell <keven.boell@intel.com>
test: correct ptype of dynamic arrays in Fortran.

Tests ensure that the ptype of dynamic arrays in
Fortran can be printed in GDB correctly.

2013-10-28  Keven Boell  <keven.boell@intel.com>
            Sanimir Agovic  <sanimir.agovic@intel.com>

testsuite/gdb.fortran/:

	* vla-ptype.exp: New file.

Change-Id: Ifcd99ea754b39cf6fa2a5487964029aa1f1b3edd
Signed-off-by: Keven Boell <keven.boell@intel.com>
test: evaluating allocation/association status

Tests ensure that dynamic arrays in different states
(allocated/associated) can be evaluated.

2013-10-28  Keven Boell  <keven.boell@intel.com>
            Sanimir Agovic  <sanimir.agovic@intel.com>

testsuite/gdb.fortran/:

	* vla-alloc-assoc.exp: New file.

Change-Id: I9df7aa4c420e695c91b5694d0c06651698cf96af
Signed-off-by: Keven Boell <keven.boell@intel.com>
test: dynamic arrays passed to functions.

Tests for dynamic arrays passed to functions
and returned from functions.

2013-10-28  Keven Boell  <keven.boell@intel.com>
            Sanimir Agovic  <sanimir.agovic@intel.com>

testsuite/gdb.fortran/:

	* vla-func.f90: New file.
	* vla-func.exp: New file.

Change-Id: Idd8dc0a34e2f98b63bc72652f706c75bbe1e0ffc
Signed-off-by: Keven Boell <keven.boell@intel.com>
test: accessing dynamic array history values.

Tests if the history values of dynamic arrays can be
accessed and printed again with the correct values.

2013-10-28  Keven Boell  <keven.boell@intel.com>
            Sanimir Agovic  <sanimir.agovic@intel.com>

testsuite/gdb.fortran/:

	* vla-history.exp: New file.

Change-Id: Ie4487adccb52030112c6789f62a2a54837c8bdef
Signed-off-by: Keven Boell <keven.boell@intel.com>
test: dynamic string evaluations.

Tests various dynamic string evaluations. Dynamic strings
will be handled internally the same way as dynamic arrays.

2013-10-28  Keven Boell  <keven.boell@intel.com>
            Sanimir Agovic  <sanimir.agovic@intel.com>

testsuite/gdb.fortran/:

	* vla-strings.f90: New file.
	* vla-strings.exp: New file.

Change-Id: I2c11f0423b7877aff35dae05ef90ff874b927630
Signed-off-by: Keven Boell <keven.boell@intel.com>