[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.
This commit is contained in:
Siva Chandra 2014-03-21 06:42:50 -07:00
parent 5e70318114
commit 7af389b892
5 changed files with 18 additions and 1 deletions

View file

@ -309,7 +309,10 @@ valpy_get_dynamic_type (PyObject *self, void *closure)
struct value *target;
int was_pointer = TYPE_CODE (type) == TYPE_CODE_PTR;
target = value_ind (val);
if (was_pointer)
target = value_ind (val);
else
target = coerce_ref (val);
type = value_rtti_type (target, NULL, NULL, NULL);
if (type)