[v2] inf-ptrace: Do not stop memory transfers after a single word

Message ID c13d8a01-71a8-2bef-2e85-1d52edc919f2@foss.arm.com
State New, archived
Headers

Commit Message

Jiong Wang March 16, 2017, 10:44 a.m. UTC
  On 14/03/17 15:44, Andreas Arnez wrote:
> +      /* Restrict to a chunk that fits in the current word.  */
> +      chunk = std::min (sizeof (PTRACE_TYPE_RET) - skip, len - n);
>
On 14/03/17 15:44, Andreas Arnez wrote:
>
> +      /* Restrict to a chunk that fits in the current word.  */
> +      chunk = std::min (sizeof (PTRACE_TYPE_RET) - skip, len - n);

Hi Andres,

I am seeing the following build failure on my local AArch32 native build:

...binutils-gdb/gdb/inf-ptrace.c:473:65: error: no matching function for call to 'min(unsigned int, ULONGEST)'

There are a few ways to fix this, this patch simply change the type of "skip" from "unsigned int" to "ULONGEST" so operands for std::min can have the same type.

OK for master?

gdb/
2017-03-16  Jiong Wang  <jiong.wang@arm.com>

         * inf-ptrace.c (inf_ptrace_peek_poke): Change the type to "ULONGEST" for
         "skip".
  

Comments

Yao Qi March 16, 2017, 2:39 p.m. UTC | #1
Jiong Wang <jiong.wang@foss.arm.com> writes:

> I am seeing the following build failure on my local AArch32 native build:
>
> ...binutils-gdb/gdb/inf-ptrace.c:473:65: error: no matching function
> for call to 'min(unsigned int, ULONGEST)'
>
> There are a few ways to fix this, this patch simply change the type of
> "skip" from "unsigned int" to "ULONGEST" so operands for std::min can
> have the same type.
>
> OK for master?
>

Yes, pleas apply, a nit below,

> gdb/
> 2017-03-16  Jiong Wang  <jiong.wang@arm.com>
>
>         * inf-ptrace.c (inf_ptrace_peek_poke): Change the type to "ULONGEST" for

This line is too long.  The max line length of ChangeLog is 74.

>         "skip".
  
Andreas Arnez March 16, 2017, 3:21 p.m. UTC | #2
On Thu, Mar 16 2017, Jiong Wang wrote:

> I am seeing the following build failure on my local AArch32 native build:
>
> ...binutils-gdb/gdb/inf-ptrace.c:473:65: error: no matching function for
> call to 'min(unsigned int, ULONGEST)'

Hm, sorry for the breakage.

> There are a few ways to fix this, this patch simply change the type of
> "skip" from "unsigned int" to "ULONGEST" so operands for std::min can have
> the same type.

Right, that's a possibility, although the reader may be confused why a
variable whose value is known to be less than 8 needs to be declared as
ULONGEST...

--
Andreas
  

Patch

diff --git a/gdb/inf-ptrace.c b/gdb/inf-ptrace.c
index 32794ec132f72c261debd329196c73a4e3cff75b..431a36b8c726f8475650de00bf895b8d5f48fa83 100644
--- a/gdb/inf-ptrace.c
+++ b/gdb/inf-ptrace.c
@@ -462,7 +462,7 @@  inf_ptrace_peek_poke (pid_t pid, gdb_byte *readbuf,
   /* We transfer aligned words.  Thus align ADDR down to a word
      boundary and determine how many bytes to skip at the
      beginning.  */
-  unsigned int skip = addr & (sizeof (PTRACE_TYPE_RET) - 1);
+  ULONGEST skip = addr & (sizeof (PTRACE_TYPE_RET) - 1);
   addr -= skip;
 
   for (n = 0;