This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] Assert on lval_register
- From: "Ulrich Weigand" <uweigand at de dot ibm dot com>
- To: qiyaoltc at gmail dot com (Yao Qi)
- Cc: gdb-patches at sourceware dot org
- Date: Wed, 30 Nov 2016 22:16:37 +0100 (CET)
- Subject: Re: [PATCH] Assert on lval_register
- Authentication-results: sourceware.org; auth=none
Yao Qi wrote:
> This patch adds asserts where the value's lval must be lval_register.
> This triggers an error in frame_register_unwind because VALUE_REGNUM
> is used but value's lval is not lval_register.
Makes sense to me.
> This also reveals a design issue in frame_register_unwind, that is
> arguments addrp and realnump are mutually exclusive, we either use
> addrp (for lval_memory), or use realnump (for lval_register). This
> can be done in a separate patch.
I think we should simply get rid of frame_register_unwind. Callers
should be changed to use frame_unwind_register_value directly, and
just operate on the value.
> *lvalp = VALUE_LVAL (value);
> *addrp = value_address (value);
> - *realnump = VALUE_REGNUM (value);
> + if (*lvalp == lval_register)
> + *realnump = VALUE_REGNUM (value);
But as long as the above change is not done yet, maybe we ought to
at least provide a defined value (e.g. -1), to avoid callers maybe
making use of uninitialized variables?
Bye,
Ulrich
--
Dr. Ulrich Weigand
GNU/Linux compilers and toolchain
Ulrich.Weigand@de.ibm.com