aboutsummaryrefslogtreecommitdiff
path: root/gdb/eval.c
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2018-03-07 15:55:01 -0700
committerTom Tromey <tom@tromey.com>2018-03-08 21:57:14 -0700
commitfdf07f3aeba5906fec462fba33801c173862f241 (patch)
treefd68e3d0ab16ad5ce80e87f998f4f5db71d8d845 /gdb/eval.c
parent0089daceaba4338046932e65a1b5882065416633 (diff)
downloadgdb-fdf07f3aeba5906fec462fba33801c173862f241.zip
gdb-fdf07f3aeba5906fec462fba33801c173862f241.tar.gz
gdb-fdf07f3aeba5906fec462fba33801c173862f241.tar.bz2
Change enable_thread_stack_temporaries to an RAII class
This started as a patch to change enable_thread_stack_temporaries to be an RAII class, but then I noticed that this code used a VEC, so I went ahead and did a bit more C++-ification, changing stack_temporaries_enabled to a bool and changing stack_temporaries to a std::vector. Regression tested by the buildbot. gdb/ChangeLog 2018-03-08 Tom Tromey <tom@tromey.com> * infcall.c (struct call_return_meta_info) <stack_temporaries_enabled>: Remove. (get_call_return_value, call_function_by_hand_dummy): Update. * thread.c (disable_thread_stack_temporaries): Remove. (enable_thread_stack_temporaries): Remove. (thread_stack_temporaries_enabled_p): Return bool. (push_thread_stack_temporary, value_in_thread_stack_temporaries) (get_last_thread_stack_temporary): Update. * eval.c (evaluate_subexp): Update. * gdbthread.h (class enable_thread_stack_temporaries): Now a class, not a function. (value_ptr, value_vec): Remove typedefs. (class thread_info) <stack_temporaries_enabled>: Now bool. <stack_temporaries>: Now a std::vector. (thread_stack_temporaries_enabled_p) (value_in_thread_stack_temporaries): Return bool.
Diffstat (limited to 'gdb/eval.c')
-rw-r--r--gdb/eval.c17
1 files changed, 5 insertions, 12 deletions
diff --git a/gdb/eval.c b/gdb/eval.c
index 4899011..b2032c3 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -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<enable_thread_stack_temporaries> 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;
}