public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
From: Andrew Burgess <andrew.burgess@embecosm.com>
To: Ahmad Nouralizadeh <ahmad.mlists@gmail.com>
Cc: Jan Kratochvil <jan.kratochvil@redhat.com>,
	"gdb@sourceware.org" <gdb@sourceware.org>
Subject: Re: GDB Frame Unwinding for Pure Assembly Code
Date: Wed, 24 Jun 2020 16:06:02 +0100	[thread overview]
Message-ID: <20200624150602.GN623665@embecosm.com> (raw)
In-Reply-To: <CAMYFX7nxegE8ZZKGT3JQMS3B7kxf9BErn+sWxYknkxpej-cvew@mail.gmail.com>

* 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
> >
> >

  parent reply	other threads:[~2020-06-24 15:06 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-22 21:29 Ahmad Nouralizadeh
2020-06-22 21:39 ` Jan Kratochvil
2020-06-22 21:55   ` Ahmad Nouralizadeh
2020-06-23  7:26     ` Jan Kratochvil
2020-06-23 11:48       ` Ahmad Nouralizadeh
2020-06-23 12:23         ` Jan Kratochvil
2020-06-23 14:23           ` Ahmad Nouralizadeh
2020-06-24 14:00         ` Simon Marchi
2020-06-24 19:09           ` Ahmad Nouralizadeh
2020-06-24 15:06         ` Andrew Burgess [this message]
2020-06-25  9:10           ` Ahmad Nouralizadeh
2020-06-25 16:51             ` Andrew Burgess
2020-06-26 11:33               ` Ahmad Nouralizadeh

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200624150602.GN623665@embecosm.com \
    --to=andrew.burgess@embecosm.com \
    --cc=ahmad.mlists@gmail.com \
    --cc=gdb@sourceware.org \
    --cc=jan.kratochvil@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).