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: I35359f6ebe357099935610e81216ede85abd4447
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: I3c1525e7b6a9f1d621ad27aa5aee63ab24f83ffb
Signed-off-by: Keven Boell <keven.boell@intel.com>
vla: introduce allocated/associated flags

The purpose of this commit is to read allocated/associated
DWARF tags and store them to the main_type. This is a
pre-step for the Fortran dynamic array (VLA) support.

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.

Change-Id: Ib021f345a6e891a8c3cce57985ba575d1e6046f1
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 (value_fetch_lazy): Calculate data location
	only if type is allocated or associated.
	(set_value_component_location): Adjust the value address
	for single value prints.

Change-Id: I92b973fc18c08b8fea0dce1eb04688c6a7002b26
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.

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: Ied3cd54864185fa216f1bdb53832feb427d91f17
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: Ib52c17582d4ab2fd802bf59f43c362b8247b719a
vla: use value constructor instead of raw-buffer manipulation

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: I8ecdc8baf70a05ee3342ccf65de0e6952da332b3
vla: get VLA 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 VLA.

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: I106f84e11ff04b968c26da83f1b4e5183e184285
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: Icf27ab9f6a2aa763fbc366e265752e19102a9550
Signed-off-by: Keven Boell <keven.boell@intel.com>
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: I24e1a869884c7d090e78c9633d657a675afb3c83
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: I695b726b83196cd9dd35c561d8ace8bfc1760c71
test: basic tests for VLA evaluation in Fortran.

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

testsuite/gdb.fortran/:

	* vla.f90: Test source file for testing
	evaluations of VLA's.
	* vla-value.exp: Tests ensure that values
	of Fortran VLA's can be evaluated correctly
	in various ways.

Change-Id: I98cfcb3955ba4de66c4e35a1bf99d69ae666bde9
Signed-off-by: Keven Boell <keven.boell@intel.com>
test: evaluate Fortran VLA's of types.

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

testsuite/gdb.fortran/:

	* vla-type.exp: Tests ensure that VLA's of various
	Fortran datatypes can be evaluated correctly.
	* vla-type.f90: Test source file for testing Fortran
	datatypes used in VLA's.

Change-Id: Iae888b111977d128183485c4b9ab083aa9f06b24
Signed-off-by: Keven Boell <keven.boell@intel.com>
test: evaluate VLA's using Fortran datatypes.

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

testsuite/gdb.fortran/:

	* vla-datatypes.f90: Test source file for checking
	Fortran primitives used in VLA's.
	* vla-datatypes.exp: Tests ensure that Fortran
	primitives can be evaluated correctly when used as a VLA.

Change-Id: Id3dafd239f03ea391b140a9d6a2b05274a61c535
Signed-off-by: Keven Boell <keven.boell@intel.com>
test: VLA's passed to subroutines.

Tests for VLA's 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: Test source file for VLA's in
	subroutines.
	* vla-ptype-sub.exp: Check ptype of VLA's in
	subroutine.
	* vla-value-sub-arbitrary.exp: Check values of
	VLA's passed to subroutine and handled as
	arbitrary VLA in subroutine.
	* vla-value-sub-finish.exp: Check value of VLA
	when going the one up using finish.
	* vla-value-sub.exp: Check value of VLA's in
	subroutine.

Change-Id: I18f5f2bb3d365e61f0fe9af9b96f3c3e97c53360
Signed-off-by: Keven Boell <keven.boell@intel.com>
test: correct ptype of VLA's in Fortran.

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

testsuite/gdb.fortran/:

	* vla-ptype.exp: Tests ensure that the ptype
	of VLA's in Fortran can be printed in GDB
	correctly.

Change-Id: I7c8a0d04752e0d029df0b4e54b9b4efdad5faef0
Signed-off-by: Keven Boell <keven.boell@intel.com>
test: evaluating allocated and de-allocated VLA's.

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

testsuite/gdb.fortran/:

	* vla-alloc-assoc.exp: Tests ensure that allocated
	and de-allocated VLA's can be evaluated and do not
	crash.

Change-Id: I9b2daeffbe5d24c960a9e6fade8995df2334d101
Signed-off-by: Keven Boell <keven.boell@intel.com>
test: VLA's passed to functions.

Tests for VLA's passed to Fortran functions and returned
from Fortran functions.

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

testsuite/gdb.fortran/:

	* vla-func.f90: Test source file for VLA usage
	in Fortran functions.
	* vla-func.exp: Tests ensure that VLA's can be
	handled in Fortran functions correctly.

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

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

testsuite/gdb.fortran/:

	* vla-history.exp: tests if the history values
        of vla prints can be accessed and printed again.

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

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

testsuite/gdb.fortran/:

	* vla-strings.f90: Test source file for dynamic
	Fortran strings.
	* vla-strings.exp: Tests various dynamic string
	evaluations.

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