Commit Graph

34472 Commits

Author SHA1 Message Date
Tom Tromey c848d64244 constify value_aggregate_elt
While working on another patch I realized that value_aggregate_elt's
"name" parameter ought to be const.  This patch implements this.

2014-04-14  Tom Tromey  <tromey@redhat.com>

	* valops.c (value_aggregate_elt, value_struct_elt_for_reference)
	(value_namespace_elt, value_maybe_namespace_elt): Make "name"
	const.
	* value.h (value_aggregate_elt): Update.
2014-04-14 11:42:18 -06:00
Tom Tromey 0626fc76d1 handle DW_AT_type on an enumeration
DWARF allows an enumeration type to have a DW_AT_type.  GDB doesn't
recognize this, but there is a patch to change GCC to emit it, and a
DWARF proposal to further allow an enum type with a DW_AT_type to omit
the DW_AT_byte_size.  This patch changes gdb to implement this.

Built and regtested on x86-64 Fedora 20.

2014-04-14  Tom Tromey  <tromey@redhat.com>

	* dwarf2read.c (read_enumeration_type): Handle DW_AT_type.

2014-04-14  Tom Tromey  <tromey@redhat.com>

	* gdb.dwarf2/enum-type.exp: New file.
2014-04-14 11:42:17 -06:00
Sanimir Agovic dca325b370 test: add mi vla test
testsuite/ChangeLog:

	* gdb.mi/mi-vla-c99.exp: New file.
	* gdb.mi/vla.c: New file.
2014-04-14 09:52:11 -07:00
Sanimir Agovic 5854b38a00 test: basic c99 vla tests for C primitives
gdb/testsuite/ChangeLog:

	* gdb.base/vla-datatypes.c: New file.
	* gdb.base/vla-datatypes.exp: New file.
2014-04-14 09:27:42 -07:00
Sanimir Agovic 463bb9571b test: evaluate pointers to C99 vla correctly.
gdb/testsuite/ChangeLog:

	* gdb.base/vla-ptr.c: New file.
	* gdb.base/vla-ptr.exp: New file.
2014-04-14 09:26:22 -07:00
Sanimir Agovic 3dd170be25 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.

testsuite/ChangeLog:

	* gdb.dwarf2/count.exp: New file.
2014-04-14 09:23:44 -07:00
Sanimir Agovic 5ecaaa66e0 vla: evaluate operand of sizeof if its type is a vla
The c99 standard in "6.5.3.4 The sizeof operator" states:

 If the type of the operand is a variable length array type, the operand
 is evaluated;[...]

This patch mirrors the following c99 semantic in gdb:

 1| int vla[n][m];
 2| int i = 1;
 3| sizeof(vla[i++][0]); // No sideffect
 4| assert (i == 1);
 5| sizeof(vla[i++]);    // With sideffect
 6| assert (i == 2);

Note: ptype/whatis still do not allow any sideeffects.

This patch was motivated by:

  https://sourceware.org/ml/gdb-patches/2014-01/msg00732.html

gdb/ChangeLog:

	* eval.c (evaluate_subexp_for_sizeof): Add enum noside argument.
	(evaluate_subexp_standard): Pass noside argument.
	(evaluate_subexp_for_sizeof) <BINOP_SUBSCRIPT>: Handle subscript case
	if noside equals EVAL_NORMAL. If the subscript yields a vla type
	re-evaluate subscript operation with EVAL_NORMAL to enable sideffects.
	* gdbtypes.c (resolve_dynamic_bounds): Mark bound as evaluated.
	* gdbtypes.h (enum range_flags): Add RANGE_EVALUATED case.

testsuite/ChangeLog:

	* gdb.base/vla-sideeffect.c: New file.
	* gdb.base/vla-sideeffect.exp: New file.
2014-04-14 09:21:46 -07:00
Sanimir Agovic 1612e0c0f9 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.

gdb/ChangeLog:

	* findvar.c (default_read_var_value): Resolve dynamic bounds if location
	points to a constant blob.
2014-04-14 09:18:44 -07:00
Sanimir Agovic c451ebe5dd 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

gdb/ChangeLog:

	* dwarf2read.c (read_subrange_type): Convert DW_AT_count to a dynamic
	property and store it as the high bound and flag the range accordingly.
	* gdbtypes.c (resolve_dynamic_bounds): If range is flagged as
	RANGE_UPPER_BOUND_IS_COUNT assign low + high - 1 as the new high bound.
	* gdbtypes.h (enum range_flags): New enum.
	(struct range_bounds): Add flags member.
2014-04-14 09:17:54 -07:00
Sanimir Agovic 1d42e4c4d8 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.

gdb/ChangeLog:

	* 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.
2014-04-14 09:16:30 -07:00
Sanimir Agovic 9f1f738ada 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.

gdb/ChangeLog

	* ada-lang.c (ada_value_primitive_packed_val): Re-fetch type from value.
	(ada_template_to_fixed_record_type_1): Likewise.
	(ada_to_fixed_type_1): Likewise.
	* cp-valprint.c (cp_print_value_fields_rtti): Likewise.
	(cp_print_value): Likewise.
	* d-valprint.c (dynamic_array_type): Likewise.
	* findvar.c (address_of_variable): Likewise.
	* jv-valprint.c (java_value_print): Likewise.
	* valops.c (value_ind): Likewise.
	* value.c (coerce_ref): Likewise.
2014-04-14 09:15:33 -07:00
Sanimir Agovic 3c8452d46a 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 sizeof (size_t) * n.

gdb/ChangeLog:

	* eval.c (evaluate_subexp_for_sizeof) <UNOP_IND>: Create an indirect
	value and retrieve the dynamic type size.
2014-04-14 09:14:11 -07:00
Sanimir Agovic 4ad88275f8 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 * sizeof(int).

gdb/ChangeLog:

	* eval.c (evaluate_subexp_for_sizeof) <OP_VAR_VALUE>: If the type
	passed to sizeof is dynamic evaluate the argument to compute the length.
2014-04-14 09:11:48 -07:00
Sanimir Agovic 80180f796d 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>}

gdb/ChangeLog:

	* dwarf2loc.c (dwarf2_locexpr_baton_eval): New function.
	(dwarf2_evaluate_property): New function.
	* dwarf2loc.h (dwarf2_evaluate_property): New function prototype.
	* dwarf2read.c (attr_to_dynamic_prop): New function.
	(read_subrange_type): Use attr_to_dynamic_prop to read high bound
	attribute.
	* gdbtypes.c: Include dwarf2loc.h.
	(is_dynamic_type): New function.
	(resolve_dynamic_type): New function.
	(resolve_dynamic_bounds): New function.
	(get_type_length): New function.
	(check_typedef): Use get_type_length to compute type length.
	* gdbtypes.h (TYPE_HIGH_BOUND_KIND): New macro.
	(TYPE_LOW_BOUND_KIND): New macro.
	(is_dynamic_type): New function prototype.
	* value.c (value_from_contents_and_address): Call resolve_dynamic_type
	to resolve dynamic properties of the type. Update comment.
	* valops.c (get_value_at, value_at, value_at_lazy): Update comment.
2014-04-14 09:10:44 -07:00
David Blaikie 41f1ada5d2 Add return value for non-void function return statements to fix error in clang build.
Clang defaults this warning to an error, breaking the build & causing
these tests not to run.

gdb/testsuite/

	* gdb.mi/non-stop.c: Add return value for non-void function return
	statement.
	* gdb.threads/staticthreads.c: Ditto.
2014-04-14 08:34:51 -07:00
Richard Henderson a155684382 Fix typo in _initialize_alpha_linux_nat prototype
* alpha-linux-nat.c (_initialize_alpha_linux_nat): Fix prototype.
2014-04-14 08:32:09 -07:00
Doug Evans 0be03e8417 Copy over fix for fetching dynamic type of a reference from python side.
* guile/scm-value.c (gdbscm_value_dynamic_type): Use coerce_ref to
	dereference TYPE_CODE_REF values.

	testsuite/
	* gdb.guile/scm-value.c: Improve test case.
	* gdb.guile/scm-value.exp: Add new test.
2014-04-12 09:09:41 -07:00
David Blaikie f180a1fb46 Compile inline test with -std=gnu89 explicitly to override Clang's default (-std=c99)
gdb/testsuite/
	* gdb.opt/inline-break.exp: Explicitly specify -std=gnu89 to
	override Clang's default.
2014-04-11 17:26:23 -07:00
Joel Brobecker 191a8a9046 gdb/testsuite/ChangeLog: Fix path to a few files in previous entries. 2014-04-11 15:28:08 -07:00
Joel Brobecker 6b662e19e4 Revert the entire VLA series.
This reverts the following patch series, as they cause some regresssions.

commit 37c1ab67a3
type: add c99 variable length array support

	gdb/
	* dwarf2loc.c (dwarf2_locexpr_baton_eval): New function.
	(dwarf2_evaluate_property): New function.
	* dwarf2loc.h (dwarf2_evaluate_property): New function prototype.
	* dwarf2read.c (attr_to_dynamic_prop): New function.
	(read_subrange_type): Use attr_to_dynamic_prop to read high bound
	attribute.
	* gdbtypes.c: Include dwarf2loc.h.
	(is_dynamic_type): New function.
	(resolve_dynamic_type): New function.
	(resolve_dynamic_bounds): New function.
	(get_type_length): New function.
	(check_typedef): Use get_type_length to compute type length.
	* gdbtypes.h (TYPE_HIGH_BOUND_KIND): New macro.
	(TYPE_LOW_BOUND_KIND): New macro.
	(is_dynamic_type): New function prototype.
	* value.c (value_from_contents_and_address): Call resolve_dynamic_type
	to resolve dynamic properties of the type. Update comment.
	* valops.c (get_value_at, value_at, value_at_lazy): Update comment.

commit 26cb189f8b
vla: enable sizeof operator to work with variable length arrays

	gdb/
	* eval.c (evaluate_subexp_for_sizeof) <OP_VAR_VALUE>: If the type
	passed to sizeof is dynamic evaluate the argument to compute the length.

commit 04b19544ef
vla: enable sizeof operator for indirection

	gdb/
	* eval.c (evaluate_subexp_for_sizeof) <UNOP_IND>: Create an indirect
	value and retrieve the dynamic type size.

commit bcd629a44f
vla: update type from newly created value

	gdb/
	* ada-lang.c (ada_value_primitive_packed_val): Re-fetch type from value.
	(ada_template_to_fixed_record_type_1): Likewise.
	(ada_to_fixed_type_1): Likewise.
	* cp-valprint.c (cp_print_value_fields_rtti): Likewise.
	(cp_print_value): Likewise.
	* d-valprint.c (dynamic_array_type): Likewise.
	* eval.c (evaluate_subexp_with_coercion): Likewise.
	* findvar.c (address_of_variable): Likewise.
	* jv-valprint.c (java_value_print): Likewise.
	* valops.c (value_ind): Likewise.
	* value.c (coerce_ref): Likewise.

commit b86138fb04
vla: print "variable length" for unresolved dynamic bounds

	gdb/
	* 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.

commit e1969afbd4
vla: support for DW_AT_count

	gdb/
	* dwarf2read.c (read_subrange_type): Convert DW_AT_count to a dynamic
	property and store it as the high bound and flag the range accordingly.
	* gdbtypes.c (resolve_dynamic_bounds): If range is flagged as
	RANGE_UPPER_BOUND_IS_COUNT assign low + high - 1 as the new high bound.
	* gdbtypes.h (enum range_flags): New enum.
	(struct range_bounds): Add flags member.

commit 92b09522dc
vla: resolve dynamic bounds if value contents is a constant byte-sequence

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

commit 3bce82377f
vla: evaluate operand of sizeof if its type is a vla

	gdb/
	* eval.c (evaluate_subexp_for_sizeof): Add enum noside argument.
	(evaluate_subexp_standard): Pass noside argument.
	(evaluate_subexp_for_sizeof) <BINOP_SUBSCRIPT>: Handle subscript case
	if noside equals EVAL_NORMAL. If the subscript yields a vla type
	re-evaluate subscript operation with EVAL_NORMAL to enable sideffects.
	* gdbtypes.c (resolve_dynamic_bounds): Mark bound as evaluated.
	* gdbtypes.h (enum range_flags): Add RANGE_EVALUATED case.

	gdb/testsuite

	* gdb.base/vla-sideeffect.c: New file.
	* gdb.base/vla-sideeffect.exp: New file.

commit 504f34326e
test: cover subranges with present DW_AT_count attribute

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

commit 1a237e0ee5
test: multi-dimensional c99 vla.

	gdb/testsuite/
	* gdb.base/vla-multi.c: New file.
	* gdb.base/vla-multi.exp: New file.

commit 024e13b46f
test: evaluate pointers to C99 vla correctly.

	gdb/testsuite/
	* gdb.base/vla-ptr.c: New file.
	* gdb.base/vla-ptr.exp: New file.

commit c8655f75e2
test: basic c99 vla tests for C primitives

	gdb/testsuite/
	* gdb.base/vla-datatypes.c: New file.
	* gdb.base/vla-datatypes.exp: New file.

commit 58a84dcf29
test: add mi vla test

	gdb/testsuite/
	* gdb.mi/mi-vla-c99.exp: New file.
	* gdb.mi/vla.c: New file.
2014-04-11 15:26:21 -07:00
Keith Seitz 245a5f0b74 Fix c++/16675 -- sizeof reference type should give the size of
the referent, not the size of the actual reference variable.
2014-04-11 14:17:17 -07:00
Sanimir Agovic 58a84dcf29 test: add mi vla test
testsuite/gdb.mi/

	* mi-vla-c99.exp: New file.
	* vla.c: New file.
2014-04-11 13:44:00 +01:00
Sanimir Agovic c8655f75e2 test: basic c99 vla tests for C primitives
gdb/testsuite:
	* gdb.base/vla-datatypes.c: New file.
	* gdb.base/vla-datatypes.exp: New file.
2014-04-11 13:43:59 +01:00
Sanimir Agovic 024e13b46f test: evaluate pointers to C99 vla correctly.
gdb/testsuite:
	* gdb.base/vla-ptr.c: New file.
	* gdb.base/vla-ptr.exp: New file.
2014-04-11 13:43:58 +01:00
Sanimir Agovic 1a237e0ee5 test: multi-dimensional c99 vla.
gdb/testsuite:
	* gdb.base/vla-multi.c: New file.
	* gdb.base/vla-multi.exp: New file.
2014-04-11 13:43:57 +01:00
Sanimir Agovic 504f34326e 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.

testsuite:
	* gdb.dwarf2/count.exp: New file.
2014-04-11 13:43:56 +01:00
Sanimir Agovic 3bce82377f vla: evaluate operand of sizeof if its type is a vla
The c99 standard in "6.5.3.4 The sizeof operator" states:

 If the type of the operand is a variable length array type, the operand
 is evaluated;[...]

This patch mirrors the following c99 semantic in gdb:

 1| int vla[n][m];
 2| int i = 1;
 3| sizeof(vla[i++][0]); // No sideffect
 4| assert (i == 1);
 5| sizeof(vla[i++]);    // With sideffect
 6| assert (i == 2);

Note: ptype/whatsis still do not allow any sideeffects.

This patch was motivated by:

  https://sourceware.org/ml/gdb-patches/2014-01/msg00732.html

	* eval.c (evaluate_subexp_for_sizeof): Add enum noside argument.
	(evaluate_subexp_standard): Pass noside argument.
	(evaluate_subexp_for_sizeof) <BINOP_SUBSCRIPT>: Handle subscript case
	if noside equals EVAL_NORMAL. If the subscript yields a vla type
	re-evaluate subscript operation with EVAL_NORMAL to enable sideffects.
	* gdbtypes.c (resolve_dynamic_bounds): Mark bound as evaluated.
	* gdbtypes.h (enum range_flags): Add RANGE_EVALUATED case.

testsuite/gdb.base/

	* vla-sideeffect.c: New file.
	* vla-sideeffect.exp: New file.
2014-04-11 13:43:55 +01:00
Sanimir Agovic 92b09522dc 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.

	* findvar.c (default_read_var_value): Resolve dynamic bounds if location
	points to a constant blob.
2014-04-11 13:43:54 +01:00
Sanimir Agovic e1969afbd4 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

	* dwarf2read.c (read_subrange_type): Convert DW_AT_count to a dynamic
	property and store it as the high bound and flag the range accordingly.
	* gdbtypes.c (resolve_dynamic_bounds): If range is flagged as
	RANGE_UPPER_BOUND_IS_COUNT assign low + high - 1 as the new high bound.
	* gdbtypes.h (enum range_flags): New enum.
	(struct range_bounds): Add flags member.
2014-04-11 13:43:53 +01:00
Sanimir Agovic b86138fb04 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.

	* 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.
2014-04-11 13:43:52 +01:00
Sanimir Agovic bcd629a44f 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.

	* ada-lang.c (ada_value_primitive_packed_val): Re-fetch type from value.
	(ada_template_to_fixed_record_type_1): Likewise.
	(ada_to_fixed_type_1): Likewise.
	* cp-valprint.c (cp_print_value_fields_rtti): Likewise.
	(cp_print_value): Likewise.
	* d-valprint.c (dynamic_array_type): Likewise.
	* eval.c (evaluate_subexp_with_coercion): Likewise.
	* findvar.c (address_of_variable): Likewise.
	* jv-valprint.c (java_value_print): Likewise.
	* valops.c (value_ind): Likewise.
	* value.c (coerce_ref): Likewise.
2014-04-11 13:43:51 +01:00
Sanimir Agovic 04b19544ef 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 sizeof (size_t) * n.

	* eval.c (evaluate_subexp_for_sizeof) <UNOP_IND>: Create an indirect
	value and retrieve the dynamic type size.
2014-04-11 13:43:50 +01:00
Sanimir Agovic 26cb189f8b 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 * sizeof(int).

	* eval.c (evaluate_subexp_for_sizeof) <OP_VAR_VALUE>: If the type
	passed to sizeof is dynamic evaluate the argument to compute the length.
2014-04-11 13:43:49 +01:00
Sanimir Agovic 37c1ab67a3 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>}

	* dwarf2loc.c (dwarf2_locexpr_baton_eval): New function.
	(dwarf2_evaluate_property): New function.
	* dwarf2loc.h (dwarf2_evaluate_property): New function prototype.
	* dwarf2read.c (attr_to_dynamic_prop): New function.
	(read_subrange_type): Use attr_to_dynamic_prop to read high bound
	attribute.
	* gdbtypes.c: Include dwarf2loc.h.
	(is_dynamic_type): New function.
	(resolve_dynamic_type): New function.
	(resolve_dynamic_bounds): New function.
	(get_type_length): New function.
	(check_typedef): Use get_type_length to compute type length.
	* gdbtypes.h (TYPE_HIGH_BOUND_KIND): New macro.
	(TYPE_LOW_BOUND_KIND): New macro.
	(is_dynamic_type): New function prototype.
	* value.c (value_from_contents_and_address): Call resolve_dynamic_type
	to resolve dynamic properties of the type. Update comment.
	* valops.c (get_value_at, value_at, value_at_lazy): Update comment.
2014-04-11 13:43:48 +01:00
Sanimir Agovic 729efb1317 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 BOUND_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 introduced.

	* dwarf2read.c (read_subrange_type): Use struct bound_prop for
	declaring high/low bounds and change uses accordingly. Call
	create_range_type instead of create_static_range_type.
	* gdbtypes.c (create_range_type): New function.
	(create_range_type): Convert bounds into struct bound_prop and pass
	them to create_range_type.
	* gdbtypes.h (struct bound_prop): New struct.
	(create_range_type): New function prototype.
	(struct range_bounds): Use struct bound_prop instead of LONGEST for
	high/low bounds. Remove low_undefined/high_undefined and adapt all uses.
	(TYPE_LOW_BOUND,TYPE_HIGH_BOUND): Adapt macros to refer to the static
	part of the bound.
	* parse.c (follow_types): Set high bound kind to BOUND_UNDEFINED.
2014-04-11 13:43:47 +01:00
Sanimir Agovic 0c9c347402 refactoring: rename create_range_type to create_static_range_type
* gdbtypes.c (create_static_range_type): Renamed from create_range_type.
	* gdbtypes.h (create_static_range_type): Renamed from create_range_type.
	* ada-lang.c: All uses of create_range_type updated.
	* coffread.c: All uses of create_range_type updated.
	* dwarf2read.c: All uses of create_range_type updated.
	* f-exp.y: All uses of create_range_type updated.
	* m2-valprint.c: All uses of create_range_type updated.
	* mdebugread.c: All uses of create_range_type updated.
	* stabsread.c: All uses of create_range_type updated.
	* valops.c: All uses of create_range_type updated.
	* valprint.c: All uses of create_range_type updated.
2014-04-11 13:43:45 +01:00
Yao Qi 322f9c2100 Check file exists before completion tests
Doug told me that there are some regressions in gdb.base/completion.exp.
They are caused by my recent change, and can be reproduced via:

$ make check-parallel TESTS=gdb.base/completion.exp
FAIL: gdb.base/completion.exp: complete target core ./gdb.base/completion
FAIL: gdb.base/completion.exp: complete target tfile ./gdb.base/completion
FAIL: gdb.base/completion.exp: complete target exec ./gdb.base/completion

Current tests assume that gdb.base/completion exists but that is wrong
in a parallel run, because binary file and object files are placed
in outputs/gdb.base/completion/.

This patch is to check file exists on two candidate directories,
"gdb.base" and "outputs/gdb.base/completion/", and run tests with files
existed in either of them.

gdb/testsuite:

2014-04-11  Yao Qi  <yao@codesourcery.com>

	* gdb.base/completion.exp: Check file exists before running tests
	on file completion.
2014-04-11 12:54:09 +08:00
Pedro Alves d708bcd102 Conditional Z1 breakpoint hangs GDBserver.
While trying to fix hbreak2.exp against GDBserver I noticed this...

 (gdb) hbreak main if 1
 Sending packet: $m400580,40#2e...Packet received: e8d2ffffff5dc3554889e54883ec10c745fc00000000eb0eb800000000e8c1ffffff8345fc01817dfce70300007ee9b800000000c9c3662e0f1f840000000000
 Sending packet: $m40058f,1#31...Packet received: c7
 Hardware assisted breakpoint 1 at 0x40058f: file ../../../src/gdb/testsuite/gdb.base/break-idempotent.c, line 46.
 Sending packet: $Z1,40058f,1;X3,220127#9b...
 *hangs forever*

The issue is that nothing advances the packet pointer if
add_breakpoint_condition either fails to parse the agent expression,
or fails to find the breakpoint, resulting in an infinite loop in
process_point_options.  The latter case should really be fixed by
GDBserver tracking GDB Z1 breakpoints in its breakpoint structures
like Z0 breakpoints are, but the latter case still needs handling.
add_breakpoint_commands has the same issue, though at present I don't
know any way to trigger it other than sending a manually cooked
packet.

Unbelievably, it doesn't look like we have any test that tries setting
a conditional hardware breakpoint.  Looking at cond-eval-mode.exp, it
looks like the file was meant to actually test something, but it's
mostly empty today.  This patch adds tests that tries all sorts of
conditional breakpoints and watchpoints.  The test hangs/fails without
the GDBserver fix.

Tested on x86_64 Fedora 17.

gdb/gdbserver/
2014-04-10  Pedro Alves  <palves@redhat.com>

	* mem-break.c (add_breakpoint_condition, add_breakpoint_commands):
	Check if the condition or command is NULL before checking if the
	breakpoint is known.  On success, return true.
	* mem-break.h (add_breakpoint_condition): Document return.
	(add_breakpoint_commands): Add describing comment.
	* server.c (skip_to_semicolon): New function.
	(process_point_options): Use it.

gdb/testsuite/
2014-04-10  Pedro Alves  <palves@redhat.com>

	* gdb.base/cond-eval-mode.c: New file.
	* gdb.base/cond-eval-mode.exp: Use standard_testfile.  Adjust
	prepare_for_testing to build the new file.  Check result of
	runto_main.
	(test_break, test_watch): New procedures.
	(top level): Use them.
2014-04-10 17:14:12 +01:00
Pedro Alves 9d497a19ea breakpoint shadowing, take single-step breakpoints into account.
Breakpoints are supposed to be transparent to memory accesses.  For
all kinds of breakpoints breakpoint_xfer_memory hides the breakpoint
instructions.  However, sss breakpoints aren't tracked like all other
breakpoints, and nothing is taking care of hiding them from memory
reads.

Say, as is, a background step + disassemble will see breakpoints
instructions on software step targets.  E.g., stepping over this line:

  while (1);

with s&

and then "disassemble" would show sss breakpoints.

Actually, that's still not be possible to see today, because:

 - in native Linux, you can't read memory while the program
   is running.
 - with Linux gdbserver, you can, but in the all-stop RSP you
   can't talk to the server while the program is running...
 - and with non-stop, on software step targets, we presently
   force the use of displaced-stepping for all single-steps,
   so no single-step breakpoints are used...

I've been working towards making non-stop not force displaced stepping
on sss targets, and I noticed the issue then.  With that, I indeed see
this:

(gdb) set remote Z-packet off
(gdb) s&
(gdb) disassemble main
Dump of assembler code for function main:
   0x000000000040049c <+0>:     push   %rbp
   0x000000000040049d <+1>:     mov    %rsp,%rbp
   0x00000000004004a0 <+4>:     int3
   0x00000000004004a1 <+5>:     (bad)
End of assembler dump.

Instead of the correct:

(gdb) disassemble main
Dump of assembler code for function main:
   0x000000000040049c <+0>:     push   %rbp
   0x000000000040049d <+1>:     mov    %rsp,%rbp
   0x00000000004004a0 <+4>:     jmp    0x4004a0 <main+4>

This is actually one thing that my v1 of the recent "fix a bunch of
run control bugs" series was fixing, because it made sss breakpoints
be regular breakpoints in the breakpoint chain.  But dropped it in the
version that landed in the tree, due to some problems.

So instead of making sss breakpoints regular breakpoints, go with a
simpler fix (at least for now) -- make breakpoint_xfer_memory take
software single-step breakpoints into account.  After the patch, I get
the correct disassemble output.

Tested on x86_64 Fedora 17, and also on top of my "use software
single-step on x86" series.

Also fixes the issue pointed out by Yao at
https://sourceware.org/ml/gdb-patches/2014-04/msg00045.html, where the
prologue analysis/frame sniffing manages to see software step
breakpoint instructions.

gdb/
2014-04-10  Pedro Alves  <palves@redhat.com>

	* breakpoint.c (single_step_breakpoints)
	(single_step_gdbarch): Move up in the file.
	(one_breakpoint_xfer_memory): New function, factored out from ...
	(breakpoint_xfer_memory): ... here.  Also process single-step
	breakpoints.
2014-04-10 14:19:52 +01:00
Pedro Alves 2eec7d5ba1 [GDBserver] Fix SH/Linux build.
sh-linux-gnu-gcc (...) src/gdb/gdbserver/linux-low.c
 .../src/gdb/gdbserver/linux-low.c: In function 'linux_read_loadmap':
 .../src/gdb/gdbserver/linux-low.c:5284:13: error: 'struct lwp_info' has no member named 'entry'
 make[1]: *** [linux-low.o] Error 1

gdb/gdbserver/
2014-04-09  Pedro Alves  <palves@redhat.com>

	* linux-low.c (linux_read_loadmap): Pass current_inferior directly
	to lwpid_of.
2014-04-09 16:12:33 +01:00
Tristan Gingold 15a9128a96 darwin: fix thinko (free thread port after threads are discovered).
Due to a thinko, a message could be not understood and ignored.  The result
was a dead-lock (gdb is waiting for an event that never happen).  The port
of the thread was deallocated before new threads are discovered.  As a
consequence, the origin of the message was unknown (instead of being
linked to the newly created thread).

gdb/
	* darwin-nat.c (darwin_check_new_threads): Fix port leak, add
	comments.
	(darwin_decode_exception_message): Free port only after use.
2014-04-09 10:23:19 +02:00
Pierre Langlois 9c97a0704e Fix erroneous backtrace on avrxmega architectures.
* avr-tdep.c (struct gdbarch_tdep): Mention avrxmega in the comment.
	(avr_gdbarch_init): Add xmega architectures given by bfd_architecture
	when setting the size of call_length.
2014-04-08 18:04:25 +01:00
Pierre Muller ae1d276159 [testsuite] Disable Ctrl-V use for mingw hosts.
On mingw host, we have seen two fails as below,

p int1dim[0]^V@2
Invalid character '^V' in expression.
(gdb) FAIL: gdb.base/printcmds.exp: p int1dim[0]@2
p int1dim[0]^V@2^V@3
Invalid character '^V' in expression.
(gdb) FAIL: gdb.base/printcmds.exp: p int1dim[0]@2@3

In the test, the comment says "# Send \026@ instead of just @ in case
the kill character is @".  Historically, kill character was @, and
Ctrl-V (\026) is to escape the next character.  However, we don't have
to do so on mingw.  This patch is to disable ctrl-v usage on mingw
hots.  With this patch applied, it becomes:

p int1dim[0]@2
$607 = {0, 1}
(gdb) PASS: gdb.base/printcmds.exp: p int1dim[0]@2
p int1dim[0]@2@3
$608 = {{0, 1}, {2, 3}, {4, 5}}

Note that this patch is picked from Pierre's submission,

  [RFC 6/6] Fix remaining failures in gdb.base/printcmds.exp for mingw hosts.
  https://www.sourceware.org/ml/gdb-patches/2013-09/msg00943.html

gdb/testsuite:

2014-04-08  Pierre Muller  <muller@sourceware.org>

	* gdb.base/printcmds.exp (test_artificial_arrays): Disable
	Ctrl-V use for mingw hosts.
2014-04-08 14:07:28 +08:00
Siva Chandra 7af389b892 [python] Fix gdb.Value.dynamic_type for reference values.
gdb.Value.dynamic_type is supposed to work for reference and pointer
values.  However, the value object in the function 'valpy_get_dynamic_type'
was being dereferenced using 'value_ind' irrespective of the value type
being TYPE_CODE_PTR or TYPE_CODE_REF.  This patch fixes that to use
'coerce_ref' for TYPE_CODE_REF values.

ChangeLog:

	* python/py-value.c (valpy_get_dynamic_type): Use coerce_ref to
	dereference TYPE_CODE_REF values.

	testsuite/
	* gdb.python/py-value.c: Improve test case.
	* gdb.python/py-value.exp: Add new test.
2014-04-07 14:18:44 -07:00
Doug Evans 5e70318114 Add support to recognize clang.
* lib/compiler.c: Identify the clang compiler.
	* lib/compiler.cc: Ditto.
2014-04-07 14:14:03 -07:00
Joel Brobecker 86ad98c392 Fix ARI warning in darwin-nat.c::darwin_decode_message
gdb/ChangeLog:

        * darwin-nat.c (darwin_decode_message): Remove trailing '\n' at
        end of warning message.
2014-04-07 09:44:40 -07:00
Doug Evans c54a1dd8a2 (read_cutu_die_from_dwo): Update function comment to match previous change. 2014-04-03 12:11:58 -07:00
Doug Evans b0aeadb398 * dwarf2read.c (read_cutu_die_from_dwo): Fix assertion, at most one
of stub_comp_unit_die, stub_comp_dir is non-NULL.
2014-04-03 12:07:25 -07:00
Yao Qi 9810b41048 Escape backslash in windows path
Hi,
On windows host, we see the following ERROR,

(gdb) PASS: gdb.base/setshow.exp: set history filename ~/foobar.baz
ERROR OCCURED: couldn't compile regular expression pattern: invalid escape \ seq
uence
    while executing
"expect -nobrace -i exp13 -timeout 10 -re {.*A problem internal to GDB has been
detected} {
	    fail "$message (GDB internal error)"
	    gdb_internal..."
    invoked from within
"expect {
-i exp13 -timeout 10
	-re ".*A problem internal to GDB has been detected" {
	    fail "$message (GDB internal error)"
	    gdb_internal_erro..."
    ("uplevel" body line 1)
    invoked from within
"uplevel $body" REGEXP REG_EESCAPE {invalid escape \ sequence} couldn't compile
regular expression pattern: invalid escape \ sequenceERROR: Process no longer ex
ists

which leads to
UNRESOLVED: gdb.base/setshow.exp: show history filename (~/foobar.baz)

and this error is thrown from this test below:

gdb_test "show history filename" \
    "The filename in which to record the command history is \"$HOME/foobar.baz\"..*" \
    "show history filename (~/foobar.baz)"

HOME is a windows path, like C:\foo\bar.  When it is used in gdb_test to match
output, the error is thrown because backslash is a special character in
regular expression.  This patch is to escape backslash to fix this
error by using string_to_regexp.

gdb/testsuite:

2014-04-03  Yao Qi  <yao@codesourcery.com>

	* gdb.base/setshow.exp: Invoke string_to_regexp to HOME and PWD.
2014-04-03 14:51:40 +08:00
Alan Modra 5979d6b69b Handle VDSO section headers past end of page
When a VDSO gets large enough that it doesn't entirely fit in one page,
but not so large that the part described by the program header exceeds
one page, then gdb/BFD doesn't read the section headers and symbol
table information.  This patch cures that by passing the size of the
vdso to BFD, and fixes a number of other issues in the BFD code.

bfd/
	* elfcode.h (bfd_from_remote_memory): Add "size" parameter.
	Consolidate code handling possible section headers past end of
	segment.  Don't use p_align for page size guess, instead use
	minpagesize.  Take note of ld.so clearing section headers when
	p_memsz > p_filesz.  Handle file header specifying no section
	headers.  Handle zero p_align throughout.  Default loadbase to
	zero.  Add comments.  Rename contents_size to high_offset, and
	make it a bfd_vma.  Delete unnecessary bfd_set_error calls.
	* bfd-in.h (bfd_elf_bfd_from_remote_memory): Update prototpe.
	* elf-bfd.h (struct elf_backend_data <elf_backend_from_remote_memory>):
	Likewise.
	(_bfd_elf32_bfd_from_remote_memory): Likewise.
	(_bfd_elf64_bfd_from_remote_memory): Likewise.
	* elf.c (bfd_elf_bfd_from_remote_memory): Adjust.
	* bfd-in2.h: Regnerate.
gdb/
	* symfile-mem.c (symbol_file_add_from_memory): Add size parameter.
	Pass to bfd_elf_bfd_from_remote_memory.  Adjust all callers.
	(struct symbol_file_add_from_memory_args): Add size field.
	(find_vdso_size): New function.
	(add_vsyscall_page): Attempt to find vdso size.
2014-04-02 12:07:33 +10:30