X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=gdb%2Feval.c;h=5d32a3cd4bc2f7f6ada7185f5cd9caf188db03be;hb=35fd2deb6916e972248d52b1bc1d584fa9059f8f;hp=655ea223b1d65f5bde098ec0e94b277481ce0c0a;hpb=b1f28d992c916eab861df3fa62d436755f874b62;p=deliverable%2Fbinutils-gdb.git diff --git a/gdb/eval.c b/gdb/eval.c index 655ea223b1..5d32a3cd4b 100644 --- a/gdb/eval.c +++ b/gdb/eval.c @@ -1,6 +1,6 @@ /* Evaluate expressions for GDB. - Copyright (C) 1986-2014 Free Software Foundation, Inc. + Copyright (C) 1986-2016 Free Software Foundation, Inc. This file is part of GDB. @@ -24,6 +24,7 @@ #include "expression.h" #include "target.h" #include "frame.h" +#include "gdbthread.h" #include "language.h" /* For CAST_IS_CONVERSION. */ #include "f-lang.h" /* For array bound stuff. */ #include "cp-abi.h" @@ -63,8 +64,29 @@ struct value * evaluate_subexp (struct type *expect_type, struct expression *exp, int *pos, enum noside noside) { - return (*exp->language_defn->la_exp_desc->evaluate_exp) + struct cleanup *cleanups; + struct value *retval; + int cleanup_temps = 0; + + if (*pos == 0 && target_has_execution + && exp->language_defn->la_language == language_cplus + && !thread_stack_temporaries_enabled_p (inferior_ptid)) + { + cleanups = enable_thread_stack_temporaries (inferior_ptid); + cleanup_temps = 1; + } + + retval = (*exp->language_defn->la_exp_desc->evaluate_exp) (expect_type, exp, pos, noside); + + if (cleanup_temps) + { + if (value_in_thread_stack_temporaries (retval, inferior_ptid)) + retval = value_non_lval (retval); + do_cleanups (cleanups); + } + + return retval; } /* Parse the string EXP as a C expression, evaluate it, @@ -190,7 +212,6 @@ fetch_subexp_value (struct expression *exp, int *pc, struct value **valp, int preserve_errors) { struct value *mark, *new_mark, *result; - volatile struct gdb_exception ex; *valp = NULL; if (resultp) @@ -202,11 +223,11 @@ fetch_subexp_value (struct expression *exp, int *pc, struct value **valp, mark = value_mark (); result = NULL; - TRY_CATCH (ex, RETURN_MASK_ALL) + TRY { result = evaluate_subexp (NULL_TYPE, exp, pc, EVAL_NORMAL); } - if (ex.reason < 0) + CATCH (ex, RETURN_MASK_ALL) { /* Ignore memory errors if we want watchpoints pointing at inaccessible memory to still be created; otherwise, throw the @@ -221,6 +242,7 @@ fetch_subexp_value (struct expression *exp, int *pc, struct value **valp, break; } } + END_CATCH new_mark = value_mark (); if (mark == new_mark) @@ -236,13 +258,16 @@ fetch_subexp_value (struct expression *exp, int *pc, struct value **valp, *valp = result; else { - volatile struct gdb_exception except; - TRY_CATCH (except, RETURN_MASK_ERROR) + TRY { value_fetch_lazy (result); *valp = result; } + CATCH (except, RETURN_MASK_ERROR) + { + } + END_CATCH } } @@ -381,7 +406,8 @@ value_f90_subarray (struct value *array, int pc = (*pos) + 1; LONGEST low_bound, high_bound; struct type *range = check_typedef (TYPE_INDEX_TYPE (value_type (array))); - enum f90_range_type range_type = longest_to_int (exp->elts[pc].longconst); + enum f90_range_type range_type + = (enum f90_range_type) longest_to_int (exp->elts[pc].longconst); *pos += 3; @@ -642,7 +668,6 @@ make_params (int num_types, struct type **param_types) TYPE_MAIN_TYPE (type) = XCNEW (struct main_type); TYPE_LENGTH (type) = 1; TYPE_CODE (type) = TYPE_CODE_METHOD; - TYPE_VPTR_FIELDNO (type) = -1; TYPE_CHAIN (type) = type; if (num_types > 0) { @@ -741,16 +766,15 @@ evaluate_subexp_standard (struct type *expect_type, or reference to a base class and print object is on. */ { - volatile struct gdb_exception except; struct value *ret = NULL; - TRY_CATCH (except, RETURN_MASK_ERROR) + TRY { ret = value_of_variable (exp->elts[pc + 2].symbol, exp->elts[pc + 1].block); } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ERROR) { if (noside == EVAL_AVOID_SIDE_EFFECTS) ret = value_zero (SYMBOL_TYPE (exp->elts[pc + 2].symbol), @@ -758,6 +782,7 @@ evaluate_subexp_standard (struct type *expect_type, else throw_exception (except); } + END_CATCH return ret; } @@ -973,7 +998,7 @@ evaluate_subexp_standard (struct type *expect_type, return set; } - argvec = (struct value **) alloca (sizeof (struct value *) * nargs); + argvec = XALLOCAVEC (struct value *, nargs); for (tem = 0; tem < nargs; tem++) { /* Ensure that array expressions are coerced into pointer @@ -1039,7 +1064,7 @@ evaluate_subexp_standard (struct type *expect_type, CORE_ADDR selector = 0; int struct_return = 0; - int sub_no_side = 0; + enum noside sub_no_side = EVAL_NORMAL; struct value *msg_send = NULL; struct value *msg_send_stret = NULL; @@ -1057,8 +1082,7 @@ evaluate_subexp_standard (struct type *expect_type, selector = exp->elts[pc + 1].longconst; nargs = exp->elts[pc + 2].longconst; - argvec = (struct value **) alloca (sizeof (struct value *) - * (nargs + 5)); + argvec = XALLOCAVEC (struct value *, nargs + 5); (*pos) += 3; @@ -1202,7 +1226,7 @@ evaluate_subexp_standard (struct type *expect_type, block_for_pc (funaddr); - CHECK_TYPEDEF (val_type); + val_type = check_typedef (val_type); if ((val_type == NULL) || (TYPE_CODE(val_type) == TYPE_CODE_ERROR)) @@ -1368,7 +1392,7 @@ evaluate_subexp_standard (struct type *expect_type, else if (TYPE_CODE (type) == TYPE_CODE_MEMBERPTR) { struct type *type_ptr - = lookup_pointer_type (TYPE_DOMAIN_TYPE (type)); + = lookup_pointer_type (TYPE_SELF_TYPE (type)); struct type *target_type_ptr = lookup_pointer_type (TYPE_TARGET_TYPE (type)); @@ -1425,20 +1449,21 @@ evaluate_subexp_standard (struct type *expect_type, operator and continue evaluation. */ while (unop_user_defined_p (op, arg2)) { - volatile struct gdb_exception except; struct value *value = NULL; - TRY_CATCH (except, RETURN_MASK_ERROR) + TRY { value = value_x_unop (arg2, op, noside); } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ERROR) { if (except.error == NOT_FOUND_ERROR) break; else throw_exception (except); } + END_CATCH + arg2 = value; } } @@ -1467,7 +1492,7 @@ evaluate_subexp_standard (struct type *expect_type, function = cp_lookup_symbol_namespace (TYPE_TAG_NAME (type), name, get_selected_block (0), - VAR_DOMAIN); + VAR_DOMAIN).symbol; if (function == NULL) error (_("No symbol \"%s\" in namespace \"%s\"."), name, TYPE_TAG_NAME (type)); @@ -1717,6 +1742,15 @@ evaluate_subexp_standard (struct type *expect_type, return value_zero (builtin_type (exp->gdbarch)->builtin_int, not_lval); } + else if (TYPE_CODE (ftype) == TYPE_CODE_XMETHOD) + { + struct type *return_type + = result_type_of_xmethod (argvec[0], nargs, argvec + 1); + + if (return_type == NULL) + error (_("Xmethod is missing return type.")); + return value_zero (return_type, not_lval); + } else if (TYPE_GNU_IFUNC (ftype)) return allocate_value (TYPE_TARGET_TYPE (TYPE_TARGET_TYPE (ftype))); else if (TYPE_TARGET_TYPE (ftype)) @@ -1828,7 +1862,7 @@ evaluate_subexp_standard (struct type *expect_type, arg3 = value_struct_elt (&arg1, NULL, &exp->elts[pc + 2].string, NULL, "structure"); if (noside == EVAL_AVOID_SIDE_EFFECTS) - arg3 = value_zero (value_type (arg3), not_lval); + arg3 = value_zero (value_type (arg3), VALUE_LVAL (arg3)); return arg3; case STRUCTOP_PTR: @@ -1842,20 +1876,21 @@ evaluate_subexp_standard (struct type *expect_type, arg1 with the value returned by evaluating operator->(). */ while (unop_user_defined_p (op, arg1)) { - volatile struct gdb_exception except; struct value *value = NULL; - TRY_CATCH (except, RETURN_MASK_ERROR) + TRY { value = value_x_unop (arg1, op, noside); } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ERROR) { if (except.error == NOT_FOUND_ERROR) break; else throw_exception (except); } + END_CATCH + arg1 = value; } @@ -1912,7 +1947,7 @@ evaluate_subexp_standard (struct type *expect_type, case TYPE_CODE_MEMBERPTR: /* Now, convert these values to an address. */ - arg1 = value_cast_pointers (lookup_pointer_type (TYPE_DOMAIN_TYPE (type)), + arg1 = value_cast_pointers (lookup_pointer_type (TYPE_SELF_TYPE (type)), arg1, 1); mem_offset = value_as_long (arg2); @@ -2392,7 +2427,8 @@ evaluate_subexp_standard (struct type *expect_type, if (noside == EVAL_SKIP) goto nosideret; type = check_typedef (value_type (arg2)); - if (TYPE_CODE (type) != TYPE_CODE_INT) + if (TYPE_CODE (type) != TYPE_CODE_INT + && TYPE_CODE (type) != TYPE_CODE_ENUM) error (_("Non-integral right operand for \"@\" operator.")); if (noside == EVAL_AVOID_SIDE_EFFECTS) { @@ -3054,7 +3090,7 @@ evaluate_subexp_for_sizeof (struct expression *exp, int *pos, /* $5.3.3/2 of the C++ Standard (n3290 draft) says of sizeof: "When applied to a reference or a reference type, the result is the size of the referenced type." */ - CHECK_TYPEDEF (type); + type = check_typedef (type); if (exp->language_defn->la_language == language_cplus && TYPE_CODE (type) == TYPE_CODE_REF) type = check_typedef (TYPE_TARGET_TYPE (type));