diff options
author | Doug Evans <dje@google.com> | 2015-04-29 13:24:21 -0700 |
---|---|---|
committer | Doug Evans <dje@google.com> | 2015-04-29 13:24:21 -0700 |
commit | 2ce1cdbf84ce883b992bc8ffec3d29b4da229b72 (patch) | |
tree | 4143b5da94595cdef5199d0ca8afd6ec14bc30e6 /gdb/testsuite/gdb.python | |
parent | 99b2a2dd3cd91ee45aba56a90b52be943001e8f4 (diff) | |
download | gdb-2ce1cdbf84ce883b992bc8ffec3d29b4da229b72.zip gdb-2ce1cdbf84ce883b992bc8ffec3d29b4da229b72.tar.gz gdb-2ce1cdbf84ce883b992bc8ffec3d29b4da229b72.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/testsuite/gdb.python')
-rw-r--r-- | gdb/testsuite/gdb.python/py-xmethods.exp | 13 | ||||
-rw-r--r-- | gdb/testsuite/gdb.python/py-xmethods.py | 5 |
2 files changed, 16 insertions, 2 deletions
diff --git a/gdb/testsuite/gdb.python/py-xmethods.exp b/gdb/testsuite/gdb.python/py-xmethods.exp index a83b14d..eea1283 100644 --- a/gdb/testsuite/gdb.python/py-xmethods.exp +++ b/gdb/testsuite/gdb.python/py-xmethods.exp @@ -107,8 +107,9 @@ gdb_test "p a_ptr->geta()" "From Python <A_geta>.*30" "After: a_ptr->geta()" gdb_test "p e.geta()" "From Python <A_geta>.*100" "After: e.geta()" gdb_test "p e_ptr->geta()" "From Python <A_geta>.*100" "After: e_ptr->geta()" gdb_test "p e_ref.geta()" "From Python <A_geta>.*100" "After: e_ref.geta()" -gdb_test "p e.method(10)" "From Python <E_method_int>.*" "After: e.method(10)" -gdb_test "p e.method('a')" "From Python <E_method_char>.*" \ +gdb_test "p e.method(10)" "From Python <E_method_int>.* = void" \ + "After: e.method(10)" +gdb_test "p e.method('a')" "From Python <E_method_char>.* = void" \ "After: e.method('a')" gdb_test "p g.size_diff<float> ()" "From Python G<>::size_diff.*" \ "After: g.size_diff<float>()" @@ -149,3 +150,11 @@ gdb_test_no_output "disable xmethod progspace E_methods;method_int" \ "disable xmethod progspace E_methods;method_int" gdb_test "info xmethod progspace E_methods;method_int" ".* \\\[disabled\\\]" \ "info xmethod xmethods E_methods;method_int" + +# PR 18285 +# First make sure both are enabled. +gdb_test_no_output "enable xmethod progspace E_methods;method_char" +gdb_test_no_output "enable xmethod progspace E_methods;method_int" +gdb_test "pt e.method('a')" "type = void" +gdb_test "pt e.method(10)" \ + "NotImplementedError.*Error while fetching result type of an xmethod worker defined in Python." diff --git a/gdb/testsuite/gdb.python/py-xmethods.py b/gdb/testsuite/gdb.python/py-xmethods.py index 78935e1..3a2f100 100644 --- a/gdb/testsuite/gdb.python/py-xmethods.py +++ b/gdb/testsuite/gdb.python/py-xmethods.py @@ -60,6 +60,9 @@ class E_method_char_worker(XMethodWorker): def get_arg_types(self): return gdb.lookup_type('char') + def get_result_type(self, obj, arg): + return gdb.lookup_type('void') + def __call__(self, obj, arg): print('From Python <E_method_char>') return None @@ -72,6 +75,8 @@ class E_method_int_worker(XMethodWorker): def get_arg_types(self): return gdb.lookup_type('int') + # Note: get_result_type method elided on purpose + def __call__(self, obj, arg): print('From Python <E_method_int>') return None |