+2010-03-14 Pedro Alves <pedro@codesourcery.com>
+
+ * linux-low.c (linux_write_memory): Bail out early if peeking
+ memory failed.
+
2010-03-14 Pedro Alves <pedro@codesourcery.com>
* linux-low.h (struct lwp_info): New fields
return 0;
}
-/* Copy LEN bytes of data from debugger memory at MYADDR
- to inferior's memory at MEMADDR.
- On failure (cannot write the inferior)
+/* Copy LEN bytes of data from debugger memory at MYADDR to inferior's
+ memory at MEMADDR. On failure (cannot write to the inferior)
returns the value of errno. */
static int
/* Fill start and end extra bytes of buffer with existing memory data. */
+ errno = 0;
/* Coerce the 3rd arg to a uintptr_t first to avoid potential gcc warning
about coercing an 8 byte integer to a 4 byte pointer. */
buffer[0] = ptrace (PTRACE_PEEKTEXT, pid,
(PTRACE_ARG3_TYPE) (uintptr_t) addr, 0);
+ if (errno)
+ return errno;
if (count > 1)
{
+ errno = 0;
buffer[count - 1]
= ptrace (PTRACE_PEEKTEXT, pid,
/* Coerce to a uintptr_t first to avoid potential gcc warning
(PTRACE_ARG3_TYPE) (uintptr_t) (addr + (count - 1)
* sizeof (PTRACE_XFER_TYPE)),
0);
+ if (errno)
+ return errno;
}
- /* Copy data to be written over corresponding part of buffer */
+ /* Copy data to be written over corresponding part of buffer. */
memcpy ((char *) buffer + (memaddr & (sizeof (PTRACE_XFER_TYPE) - 1)), myaddr, len);