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: If24f1cd18fff878183c8dac0e070122733241991
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.

Change-Id: I34f8bad4716d5962f640f21ed350b40082b7f1c1
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: I8db4cb9c3d1aeba967cedef5f081145d22608c48
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_bounds): Add resolving of allocated/
	associated attributes and copy type in the Fortran
	case as the original attributes need to be preserved.
	attributes.
	(resolve_dynamic_type): Added support for structs and
	resolved them relative to the types data_location.
	(copy_type_recursive): Add allocated/associated
	attributes to be copied.
	(copy_type): Copy allocated/associated/data_location
	as well as the fields structure if available.
	* 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: Ic3a9af91ce575b1096b4cd4e28690d5dcd2d3d03
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: Ia1a67e48c8968f177828a9156310172228d75bba
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: I9bdcdc054aeb206f6966ab4ac165d18ca2e61701
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: I678ab40a79d76bf33ef49e5784cf0d01e385563e
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: I8ec5bb43dd4b176de9fd2f5dbaba852df4a9259c
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.
	(attr_to_dynamic_prop): added
	functionality to add Dwarf operators to baton
	data attribute.
	(read_subrange_type): Adapt caller.
	(set_die_type): Adapt caller.

Change-Id: Ia0845ccced2379f8ebd2c4331ca39abdbe78f0cb
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_bounds): Add conditions
	for dynamic strings and create a new string type.
	(resolve_dynamic_type): Add conditions to support
	string types.
	(is_dynamic_type): Follow pointer if detected a
	string type, as Fortran strings are represented
	as pointers to strings internally.
	Check the range type if it has dynamic ranges,
	as a dynamic string does not provide an allocated/
	associated tag. Only the bounds are dynamic.

Change-Id: Ia633799f74f2eb66ce55cb0f0a0a3c6544171640
vla: add stride support to 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: I985e6346745f2f988dac0324eff642044bc5be84
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: I284916a98de3b5674fbb8b3991dfbcf10df57cfc
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: I516c2135907ecaf9e26506f5aa01ef9aa955167b
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: Ie2af44a29d8b894b6530ffd662ee7766cf25e889
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: Iaf166ba24f1af2908dbb761d9dbab58e4f3a8c5a
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: I9e0bd977094323e8d5f7a3ea587ef092c2f9032c
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: I1354cc121558eec6627a11ca384634c02c8e0cff
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: I91c8de7b80abc6d3aea739851b28b709ffa6391f
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: Ibfd0815e3b7c41d99d522c78081dba51751a3782
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: I253b6c9369e6ae6aec1aac83c3960e0b9bd3f627