vla: make dynamic fortran 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)

(gdb) p vla_not_associated
$1 = <not associated>

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

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

2014-05-28  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 (create_array_type_with_stride): Add
	query for valid data location.
	(is_dynamic_type): Extend dynamic type detection
	with allocated/associated. Add type detection for
	fields.
	(resolve_dynamic_range): Copy type before resolving
	it as dynamic attributes need to be preserved.
	(resolve_dynamic_array): Copy type before resolving
	it as dynamic attributes need to be preserved. Add
	resolving of allocated/associated attributes.
	(resolve_dynamic_type): Add call to nested
	type resolving.
	(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: Idfb44c8a6b38008f8e2c84cb0fdb13729ec160f4
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

2014-05-28  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: Ic22c37324963aca520c52a80fbbd0042d1fddc05
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.

2014-05-28  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.

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

2014-05-28  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: I09e482ceb114eeb0f08b5528d40ffed8d79119ee
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
e.g. pointer to a Fortran type, which contains 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

2014-05-28  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: If1c6fb0bd3c1d04619e89a1b58850edb69bbfde0
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 to work.

2014-05-28  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. Added post values to baton
	as required by the string evaluation case.
	(read_subrange_type): Adapt caller.
	(set_die_type): Adapt caller.
	(add_post_values_to_baton): New function.
	* dwarf2loc.c (dwarf2_evaluate_property): Evaluate
	post processing dwarf.
	* dwarf2loc.h (struct dwarf2_property_baton): Add
	post dwarf values attribute.

Change-Id: I6edfa005f416cddc8e364d34891b9abf6b44f757
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

(gdb) p *my_dyn_string
Cannot access memory at address 0x605fc0

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

(gdb) p *my_dyn_string
$2 = 'foo'

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

	* gdbtypes.c (resolve_dynamic_type): Add
	conditions to support string types.
	(resolve_dynamic_array): Add conditions for dynamic
	strings and create a new string type.
	(is_dynamic_type): Follow pointer if a string type
	was detected, as Fortran strings are represented
	as pointers to strings internally.

Change-Id: I7d54d762a081ce034be37ac3e368bac8111dc4e6
vla: add stride support to fortran arrays.

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

	* dwarf2read.c (read_subrange_type): Read dynamic
	stride attributes.
	* gdbtypes.c (create_array_type_with_stride): Add
	stride support
	(create_range_type): Add stride parameter.
	(create_static_range_type): Pass default stride
	parameter.
	(resolve_dynamic_range): Evaluate stride baton.
	(resolve_dynamic_type): Adjust data location with
	the value of byte stride.
	* 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.
	* valarith.c (value_subscripted_rvalue): Use stride.

Change-Id: I3d810c0dc37f9d9fd84dba4c764cdefc52d8501e
vla: add NEWS entry for dynamic array support

2014-06-27  Keven Boell  <keven.boell@intel.com>
            Sanimir Agovic  <sanimir.agovic@intel.com>

	* NEWS: add entry for dynamic array support
	in Fortran.

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

2014-05-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: I0229c3b58f72ae89c2ee42d1219e4538cb6bf023
test: evaluate dynamic arrays using Fortran primitives.

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

2014-05-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: I8e82fa3833d77bfd7e9b4bdc40e3f96ce5e72da2
test: dynamic arrays passed to subroutines.

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

2014-05-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: I76db950fbacbf15b1f5e887bfd164eb8f85c55d1
test: correct ptype of dynamic arrays in Fortran.

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

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

testsuite/gdb.fortran/:

	* vla-ptype.exp: New file.

Change-Id: I508a0537be7cac5739a263788be89b18e84d8f8f
test: evaluating allocation/association status

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

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

testsuite/gdb.fortran/:

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

Change-Id: I6950473c3f1724ebf5c7b037706186b2cd6af5f0
test: dynamic arrays passed to functions.

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

2014-05-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: Ic3eb212f35f599e4c10a284c23125491653b17df
test: accessing dynamic array history values.

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

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

testsuite/gdb.fortran/:

	* vla-history.exp: New file.

Change-Id: Ib6d2d30272aefc24b6db5fa0633fe72274390e91
test: dynamic string evaluations.

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

2014-05-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: Ib2f3dded2fbc5f0a9684050c5cfa22a450e18358
test: basic MI test for the dynamic array support.

Tests dynamic array evaluations using MI protocol.

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

testsuite/gdb.mi/:

	* mi-vla-fortran.exp: New file.
	* vla.f90: New file.

Change-Id: I37caa85b1498478f5eff0f52d3fd431388aaab6f
test: test sizeof for dynamic fortran arrays.

Tests sizeof output of dynamic arrays in various states.

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

testsuite/gdb.fortran/:

	* vla-sizeof.exp: New file.

Change-Id: I68d81d03ff2daa32ab87d2750873652d684e7389
test: stride support for dynamic arrays.

Tests the usage of stride values in dynamic arrays.

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

testsuite/gdb.fortran/:

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

Change-Id: Ic4f68cf97046cc9f5f3664fe4c12d2b7528c22ee