X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=gdb%2Feval.c;h=5bd6e2cbfea489c6baa775c84378c51610323c81;hb=10b2ded43caa3298cded1df8b620caaaee3f9209;hp=2587f776c2ad30de4bfb10f94857ebd9c76344a1;hpb=c83833f49353e1fe7fa727291210be751161ade1;p=deliverable%2Fbinutils-gdb.git diff --git a/gdb/eval.c b/gdb/eval.c index 2587f776c2..5bd6e2cbfe 100644 --- a/gdb/eval.c +++ b/gdb/eval.c @@ -1,6 +1,6 @@ /* Evaluate expressions for GDB. - Copyright (C) 1986-2017 Free Software Foundation, Inc. + Copyright (C) 1986-2018 Free Software Foundation, Inc. This file is part of GDB. @@ -69,27 +69,20 @@ struct value * evaluate_subexp (struct type *expect_type, struct expression *exp, int *pos, enum noside noside) { - struct cleanup *cleanups; struct value *retval; - int cleanup_temps = 0; + gdb::optional stack_temporaries; 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; - } + stack_temporaries.emplace (inferior_ptid); 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); - } + if (stack_temporaries.has_value () + && value_in_thread_stack_temporaries (retval, inferior_ptid)) + retval = value_non_lval (retval); return retval; } @@ -186,14 +179,14 @@ evaluate_subexpression_type (struct expression *exp, int subexp) set to any referenced values. *VALP will never be a lazy value. This is the value which we store in struct breakpoint. - If VAL_CHAIN is non-NULL, *VAL_CHAIN will be released from the - value chain. The caller must free the values individually. If - VAL_CHAIN is NULL, all generated values will be left on the value - chain. */ + If VAL_CHAIN is non-NULL, the values put into *VAL_CHAIN will be + released from the value chain. If VAL_CHAIN is NULL, all generated + values will be left on the value chain. */ void fetch_subexp_value (struct expression *exp, int *pc, struct value **valp, - struct value **resultp, struct value **val_chain, + struct value **resultp, + std::vector *val_chain, int preserve_errors) { struct value *mark, *new_mark, *result; @@ -202,7 +195,7 @@ fetch_subexp_value (struct expression *exp, int *pc, struct value **valp, if (resultp) *resultp = NULL; if (val_chain) - *val_chain = NULL; + val_chain->clear (); /* Evaluate the expression. */ mark = value_mark (); @@ -222,6 +215,7 @@ fetch_subexp_value (struct expression *exp, int *pc, struct value **valp, case MEMORY_ERROR: if (!preserve_errors) break; + /* Fall through. */ default: throw_exception (ex); break; @@ -260,8 +254,7 @@ fetch_subexp_value (struct expression *exp, int *pc, struct value **valp, { /* Return the chain of intermediate values. We use this to decide which addresses to watch. */ - *val_chain = new_mark; - value_release_to_mark (mark); + *val_chain = value_release_to_mark (mark); } } @@ -272,7 +265,7 @@ fetch_subexp_value (struct expression *exp, int *pc, struct value **valp, subexpression of the left-hand-side of the dereference. This is used when completing field names. */ -char * +const char * extract_field_op (struct expression *exp, int *subexp) { int tem; @@ -705,7 +698,7 @@ fake_method::~fake_method () /* Helper for evaluating an OP_VAR_VALUE. */ -static value * +value * evaluate_var_value (enum noside noside, const block *blk, symbol *var) { /* JYG: We used to just return value_zero of the symbol type if @@ -738,26 +731,22 @@ evaluate_var_value (enum noside noside, const block *blk, symbol *var) /* Helper for evaluating an OP_VAR_MSYM_VALUE. */ -static value * +value * evaluate_var_msym_value (enum noside noside, struct objfile *objfile, minimal_symbol *msymbol) { - if (noside == EVAL_AVOID_SIDE_EFFECTS) - { - type *the_type = find_minsym_type_and_address (msymbol, objfile, NULL); - return value_zero (the_type, not_lval); - } + CORE_ADDR address; + type *the_type = find_minsym_type_and_address (msymbol, objfile, &address); + + if (noside == EVAL_AVOID_SIDE_EFFECTS && !TYPE_GNU_IFUNC (the_type)) + return value_zero (the_type, not_lval); else - { - CORE_ADDR address; - type *the_type = find_minsym_type_and_address (msymbol, objfile, &address); - return value_at_lazy (the_type, address); - } + return value_at_lazy (the_type, address); } /* Helper for returning a value when handling EVAL_SKIP. */ -static value * +value * eval_skip_value (expression *exp) { return value_from_longest (builtin_type (exp->gdbarch)->builtin_int, 1); @@ -805,6 +794,15 @@ eval_call (expression *exp, enum noside noside, else if (TYPE_CODE (ftype) == TYPE_CODE_FUNC || TYPE_CODE (ftype) == TYPE_CODE_METHOD) { + if (TYPE_GNU_IFUNC (ftype)) + { + CORE_ADDR address = value_address (argvec[0]); + type *resolved_type = find_gnu_ifunc_target_type (address); + + if (resolved_type != NULL) + ftype = resolved_type; + } + type *return_type = TYPE_TARGET_TYPE (ftype); if (return_type == NULL) @@ -1046,13 +1044,13 @@ evaluate_funcall (type *expect_type, expression *exp, int *pos, { if (op == OP_VAR_MSYM_VALUE) { - symbol *sym = exp->elts[*pos + 2].symbol; - var_func_name = SYMBOL_PRINT_NAME (sym); + minimal_symbol *msym = exp->elts[*pos + 2].msymbol; + var_func_name = MSYMBOL_PRINT_NAME (msym); } else if (op == OP_VAR_VALUE) { - minimal_symbol *msym = exp->elts[*pos + 2].msymbol; - var_func_name = MSYMBOL_PRINT_NAME (msym); + symbol *sym = exp->elts[*pos + 2].symbol; + var_func_name = SYMBOL_PRINT_NAME (sym); } argvec[0] = evaluate_subexp_with_coercion (exp, pos, noside); @@ -1277,15 +1275,10 @@ evaluate_subexp_standard (struct type *expect_type, return value_from_longest (exp->elts[pc + 1].type, exp->elts[pc + 2].longconst); - case OP_DOUBLE: - (*pos) += 3; - return value_from_double (exp->elts[pc + 1].type, - exp->elts[pc + 2].doubleconst); - - case OP_DECFLOAT: + case OP_FLOAT: (*pos) += 3; - return value_from_decfloat (exp->elts[pc + 1].type, - exp->elts[pc + 2].decfloatconst); + return value_from_contents (exp->elts[pc + 1].type, + exp->elts[pc + 2].floatconst); case OP_ADL_FUNC: case OP_VAR_VALUE: @@ -1755,7 +1748,7 @@ evaluate_subexp_standard (struct type *expect_type, /* The address might point to a function descriptor; resolve it to the actual code address instead. */ addr = gdbarch_convert_from_func_ptr_addr (exp->gdbarch, addr, - ¤t_target); + target_stack); /* Is it a high_level symbol? */ sym = find_pc_function (addr); @@ -2675,6 +2668,19 @@ evaluate_subexp_standard (struct type *expect_type, } return evaluate_subexp_for_sizeof (exp, pos, noside); + case UNOP_ALIGNOF: + { + struct type *type + = value_type (evaluate_subexp (NULL_TYPE, exp, pos, + EVAL_AVOID_SIDE_EFFECTS)); + /* FIXME: This should be size_t. */ + struct type *size_type = builtin_type (exp->gdbarch)->builtin_int; + ULONGEST align = type_align (type); + if (align == 0) + error (_("could not determine alignment of type")); + return value_from_longest (size_type, align); + } + case UNOP_CAST: (*pos) += 2; type = exp->elts[pc + 1].type;