* Problems in the edge of functions
@ 2003-02-13 17:02 a2782
2003-02-13 17:08 ` Daniel Jacobowitz
0 siblings, 1 reply; 2+ messages in thread
From: a2782 @ 2003-02-13 17:02 UTC (permalink / raw)
To: gdb, a2782
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!
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Problems in the edge of functions
2003-02-13 17:02 Problems in the edge of functions a2782
@ 2003-02-13 17:08 ` Daniel Jacobowitz
0 siblings, 0 replies; 2+ messages in thread
From: Daniel Jacobowitz @ 2003-02-13 17:08 UTC (permalink / raw)
To: a2782; +Cc: gdb
On Thu, Feb 13, 2003 at 05:57:37PM +0000, a2782@dis.ulpgc.es wrote:
> 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:
> 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?
It's a bug, but there's no real plans to fix it right now; eventually,
better unwind information will probably fix it, and it's not a big
deal. The locals don't have a value yet, after all.
Sometimes this causes messed up backtraces, too. It's really less
headache for everyone if you just stop after the prologue :)
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2003-02-13 17:08 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-02-13 17:02 Problems in the edge of functions a2782
2003-02-13 17:08 ` Daniel Jacobowitz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox