From patchwork Sat Apr 2 08:44:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artemiy Volkov X-Patchwork-Id: 11601 Received: (qmail 80146 invoked by alias); 2 Apr 2016 08:45:37 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 80135 invoked by uid 89); 2 Apr 2016 08:45:35 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-lf0-f65.google.com Received: from mail-lf0-f65.google.com (HELO mail-lf0-f65.google.com) (209.85.215.65) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Sat, 02 Apr 2016 08:45:25 +0000 Received: by mail-lf0-f65.google.com with SMTP id p81so8210376lfb.3 for ; Sat, 02 Apr 2016 01:45:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to:user-agent; bh=+AP3sGAPANzs8yv/ueK5JRipyfXCeA6D3YWSABgPM4Y=; b=cZi2l4DT+PdwPECIaV7U1zs90spO0LQJRK6DDRlZp5HF7n9cbkZP8T3h7KTtTW6p+H BWfqAOWzKZvYxdvuxpEScI/IdABqmorUET6izR0oxXG6q66T8sYN4O/lcm+IxCddicoM sp15ifPY6U1/A5FctyUNot0Jr8S9dAIZxSrf56fYjjSp1npITFEUKp+rLG6yVZNIDKE0 vuQB/5hyaobTpbEKBDCkiAta/iqPxn1oq/hmgAyw8g3Y10JIraHe48R67KEyxEkc0hs1 HaPURquzMCnG3uY3wC1bD2th/PDKTfvkaOhEj9yLBenh1rCm34srd/2TklHROxYArAxi XaEA== X-Gm-Message-State: AD7BkJLtBleErqj4xqJMBz9VdH0K1hAsaL+7cPcuY8IDVrZ/NFrkl0SCfPdwlNkyjLonOg== X-Received: by 10.25.87.19 with SMTP id l19mr3457999lfb.27.1459586722488; Sat, 02 Apr 2016 01:45:22 -0700 (PDT) Received: from gmail.com (broadband-90-154-70-42.nationalcablenetworks.ru. [90.154.70.42]) by smtp.gmail.com with ESMTPSA id g199sm1110335lfe.30.2016.04.02.01.45.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 02 Apr 2016 01:45:21 -0700 (PDT) Date: Sat, 2 Apr 2016 01:44:00 -0700 From: Artemiy Volkov To: Keith Seitz Cc: gdb-patches@sourceware.org Subject: Re: [PATCH v4 08/11] [PR gdb/14441] gdb: python: support rvalue references in the gdb module Message-ID: <20160402084400.GC7371@gmail.com> References: <1457147955-21871-1-git-send-email-artemiyv@acm.org> <1458593958-25656-1-git-send-email-artemiyv@acm.org> <1458593958-25656-9-git-send-email-artemiyv@acm.org> <56FD8A19.8050403@redhat.com> <20160402082709.GA7371@gmail.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20160402082709.GA7371@gmail.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-IsSubscribed: yes On Sat, Apr 02, 2016 at 01:27:09AM -0700, Artemiy Volkov wrote: > On Thu, Mar 31, 2016 at 01:35:37PM -0700, Keith Seitz wrote: > > [snip] > > > Both of the above hunks need to keep the deleted whitespace. We like a > > blank line between the (last) variable declaration and the first line of > > code: > > > > else if (TYPE_IS_REFERENCE 9obj_type)) > > { > > struct type *this_ref > > = lookup_reference_type (this_type, TYPE_CODE (obj_type)); > > > > if (!types_equal (obj_type, this_ref)) > > ... > > } > Whoops, please disregard my previous message as the patch will not apply. Here is the correct version. --- gdb/python/lib/gdb/command/explore.py | 2 +- gdb/python/lib/gdb/types.py | 4 +++- gdb/python/py-type.c | 1 + gdb/python/py-value.c | 3 +++ gdb/python/py-xmethods.c | 10 ++++++---- 5 files changed, 14 insertions(+), 6 deletions(-) diff --git a/gdb/python/lib/gdb/command/explore.py b/gdb/python/lib/gdb/command/explore.py index 6c9f17b..ed25fa6 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 c22e8a9..59b7df2 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 4ec920e..259bb70 100644 --- a/gdb/python/py-type.c +++ b/gdb/python/py-type.c @@ -105,6 +105,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 141f180..7802ae0 100644 --- a/gdb/python/py-value.c +++ b/gdb/python/py-value.c @@ -768,6 +768,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); } diff --git a/gdb/python/py-xmethods.c b/gdb/python/py-xmethods.c index d70cdd1..debc3a8 100644 --- a/gdb/python/py-xmethods.c +++ b/gdb/python/py-xmethods.c @@ -548,9 +548,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); @@ -634,9 +635,10 @@ gdbpy_invoke_xmethod (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);