aboutsummaryrefslogtreecommitdiff
path: root/gdb/eval.c
diff options
context:
space:
mode:
authorSiva Chandra <sivachandra@chromium.org>2014-11-11 05:43:03 -0800
committerSiva Chandra <sivachandra@chromium.org>2014-11-28 16:01:16 -0800
commit6c659fc2c7cd2da6d2b9a3d7c38597ad3821832a (patch)
tree4d45593c088252f07a928ff05ba96e79ea629daf /gdb/eval.c
parentf4f855e84b45eb41987641b4a26037c7444dda33 (diff)
Enable chained function calls in C++ expressions.
gdb/ChangeLog: * eval.c: Include gdbthread.h. (evaluate_subexp): Enable thread stack temporaries before evaluating a complete expression and clean them up after the evaluation is complete. * gdbthread.h: Include common/vec.h. (value_ptr): New typedef. (VEC (value_ptr)): New vector type. (value_vec): New typedef. (struct thread_info): Add new fields stack_temporaries_enabled and stack_temporaries. (enable_thread_stack_temporaries) (thread_stack_temporaries_enabled_p, push_thread_stack_temporary) (get_last_thread_stack_temporary) (value_in_thread_stack_temporaries): Declare. * gdbtypes.c (class_or_union_p): New function. * gdbtypes.h (class_or_union_p): Declare. * infcall.c (call_function_by_hand): Store return values of class type as temporaries on stack. * thread.c (enable_thread_stack_temporaries): New function. (thread_stack_temporaries_enabled_p, push_thread_stack_temporary) (get_last_thread_stack_temporary): Likewise. (value_in_thread_stack_temporaries): Likewise. * value.c (value_force_lval): New function. * value.h (value_force_lval): Declare. gdb/testsuite/ChangeLog: * gdb.cp/chained-calls.cc: New file. * gdb.cp/chained-calls.exp: New file. * gdb.cp/smartp.exp: Remove KFAIL for "p c2->inta".
Diffstat (limited to 'gdb/eval.c')
-rw-r--r--gdb/eval.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/gdb/eval.c b/gdb/eval.c
index 655ea223b1..a13793ca72 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -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,28 @@ 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)
+ {
+ 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,