This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
Re: Backtraces broken on i386 by unorthodox encoding of push %ebp
- From: Jan Kratochvil <jan dot kratochvil at redhat dot com>
- To: Richard Smith <richard at ex-parrot dot com>
- Cc: gdb at sourceware dot org
- Date: Sat, 30 Mar 2013 20:50:08 +0100
- Subject: Re: Backtraces broken on i386 by unorthodox encoding of push %ebp
- References: <alpine dot LRH dot 2 dot 02 dot 1303301849040 dot 2445 at sphinx dot mythic-beasts dot com>
On Sat, 30 Mar 2013 20:13:06 +0100, Richard Smith wrote:
> 08048104 <foo>:
> 8048104: ff f5 push %ebp
> 8048106: 89 e5 mov %esp,%ebp
>
> However, when I have this form of prologue, gdb doesn't recongnise
> it, and doesn't give a meaningful backtrace.
You should always provide unwind information and then it is irrelevant which
instructions and/or which their coding you use.
See how GCC does it: -S -fasynchronous-unwind-tables -m32
.cfi_startproc
pushl %ebp
.cfi_def_cfa_offset 8
.cfi_offset 5, -8
movl %esp, %ebp
.cfi_def_cfa_register 5
Then for:
0: 55 push %ebp
1: 89 e5 mov %esp,%ebp
3:
readelf -wf will show:
DW_CFA_advance_loc: 1 to 00000001
DW_CFA_def_cfa_offset: 8
DW_CFA_offset: r5 (ebp) at cfa-8
DW_CFA_advance_loc: 2 to 00000003
DW_CFA_def_cfa_register: r5 (ebp)
and readelf -wF will show:
LOC CFA ebp ra
00000000 esp+4 u c-4
00000001 esp+8 c-8 c-4
00000003 ebp+8 c-8 c-4
See DWARF .debug_frame documentation.
Jan