GDB_PY_HANDLE_EXCEPTION (except);
}
- if (ftype->code () != TYPE_CODE_FUNC && ftype->code () != TYPE_CODE_METHOD)
+ if (ftype->code () != TYPE_CODE_FUNC && ftype->code () != TYPE_CODE_METHOD
+ && ftype->code () != TYPE_CODE_INTERNAL_FUNCTION)
{
PyErr_SetString (PyExc_RuntimeError,
_("Value is not callable (not TYPE_CODE_FUNC"
- " or TYPE_CODE_METHOD)."));
+ " or TYPE_CODE_METHOD"
+ " or TYPE_CODE_INTERNAL_FUNCTION)."));
return NULL;
}
{
scoped_value_mark free_values;
- value *return_value
- = call_function_by_hand (function, NULL,
- gdb::make_array_view (vargs, args_count));
+ value *return_value;
+ if (ftype->code () == TYPE_CODE_INTERNAL_FUNCTION)
+ return_value = call_internal_function (gdbpy_enter::get_gdbarch (),
+ current_language,
+ function, args_count, vargs);
+ else
+ return_value
+ = call_function_by_hand (function, NULL,
+ gdb::make_array_view (vargs, args_count));
result = value_to_value_object (return_value);
}
catch (const gdb_exception &except)
gdb_test "python result2 = fp3(10)" ".*Too few arguments in function call.*"
}
+proc test_convenience_function_call {} {
+ # Get convenience function with gdb.convenience_variable.
+ gdb_test "python print(gdb.convenience_variable('_isvoid')(2))" "0"
+ gdb_test "python print(gdb.convenience_variable('_strlen')('two'))" "3"
+
+ # Get convenience function with gdb.parse_and_eval.
+ gdb_test "python print(gdb.parse_and_eval('\$_isvoid')(3))" "0"
+ gdb_test "python print(gdb.parse_and_eval('\$_strlen')('three'))" "5"
+}
+
# A few objfile tests.
proc test_objfiles {} {
gdb_test "python\nok=False\nfor file in gdb.objfiles():\n if 'py-value' in file.filename:\n ok=True\nprint (ok)\nend" "True" \
test_value_from_buffer
test_value_sub_classes
test_inferior_function_call
+test_convenience_function_call
test_assign
test_value_bytes
test_value_after_death