/* Evaluate expressions for GDB.
- Copyright (C) 1986-2018 Free Software Foundation, Inc.
+ Copyright (C) 1986-2019 Free Software Foundation, Inc.
This file is part of GDB.
struct value *
parse_to_comma_and_eval (const char **expp)
{
- expression_up expr = parse_exp_1 (expp, 0, (struct block *) 0, 1);
+ expression_up expr = parse_exp_1 (expp, 0, nullptr, 1);
return evaluate_expression (expr.get ());
}
mark = value_mark ();
result = NULL;
- TRY
+ try
{
result = evaluate_subexp (NULL_TYPE, exp, pc, EVAL_NORMAL);
}
- CATCH (ex, RETURN_MASK_ALL)
+ catch (const gdb_exception &ex)
{
/* Ignore memory errors if we want watchpoints pointing at
inaccessible memory to still be created; otherwise, throw the
break;
/* Fall through. */
default:
- throw_exception (ex);
+ throw;
break;
}
}
- END_CATCH
new_mark = value_mark ();
if (mark == new_mark)
else
{
- TRY
+ try
{
value_fetch_lazy (result);
*valp = result;
}
- CATCH (except, RETURN_MASK_ERROR)
+ catch (const gdb_exception_error &except)
{
}
- END_CATCH
}
}
struct value *ret = NULL;
- TRY
+ try
{
ret = value_of_variable (var, blk);
}
- CATCH (except, RETURN_MASK_ERROR)
+ catch (const gdb_exception_error &except)
{
if (noside != EVAL_AVOID_SIDE_EFFECTS)
- throw_exception (except);
+ throw;
ret = value_zero (SYMBOL_TYPE (var), not_lval);
}
- END_CATCH
return ret;
}
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."));
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));
while (unop_user_defined_p (op, arg2))
{
struct value *value = NULL;
- TRY
+ try
{
value = value_x_unop (arg2, op, noside);
}
- CATCH (except, RETURN_MASK_ERROR)
+ catch (const gdb_exception_error &except)
{
if (except.error == NOT_FOUND_ERROR)
break;
else
- throw_exception (except);
+ throw;
}
- END_CATCH
arg2 = value;
}
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 */
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,
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 */
case TYPE_CODE_PTR:
case TYPE_CODE_FUNC:
+ case TYPE_CODE_INTERNAL_FUNCTION:
/* It's a function call. */
/* Allocate arg vector, including space for the function to be
called in argvec[0] and a terminating NULL. */
argvec[0] = arg1;
tem = 1;
for (; tem <= nargs; tem++)
- argvec[tem] = evaluate_subexp_with_coercion (exp, pos, noside);
+ {
+ argvec[tem] = evaluate_subexp_with_coercion (exp, pos, noside);
+ /* Arguments in Fortran are passed by address. Coerce the
+ arguments here rather than in value_arg_coerce as otherwise
+ the call to malloc to place the non-lvalue parameters in
+ target memory is hit by this Fortran specific logic. This
+ results in malloc being called with a pointer to an integer
+ followed by an attempt to malloc the arguments to malloc in
+ target memory. Infinite recursion ensues. */
+ if (code == TYPE_CODE_PTR || code == TYPE_CODE_FUNC)
+ {
+ bool is_artificial
+ = TYPE_FIELD_ARTIFICIAL (value_type (arg1), tem - 1);
+ argvec[tem] = fortran_argument_convert (argvec[tem],
+ is_artificial);
+ }
+ }
argvec[tem] = 0; /* signal end of arglist */
if (noside == EVAL_SKIP)
return eval_skip_value (exp);
while (unop_user_defined_p (op, arg1))
{
struct value *value = NULL;
- TRY
+ try
{
value = value_x_unop (arg1, op, noside);
}
- CATCH (except, RETURN_MASK_ERROR)
+ catch (const gdb_exception_error &except)
{
if (except.error == NOT_FOUND_ERROR)
break;
else
- throw_exception (except);
+ throw;
}
- END_CATCH
arg1 = value;
}