PR python/18285
gdb/ChangeLog: PR python/18285 * NEWS: Document new gdb.XMethodWorker.get_result_type method. * eval.c (evaluate_subexp_standard) <OP_FUNCALL>: Handle EVAL_AVOID_SIDE_EFFECTS for xmethods. * extension-priv.h (struct extension_language_ops) <get_xmethod_result_type>: New member. * extension.c (get_xmethod_result_type): New function. * extension.h (get_xmethod_result_type): Declare. * python/py-xmethods.c (get_result_type_method_name): New static global. (py_get_result_type_method_name): Ditto. (gdbpy_get_xmethod_result_type): New function. (gdbpy_initialize_xmethods): Initialize py_get_result_type_method_name. * python/python-internal.h (gdbpy_get_xmethod_result_type): Declare. * python/python.c (python_extension_ops): Add gdbpy_get_xmethod_result_type. * python/lib/gdb/xmethod.py (XMethodWorker): Add get_result_type. * valarith.c (value_x_binop): Handle EVAL_AVOID_SIDE_EFFECTS for xmethods. (value_x_unop): Ditto. * value.c (result_type_of_xmethod): New function. * value.h (result_type_of_xmethod): Declare. gdb/testsuite/ChangeLog: * gdb.python/py-xmethods.exp: Add ptype tests. * gdb.python/py-xmethods.py (E_method_char_worker): Add get_result_type method. gdb/doc/ChangeLog: * python.texi (Xmethod API) <gdb.XMethodWorker.get_result_type>: Document. (Writing an Xmethod): Add get_result_type to example.
This commit is contained in:
parent
99b2a2dd3c
commit
2ce1cdbf84
18 changed files with 304 additions and 28 deletions
|
@ -101,9 +101,11 @@ class XMethodWorker(object):
|
|||
invokes the method when GDB wants it to. Internally, GDB first invokes the
|
||||
'get_arg_types' method to perform overload resolution. If GDB selects to
|
||||
invoke this Python xmethod, then it invokes it via the overridden
|
||||
'__call__' method.
|
||||
'__call__' method. The 'get_result_type' method is used to implement
|
||||
'ptype' on the xmethod.
|
||||
|
||||
Derived classes should override the 'get_arg_types' and '__call__' methods.
|
||||
Derived classes should override the 'get_arg_types', 'get_result_type'
|
||||
and '__call__' methods.
|
||||
"""
|
||||
|
||||
def get_arg_types(self):
|
||||
|
@ -117,6 +119,20 @@ class XMethodWorker(object):
|
|||
"""
|
||||
raise NotImplementedError("XMethodWorker get_arg_types")
|
||||
|
||||
def get_result_type(self, *args):
|
||||
"""Return the type of the result of the xmethod.
|
||||
|
||||
Args:
|
||||
args: Arguments to the method. Each element of the tuple is a
|
||||
gdb.Value object. The first element is the 'this' pointer
|
||||
value. These are the same arguments passed to '__call__'.
|
||||
|
||||
Returns:
|
||||
A gdb.Type object representing the type of the result of the
|
||||
xmethod.
|
||||
"""
|
||||
raise NotImplementedError("XMethodWorker get_result_type")
|
||||
|
||||
def __call__(self, *args):
|
||||
"""Invoke the xmethod.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue