This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Backtraces broken on i386 by unorthodox encoding of push %ebp


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]