This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] Forward VALUE_LVAL when avoiding side effects for STRUCTOP_STRUCT
- From: Joel Brobecker <brobecker at adacore dot com>
- To: Pierre-Marie de Rodat <derodat at adacore dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Thu, 24 Sep 2015 09:24:27 -0400
- Subject: Re: [PATCH] Forward VALUE_LVAL when avoiding side effects for STRUCTOP_STRUCT
- Authentication-results: sourceware.org; auth=none
- References: <1442325448-27163-1-git-send-email-derodat at adacore dot com>
Hi Pierre-Marie,
> 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.
Comments below...
> 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;
I'm not really sure this is a good idea to be doing that. We're building
somewhat of a fake "struct value", and the value's "discriminant" should,
in my mind at least, always reflect that through setting the lval to
"not_lval".
Have you tried modifying this function's handling of UNOP_ADDR
in the case of EVAL_AVOID_SIDE_EFFECTS instead? Add some code there
to return a not_lval value_zero with the correct type...
> +# Sanity checking:
> +gdb_test "print &foo_array\[1\].a" "= \\(int \\*\\) 0x.*"
Use "$hex.*" instead of "0x.*"...
> +# A bug in EVAL_AVOID_SIDE_EFFECTS mode used to yield the following error:
> +# Attempt to take address of value not located in memory.
> +gdb_test "print 1 && &foo_array\[1\].a" "= 1"
--
Joel