Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Michael Snyder <Michael.Snyder@palmsource.com>
To: Jan Kratochvil <jan.kratochvil@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [patch] Cut memory address width
Date: Wed, 27 Sep 2006 18:20:00 -0000	[thread overview]
Message-ID: <1159381222.9768.43.camel@localhost.localdomain> (raw)
In-Reply-To: <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.


  reply	other threads:[~2006-09-27 18:20 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-09-27 16:15 Jan Kratochvil
2006-09-27 18:20 ` Michael Snyder [this message]
2006-09-27 18:22   ` Daniel Jacobowitz
2006-09-27 18:37     ` Jan Kratochvil
2006-09-27 18:55       ` Daniel Jacobowitz
2006-09-27 20:19         ` Jim Blandy
2006-09-27 19:01 ` Mark Kettenis
2006-09-28 17:27   ` Jan Kratochvil
2006-10-05 22:26     ` Daniel Jacobowitz
2006-09-27 19:23 ` Jim Blandy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1159381222.9768.43.camel@localhost.localdomain \
    --to=michael.snyder@palmsource.com \
    --cc=gdb-patches@sourceware.org \
    --cc=jan.kratochvil@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox