vla: print "variable length" for unresolved dynamic bounds

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

Given the following expression

  (gdb) ptype &vla

Gdb evaluates the expression with EVAL_AVOID_SIDE_EFFECTS and thus
does not resolve the bounds information and misinterprets the high
bound as a constant. The current output is:

  type = int (*)[1289346]

this patch deals with this case and prints:

  type = int (*)[variable length]

instead.

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

	* c-typeprint.c (c_type_print_varspec_suffix): Added
	check for not yet resolved high bound. If unresolved, print
	"variable length" string to the console instead of random
	length.

Change-Id: Ic6a5fc08c8651ef18760bdacacc492ed44fe4af4
vla: support for DW_AT_count

This patch adds support for DW_AT_count as requested in the code review:

  https://sourceware.org/ml/gdb-patches/2013-11/msg00200.html

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

	* dwarf2read.c (read_subrange_type): If DW_AT_count is dynamic
	create the following upper bound dwarf expression 'low + count + 1'
	by hand.

Change-Id: I0f70edd22f2f6d8d7aa32f245e45617a7dc1b24a
vla: resolve dynamic bounds if value contents is a constant byte-sequence

A variable location might be a constant value and therefore no inferior memory
access is needed to read the content. In this case try to resolve the type
bounds.

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

	* findvar.c (default_read_var_value): Resolve dynamic bounds if location
	points to a constant blob.

Change-Id: I73c31b64976b7d2c603c68d4584909502c8c5928
test: cover subranges with present DW_AT_count attribute

The dwarf attribute DW_AT_count specifies the elements of a subrange.
This test covers subranges with present count but absent upper bound
attribute, both with static and dynamic attribute values.

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

testsuite:
	* gdb.dwarf2/count.exp: New test.

Change-Id: I0a537c23bc7d5e0bffe58d14d0125dc7cd753f48
test: multi-dimensional c99 vla.

2013-10-18  Keven Boell  <keven.boell@intel.com>
            Sanimir Agovic  <sanimir.agovic@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: If9cf7517301e0558aced1358723e1b62f6df0c97
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: Iea007544b3e95f9da4ca746d142e7be0350cf87b
test: basic c99 vla tests for C primitives

2013-10-18  Keven Boell  <keven.boell@intel.com>
            Sanimir Agovic  <sanimir.agovic@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: I7e9ac796ac7e9afa983d60e6d4b506017e4afe54
test: add mi vla test

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

testsuite/gdb.mi/

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

Change-Id: If86f3a770c9c1d6b415057a40f51ba2a6f20ba0e
dwarf: add dwarf3 DW_OP_push_object_address opcode

The opcode pushes the address of the object being evaluated. The semantic is
equivalent to the implicit push of the base address of a data member location.

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

	* dwarf2expr.c (execute_stack_op): Add case for
	DW_OP_push_object_address opcode which returns the object address.
	* dwarf2expr.h (struct dwarf_expr_context_funcs): New function pointer
	get_object_addr.
	* dwarf2loc.c (struct dwarf_expr_baton): Add obj_address.
	(dwarf_expr_get_obj_addr): New function.
	(struct dwarf_expr_context_funcs): Add
	dwarf_expr_get_obj_addr to dwarf_expr_ctx_funcs.
	(dwarf2_evaluate_loc_desc_full): Initialize baton.obj_address.
	(dwarf2_locexpr_baton_eval): Set baton.obj_address to addr.
	(needs_get_obj_addr): New function.
	(struct dwarf_expr_context_funcs): Add needs_get_obj_addr to
	needs_frame_ctx_funcs.

Change-Id: Ic376b22c8f94e630ddba21ac71849d79b8c06ebc
dwarf: add DW_AT_data_location support

The attribute DW_AT_data_location is used for indirection to actual data.

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

	* dwarf2read.c (set_die_type): Parse and save DW_AT_data_location
	attribute.
	* gdbtypes.c (is_dynamic_type): Consider a type being dynamic if
	the data location has not yet been resolved.
	(resolve_dynamic_bounds): Evaluate data location baton
	if present and save its value.
	* gdbtypes.h (struct main_type): Add data_location.
	(TYPE_DATA_LOCATION): 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.
	(coerce_ref): Construct new value from data location.

Change-Id: I9f303a6891d1dc50ce4ea64072a99cf0ddc10b62