diff options
author | Pedro Alves <palves@redhat.com> | 2018-11-21 11:55:12 +0000 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2018-11-21 12:06:20 +0000 |
commit | 6b1747cd135ff9859fceb6043179b1ef94363996 (patch) | |
tree | 9dd00eb42169b61747d43efeec410c66ba7070e3 /gdb/eval.c | |
parent | e71585ffe2e1394858f0fcf809e86f1b324fe4e6 (diff) | |
download | gdb-6b1747cd135ff9859fceb6043179b1ef94363996.zip gdb-6b1747cd135ff9859fceb6043179b1ef94363996.tar.gz gdb-6b1747cd135ff9859fceb6043179b1ef94363996.tar.bz2 |
invoke_xmethod & array_view
This replaces more pointer+length with gdb::array_view. This time,
around invoke_xmethod, and then propagating the fallout around, which
inevitably leaks to the overload resolution code.
There are several places in the code that want to grab a slice of an
array, by advancing the array pointer, and decreasing the length
pointer. This patch introduces a pair of new
gdb::array_view::slice(...) methods to make that convenient and clear.
Unit test included.
gdb/ChangeLog:
2018-11-21 Pedro Alves <palves@redhat.com>
* common/array-view.h (array_view::splice(size_type, size_t)): New.
(array_view::splice(size_type)): New.
* eval.c (eval_call, evaluate_funcall): Adjust to use array_view.
* extension.c (xmethod_worker::get_arg_types): Adjust to return an
std::vector.
(xmethod_worker::get_result_type): Adjust to use gdb::array_view.
* extension.h: Include "common/array-view.h".
(xmethod_worker::invoke): Adjust to use gdb::array_view.
(xmethod_worker::get_arg_types): Adjust to return an std::vector.
(xmethod_worker::get_result_type): Adjust to use gdb::array_view.
(xmethod_worker::do_get_arg_types): Adjust to use std::vector.
(xmethod_worker::do_get_result_type): Adjust to use
gdb::array_view.
* gdbtypes.c (rank_function): Adjust to use gdb::array_view.
* gdbtypes.h: Include "common/array-view.h".
(rank_function): Adjust to use gdb::array_view.
* python/py-xmethods.c (python_xmethod_worker::invoke)
(python_xmethod_worker::do_get_arg_types)
(python_xmethod_worker::do_get_result_type)
(python_xmethod_worker::invoke): Adjust to new interfaces.
* valarith.c (value_user_defined_cpp_op, value_user_defined_op)
(value_x_binop, value_x_unop): Adjust to use gdb::array_view.
* valops.c (find_overload_match, find_oload_champ_namespace)
(find_oload_champ_namespace_loop, find_oload_champ): Adjust to use
gdb:array_view and the new xmethod_worker interfaces.
* value.c (result_type_of_xmethod, call_xmethod): Adjust to use
gdb::array_view.
* value.h (find_overload_match, result_type_of_xmethod)
(call_xmethod): Adjust to use gdb::array_view.
* unittests/array-view-selftests.c: Add slicing tests.
Diffstat (limited to 'gdb/eval.c')
-rw-r--r-- | gdb/eval.c | 14 |
1 files changed, 9 insertions, 5 deletions
@@ -789,7 +789,9 @@ eval_call (expression *exp, enum noside noside, else if (TYPE_CODE (ftype) == TYPE_CODE_XMETHOD) { type *return_type - = result_type_of_xmethod (argvec[0], nargs, argvec + 1); + = result_type_of_xmethod (argvec[0], + gdb::make_array_view (argvec + 1, + nargs)); if (return_type == NULL) error (_("Xmethod is missing return type.")); @@ -827,7 +829,7 @@ eval_call (expression *exp, enum noside noside, return call_internal_function (exp->gdbarch, exp->language_defn, argvec[0], nargs, argvec + 1); case TYPE_CODE_XMETHOD: - return call_xmethod (argvec[0], nargs, argvec + 1); + return call_xmethod (argvec[0], gdb::make_array_view (argvec + 1, nargs)); default: return call_function_by_hand (argvec[0], default_return_type, gdb::make_array_view (argvec + 1, nargs)); @@ -1100,7 +1102,8 @@ evaluate_funcall (type *expect_type, expression *exp, int *pos, func_name = (char *) alloca (name_len + 1); strcpy (func_name, &exp->elts[string_pc + 1].string); - find_overload_match (&argvec[1], nargs, func_name, + find_overload_match (gdb::make_array_view (&argvec[1], nargs), + func_name, NON_METHOD, /* not method */ NULL, NULL, /* pass NULL symbol since symbol is unknown */ @@ -1136,7 +1139,8 @@ evaluate_funcall (type *expect_type, expression *exp, int *pos, evaluation. */ struct value *valp = NULL; - (void) find_overload_match (&argvec[1], nargs, tstr, + (void) find_overload_match (gdb::make_array_view (&argvec[1], nargs), + tstr, METHOD, /* method */ &arg2, /* the object */ NULL, &valp, NULL, @@ -1207,7 +1211,7 @@ evaluate_funcall (type *expect_type, expression *exp, int *pos, if (op == OP_VAR_VALUE) function = exp->elts[save_pos1+2].symbol; - (void) find_overload_match (&argvec[1], nargs, + (void) find_overload_match (gdb::make_array_view (&argvec[1], nargs), NULL, /* no need for name */ NON_METHOD, /* not method */ NULL, function, /* the function */ |