Handle other cases than EVAL_NORMAL in the default case
authorJerome Guitton <guitton@adacore.com>
Thu, 29 Nov 2012 16:26:12 +0000 (16:26 +0000)
committerJerome Guitton <guitton@adacore.com>
Thu, 29 Nov 2012 16:26:12 +0000 (16:26 +0000)
In the evaluation of an expression in Ada mode, the default case
unwraps the argument unconditionally. For an object of a variant
record type, this unwrapping builds a fixed type from the
specification of the variant type and the actual values of the
object's discriminants.  It means that unwrapping needs the "proper"
value for the object, not just a zero value with the proper type.

When not in EVAL_NORMAL, we cannot assume that the evaluation returns
such a proper value; it may well return a zero value of the
appropriate type e.g in EVAL_AVOID_SIDE_EFFECTS. It is wrong to try to
unwrap in that case.

In particular, a problem shows up when using expression of the form
{VARIANT_TYPE}OBJ. GDB first evaluates this expression in
EVAL_AVOID_SIDE_EFFECTS to compute the type, the evaluation of OBJ
in most cases returns a zero value of its type, and as UNOP_MEMVAL
is mapped to the default case its evaluation ends up trying to
read memory around address 0.

gdb/ChangeLog:

* ada-lang.c (ada_evaluate_subexp): Unwrap only in EVAL_NORMAL.

gdb/ChangeLog
gdb/ada-lang.c

index 48c18459d9fa9141db5413906be89d043bdacea3..cd86c848b94ad7444e1de721c38401312353cacb 100644 (file)
@@ -1,3 +1,7 @@
+2012-11-29  Jerome Guitton  <guitton@adacore.com>
+
+       * ada-lang.c (ada_evaluate_subexp): Unwrap only in EVAL_NORMAL.
+
 2012-11-29  Joel Brobecker  <brobecker@adacore.com>
 
        GDB 7.5.1 released.
index 0621c79b32c7369325772e6d5f07b20c0d0bc9f7..ee2f76529da61644fb1d3f3aef9eaaa1fa874816 100644 (file)
@@ -9453,7 +9453,9 @@ ada_evaluate_subexp (struct type *expect_type, struct expression *exp,
     default:
       *pos -= 1;
       arg1 = evaluate_subexp_standard (expect_type, exp, pos, noside);
-      arg1 = unwrap_value (arg1);
+
+      if (noside == EVAL_NORMAL)
+       arg1 = unwrap_value (arg1);
 
       /* If evaluating an OP_DOUBLE and an EXPECT_TYPE was provided,
          then we need to perform the conversion manually, because
This page took 0.039517 seconds and 4 git commands to generate.