+2005-05-16 Ulrich Weigand <uweigand@de.ibm.com>
+
+ * linux-low.c (fetch_register): Ensure buffer size is a multiple
+ of sizeof (PTRACE_XFER_TYPE).
+ (usr_store_inferior_registers): Likewise. Zero out excess bytes.
+
2005-05-12 Orjan Friberg <orjanf@axis.com>
* target.h (struct target_ops): Add insert_watchpoint,
fetch_register (int regno)
{
CORE_ADDR regaddr;
- register int i;
+ int i, size;
char *buf;
if (regno >= the_low_target.num_regs)
regaddr = register_addr (regno);
if (regaddr == -1)
return;
- buf = alloca (register_size (regno));
- for (i = 0; i < register_size (regno); i += sizeof (PTRACE_XFER_TYPE))
+ size = (register_size (regno) + sizeof (PTRACE_XFER_TYPE) - 1)
+ & - sizeof (PTRACE_XFER_TYPE);
+ buf = alloca (size);
+ for (i = 0; i < size; i += sizeof (PTRACE_XFER_TYPE))
{
errno = 0;
*(PTRACE_XFER_TYPE *) (buf + i) =
usr_store_inferior_registers (int regno)
{
CORE_ADDR regaddr;
- int i;
+ int i, size;
char *buf;
if (regno >= 0)
if (regaddr == -1)
return;
errno = 0;
- buf = alloca (register_size (regno));
+ size = (register_size (regno) + sizeof (PTRACE_XFER_TYPE) - 1)
+ & - sizeof (PTRACE_XFER_TYPE);
+ buf = alloca (size);
+ memset (buf, 0, size);
collect_register (regno, buf);
- for (i = 0; i < register_size (regno); i += sizeof (PTRACE_XFER_TYPE))
+ for (i = 0; i < size; i += sizeof (PTRACE_XFER_TYPE))
{
errno = 0;
ptrace (PTRACE_POKEUSER, inferior_pid, (PTRACE_ARG3_TYPE) regaddr,