This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Assert on lval_register


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]