diff --git a/gdb/ChangeLog b/gdb/ChangeLog index e97559311ed..e2962c97de0 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2014-04-07 Siva Chandra Reddy + + * python/py-value.c (valpy_get_dynamic_type): Use coerce_ref to + dereference TYPE_CODE_REF values. + 2014-04-07 Joel Brobecker * darwin-nat.c (darwin_decode_message): Remove trailing '\n' at diff --git a/gdb/python/py-value.c b/gdb/python/py-value.c index a118f6ca739..54da67a226e 100644 --- a/gdb/python/py-value.c +++ b/gdb/python/py-value.c @@ -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) diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 991c4e81485..6826ec4bf65 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2014-04-07 Siva Chandra Reddy + + * gdb.python/py-value.c: Improve test case. + * gdb.python/py-value.exp: Add new test. + 2014-04-07 David Blaikie * lib/compiler.c: Identify the clang compiler. diff --git a/gdb/testsuite/gdb.python/py-value.c b/gdb/testsuite/gdb.python/py-value.c index 90dc055564e..4d1c9c6cb50 100644 --- a/gdb/testsuite/gdb.python/py-value.c +++ b/gdb/testsuite/gdb.python/py-value.c @@ -58,6 +58,8 @@ struct Derived : public Base { }; Base *base = new Derived (); +Derived derived; +Base &base_ref = derived; void ptr_ref(int*& rptr_int) { diff --git a/gdb/testsuite/gdb.python/py-value.exp b/gdb/testsuite/gdb.python/py-value.exp index ed332db92aa..13433fd9337 100644 --- a/gdb/testsuite/gdb.python/py-value.exp +++ b/gdb/testsuite/gdb.python/py-value.exp @@ -416,6 +416,8 @@ proc test_subscript_regression {exefile lang} { # Likewise. gdb_test "python print (gdb.parse_and_eval('base').dynamic_type)" \ "Derived \[*\]" + gdb_test "python print (gdb.parse_and_eval('base_ref').dynamic_type)" \ + "Derived \[&\]" # A static type case. gdb_test "python print (gdb.parse_and_eval('5').dynamic_type)" \ "int"