[PATCH v2 3/3] Use partial register read/writes in transfer_regset

Simon Marchi simon.marchi@ericsson.com
Thu Jun 21 14:16:00 GMT 2018


Hi Alan,

On 2018-06-21 05:38 AM, Alan Hayward wrote:
> @@ -1013,12 +1077,18 @@ regcache::transfer_regset (const struct regset *regset,
>  	    if (offs + slot_size > size)
>  	      break;
>  
> +	    /* Use part versions to prevent possible overflow.  */
>  	    if (out_buf)

Can you update the pointer comparisons in the code you touch to use != NULL or != nullptr?

> diff --git a/gdb/regcache.h b/gdb/regcache.h
> index c17ce09dee..a69b67d513 100644
> --- a/gdb/regcache.h
> +++ b/gdb/regcache.h
> @@ -162,6 +162,11 @@ public:
>    void raw_collect_integer (int regnum, gdb_byte *addr, int addr_len,
>  			    bool is_signed) const;
>  
> +  /* Collect register REGNUM from REGCACHE, starting at offset in REGCACHE,
> +     reading only LEN.  If this runs off the end of the register, then fill the
> +     additional space with zeros.  */

To have a consistent interface,  I would be tempted to use the same behavior as
read_part and write_part for reads and writes that run off the end of the register
(not allow it).  It would be the responsibility of the caller to ensure that they
don't overflow.  I think it would just be a matter of

  std::min (reg_size, slot_size)

?

Simon



More information about the Gdb-patches mailing list