diff options
author | Doug Evans <dje@google.com> | 2015-05-12 09:18:06 -0700 |
---|---|---|
committer | Doug Evans <dje@google.com> | 2015-05-12 09:18:06 -0700 |
commit | 6b2a76d583a91ae9dad0653c60c91b72f07ff941 (patch) | |
tree | 9c090375d7ca2564c76f64b6d5d92001f9ed02f1 /gdb/valarith.c | |
parent | 333f04a6317eba12fdcc6aef2d22058576651f3a (diff) | |
download | binutils-6b2a76d583a91ae9dad0653c60c91b72f07ff941.zip binutils-6b2a76d583a91ae9dad0653c60c91b72f07ff941.tar.gz binutils-6b2a76d583a91ae9dad0653c60c91b72f07ff941.tar.bz2 |
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.
Diffstat (limited to 'gdb/valarith.c')
-rw-r--r-- | gdb/valarith.c | 51 |
1 files changed, 33 insertions, 18 deletions
diff --git a/gdb/valarith.c b/gdb/valarith.c index f33515c..1d94cf6 100644 --- a/gdb/valarith.c +++ b/gdb/valarith.c @@ -482,6 +482,21 @@ value_x_binop (struct value *arg1, struct value *arg2, enum exp_opcode op, argvec[1] = argvec[0]; argvec++; } + if (TYPE_CODE (value_type (argvec[0])) == TYPE_CODE_XMETHOD) + { + /* Static xmethods are not supported yet. */ + gdb_assert (static_memfuncp == 0); + if (noside == EVAL_AVOID_SIDE_EFFECTS) + { + struct type *return_type + = result_type_of_xmethod (argvec[0], 2, argvec + 1); + + if (return_type == NULL) + error (_("Xmethod is missing return type.")); + return value_zero (return_type, VALUE_LVAL (arg1)); + } + return call_xmethod (argvec[0], 2, argvec + 1); + } if (noside == EVAL_AVOID_SIDE_EFFECTS) { struct type *return_type; @@ -490,16 +505,8 @@ value_x_binop (struct value *arg1, struct value *arg2, enum exp_opcode op, = TYPE_TARGET_TYPE (check_typedef (value_type (argvec[0]))); return value_zero (return_type, VALUE_LVAL (arg1)); } - - if (TYPE_CODE (value_type (argvec[0])) == TYPE_CODE_XMETHOD) - { - /* Static xmethods are not supported yet. */ - gdb_assert (static_memfuncp == 0); - return call_xmethod (argvec[0], 2, argvec + 1); - } - else - return call_function_by_hand (argvec[0], 2 - static_memfuncp, - argvec + 1); + return call_function_by_hand (argvec[0], 2 - static_memfuncp, + argvec + 1); } throw_error (NOT_FOUND_ERROR, _("member function %s not found"), tstr); @@ -594,6 +601,21 @@ value_x_unop (struct value *arg1, enum exp_opcode op, enum noside noside) nargs --; argvec++; } + if (TYPE_CODE (value_type (argvec[0])) == TYPE_CODE_XMETHOD) + { + /* Static xmethods are not supported yet. */ + gdb_assert (static_memfuncp == 0); + if (noside == EVAL_AVOID_SIDE_EFFECTS) + { + struct type *return_type + = result_type_of_xmethod (argvec[0], 1, argvec + 1); + + if (return_type == NULL) + error (_("Xmethod is missing return type.")); + return value_zero (return_type, VALUE_LVAL (arg1)); + } + return call_xmethod (argvec[0], 1, argvec + 1); + } if (noside == EVAL_AVOID_SIDE_EFFECTS) { struct type *return_type; @@ -602,14 +624,7 @@ value_x_unop (struct value *arg1, enum exp_opcode op, enum noside noside) = TYPE_TARGET_TYPE (check_typedef (value_type (argvec[0]))); return value_zero (return_type, VALUE_LVAL (arg1)); } - if (TYPE_CODE (value_type (argvec[0])) == TYPE_CODE_XMETHOD) - { - /* Static xmethods are not supported yet. */ - gdb_assert (static_memfuncp == 0); - return call_xmethod (argvec[0], 1, argvec + 1); - } - else - return call_function_by_hand (argvec[0], nargs, argvec + 1); + return call_function_by_hand (argvec[0], nargs, argvec + 1); } throw_error (NOT_FOUND_ERROR, _("member function %s not found"), tstr); |