Re: [patch] Fix i386 memory-by-register access on amd64

Mark Kettenis
2009-04-29T19:05:00Z

> Date: Wed, 29 Apr 2009 12:27:19 +0200
> From: Jan Kratochvil <jan.kratochvil@redhat.com>
>
> Hi,
>
> original bugreport:
> https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=181390
>
> (gdb) x/x $esp
> 0xffffce70: 0x00000001
> (gdb) x/x $ebx
> 0xffffce70: Cannot access memory at address 0xffffce70
> (gdb) x/x 0xffffce70
> 0xffffce70: 0x00000001
>
> One point is there should have been printed this error message instead:
> 0xffffffffffffce70: Cannot access memory at address 0xffffffffffffce70
> but this problem is just a consequence of paddress() truncating the printed
> address width. This printing issue is unrelated to the patch below.
>
> The error happens because $ebx is considered signed while $esp unsigned, as
> initialized by i386_register_type (or also amd64_register_type). Therefore
> the address width should be cut to the right size at the right point of
> processing, I hope I caught (one of) such points.

I'm not sure this is the right solution. On 64-bit machines where
addresses are signed I think we actually want the sign extension to
happen.

> 2006-09-28 Jan Kratochvil <jan.kratochvil@redhat.com>
>
> Fix signed 32bit inferior registers on 64bit GDB.
> * gdb/value.c (value_as_address): Make it static, rename it to ...
> (value_as_address1): ... this function.
> (value_as_address): New function.

What is your motiviation for using a wrapper function?