diff options
author | Jerome Guitton <guitton@adacore.com> | 2012-11-29 16:26:12 +0000 |
---|---|---|
committer | Jerome Guitton <guitton@adacore.com> | 2012-11-29 16:26:12 +0000 |
commit | ca1f964d4b41c778c8f2249e78990a5695645f23 (patch) | |
tree | d54c05cc3ac7e4be1ac3052fdf3091eb6e2578cf /gdb/ada-lang.c | |
parent | 17a5e4b87533c9639c75082bf81bd034aafc3b4f (diff) | |
download | gdb-ca1f964d4b41c778c8f2249e78990a5695645f23.zip gdb-ca1f964d4b41c778c8f2249e78990a5695645f23.tar.gz gdb-ca1f964d4b41c778c8f2249e78990a5695645f23.tar.bz2 |
Handle other cases than EVAL_NORMAL in the default case
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.
Diffstat (limited to 'gdb/ada-lang.c')
-rw-r--r-- | gdb/ada-lang.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 0621c79..ee2f765 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -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 |