From: Keith Seitz <keiths@redhat.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH v6 08/11] Support rvalue references in the gdb python module (includes doc/)
Date: Tue, 14 Mar 2017 18:14:00 -0000 [thread overview]
Message-ID: <58C8330B.3010702@redhat.com> (raw)
In-Reply-To: <83k27weqks.fsf@gnu.org>
On 03/10/2017 02:04 PM, Eli Zaretskii wrote:
>> From: Keith Seitz <keiths@redhat.com>
>> Date: Fri, 10 Mar 2017 12:04:43 -0800
>>
>> diff --git a/gdb/doc/python.texi b/gdb/doc/python.texi
>> index c3ea203..d463afe 100644
>> --- a/gdb/doc/python.texi
>> +++ b/gdb/doc/python.texi
>> @@ -1162,6 +1162,10 @@ A pointer-to-member.
>> @item gdb.TYPE_CODE_REF
>> A reference type.
>>
>> +@vindex TYPE_CODE_RVALUE_REF
>> +@item gdb.TYPE_CODE_RVALUE_REF
>> +An rvalue reference type.
>
> Thanks. However, I'm not sure this is enough to explain to the reader
> what this is about. At the very least, the text should mention C++.
>
I've added that this is a C++11 feature. Updated patch below.
Thanks again!
Keith
> commit 731f0b2600518fce3ec1a94a9a53483bb29f3be3
> Author: Artemiy Volkov <artemiyv@acm.org>
> Date: Tue Mar 7 15:05:51 2017 -0800
>
> Support rvalue references in the gdb python module (includes doc/)
>
> This patch adds the ability to inspect rvalue reference types and values using
> the gdb python module. This is achieved by creating two wrappers for
> valpy_reference_value(), using the ReferenceExplorer class to handle the
> objects of rvalue reference types and placing necessary checks for a
> TYPE_CODE_RVALUE_REF type code next to the checks for a TYPE_CODE_REF type
> code.
>
> gdb/ChangeLog
>
> PR gdb/14441
> * doc/python.texi (Types in Python): Add TYPE_CODE_RVALUE_REF to
> table of constants.
> * python/lib/gdb/command/explore.py: Support exploring values
> of rvalue reference types.
> * python/lib/gdb/types.py: Implement get_basic_type() for
> rvalue reference types.
> * python/py-type.c (pyty_codes) <TYPE_CODE_RVALUE_REF>: New
> constant.
> * python/py-value.c (valpy_getitem): Add an rvalue reference
> check.
> (valpy_reference_value): Add new parameter "refcode".
> (valpy_lvalue_reference_value, valpy_rvalue_reference_value):
> New wrappers for valpy_reference_value().
> * python/py-xmethods.c (gdbpy_get_xmethod_result_type)
> (gdbpy_invoke_xmethod): Likewise.
>
> diff --git a/gdb/ChangeLog b/gdb/ChangeLog
> index 9670b14..20ca925 100644
> --- a/gdb/ChangeLog
> +++ b/gdb/ChangeLog
> @@ -1,6 +1,25 @@
> 2017-MM-DD Artemiy Volkov <artemiyv@acm.org>
>
> PR gdb/14441
> + * doc/python.texi (Types in Python): Add TYPE_CODE_RVALUE_REF to
> + table of constants.
> + * python/lib/gdb/command/explore.py: Support exploring values
> + of rvalue reference types.
> + * python/lib/gdb/types.py: Implement get_basic_type() for
> + rvalue reference types.
> + * python/py-type.c (pyty_codes) <TYPE_CODE_RVALUE_REF>: New
> + constant.
> + * python/py-value.c (valpy_getitem): Add an rvalue reference
> + check.
> + (valpy_reference_value): Add new parameter "refcode".
> + (valpy_lvalue_reference_value, valpy_rvalue_reference_value):
> + New wrappers for valpy_reference_value().
> + * python/py-xmethods.c (gdbpy_get_xmethod_result_type)
> + (gdbpy_invoke_xmethod): Likewise.
> +
> +2017-MM-DD Artemiy Volkov <artemiyv@acm.org>
> +
> + PR gdb/14441
> * dwarf2read.c (process_die, read_type_die_1): Handle the
> DW_TAG_rvalue_reference_type DIE.
> (read_tag_reference_type): Add new parameter "refcode".
> diff --git a/gdb/doc/python.texi b/gdb/doc/python.texi
> index c3ea203..15ff2a2 100644
> --- a/gdb/doc/python.texi
> +++ b/gdb/doc/python.texi
> @@ -1162,6 +1162,10 @@ A pointer-to-member.
> @item gdb.TYPE_CODE_REF
> A reference type.
>
> +@vindex TYPE_CODE_RVALUE_REF
> +@item gdb.TYPE_CODE_RVALUE_REF
> +A C@t{++}11 rvalue reference type.
> +
> @vindex TYPE_CODE_CHAR
> @item gdb.TYPE_CODE_CHAR
> A character type.
> diff --git a/gdb/python/lib/gdb/command/explore.py b/gdb/python/lib/gdb/command/explore.py
> index b2878b9..4eb2e24 100644
> --- a/gdb/python/lib/gdb/command/explore.py
> +++ b/gdb/python/lib/gdb/command/explore.py
> @@ -132,6 +132,7 @@ class Explorer(object):
> gdb.TYPE_CODE_UNION : CompoundExplorer,
> gdb.TYPE_CODE_PTR : PointerExplorer,
> gdb.TYPE_CODE_REF : ReferenceExplorer,
> + gdb.TYPE_CODE_RVALUE_REF : ReferenceExplorer,
> gdb.TYPE_CODE_TYPEDEF : TypedefExplorer,
> gdb.TYPE_CODE_ARRAY : ArrayExplorer
> }
> @@ -318,7 +319,6 @@ class ReferenceExplorer(object):
> Explorer.explore_type(name, target_type, is_child)
> return False
>
> -
> class ArrayExplorer(object):
> """Internal class used to explore arrays."""
>
> diff --git a/gdb/python/lib/gdb/types.py b/gdb/python/lib/gdb/types.py
> index 799a07d..26a5027 100644
> --- a/gdb/python/lib/gdb/types.py
> +++ b/gdb/python/lib/gdb/types.py
> @@ -31,8 +31,10 @@ def get_basic_type(type_):
> """
>
> while (type_.code == gdb.TYPE_CODE_REF or
> + type_.code == gdb.TYPE_CODE_RVALUE_REF or
> type_.code == gdb.TYPE_CODE_TYPEDEF):
> - if type_.code == gdb.TYPE_CODE_REF:
> + if (type_.code == gdb.TYPE_CODE_REF or
> + type_.code == gdb.TYPE_CODE_RVALUE_REF):
> type_ = type_.target()
> else:
> type_ = type_.strip_typedefs()
> diff --git a/gdb/python/py-type.c b/gdb/python/py-type.c
> index 0249cbb..c063d2c 100644
> --- a/gdb/python/py-type.c
> +++ b/gdb/python/py-type.c
> @@ -106,6 +106,7 @@ static struct pyty_code pyty_codes[] =
> ENTRY (TYPE_CODE_METHODPTR),
> ENTRY (TYPE_CODE_MEMBERPTR),
> ENTRY (TYPE_CODE_REF),
> + ENTRY (TYPE_CODE_RVALUE_REF),
> ENTRY (TYPE_CODE_CHAR),
> ENTRY (TYPE_CODE_BOOL),
> ENTRY (TYPE_CODE_COMPLEX),
> diff --git a/gdb/python/py-value.c b/gdb/python/py-value.c
> index c0199ea..aacf628 100644
> --- a/gdb/python/py-value.c
> +++ b/gdb/python/py-value.c
> @@ -238,7 +238,7 @@ valpy_referenced_value (PyObject *self, PyObject *args)
> /* Return a value which is a reference to the value. */
>
> static PyObject *
> -valpy_reference_value (PyObject *self, PyObject *args)
> +valpy_reference_value (PyObject *self, PyObject *args, enum type_code refcode)
> {
> PyObject *result = NULL;
>
> @@ -248,7 +248,7 @@ valpy_reference_value (PyObject *self, PyObject *args)
> scoped_value_mark free_values;
>
> self_val = ((value_object *) self)->value;
> - result = value_to_value_object (value_ref (self_val, TYPE_CODE_REF));
> + result = value_to_value_object (value_ref (self_val, refcode));
> }
> CATCH (except, RETURN_MASK_ALL)
> {
> @@ -259,6 +259,18 @@ valpy_reference_value (PyObject *self, PyObject *args)
> return result;
> }
>
> +static PyObject *
> +valpy_lvalue_reference_value (PyObject *self, PyObject *args)
> +{
> + return valpy_reference_value (self, args, TYPE_CODE_REF);
> +}
> +
> +static PyObject *
> +valpy_rvalue_reference_value (PyObject *self, PyObject *args)
> +{
> + return valpy_reference_value (self, args, TYPE_CODE_RVALUE_REF);
> +}
> +
> /* Return a "const" qualified version of the value. */
>
> static PyObject *
> @@ -585,8 +597,7 @@ value_has_field (struct value *v, PyObject *field)
> {
> val_type = value_type (v);
> val_type = check_typedef (val_type);
> - if (TYPE_CODE (val_type) == TYPE_CODE_REF
> - || TYPE_CODE (val_type) == TYPE_CODE_PTR)
> + if (TYPE_IS_REFERENCE (val_type) || TYPE_CODE (val_type) == TYPE_CODE_PTR)
> val_type = check_typedef (TYPE_TARGET_TYPE (val_type));
>
> type_code = TYPE_CODE (val_type);
> @@ -743,6 +754,9 @@ valpy_getitem (PyObject *self, PyObject *key)
> else if (TYPE_CODE (val_type) == TYPE_CODE_REF)
> res_val = value_cast (lookup_lvalue_reference_type (base_class_type),
> tmp);
> + else if (TYPE_CODE (val_type) == TYPE_CODE_RVALUE_REF)
> + res_val = value_cast (lookup_rvalue_reference_type (base_class_type),
> + tmp);
> else
> res_val = value_cast (base_class_type, tmp);
> }
> @@ -1724,8 +1738,10 @@ reinterpret_cast operator."
> { "dereference", valpy_dereference, METH_NOARGS, "Dereferences the value." },
> { "referenced_value", valpy_referenced_value, METH_NOARGS,
> "Return the value referenced by a TYPE_CODE_REF or TYPE_CODE_PTR value." },
> - { "reference_value", valpy_reference_value, METH_NOARGS,
> + { "reference_value", valpy_lvalue_reference_value, METH_NOARGS,
> "Return a value of type TYPE_CODE_REF referencing this value." },
> + { "rvalue_reference_value", valpy_rvalue_reference_value, METH_NOARGS,
> + "Return a value of type TYPE_CODE_RVALUE_REF referencing this value." },
> { "const_value", valpy_const_value, METH_NOARGS,
> "Return a 'const' qualied version of the same value." },
> { "lazy_string", (PyCFunction) valpy_lazy_string,
> diff --git a/gdb/python/py-xmethods.c b/gdb/python/py-xmethods.c
> index d01488f..e061da2 100644
> --- a/gdb/python/py-xmethods.c
> +++ b/gdb/python/py-xmethods.c
> @@ -464,9 +464,10 @@ gdbpy_get_xmethod_result_type (const struct extension_language_defn *extlang,
> if (!types_equal (obj_type, this_ptr))
> obj = value_cast (this_ptr, obj);
> }
> - else if (TYPE_CODE (obj_type) == TYPE_CODE_REF)
> + else if (TYPE_IS_REFERENCE (obj_type))
> {
> - struct type *this_ref = lookup_lvalue_reference_type (this_type);
> + struct type *this_ref
> + = lookup_reference_type (this_type, TYPE_CODE (obj_type));
>
> if (!types_equal (obj_type, this_ref))
> obj = value_cast (this_ref, obj);
next prev parent reply other threads:[~2017-03-14 18:14 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-10 20:04 [PATCH v6 00/11] c++/14441: Rvalue reference support Keith Seitz
2017-03-10 20:04 ` [PATCH v6 01/11] Add definitions for rvalue reference types Keith Seitz
2017-03-10 20:05 ` [PATCH v6 03/11] Add ability to return rvalue reference values from value_ref Keith Seitz
2017-03-10 20:05 ` [PATCH v6 11/11] Add rvalue reference tests and NEWS entry Keith Seitz
2017-03-10 22:02 ` Eli Zaretskii
2017-03-14 18:14 ` Keith Seitz
2017-03-17 17:06 ` Keith Seitz
2017-03-17 18:51 ` Eli Zaretskii
2017-03-13 18:52 ` Pedro Alves
2017-03-14 18:15 ` Keith Seitz
2017-03-14 18:39 ` Pedro Alves
2017-04-04 11:10 ` Yao Qi
2017-03-10 20:05 ` [PATCH v6 02/11] Change {lookup,make}_reference_type API Keith Seitz
2017-03-10 20:10 ` [PATCH v6 04/11] Support rvalue reference type in parser Keith Seitz
2017-03-10 20:10 ` [PATCH v6 05/11] Implement demangling for rvalue reference type names Keith Seitz
2017-03-10 20:10 ` [PATCH v6 08/11] Support rvalue references in the gdb python module (includes doc/) Keith Seitz
2017-03-10 22:04 ` Eli Zaretskii
2017-03-14 18:14 ` Keith Seitz [this message]
2017-03-17 17:06 ` Keith Seitz
2017-03-17 18:51 ` Eli Zaretskii
2017-03-10 20:10 ` [PATCH v6 07/11] Support DW_TAG_rvalue_reference type Keith Seitz
2017-03-10 20:10 ` [PATCH v6 06/11] Implement printing of rvalue reference types and values Keith Seitz
2017-03-10 20:12 ` [PATCH v6 09/11] Convert lvalue reference type check to general reference type check Keith Seitz
2017-03-10 20:14 ` [PATCH v6 10/11] Add rvalue references to overloading resolution Keith Seitz
2017-03-13 18:51 ` [PATCH v6 00/11] c++/14441: Rvalue reference support Pedro Alves
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=58C8330B.3010702@redhat.com \
--to=keiths@redhat.com \
--cc=eliz@gnu.org \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox