From 3fcf899da106890f3948093c2424f9dff67d6fe0 Mon Sep 17 00:00:00 2001 From: Artemiy Volkov Date: Mon, 20 Mar 2017 13:47:52 -0700 Subject: 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) : 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. --- gdb/python/lib/gdb/command/explore.py | 2 +- gdb/python/lib/gdb/types.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'gdb/python/lib') 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() -- cgit v1.1