aboutsummaryrefslogtreecommitdiff
path: root/gdb/eval.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/eval.c')
-rw-r--r--gdb/eval.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/gdb/eval.c b/gdb/eval.c
index 659493c..ab070a3 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -872,7 +872,9 @@ structop_base_operation::evaluate_funcall
(struct type *expect_type, struct expression *exp, enum noside noside,
const std::vector<operation_up> &args)
{
- std::vector<value *> vals (args.size () + 1);
+ /* Allocate space for the function call arguments. Include space for a
+ `this' pointer at the start, and a trailing nullptr. */
+ std::vector<value *> vals (args.size () + 2);
/* First, evaluate the structure into vals[0]. */
enum exp_opcode op = opcode ();
if (op == STRUCTOP_STRUCT)
@@ -918,9 +920,16 @@ structop_base_operation::evaluate_funcall
}
}
+ /* Evaluate the arguments, and add the trailing nullptr. The '+ 1' here
+ is to allow for the `this' pointer we placed into vals[0]. */
for (int i = 0; i < args.size (); ++i)
vals[i + 1] = args[i]->evaluate_with_coercion (exp, noside);
- gdb::array_view<value *> arg_view = vals;
+ vals[args.size () + 1] = nullptr;
+
+ /* The array view includes the `this' pointer, but not the trailing
+ nullptr. */
+ gdb::array_view<value *> arg_view
+ = gdb::make_array_view (&vals[0], args.size () + 1);
int static_memfuncp;
value *callee;
@@ -941,7 +950,7 @@ structop_base_operation::evaluate_funcall
{
struct value *temp = vals[0];
- callee = value_struct_elt (&temp, &vals[1], tstr,
+ callee = value_struct_elt (&temp, &vals[0], tstr,
&static_memfuncp,
op == STRUCTOP_STRUCT
? "structure" : "structure pointer");