From: Maciej W. Rozycki Date: Tue, 22 May 2012 23:17:51 +0000 (+0000) Subject: * linux-low.c (linux_store_registers): Avoid the copying sequence X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=8d409d16dd8660cfca6c32f3feed3eca36d55c20;p=binutils-gdb.git * linux-low.c (linux_store_registers): Avoid the copying sequence when no data has been retrieved by ptrace. --- diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog index 5017bc600f5..1976a42efdd 100644 --- a/gdb/gdbserver/ChangeLog +++ b/gdb/gdbserver/ChangeLog @@ -1,3 +1,8 @@ +2012-05-22 Maciej W. Rozycki + + * linux-low.c (linux_store_registers): Avoid the copying sequence + when no data has been retrieved by ptrace. + 2012-05-22 Will Deacon * linux-low (__UCLIBC__ && !(__UCLIBC_HAS_MMU__ || __ARCH_HAS_MMU__)): diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c index 19f7be64170..5fe19fdf72c 100644 --- a/gdb/gdbserver/linux-low.c +++ b/gdb/gdbserver/linux-low.c @@ -4449,11 +4449,14 @@ linux_read_memory (CORE_ADDR memaddr, unsigned char *myaddr, int len) ret = errno; /* Copy appropriate bytes out of the buffer. */ - i *= sizeof (PTRACE_XFER_TYPE); - i -= memaddr & (sizeof (PTRACE_XFER_TYPE) - 1); - memcpy (myaddr, - (char *) buffer + (memaddr & (sizeof (PTRACE_XFER_TYPE) - 1)), - i < len ? i : len); + if (i > 0) + { + i *= sizeof (PTRACE_XFER_TYPE); + i -= memaddr & (sizeof (PTRACE_XFER_TYPE) - 1); + memcpy (myaddr, + (char *) buffer + (memaddr & (sizeof (PTRACE_XFER_TYPE) - 1)), + i < len ? i : len); + } return ret; }