X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=gdb%2Feval.c;h=00a107c270c84af7d83cfbe9aa6fff23a7bb9d28;hb=463888ab6be549e8dcc9eac36dc07c1c237e2968;hp=a13793ca7289020643dc909ebe48ad0b0e536cde;hpb=6c659fc2c7cd2da6d2b9a3d7c38597ad3821832a;p=deliverable%2Fbinutils-gdb.git diff --git a/gdb/eval.c b/gdb/eval.c index a13793ca72..00a107c270 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. @@ -69,7 +69,8 @@ evaluate_subexp (struct type *expect_type, struct expression *exp, int cleanup_temps = 0; if (*pos == 0 && target_has_execution - && exp->language_defn->la_language == language_cplus) + && exp->language_defn->la_language == language_cplus + && !thread_stack_temporaries_enabled_p (inferior_ptid)) { cleanups = enable_thread_stack_temporaries (inferior_ptid); cleanup_temps = 1; @@ -211,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) @@ -223,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 @@ -242,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) @@ -257,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 } } @@ -402,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 range_type range_type + = (enum range_type) longest_to_int (exp->elts[pc].longconst); *pos += 3; @@ -663,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) { @@ -762,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), @@ -779,6 +782,7 @@ evaluate_subexp_standard (struct type *expect_type, else throw_exception (except); } + END_CATCH return ret; } @@ -994,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 @@ -1060,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; @@ -1078,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; @@ -1223,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)) @@ -1389,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)); @@ -1446,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; } } @@ -1488,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)); @@ -1738,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)) @@ -1797,13 +1810,13 @@ evaluate_subexp_standard (struct type *expect_type, switch (code) { case TYPE_CODE_ARRAY: - if (exp->elts[*pos].opcode == OP_F90_RANGE) + if (exp->elts[*pos].opcode == OP_RANGE) return value_f90_subarray (arg1, exp, pos, noside); else goto multi_f77_subscript; case TYPE_CODE_STRING: - if (exp->elts[*pos].opcode == OP_F90_RANGE) + if (exp->elts[*pos].opcode == OP_RANGE) return value_f90_subarray (arg1, exp, pos, noside); else { @@ -1849,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: @@ -1863,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; } @@ -1886,7 +1900,8 @@ evaluate_subexp_standard (struct type *expect_type, { struct type *type = value_type (arg1); struct type *real_type; - int full, top, using_enc; + int full, using_enc; + LONGEST top; struct value_print_options opts; get_user_print_options (&opts); @@ -1903,7 +1918,7 @@ evaluate_subexp_standard (struct type *expect_type, arg3 = value_struct_elt (&arg1, NULL, &exp->elts[pc + 2].string, NULL, "structure pointer"); 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_MEMBER: @@ -1933,7 +1948,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); @@ -2413,7 +2428,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) { @@ -3075,7 +3091,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));