Re: [PATCH 23/26] gdbserver: set register statuses in registers_from_string

Simon Marchi
2023-12-22T04:40:41Z

On 2023-02-28 06:28, Tankut Baris Aktemur via Gdb-patches wrote:
> The registers_from_string function uses hex2bin to set the values of
> all registers. Set the register statuses to REG_VALID to reflect this
> change.
> ---
> gdbserver/regcache.cc | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/gdbserver/regcache.cc b/gdbserver/regcache.cc
> index 644f436c681..32f0e1109e6 100644
> --- a/gdbserver/regcache.cc
> +++ b/gdbserver/regcache.cc
> @@ -259,6 +259,8 @@ regcache::registers_from_string (const char *buf)
> len = tdesc->registers_size * 2;
> }
> hex2bin (buf, registers, len / 2);
> + /* All register data have been re-written. Update the statuses. */
> + memset (register_status, REG_VALID, tdesc->reg_defs.size ());
> }
>
> /* See regcache.h */

Well... technically, registers_from_string is written in a way that if
the input buffer is too short, the registers at the end will not be
written (don't know why it's written like that, instead of erroring out,
but that's how it is right now). So you should only set to REG_VALID the
registers that are actually completely written, setting the rest to
REG_UNKNOWN.

Simon