From: Doug Evans Date: Sat, 12 Apr 2014 16:09:41 +0000 (-0700) Subject: Copy over fix for fetching dynamic type of a reference from python side. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0be03e84176ab0077462b84ef236c56a7a0376fd;p=binutils-gdb.git 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. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 21844795889..83d75ac67fb 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2014-04-12 Siva Chandra Reddy + Doug Evans + + * guile/scm-value.c (gdbscm_value_dynamic_type): Use coerce_ref to + dereference TYPE_CODE_REF values. + 2014-04-11 Joel Brobecker Revert the following changes due to regressions: diff --git a/gdb/guile/scm-value.c b/gdb/guile/scm-value.c index 8ca076211c4..2160a1eceff 100644 --- a/gdb/guile/scm-value.c +++ b/gdb/guile/scm-value.c @@ -585,7 +585,10 @@ gdbscm_value_dynamic_type (SCM self) struct value *target; int was_pointer = TYPE_CODE (type) == TYPE_CODE_PTR; - target = value_ind (value); + if (was_pointer) + target = value_ind (value); + else + target = coerce_ref (value); type = value_rtti_type (target, NULL, NULL, NULL); if (type) diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index f7a4b8e3fcb..730c116cefd 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2014-04-12 Siva Chandra Reddy + Doug Evans + + * gdb.guile/scm-value.c: Improve test case. + * gdb.guile/scm-value.exp: Add new test. + 2014-04-11 David Blaikie * gdb.opt/inline-break.exp: Explicitly specify -std=gnu89 to diff --git a/gdb/testsuite/gdb.guile/scm-value.c b/gdb/testsuite/gdb.guile/scm-value.c index 3c61911aaac..e4f75303222 100644 --- a/gdb/testsuite/gdb.guile/scm-value.c +++ b/gdb/testsuite/gdb.guile/scm-value.c @@ -49,6 +49,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.guile/scm-value.exp b/gdb/testsuite/gdb.guile/scm-value.exp index 0bcd3816c62..2784da2e27d 100644 --- a/gdb/testsuite/gdb.guile/scm-value.exp +++ b/gdb/testsuite/gdb.guile/scm-value.exp @@ -335,6 +335,8 @@ proc test_subscript_regression {exefile lang} { # Likewise. gdb_test "gu (print (value-dynamic-type (parse-and-eval \"base\")))" \ "= Derived \[*\]" + gdb_test "gu (print (value-dynamic-type (parse-and-eval \"base_ref\")))" \ + "= Derived \[&\]" # A static type case. gdb_test "gu (print (value-dynamic-type (parse-and-eval \"5\")))" \ "= int"