This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [patch] Cut memory address width
- From: Michael Snyder <Michael dot Snyder at palmsource dot com>
- To: Jan Kratochvil <jan dot kratochvil at redhat dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Wed, 27 Sep 2006 11:20:22 -0700
- Subject: Re: [patch] Cut memory address width
- References: <20060927161501.GA23340@host0.dyn.jankratochvil.net>
On Wed, 2006-09-27 at 18:15 +0200, Jan Kratochvil wrote:
> Hi,
>
> `x/x $ebx' on gdb/amd64 debugging inferior/i386 causes Cannot access memory at
> address 0xffffce70 (or so) as $ebx is considered `int' and sign-extended to
> 64-bit while the resulting address 0xffffffffffffce70 fails to be accessed.
>
> $esp does not exhibit this problem as it is `builtin_type_void_data_ptr' not
> `builtin_type_int' as $ebx is. Therefore it gets extended as unsigned.
>
> Simulate the part of paddress(); it is questionable how deep in the functions
> calling stack the address width cut should be.
Yes, but I think the assumption is that esp is most commonly used
to hold an address, while ebx is most commonly used to hold an integer.
Hence the default types.
I would tend to say that what the user should do is use an explicit
cast. As is, he is using an implicit cast and not getting what he
expects.
>
> As bugreported by John Reiser <jreiser(at)BitWagon.com>:
>
> When debugging a 32-bit executable on x86_64, gdb does not allow examining the stack if pointed to by a non-$esp register. For example,
> -----foo.S
> _start: .globl _start
> nop
> int3
> movl %esp,%ebx
> int3 # examining memory from $ebx fails, from $esp succeeds
> nop
> nop
> -----
> $ gcc -m32 -o foo -nostartfiles -nostdlib foo.S
> $ gdb foo
> Program received signal SIGTRAP, Trace/breakpoint trap.
> 0x08048076 in _start ()
> (gdb) x/i $pc
> 0x8048076 <_start+2>: mov %esp,%ebx
> (gdb) stepi
> 0x08048078 in _start ()
> (gdb) x/x $esp
> 0xffffce70: 0x00000001
> (gdb) x/x $ebx
> 0xffffce70: Cannot access memory at address 0xffffce70
> (gdb) x/x 0xffffce70
> 0xffffce70: 0x00000001
>
> Expected Results: "x/x $ebx" should have succeeded, too, when %ebx has the
> same value as %esp and examining from $esp works.