GDB Frame Unwinding for Pure Assembly Code

Andrew Burgess andrew.burgess@embecosm.com
Wed Jun 24 15:06:02 GMT 2020


* Ahmad Nouralizadeh via Gdb <gdb@sourceware.org> [2020-06-23 16:18:42 +0430]:

> Thanks for the answer! Could you tell me why is an inline unwinder used?

What you saw in your GDB backtrace was this:

  #5  0x00005555558b1b0b in frame_unwind_pc (this_frame=0x55555673c2e0) at frame.c:885
  #6  0x00005555558b4f72 in _Z12get_frame_pcP10frame_info (frame=0x55555673c490) at frame.c:2379
  #7  0x00005555558b50ea in _Z26get_frame_address_in_blockP10frame_info (this_frame=0x55555673c490) at frame.c:2410
  #8  0x0000555555905d53 in inline_frame_sniffer (self=0x555556193520 <inline_frame_unwind>, this_frame=0x55555673c490, this_cache=0x55555673c4a8) at inline-frame.c:215
  #9  0x00005555558b719a in frame_unwind_try_unwinder (this_frame=0x55555673c490, this_cache=0x55555673c4a8, unwinder=0x555556193520 <inline_frame_unwind>) at frame-unwind.c:106

So GDB hasn't decided for sure that a frame is an inline frame,
instead it is running the inline_frame_sniffer to see if a particular
frame is an inline frame or not.

In order to figure this out GDB needs to know the value of $pc in the
frame that is being sniffed.  To get the $pc value GDB asks the next
frame (that would be a frame with a lower frame number in GDB terms)
to unwind the $pc register.  You can see this happening between frames
#8 and #6 in the above, before finally in #5 we ask the next frame to
unwind the $pc.

Almost every frame will have had the inline frame unwinder run on it
in order to figure out if it was an inline frame, that doesn't mean
the inline frame unwinder will claim the frame.

Hope that helps,
Thanks,
Andrew





> 
> On Tuesday, 23 June 2020, Jan Kratochvil <jan.kratochvil@redhat.com> wrote:
> 
> > On Mon, 22 Jun 2020 23:55:30 +0200, Ahmad Nouralizadeh via Gdb wrote:
> > > But knowing the GDB mechanism to get over the problem will be helpful.
> >
> > GDB disassembles the code and tries to guess how to unwind it.
> > amd64-tdep.c amd64_analyze_prologue(), amd64_frame_cache_1() etc.
> >
> > That is just a last resort way of unwinding (=a bug in the debuggee), there
> > should always be .eh_frame in the debuggee, also for throwing exceptions
> > across such .eh_frame-less functions if there is any callback there.
> >
> >
> > Jan
> >
> >


More information about the Gdb mailing list