Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: a2782@dis.ulpgc.es
To: gdb@sources.redhat.com, a2782@dis.ulpgc.es
Subject: Problems in the edge of functions
Date: Thu, 13 Feb 2003 17:02:00 -0000	[thread overview]
Message-ID: <200302131757.h1DHvbE01132@siglo21.dis.ulpgc.es> (raw)

Hi to all!

I\'m using GDB to design a didactic graphic environment over it (as 
DDD). But I have found that, when I put a breakpoint in the first 
machine instruction of a function (push %ebp) and I ask the debugger 
for the information of the frames, GDB \"lies\". An example:

void foo() <-- breakpoint
{
  int b = 2;
}

int main()
{
  int a = 10;
  foo();
}

(in i386 code:
.globl foo
foo:
   pushl %ebp <-- breakpoint
   movl %esp, %ebp
   subl $8, %esp
   movl $2, -4(%ebp)
   leave
   ret

.globl main
main:
   pushl %ebp
   movl %esp, %ebp
   subl $24, %esp
   movl $10, -4(%ebp)
   call foo
   leave
   ret
)

If I type \"info locals\" when the program stops in the breakpoint, GDB 
returns: \"b = 10\" (it should return \"b = 14726457264\"). It\'s evident 
that GDB is looking in the position where it thinks that \'b\' should be 
(but in this position we find \'a\'). The reason why this occurs is that 
the stack has not been updated (the stack updates with the 
instructions \'mov %esp, %ebp\', and \'subl $8, %esp\', but they haven\'t 
been executed). However, if I type \'x /1wx 0x0bfff...\' and \'info 
registers\', I\'ll be able to discover the real state of the stack.

There\'s a similar problem with the instruction \'leave\'.

My question is: is this a bug? Or is there a way of solving it?

Thanks in advance!


             reply	other threads:[~2003-02-13 17:02 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-02-13 17:02 a2782 [this message]
2003-02-13 17:08 ` Daniel Jacobowitz

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=200302131757.h1DHvbE01132@siglo21.dis.ulpgc.es \
    --to=a2782@dis.ulpgc.es \
    --cc=gdb@sources.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