This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH obv/c++] Add/adjust casts in gdbserver's proc-service
- From: Pedro Alves <palves at redhat dot com>
- To: Simon Marchi <simon dot marchi at ericsson dot com>, gdb-patches <gdb-patches at sourceware dot org>
- Date: Fri, 30 Oct 2015 15:05:05 +0000
- Subject: Re: [PATCH obv/c++] Add/adjust casts in gdbserver's proc-service
- Authentication-results: sourceware.org; auth=none
- References: <1446142796-22900-1-git-send-email-simon dot marchi at ericsson dot com> <56337019 dot 4060609 at ericsson dot com>
On 10/30/2015 01:26 PM, Simon Marchi wrote:
> Turns out this wasn't obvious. Casting a psaddr_t to a CORE_ADDR on i386 gives:
Yeah, that's easy to miss.
>
> ../../../binutils-gdb/gdb/gdbserver/proc-service.c: In function ps_pdread:
> ../../../binutils-gdb/gdb/gdbserver/proc-service.c:83:25: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
> ../../../binutils-gdb/gdb/gdbserver/proc-service.c: In function ps_pdwrite:
> ../../../binutils-gdb/gdb/gdbserver/proc-service.c:93:30: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
>
> I think the right fix would be to go through uintptr_t: (CORE_ADDR) (uintptr_t) addr.
> It builds on 32 and 64 bits. Is it ok to apply?
The original fix could have been just:
- if (write_inferior_memory ((unsigned long) addr, buf, size) != 0)
- if (write_inferior_memory ((unsigned long) addr, (const gdb_byte *) buf, size)
As it was the pointer type difference that really was causing an issue.
So this:
if (write_inferior_memory ((uintptr_pt) addr, (const gdb_byte *) buf, size)
would also be fine, as then you get an implicit cast to CORE_ADDR anyway.
Patch is OK, with or without double-cast.
Thanks,
Pedro Alves