GDB_PY_HANDLE_EXCEPTION (except);
}
- if (ftype->code () != TYPE_CODE_FUNC)
+ if (ftype->code () != TYPE_CODE_FUNC && ftype->code () != TYPE_CODE_METHOD)
{
PyErr_SetString (PyExc_RuntimeError,
- _("Value is not callable (not TYPE_CODE_FUNC)."));
+ _("Value is not callable (not TYPE_CODE_FUNC"
+ " or TYPE_CODE_METHOD)."));
return NULL;
}
class B : public A {
public:
char a;
+
+ static int static_func ();
+ int arg0_func ();
+ int arg1_func (int arg1);
+ int arg2_func (int arg1, int arg2);
};
+int B::static_func ()
+{
+ return 1111;
+}
+
+int B::arg0_func ()
+{
+ return A::a + a;
+}
+
+int B::arg1_func (int arg1)
+{
+ return a * arg1;
+}
+
+int B::arg2_func (int arg1, int arg2)
+{
+ return a * arg1 + arg2;
+}
+
struct X
{
union { int x; char y; };
# Test overloaded operators.
gdb_test_no_output "python a = gdb.parse_and_eval('a')" "init a"
gdb_test "python print(a + 5)" "10" "a + 5"
+
+# Test inferior function calls of methods.
+gdb_test "py print(b_obj\['static_func'\]())" "1111"
+gdb_test "py print(b_obj\['arg0_func'\]())" ".*Too few arguments in function call.*"
+gdb_test "py print(b_obj\['arg0_func'\](b_obj))" "198"
+gdb_test "py print(b_obj\['arg1_func'\]())" ".*Too few arguments in function call.*"
+gdb_test "py print(b_obj\['arg1_func'\](b_obj))" ".*Too few arguments in function call.*"
+gdb_test "py print(b_obj\['arg1_func'\](b_obj, 3))" "294"
+gdb_test "py print(b_obj\['arg2_func'\]())" ".*Too few arguments in function call.*"
+gdb_test "py print(b_obj\['arg2_func'\](b_obj))" ".*Too few arguments in function call.*"
+gdb_test "py print(b_obj\['arg2_func'\](b_obj, 4))" ".*Too few arguments in function call.*"
+gdb_test "py print(b_obj\['arg2_func'\](b_obj, 5, 6))" "496"