Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <pedro@codesourcery.com>
To: gdb-patches@sourceware.org
Subject: Re: graceful unwind termination when we'd need unavailable/uncollect memory or registers to unwind further
Date: Fri, 18 Mar 2011 20:21:00 -0000	[thread overview]
Message-ID: <201103181856.13372.pedro@codesourcery.com> (raw)
In-Reply-To: <201102221834.42413.pedro@codesourcery.com>

I've checked this one in as well.

On Tuesday 22 February 2011 18:34:42, Pedro Alves wrote:
> This patch applies on top of the "unavailable regs/locals"
> series, starting at:
> <http://sourceware.org/ml/gdb-patches/2011-02/msg00581.html>.
> 
> This teaches GDB about terminating unwinding gracefully if
> unwind further we would need registers/memory that haven't
> been collected.
> 
> Here's the result:
> 
>  (gdb) bt
>  #0  begin (a=<unavailable>) at ../../../src/gdb/testsuite/gdb.trace/unavailable.cc:182
>  #1  0x00000000004008ad in main (argc=1, argv=0x7fff0e22cf28, envp=0x7fff0e22cf38)
>      at ../../../src/gdb/testsuite/gdb.trace/unavailable.cc:210
>  #2  <unavailable> in ?? ()
>  Backtrace stopped: Not enough registers or memory available to unwind further
> 
> I think I've implemented this differently in about 10
> different ways.  This is the design that I ended up with and
> that I think is best.
> 
>  - when we sniff unwinders trying to find a matching unwinder,
>    we catch NOT_AVAILABLE_ERRORS.  If the PC is unavailable, 
>    it is impossible to determine if a given non-prologue parser unwinder
>    would have been the best unwinder or not.  By catching
>    NOT_AVAILABLE_ERRORS, we don't have too touch many sniffers.
>    When sniffing, they just read whatever minimum data they
>    require to determine they're the correct unwinder.  If
>    any of that is unavailable, we'll hit an exception.  So what
>    this means is that sniffer code does not try to check if a
>    given _required_ value is available --- it just goes ahead and
>    reads it.
> 
>  - adds a new frame_unwind method, to make it possible for an unwinder
>    to tell the core frame code that it can't unwind further.  The
>    concept here, is that if we are able to tell a given unwinder
>    would be the best unwinder, select it, even if actually trying to
>    unwind from it wouldn't work due to unavailable data.  E.g., if
>    all we have available is the PC, we'll be able to tell that we
>    have dwarf unwind info for that frame.  But if we then find out
>    that we don't have enough registers/memory to compute the CFA, we know
>    we aren't going to be able to unwind.  We _don't_ fallback to
>    prologue parsing in such cases, since if we couldn't unwind with
>    the precise unwind info missing, prologue parsing is surely not
>    going to be able to unwind correctly.
> 
>  - this new method incidently allows cleanly reporting to the core
>    frame machinery when a frame is the outermost, without resorting
>    to hacks in the frame_id, which opens the door to fixing a
>    corner case with stepping through the outermost frame when there's
>    no debug info.  I won't be implementing that, it just paves the way.
> 
>  - the prologue parsers then need to be made aware that they may trip
>    on necessary registers (e.g., PC / SP / FP) unavailable to unwine,
>    and that they should return that they can't unwind further in
>    the new frame_unwind method in that case.  I've taught the x86
>    and x64_64 unwinders, but not all others.  I did do the mechanical
>    work of adjusting all of them to the new interface, so that
>    --enable-targets=all still builds, and so that they continue working
>    as today.  Theaching other prologue unwinders how to terminate
>    gracefully with UNWIND_UNAVAILABLE is only interesting when a
>    corresponding target supports tracepoints on that architecture, so
>    it can be enabled on a case by case basis.

-- 
Pedro Alves


  parent reply	other threads:[~2011-03-18 18:56 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-22 18:35 Pedro Alves
2011-02-28 15:42 ` Jan Kratochvil
2011-02-28 15:56   ` Pedro Alves
2011-02-28 18:50     ` Jan Kratochvil
2011-03-18 20:21 ` Pedro Alves [this message]
2011-03-21 10:09 ` Regression: " Jan Kratochvil
2011-03-21 20:46   ` Pedro Alves
2011-03-22 14:40   ` Pedro Alves
2011-03-22 15:36     ` Jan Kratochvil
2011-03-22 16:19       ` Pedro Alves
2011-03-21 17:46 ` [commit] Fix tramp-frame.c crash (Re: graceful unwind termination when we'd need unavailable/uncollect memory or registers to unwind further) Ulrich Weigand
2011-03-21 20:52   ` Pedro Alves
2011-03-31 14:43 ` [rfc] Fix broken i386 signal unwinding " Ulrich Weigand
2011-03-31 16:20   ` Pedro Alves
2011-03-31 16:23     ` [rfc] Fix broken i386 signal unwinding (Re: graceful unwind termination when we'd need unavailable/uncollect memory or regis Ulrich Weigand

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=201103181856.13372.pedro@codesourcery.com \
    --to=pedro@codesourcery.com \
    --cc=gdb-patches@sourceware.org \
    /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