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: Id5e9860dc9ca9c51fa7fb499fb52bc645d93c6cc
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: If6473f36835767d4d6756b442860d499b0d00aab
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: Id1707acec3cde1f324cebd318d16f5aea6c2daba
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: I8262851d304f85187e746d62911c2d166420e6fd
Signed-off-by: Keven Boell <keven.boell@intel.com>

Conflicts:

	gdb/gdbtypes.c
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.

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: I9bee8ecb4afdd0741a51eef53d48b630247f2727
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: I3505ff7e306103e5890dff7c745e03e12dbeb46d
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: I3059287030654351e46bcfc292cfbef59902a20c
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.

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: If3f0f7c2e1029eb39d852417fdbf01abf831bc4d
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: Ice43bba36f0c626e2e3757a89ef576178fbb05e1
Signed-off-by: Keven Boell <keven.boell@intel.com>

Conflicts:

	gdb/gdbtypes.c
vla: get Fortran dynamic strings working.

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: Ia8ab5b41627b4e82c4d18d2c00fd2600051a5171
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: I373b49210b124e5b681f92fa2d89b917d5620705
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: I0ffd13f8ca5d70ba8fab2e1b7eaf44ae143c1a43
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: Ib23b224eb62ccc5157588725e62823490a99d613
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: Ie4498c0485531ca18e993af6cd5ce9b6e6ab561d
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: Iae6adb027aedcce036a2490d3cab2c2fd7f13c0f
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: I4a423601e4917f8f6f9be30413677431889cd121
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: Ie5fa4db5d1c668b07eed2468e4f9db661517ab54
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: I5eab2eea971f6936310b0b531c2a75fd573d19ae
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: I27c20538fd516d107ecdd0d1633189e766e2452a
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: I992d68b2d3005a3d95c8e7b09d332f0072e835f0
Signed-off-by: Keven Boell <keven.boell@intel.com>