Small problem

Amol Mohite amol@m-net.arbornet.org
Fri Jun 25 02:23:00 GMT 1999


 gdb@sourceware.cygnus.com 

if this is a newbie qs. please flame me in private, but please answer the
qs.

Consider this code (linux , x86)

void asmcode(void)
{
        __asm__ ("movl %ebx, %eax");
}

int main(void)
{
        int i;

        i = 5;

        asmcode();

        i = 6;

        exit(0);
}                                 

now when I run this code under gdb, setting a breakpoint gives me :

(gdb) break 16
Breakpoint 1 at 0x804814d: file en.c, line 16.
(gdb) r
Starting program: /home/jerry/tries/./a.out

Breakpoint 1, main () at en.c:16
16              asmcode();
(gdb) bt
#0  main () at en.c:16
#1  0x80480ee in ___crt_dummy__ ()                                             
(gdb) stepi
asmcode () at en.c:6
6       {
(gdb) bt
#0  asmcode () at en.c:6
#1  0x80480ee in ___crt_dummy__ ()
(gdb) stepi
0x8048135       6       {
(gdb) bt
#0  0x8048135 in asmcode () at en.c:6
#1  0x80480ee in ___crt_dummy__ ()         
(gdb) stepi
asmcode () at en.c:7
7               __asm__("movl %ebx, %eax");
(gdb) bt
#0  asmcode () at en.c:7
#1  0x8048152 in main () at en.c:16
#2  0x80480ee in ___crt_dummy__ ()


The first bt gives me 2 frames -- 0(main) and 1(crt-dummy) as expected
when I step into asmcode, I get 2 frames -- 0(asmcode) and 1(crt-dummy)
when it shud be 3 as  I have got in the last bt?

What is the reason for this ?

Also a couple of more qs. :

I was studying the stack, when I came across above problem. What I also
want to know is where the environment variables of the process are stored.
Better just telling me where, can someone tell me any web page where I
might access this info ?

Thanks a lot for any answers.

P.S. please cc any answers to me as I am not subscribed to this list.




More information about the Gdb mailing list