vla: introduce new bound type abstraction adapt uses

The rational behind this patch is to get started to implement the feature
described in dwarf4 standard (2.19) Static and Dynamic Values of Attributes.
It adds new DWARF2_PROP to store either a constant, exprloc, or reference to
describe an upper-/lower bound of a subrange. Other than that no new features
are introduce.

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

	* dwarf2read.c (read_subrange_type): Use struct dwarf2_prop for
	declaring high/low bounds and change uses accordingly. Call
	create_range_type_1 instead of create_range_type,
	* gdbtypes.c (create_range_type_1): New function.
	(create_range_type): Convert bounds into struct dwarf2_prop and pass
	them to create_range_type_1.
	* gdbtypes.h (struct dwarf2_prop): New struct.
	(create_range_type_1): New function prototype.
	(struct range_bounds): Use struct dwarf2_prop instead of LONGEST for
	high/low bounds.
	(TYPE_LOW_BOUND,TYPE_HIGH_BOUND): Adapt macros to refer to the static
	part of the bound.

Change-Id: I04ccd6b9bbf7519b99e814e9ee7119dbcd1f7baa
type: add c99 variable length array support

The dwarf standard allow certain attributes to be expressed as dwarf
expressions rather than constants. For instance upper-/lowerbound attributes.
In case of a c99 variable length array the upperbound is a dynamic attribute.

With this change c99 vla behave the same as with static arrays.

1| void foo (size_t n) {
2|   int ary[n];
3|   memset(ary, 0, sizeof(ary));
4| }

(gdb) print ary
$1 = {0 <repeats 42 times>}

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

	* dwarf2loc.c (dwarf2_locexpr_baton_eval): New function.
	* dwarf2loc.h (dwarf2_locexpr_baton_eval): New function prototype.
	* dwarf2read.c (attr_to_locexprbaton): New function.
	(attr_to_locexprbaton_1): New function.
	(attr_to_dwarf2_prop): New function.
	(read_subrange_type): Use attr_to_dwarf2_prop to read high bound
	attribute.
	* gdbtypes.c: Include dwarf2loc.h.
	(resolve_dynamic_prop): New function.
	(is_dynamic_type): New function.
	(resolve_dynamic_values_1): New function.
	(resolve_dynamic_type): New function.
	(get_type_length): New function.
	(check_typedef): Use get_type_length to compute type length.
	* gdbtypes.h (TYPE_HIGH_BOUND_KIND): Define.
	(TYPE_LOW_BOUND_KIND): Define.

Change-Id: I97b91b9ad0b8ac8d30294dae6bd0dd4c905713ce
vla: enable sizeof operator to work with variable length arrays

In C99 the sizeof operator computes the size of a variable length array
at runtime (6.5.3.4 The sizeof operator). This patch reflects the semantic
change in the debugger.

We now are able to get the size of a vla:

1| void foo (size_t n) {
2|   int vla[n];
3| }

(gdb) p sizeof(vla)

yields N.

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

	* eval.c (evaluate_subexp_for_sizeof): If the type passed to sizeof is
	dynamic	evaluate the argument to compute the length.
	* gdbtypes.c (is_dynamic_type): Make extern.
	* gdbtypes.c (is_dynamic_type): Make extern.

Change-Id: I490f695f7a164be5f1f824fe3ba33f805d1ab689
vla: enable sizeof operator for indirection

This patch enables the sizeof operator for indirections:

1| void foo (size_t n) {
2|   int vla[n];
3|   int *vla_ptr = &vla;
4| }

(gdb) p sizeof(*vla_ptr)

yields N.

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

	* eval.c (evaluate_subexp_for_sizeof): Create a indirect value and
	retrieve the dynamic type size.

Change-Id: I0251a9bece82b221f936f369dcfe9195099b6ee2
vla: allow side effects for sizeof argument

C99 requires the sizeof operator to be evaluated at runtime to compute
the size of the vla, reflect this behavior in gdb.

1| void foo (size_t n, int vla[n][n]) {
2| }

(gdb) p sizeof(vla[0])

yields N.

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

	* eval.c (evaluate_subexp_for_sizeof): Allow side effects for
	argument to sizeof.

Change-Id: I945e8a259e850cc0470faa742a0d2191122ef37b
vla: update type from newly created value

Constructing a value based on a type and address might change the type
of the newly constructed value. Thus re-fetch type via value_type to ensure
we have the correct type at hand.

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

	* valops.c (value_ind): Re-fetch type from value.
	* value.c (coerce_ref): Re-fetch type from value.

Change-Id: Ice9ae63215f637c4b99babf0f108e7b5b58988cd
dwarf: add DW_OP_push_object_address support to dwarf expression

Added a field to hold the address of a variable length array
object to the baton struct in dwarfloc. With DW_OP_push_obj-
ect_address, a callback function is invoked which returns
the address of the object.

2013-10-22  Sanimir Agovic  <sanimir.agovic@intel.com>

	* dwarf2expr.c (execute_stack_op): Added case for
	DW_OP_push_object_address opcode which returns the VLA
	object address.
	* dwarf2expr.h (get_object_addr): Added function pointer
	which returns the VLA objects' CORE_ADDR.
	* dwarf2loc.c (dwarf_expr_get_obj_addr): Implemented
	callback function for DW_OP_push_object_address and
	added function to virtual method table.
	* dwarf2loc.h (dwarf2_locexpr_baton): Added field to hold
	the address of our object.
	* dwarf2read.c (dwarf_fetch_die_loc_sect_off): Implemented
	value assignment to new field in dwarf2_loc_expr_baton.
	(dwarf2_read_obj_addr): Function implemented
	which returns an object address, if available.
	* dwarf2loc.c (dwarf_expr_get_addr_index):
	Replace struct dwarf2_locexpr_baton with struct
	dwarf_expr_baton.
	(dwarf2_evaluate_loc_desc_full): Initialize obj_address
	to be 0 to not have random values in it.
	* dwarf2loc.h (dwarf2_read_obj_addr): Remove not needed
	wrapper function prototype.
	(struct dwarf_expr_baton): Remove obj_address field.
	* dwarf2read.c: remove not needed wrapper function to get
	obj_address out of baton.
vla: add icc c99 vla support

This patch deals with icc specific dwarf vla entities.

2013-10-22  Sanimir Agovic  <sanimir.agovic@intel.com>

	* dwarf2read.c (set_die_type): Parse and save DW_AT_data_location
	attribute.
	* gdbtypes.c (resolve_dynamic_bounds): Evaluate data location baton
	if present and save its value.
	* gdbtypes.h (struct main_type): Add flag_data_location_is_address
	bitflag and union data_location.
	(TYPE_DATA_LOCATION_BATON): New macro.
	(TYPE_DATA_LOCATION_ADDR): New macro.
	(TYPE_DATA_LOCATION_IS_ADDRESS): New macro.
	* value.c: Include dwarf2loc.h.
	(value_fetch_lazy): Use data location addres to read value from
	memory.

Change-Id: I582d709ca6fa50ca216d2bbd49ccaea36d432f16
test: evaluate pointers to C99 vla correctly.

2013-10-18  Keven Boell  <keven.boell@intel.com>

gdb/testsuite:
	* gdb.base/vla-ptr.c: New. Test source file
	for testing pointers to VLA's in C.
	* gdb.base/vla-ptr.exp: New. Tests ensure that
	the evaluation of pointers to VLA's work
	correctly in C.

Change-Id: I12695184edc0d9621d658615ea48d783649f813d
Signed-off-by: Keven Boell <keven.boell@intel.com>
test: multi-dimensional c99 vla.

2013-10-18  Keven Boell  <keven.boell@intel.com>

gdb/testsuite:
	* gdb.base/vla-multi.c: New. Test source file
	for testing multi-dimensional VLA's in C.
	* gdb.base/vla-multi.exp: New. Tests ensure
	that multi-dimensional VLA's can be evaluated
	correctly in C.

Change-Id: I2fd81dc113f20eafed363e7a5a0b0a5a6ce155bc
Signed-off-by: Keven Boell <keven.boell@intel.com>
test: basic c99 vla tests

2013-10-18  Keven Boell  <keven.boell@intel.com>

gdb/testsuite:
	* gdb.base/vla-datatypes.c: New. Test source file
	for VLA datatype checks.
	* gdb.base/vla-datatypes.exp: New. Tests ensure that
	a VLA in C can be evaluated correctly with standard
	C types.

Change-Id: I0517c095522f242deeb00a0f1db31f730dbff228
Signed-off-by: Keven Boell <keven.boell@intel.com>
test: add mi vla test

2013-10-18  Keven Boell  <keven.boell@intel.com>

testsuite/gdb.mi/

	* mi-vla-c99.exp: New file.
	* vla.c: New file.

Change-Id: I9827c8b80b3ba33e2ea7a376bc725154e4ece4c6