Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Keith Seitz <keiths@redhat.com>
To: Artemiy Volkov <artemiyv@acm.org>, gdb-patches@sourceware.org
Subject: Re: [PATCH v2 10/11] [PR gdb/14441] gdb: python: support rvalue references in the gdb module
Date: Fri, 19 Feb 2016 19:48:00 -0000	[thread overview]
Message-ID: <56C7716D.60409@redhat.com> (raw)
In-Reply-To: <1453229609-20159-11-git-send-email-artemiyv@acm.org>

On 01/19/2016 10:53 AM, Artemiy Volkov wrote:
> This patch adds the ability to inspect rvalue reference types and values using
> the gdb python module. Changes include the RvalueReferenceExplorer method
> providing mechanism to get a type and a referenced value for an rvalue
> reference object, and the valpy_rvalue_reference_value() function used
> to create an rvalue reference to an object of any type.
> 
> ./ChangeLog:
> 
> 2016-01-19  Artemiy Volkov  <artemiyv@acm.org>
> 
>         * gdb/python/lib/gdb/command/explore.py: Add
>         RvalueReferenceExplorer class.

The usual way to do this would be to mention the class first:

	* python/lib/gdb/command/explore.py
	(RvalueReferenceExplorer): New class.

But more on this later...

>         * gdb/python/lib/gdb/types.py: Implement get_basic_type() for
>         rvalue reference types.

Similarly,

	* python/lib/gdb/types.py (get_basic_type): Handle
	TYPE_CODE_RVALUE_REFERENCE.

>         * gdb/python/py-type.c: Add TYPE_CODE_RVALUE_REF to pyty_codes.

I would do the same here, too.

>         * gdb/python/py-value.c (valpy_rvalue_reference_value): Add value
>         getter function.
> ---
>  gdb/python/lib/gdb/command/explore.py | 21 +++++++++++++++++++++
>  gdb/python/lib/gdb/types.py           |  4 +++-
>  gdb/python/py-type.c                  |  1 +
>  gdb/python/py-value.c                 | 26 ++++++++++++++++++++++++++
>  4 files changed, 51 insertions(+), 1 deletion(-)
> 
> diff --git a/gdb/python/lib/gdb/command/explore.py b/gdb/python/lib/gdb/command/explore.py
> index 6c9f17b..a980274 100644
> --- a/gdb/python/lib/gdb/command/explore.py
> +++ b/gdb/python/lib/gdb/command/explore.py
> @@ -318,6 +319,26 @@ class ReferenceExplorer(object):
>          Explorer.explore_type(name, target_type, is_child)
>          return False
>  
> +class RvalueReferenceExplorer(object):
> +    """Internal class used to explore rvalue reference (TYPE_CODE_RVALUE_REF) values."""
> +
> +    @staticmethod
> +    def explore_expr(expr, value, is_child):
> +        """Function to explore array values.
> +        See Explorer.explore_expr for more information.
> +        """
> +        referenced_value = value.referenced_value()
> +        Explorer.explore_expr(expr, referenced_value, is_child)
> +        return False
> +
> +    @staticmethod
> +    def explore_type(name, datatype, is_child):
> +        """Function to explore pointer types.
> +        See Explorer.explore_type for more information.
> +        """
> +        target_type = datatype.target()
> +        Explorer.explore_type(name, target_type, is_child)
> +        return False

I'm not all that familiar with python, but is there a reason for this to
be a new class? It looks identical to ReferenceExplorer?

>  class ArrayExplorer(object):
>      """Internal class used to explore arrays."""
> diff --git a/gdb/python/py-value.c b/gdb/python/py-value.c
> index 81d1225..dcc0cf9 100644
> --- a/gdb/python/py-value.c
> +++ b/gdb/python/py-value.c
> @@ -263,6 +263,30 @@ valpy_reference_value (PyObject *self, PyObject *args)
>    return result;
>  }
>  
> +/* Return a value which is an rvalue reference to the value.  */
> +
> +static PyObject *
> +valpy_rvalue_reference_value (PyObject *self, PyObject *args)
> +{
> +  PyObject *result = NULL;
> +
> +  TRY
> +    {
> +      struct value *self_val;
> +      struct cleanup *cleanup = make_cleanup_value_free_to_mark (value_mark ());
> +
> +      self_val = ((value_object *) self)->value;
> +      result = value_to_value_object (value_ref (self_val, TYPE_CODE_RVALUE_REF));
> +      do_cleanups (cleanup);
> +    }
> +  CATCH (except, RETURN_MASK_ALL)
> +    {
> +      GDB_PY_HANDLE_EXCEPTION (except);
> +    }
> +  END_CATCH
> +
> +  return result;
> +}
>  /* Return a "const" qualified version of the value.  */
>  
>  static PyObject *
> @@ -1778,6 +1802,8 @@ reinterpret_cast operator."
>      "Return the value referenced by a TYPE_CODE_REF or TYPE_CODE_PTR value." },
>    { "reference_value", valpy_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,

Same question here...

rvalue_reference_value/valpy_rvalue_reference_value have nearly
identical implementations as reference_value/valpy_reference_value.

Does TYPE_CODE (value_type (self_val)) not tell us which of the types we
are looking at? If so, I think it would be better to unify reference
handling into a common implementation, noting that the class handles
both types of references.

Keith


  reply	other threads:[~2016-02-19 19:48 UTC|newest]

Thread overview: 108+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-20 22:35 [PATCH 00/11] [PR gdb/14441] Support C++0x rvalue references in gdb Artemiy Volkov
2015-12-20 22:35 ` [PATCH 01/11] [PR gdb/14441] gdb: gdbtypes: add definitions for rvalue reference type Artemiy Volkov
2015-12-20 22:35 ` [PATCH 09/11] [PR gdb/14441] gdb: gdbtypes: add rvalue references to overloading resolution Artemiy Volkov
2015-12-20 22:35 ` [PATCH 05/11] [PR gdb/14441] gdb: demangle: implement demangling for rvalue reference typenames Artemiy Volkov
2015-12-30 19:17   ` Pedro Alves
2015-12-20 22:35 ` [PATCH 11/11] [PR gdb/14441] gdb: testsuite: add rvalue reference tests Artemiy Volkov
2015-12-20 22:35 ` [PATCH 10/11] [PR gdb/14441] gdb: python: support rvalue references in the gdb module Artemiy Volkov
2015-12-20 22:35 ` [PATCH 08/11] [PR gdb/14441] gdb: convert lvalue reference type check to general reference type check Artemiy Volkov
2015-12-20 22:35 ` [PATCH 03/11] [PR gdb/14441] gdb: valops: add ability to return rvalue reference values from value_ref() Artemiy Volkov
2015-12-20 22:35 ` [PATCH 07/11] [PR gdb/14441] gdb: dwarf2read: support DW_AT_rvalue_reference type Artemiy Volkov
2015-12-20 22:35 ` [PATCH 04/11] [PR gdb/14441] gdb: parse: support rvalue reference type Artemiy Volkov
2015-12-20 22:35 ` [PATCH 06/11] [PR gdb/14441] gdb: print: implement correct printing of rvalue reference types and values Artemiy Volkov
2015-12-20 22:35 ` [PATCH 02/11] [PR gdb/14441] gdb: gdbtypes: change {lookup,make}_reference_type() API Artemiy Volkov
2015-12-28 21:09 ` [PATCH 00/11] [PR gdb/14441] Support C++0x rvalue references in gdb Artemiy Volkov
2016-01-20  9:42   ` Yao Qi
2016-01-19 18:54 ` [PATCH v2 " Artemiy Volkov
2016-01-19 18:54   ` [PATCH v2 06/11] [PR gdb/14441] gdb: print: implement correct printing of rvalue reference types and values Artemiy Volkov
2016-02-19 18:56     ` Keith Seitz
2016-01-19 18:54   ` [PATCH v2 03/11] [PR gdb/14441] gdb: valops: add ability to return rvalue reference values from value_ref() Artemiy Volkov
2016-02-19 18:52     ` Keith Seitz
2016-01-19 18:54   ` [PATCH v2 01/11] [PR gdb/14441] gdb: gdbtypes: add definitions for rvalue reference type Artemiy Volkov
2016-02-19 18:49     ` Keith Seitz
2016-02-23  7:04       ` Artemiy Volkov
2016-02-25  1:22         ` Keith Seitz
2016-02-25  1:32           ` Artemiy Volkov
2016-02-25  1:41             ` Keith Seitz
2016-02-25  1:45               ` Artemiy Volkov
2016-01-19 18:54   ` [PATCH v2 04/11] [PR gdb/14441] gdb: parse: support " Artemiy Volkov
2016-02-19 18:53     ` Keith Seitz
2016-01-19 18:54   ` [PATCH v2 02/11] [PR gdb/14441] gdb: gdbtypes: change {lookup,make}_reference_type() API Artemiy Volkov
2016-02-19 18:50     ` Keith Seitz
2016-01-19 18:54   ` [PATCH v2 05/11] [PR gdb/14441] gdb: demangle: implement demangling for rvalue reference typenames Artemiy Volkov
2016-02-19 18:54     ` Keith Seitz
2016-01-19 18:55   ` [PATCH v2 07/11] [PR gdb/14441] gdb: dwarf2read: support DW_AT_rvalue_reference type Artemiy Volkov
2016-02-19 18:57     ` Keith Seitz
2016-01-19 18:55   ` [PATCH v2 08/11] [PR gdb/14441] gdb: convert lvalue reference type check to general reference type check Artemiy Volkov
2016-02-19 19:01     ` Keith Seitz
2016-02-26  5:08       ` Artemiy Volkov
2016-01-19 18:55   ` [PATCH v2 09/11] [PR gdb/14441] gdb: gdbtypes: add rvalue references to overloading resolution Artemiy Volkov
2016-02-19 19:46     ` Keith Seitz
2016-01-19 18:55   ` [PATCH v2 10/11] [PR gdb/14441] gdb: python: support rvalue references in the gdb module Artemiy Volkov
2016-02-19 19:48     ` Keith Seitz [this message]
2016-01-19 18:55   ` [PATCH v2 11/11] [PR gdb/14441] gdb: testsuite: add rvalue reference tests Artemiy Volkov
2016-02-19 20:05     ` Keith Seitz
2016-02-19 18:49   ` [PATCH v2 00/11] [PR gdb/14441] Support C++0x rvalue references in gdb Keith Seitz
2016-02-23  6:04     ` Artemiy Volkov
2016-03-05  3:20   ` [PATCH v3 " Artemiy Volkov
2016-03-05  3:20     ` [PATCH v3 03/11] [PR gdb/14441] gdb: valops: add ability to return rvalue reference values from value_ref() Artemiy Volkov
2016-03-16 22:22       ` Keith Seitz
2016-03-05  3:20     ` [PATCH v3 11/11] [PR gdb/14441] gdb: testsuite: add rvalue reference tests Artemiy Volkov
2016-03-16 22:48       ` Keith Seitz
2016-03-05  3:20     ` [PATCH v3 10/11] [PR gdb/14441] gdb: gdbtypes: add rvalue references to overloading resolution Artemiy Volkov
2016-03-16 22:45       ` Keith Seitz
2016-03-05  3:20     ` [PATCH v3 07/11] [PR gdb/14441] gdb: dwarf2read: support DW_AT_rvalue_reference type Artemiy Volkov
2016-03-16 22:28       ` Keith Seitz
2016-03-05  3:20     ` [PATCH v3 04/11] [PR gdb/14441] gdb: parse: support rvalue reference type Artemiy Volkov
2016-03-16 22:23       ` Keith Seitz
2016-03-05  3:20     ` [PATCH v3 09/11] [PR gdb/14441] gdb: convert lvalue reference type check to general reference type check Artemiy Volkov
2016-03-16 22:41       ` Keith Seitz
2016-03-05  3:20     ` [PATCH v3 01/11] [PR gdb/14441] gdb: gdbtypes: add definitions for rvalue reference type Artemiy Volkov
2016-03-16 22:08       ` Keith Seitz
2016-03-05  3:20     ` [PATCH v3 06/11] [PR gdb/14441] gdb: print: implement correct printing of rvalue reference types and values Artemiy Volkov
2016-03-16 22:26       ` Keith Seitz
2016-03-05  3:20     ` [PATCH v3 05/11] [PR gdb/14441] gdb: demangle: implement demangling for rvalue reference typenames Artemiy Volkov
2016-03-16 22:25       ` Keith Seitz
2016-03-05  3:20     ` [PATCH v3 08/11] [PR gdb/14441] gdb: python: support rvalue references in the gdb module Artemiy Volkov
2016-03-16 22:32       ` Keith Seitz
2016-03-05  3:20     ` [PATCH v3 02/11] [PR gdb/14441] gdb: gdbtypes: change {lookup,make}_reference_type() API Artemiy Volkov
2016-03-16 22:19       ` Keith Seitz
2016-03-20 12:10         ` Artemiy Volkov
2016-03-21 21:02     ` [PATCH v4 00/11] [PR gdb/14441] Support C++0x rvalue references in gdb Artemiy Volkov
2016-03-21 21:02       ` [PATCH v4 08/11] [PR gdb/14441] gdb: python: support rvalue references in the gdb module Artemiy Volkov
2016-03-31 20:35         ` Keith Seitz
2016-04-02  8:28           ` Artemiy Volkov
2016-04-02  8:45             ` Artemiy Volkov
2016-03-21 21:02       ` [PATCH v4 06/11] [PR gdb/14441] gdb: print: implement correct printing of rvalue reference types and values Artemiy Volkov
2016-03-21 21:02       ` [PATCH v4 07/11] [PR gdb/14441] gdb: dwarf2read: support DW_TAG_rvalue_reference type Artemiy Volkov
2016-03-21 21:02       ` [PATCH v4 01/11] [PR gdb/14441] gdb: gdbtypes: add definitions for rvalue reference type Artemiy Volkov
2016-03-21 21:02       ` [PATCH v4 02/11] [PR gdb/14441] gdb: gdbtypes: change {lookup,make}_reference_type() API Artemiy Volkov
2016-03-21 21:02       ` [PATCH v4 03/11] [PR gdb/14441] gdb: valops: add ability to return rvalue reference values from value_ref() Artemiy Volkov
2016-03-21 21:02       ` [PATCH v4 04/11] [PR gdb/14441] gdb: parse: support rvalue reference type Artemiy Volkov
2016-03-21 21:03       ` [PATCH v4 11/11] [PR gdb/14441] gdb: testsuite: add rvalue reference tests Artemiy Volkov
2016-03-21 21:03       ` [PATCH v4 05/11] [PR gdb/14441] gdb: demangle: implement demangling for rvalue reference typenames Artemiy Volkov
2016-03-21 21:03       ` [PATCH v4 09/11] [PR gdb/14441] gdb: convert lvalue reference type check to general reference type check Artemiy Volkov
2016-03-31 20:37         ` Keith Seitz
2016-04-02  8:42           ` Artemiy Volkov
2016-03-21 21:15       ` [PATCH v4 10/11] [PR gdb/14441] gdb: gdbtypes: add rvalue references to overloading resolution Artemiy Volkov
2016-03-31 20:35       ` [PATCH v4 00/11] [PR gdb/14441] Support C++0x rvalue references in gdb Keith Seitz
2016-04-02  8:48         ` Artemiy Volkov
2016-04-05 18:23           ` Pedro Alves
     [not found]             ` <20160406083016.GA31849@gmail.com>
2016-04-12 11:49               ` Pedro Alves
2016-04-19 15:51                 ` Artemiy Volkov
2016-04-22 11:31                   ` Pedro Alves
2016-06-06 19:22       ` [PATCH v5 00/11] [PR gdb/14441] Support C++11 " Artemiy Volkov
2016-06-06 19:23         ` [PATCH v5 11/11] [PR gdb/14441] gdb: testsuite: add rvalue reference tests Artemiy Volkov
2016-06-20 19:04           ` Pedro Alves
2016-06-06 19:23         ` [PATCH v5 07/11] [PR gdb/14441] gdb: dwarf2read: support DW_TAG_rvalue_reference type Artemiy Volkov
2016-06-06 19:23         ` [PATCH v5 02/11] [PR gdb/14441] gdb: gdbtypes: change {lookup,make}_reference_type() API Artemiy Volkov
2016-06-06 19:23         ` [PATCH v5 01/11] [PR gdb/14441] gdb: gdbtypes: add definitions for rvalue reference type Artemiy Volkov
2016-06-06 19:23         ` [PATCH v5 06/11] [PR gdb/14441] gdb: print: implement correct printing of rvalue reference types and values Artemiy Volkov
2016-06-06 19:23         ` [PATCH v5 04/11] [PR gdb/14441] gdb: parse: support rvalue reference type Artemiy Volkov
2016-06-06 19:23         ` [PATCH v5 05/11] [PR gdb/14441] gdb: demangle: implement demangling for rvalue reference typenames Artemiy Volkov
2016-06-06 19:23         ` [PATCH v5 09/11] [PR gdb/14441] gdb: convert lvalue reference type check to general reference type check Artemiy Volkov
2016-06-06 19:23         ` [PATCH v5 08/11] [PR gdb/14441] gdb: python: support rvalue references in the gdb module Artemiy Volkov
2016-06-20 19:07           ` Pedro Alves
2016-06-06 19:23         ` [PATCH v5 10/11] [PR gdb/14441] gdb: gdbtypes: add rvalue references to overloading resolution Artemiy Volkov
2016-06-06 19:23         ` [PATCH v5 03/11] [PR gdb/14441] gdb: valops: add ability to return rvalue reference values from value_ref() Artemiy Volkov
2016-06-19 15:08         ` [PATCH v5 00/11] [PR gdb/14441] Support C++11 rvalue references in gdb Artemiy Volkov

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=56C7716D.60409@redhat.com \
    --to=keiths@redhat.com \
    --cc=artemiyv@acm.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