This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] Cut memory address width


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]