[PATCH obv/c++] Add/adjust casts in gdbserver's proc-service
Pedro Alves
palves@redhat.com
Fri Oct 30 20:17:00 GMT 2015
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
More information about the Gdb-patches
mailing list