Forward VALUE_LVAL when avoiding side effects for STRUCTOP_STRUCT
authorPierre-Marie de Rodat <derodat@adacore.com>
Tue, 15 Sep 2015 13:46:17 +0000 (15:46 +0200)
committerPierre-Marie de Rodat <derodat@adacore.com>
Mon, 12 Oct 2015 10:22:10 +0000 (12:22 +0200)
Assume foo_array is a pointer to a C structure. GDB must evaluate the
following expression properly, but it does not currently:

    (gdb) print 1 && &foo_array[1].a
    Attempt to take address of value not located in memory.

The problem is that in EVAL_AVOID_SIDE_EFFECTS mode,
eval.c:evaluate_subexp_standard always returns a not_lval value as the
result for a STRUCTOP_STRUCT operation. As a consequence, the rest of
the code believes that one cannot take the address of the returned
value.

This patch fixes STRUCTOP_STRUCT handling so that the VALUE_LVAL
attribute for the returned value is properly initialized.  After this
change, the above session becomes:

    (gdb) print 1 && &foo_array[1].a
    $1 = 1

gdb/ChangeLog:

* eval.c (evaluate_subexp_standard) <STRUCTOP_STRUCT>: If
EVAL_AVOID_SIDE_EFFECTS mode, forward the VALUE_LVAL attribute
to the returned value.

gdb/testsuite/ChangeLog:

* gdb.base/nested-addr.c: New file.
* gdb.base/nested-addr.exp: New testcase.

Tested on x86_64-linux, no regression.


No differences found