This is the mail archive of the
gdb-prs@sources.redhat.com
mailing list for the GDB project.
Re: symtab/1253: [regression] bad backtrace for '<function called from gdb>'
- From: Michael Elizabeth Chastain <mec at shout dot net>
- To: nobody at sources dot redhat dot com
- Cc: gdb-prs at sources dot redhat dot com,
- Date: 2 Aug 2003 03:38:00 -0000
- Subject: Re: symtab/1253: [regression] bad backtrace for '<function called from gdb>'
- Reply-to: Michael Elizabeth Chastain <mec at shout dot net>
The following reply was made to PR symtab/1253; it has been noted by GNATS.
From: Michael Elizabeth Chastain <mec@shout.net>
To: drow@mvista.com
Cc: gdb-gnats@sources.redhat.com
Subject: Re: symtab/1253: [regression] bad backtrace for '<function called from gdb>'
Date: Fri, 1 Aug 2003 23:32:59 -0400
Okay some more clue droppings ...
The problem is localized inside "sleep". If I set a breakpoint
on "sleep" and then "stepi" through it, gdb has some funky ideas
of where the stack is.
The code for "sleep" is:
0x420ae310 <sleep>: push %ebp
0x420ae311 <sleep+1>: xor %ecx,%ecx
0x420ae313 <sleep+3>: mov %esp,%ebp
0x420ae315 <sleep+5>: push %edi
0x420ae316 <sleep+6>: xor %edx,%edx
0x420ae318 <sleep+8>: lea 0xfffffe50(%ebp),%edi
0x420ae31e <sleep+14>: push %esi
0x420ae31f <sleep+15>: push %ebx
0x420ae320 <sleep+16>: call 0x4201575d <__i686.get_pc_thunk.bx>
0x420ae325 <sleep+21>: add $0x7bfab,%ebx
0x420ae32b <sleep+27>: sub $0x1cc,%esp
0x420ae331 <sleep+33>: mov %ecx,0xfffffe54(%ebp)
0x420ae337 <sleep+39>: mov 0x8(%ebp),%eax
0x420ae33a <sleep+42>: test %eax,%eax
0x420ae33c <sleep+44>: mov %eax,0xfffffe50(%ebp)
0x420ae342 <sleep+50>: je 0x420ae45c <sleep+332>
Note that the stack does not get adjusted until <sleep+27>!
This is PIC-related.
When I link with -static, I get a non-PIC version of sleep:
0x0804eb1c <sleep+0>: push %ebp
0x0804eb1d <sleep+1>: mov %esp,%ebp
0x0804eb1f <sleep+3>: push %edi
0x0804eb20 <sleep+4>: push %esi
0x0804eb21 <sleep+5>: push %ebx
0x0804eb22 <sleep+6>: sub $0x1ac,%esp
0x0804eb28 <sleep+12>: mov 0x8(%ebp),%eax
0x0804eb2b <sleep+15>: xor %edx,%edx
0x0804eb2d <sleep+17>: test %eax,%eax
0x0804eb2f <sleep+19>: mov %eax,0xfffffe50(%ebp)
0x0804eb35 <sleep+25>: lea 0xfffffe50(%ebp),%esi
0x0804eb3b <sleep+31>: movl $0x0,0xfffffe54(%ebp)
0x0804eb45 <sleep+41>: je 0x804ec13 <sleep+247>
And then the backtrace is all good:
(gdb) bt
#0 subroutine (in=14) at mi-syn-frame.c:53
#1 0x0804826e in handler (sig=14) at mi-syn-frame.c:43
#2 <signal handler called>
#3 0x0804eca1 in nanosleep ()
#4 0x0804ebf3 in sleep ()
#5 0x080482cb in have_a_very_merry_interrupt () at mi-syn-frame.c:64
#6 <function called from gdb>
#7 main () at mi-syn-frame.c:14
So I think the problem really is: backtracing through a function
which is compiled PIC, so that it has a more elaborate prolog.
It might be important that the function is in a shared library
and doesn't have debug info.
I'll dig some more.
Michael C