This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH v2 3/3] Use partial register read/writes in transfer_regset
- From: Simon Marchi <simon dot marchi at ericsson dot com>
- To: Alan Hayward <alan dot hayward at arm dot com>, <gdb-patches at sourceware dot org>
- Cc: <nd at arm dot com>
- Date: Thu, 21 Jun 2018 10:14:58 -0400
- Subject: Re: [PATCH v2 3/3] Use partial register read/writes in transfer_regset
- References: <20180621093802.79342-1-alan.hayward@arm.com> <20180621093802.79342-4-alan.hayward@arm.com>
- Spamdiagnosticmetadata: NSPM
- Spamdiagnosticoutput: 1:99
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