aboutsummaryrefslogtreecommitdiff
path: root/gdb/eval.c
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2012-07-19 15:33:25 +0000
committerTom Tromey <tromey@redhat.com>2012-07-19 15:33:25 +0000
commit9eaf670568f57fc78fe40d30fc89ac5b442693fb (patch)
tree4feb162ee44c711926d1d7f72db9dd486f374cde /gdb/eval.c
parentb1e0c0fa45dd11ac221adf99789aaaa8517a7b47 (diff)
downloadgdb-9eaf670568f57fc78fe40d30fc89ac5b442693fb.zip
gdb-9eaf670568f57fc78fe40d30fc89ac5b442693fb.tar.gz
gdb-9eaf670568f57fc78fe40d30fc89ac5b442693fb.tar.bz2
* ax-gdb.c (gen_expr): Handle UNOP_CAST_TYPE, UNOP_MEMVAL_TYPE.
* breakpoint.c (watchpoint_exp_is_const): Handle UNOP_CAST_TYPE, UNOP_REINTERPRET_CAST, UNOP_DYNAMIC_CAST. * c-exp.y (exp): Emit UNOP_MEMVAL_TYPE, UNOP_CAST_TYPE. Update for changes to UNOP_REINTERPRET_CAST, UNOP_DYNAMIC_CAST. Use type_exp production where appropriate. * eval.c (evaluate_subexp_standard) <UNOP_CAST_TYPE>: New case. <UNOP_DYNAMIC_CAST, UNOP_REINTERPRET_CAST>: Update. <UNOP_MEMVAL_TYPE>: New case. (evaluate_subexp_for_address) <UNOP_MEMVAL_TYPE>: New case. (evaluate_subexp_for_sizeof) <UNOP_MEMVAL_TYPE>: New case. * expprint.c (print_subexp_standard) <UNOP_CAST_TYPE>: New case. <UNOP_MEMVAL_TYPE>: New case. (dump_subexp_body_standard) <UNOP_DYNAMIC_CAST, UNOP_REINTERPRET_CAST>: Update. <UNOP_CAST_TYPE, UNOP_MEMVAL_TYPE>: New cases. * parse.c (operator_length_standard) <UNOP_DYNAMIC_CAST, UNOP_REINTERPRET_CAST>: Update. <UNOP_CAST_TYPE, UNOP_MEMVAL_TYPE>: New cases. * stack.c (return_command): Also check for UNOP_CAST_TYPE. * std-operator.def (UNOP_CAST_TYPE, UNOP_MEMVAL_TYPE): New constants.
Diffstat (limited to 'gdb/eval.c')
-rw-r--r--gdb/eval.c47
1 files changed, 43 insertions, 4 deletions
diff --git a/gdb/eval.c b/gdb/eval.c
index 7d3a8b9..a012873 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -2707,17 +2707,27 @@ evaluate_subexp_standard (struct type *expect_type,
arg1 = value_cast (type, arg1);
return arg1;
+ case UNOP_CAST_TYPE:
+ arg1 = evaluate_subexp (NULL, exp, pos, EVAL_AVOID_SIDE_EFFECTS);
+ type = value_type (arg1);
+ arg1 = evaluate_subexp (type, exp, pos, noside);
+ if (noside == EVAL_SKIP)
+ goto nosideret;
+ if (type != value_type (arg1))
+ arg1 = value_cast (type, arg1);
+ return arg1;
+
case UNOP_DYNAMIC_CAST:
- (*pos) += 2;
- type = exp->elts[pc + 1].type;
+ arg1 = evaluate_subexp (NULL, exp, pos, EVAL_AVOID_SIDE_EFFECTS);
+ type = value_type (arg1);
arg1 = evaluate_subexp (type, exp, pos, noside);
if (noside == EVAL_SKIP)
goto nosideret;
return value_dynamic_cast (type, arg1);
case UNOP_REINTERPRET_CAST:
- (*pos) += 2;
- type = exp->elts[pc + 1].type;
+ arg1 = evaluate_subexp (NULL, exp, pos, EVAL_AVOID_SIDE_EFFECTS);
+ type = value_type (arg1);
arg1 = evaluate_subexp (type, exp, pos, noside);
if (noside == EVAL_SKIP)
goto nosideret;
@@ -2734,6 +2744,18 @@ evaluate_subexp_standard (struct type *expect_type,
return value_at_lazy (exp->elts[pc + 1].type,
value_as_address (arg1));
+ case UNOP_MEMVAL_TYPE:
+ arg1 = evaluate_subexp (NULL, exp, pos, EVAL_AVOID_SIDE_EFFECTS);
+ type = value_type (arg1);
+ arg1 = evaluate_subexp (expect_type, exp, pos, noside);
+ if (noside == EVAL_SKIP)
+ goto nosideret;
+ if (noside == EVAL_AVOID_SIDE_EFFECTS)
+ return value_zero (exp->elts[pc + 1].type, lval_memory);
+ else
+ return value_at_lazy (exp->elts[pc + 1].type,
+ value_as_address (arg1));
+
case UNOP_MEMVAL_TLS:
(*pos) += 3;
arg1 = evaluate_subexp (expect_type, exp, pos, noside);
@@ -2936,6 +2958,17 @@ evaluate_subexp_for_address (struct expression *exp, int *pos,
return value_cast (lookup_pointer_type (exp->elts[pc + 1].type),
evaluate_subexp (NULL_TYPE, exp, pos, noside));
+ case UNOP_MEMVAL_TYPE:
+ {
+ struct type *type;
+
+ (*pos) += 1;
+ x = evaluate_subexp (NULL_TYPE, exp, pos, EVAL_AVOID_SIDE_EFFECTS);
+ type = value_type (x);
+ return value_cast (lookup_pointer_type (type),
+ evaluate_subexp (NULL_TYPE, exp, pos, noside));
+ }
+
case OP_VAR_VALUE:
var = exp->elts[pc + 2].symbol;
@@ -3078,6 +3111,12 @@ evaluate_subexp_for_sizeof (struct expression *exp, int *pos)
type = check_typedef (exp->elts[pc + 1].type);
return value_from_longest (size_type, (LONGEST) TYPE_LENGTH (type));
+ case UNOP_MEMVAL_TYPE:
+ (*pos) += 1;
+ val = evaluate_subexp (NULL, exp, pos, EVAL_AVOID_SIDE_EFFECTS);
+ type = check_typedef (value_type (val));
+ return value_from_longest (size_type, (LONGEST) TYPE_LENGTH (type));
+
case OP_VAR_VALUE:
(*pos) += 4;
type = check_typedef (SYMBOL_TYPE (exp->elts[pc + 2].symbol));