aboutsummaryrefslogtreecommitdiff
path: root/gdb/eval.c
diff options
context:
space:
mode:
authorPierre-Marie de Rodat <derodat@adacore.com>2015-09-15 15:46:17 +0200
committerPierre-Marie de Rodat <derodat@adacore.com>2015-10-12 12:22:10 +0200
commit2520f728b710c0249cde01b8cfb4872a22ef10b6 (patch)
tree9aa56505b311c50b16412b867640b5364eb3059b /gdb/eval.c
parent431ff0756ac64c33f6cfbfa8f1cc21c739b7e601 (diff)
downloadgdb-2520f728b710c0249cde01b8cfb4872a22ef10b6.zip
gdb-2520f728b710c0249cde01b8cfb4872a22ef10b6.tar.gz
gdb-2520f728b710c0249cde01b8cfb4872a22ef10b6.tar.bz2
Forward VALUE_LVAL when avoiding side effects for STRUCTOP_STRUCT
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.
Diffstat (limited to 'gdb/eval.c')
-rw-r--r--gdb/eval.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/gdb/eval.c b/gdb/eval.c
index a668e76..84e2e34 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -1862,7 +1862,7 @@ evaluate_subexp_standard (struct type *expect_type,
arg3 = value_struct_elt (&arg1, NULL, &exp->elts[pc + 2].string,
NULL, "structure");
if (noside == EVAL_AVOID_SIDE_EFFECTS)
- arg3 = value_zero (value_type (arg3), not_lval);
+ arg3 = value_zero (value_type (arg3), VALUE_LVAL (arg3));
return arg3;
case STRUCTOP_PTR: