From patchwork Mon Mar 21 20:59:15 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artemiy Volkov X-Patchwork-Id: 11461 Received: (qmail 76713 invoked by alias); 21 Mar 2016 21:02:31 -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 76658 invoked by uid 89); 21 Mar 2016 21:02:30 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=3110 X-HELO: mail-lb0-f193.google.com Received: from mail-lb0-f193.google.com (HELO mail-lb0-f193.google.com) (209.85.217.193) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Mon, 21 Mar 2016 21:02:22 +0000 Received: by mail-lb0-f193.google.com with SMTP id vk4so12123860lbb.1 for ; Mon, 21 Mar 2016 14:02:22 -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:from:to:cc:subject:date:message-id :in-reply-to:references; bh=8Pk8/N42z9zNW4RZxCIKB+vFfo7z8D6Phi7zVcflCjw=; b=DxvfNn94drZZWWZdiQ5r+gZ9UHdasg1drWt277+ov5rwlXEGrXHWVT1px70tQWyOoI LhsyG678VqDV0ZO/BXgc+kf8nG9iqa8Rlug9SeqY8sPbs9ByXBf+gshTefq8sBqiMQEj Gz0OQmPPjTZ3MqIkqCcy9t+to04bzM/IapPbBEvpzdwjmo3BdgpXRYMttM9y/089V4J7 JtOqahkx3mPcRtLUyWRPcGSUqVYsv8dVWBkq+jW6xZ1iAJ27+WTjcfYyfSJl2HDmLlKM l5FeMs0qJDl0Ja1j/BMSmysUj/T3iqFsbk240P9hDmSUzgEYNtXGgXspEsE8kZTb1jvE HclQ== X-Gm-Message-State: AD7BkJJvCYlb6MGz6ztnTLT9JYnVW/Y2Jc29iERk2V93L8yl7nu5L7UI4haO0aaa60Cxvg== X-Received: by 10.25.82.203 with SMTP id g194mr12271387lfb.1.1458594139249; Mon, 21 Mar 2016 14:02:19 -0700 (PDT) Received: from arch.smware.local (broadband-90-154-70-182.nationalcablenetworks.ru. [90.154.70.182]) by smtp.gmail.com with ESMTPSA id 40sm4730939lfp.41.2016.03.21.14.02.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 21 Mar 2016 14:02:18 -0700 (PDT) From: Artemiy Volkov To: gdb-patches@sourceware.org Cc: keiths@redhat.com, palves@redhat.com, Artemiy Volkov Subject: [PATCH v4 08/11] [PR gdb/14441] gdb: python: support rvalue references in the gdb module Date: Mon, 21 Mar 2016 13:59:15 -0700 Message-Id: <1458593958-25656-9-git-send-email-artemiyv@acm.org> In-Reply-To: <1458593958-25656-1-git-send-email-artemiyv@acm.org> References: <1457147955-21871-1-git-send-email-artemiyv@acm.org> <1458593958-25656-1-git-send-email-artemiyv@acm.org> X-IsSubscribed: yes This patch adds the ability to inspect rvalue reference types and values using the gdb python module. This is achieved by simply 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: 2016-03-21 Artemiy Volkov * 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) : New constant. * python/py-value.c (valpy_getitem): Add an rvalue reference check. * python/py-xmethods.c (gdbpy_get_xmethod_result_type) (gdbpy_invoke_xmethod): Likewise. --- 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 | 12 ++++++------ 5 files changed, 14 insertions(+), 8 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..17fdfb2 100644 --- a/gdb/python/py-xmethods.c +++ b/gdb/python/py-xmethods.c @@ -548,10 +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,10 +634,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); }