public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: Andrey Turkin via Gdb <gdb@sourceware.org>
Cc: Tom Tromey <tom@tromey.com>,  Andrey Turkin <andrey.turkin@gmail.com>
Subject: Re: "previous frame inner to this frame" error when unwinding fibers
Date: Mon, 11 Dec 2023 10:46:35 -0700	[thread overview]
Message-ID: <87plzceio4.fsf@tromey.com> (raw)
In-Reply-To: <CAA7-ZorVxkhKgwB0Wu_-gBbwNniPBxZEYN9rFy_Dwro9x2pS5w@mail.gmail.com> (Andrey Turkin via Gdb's message of "Mon, 11 Dec 2023 10:44:54 +0300")

Andrey> One possible solution that comes to my mind is to allow unwinders to
Andrey> specify the type of the frame (ideally that would be the frame being
Andrey> unwinded, i.e. one from PendingFrame; UnwindInfo I think is all about
Andrey> the next frame though). This would be enough to solve this issue since
Andrey> the inner-frame checking code only works with normal caller-callee
Andrey> pairs. Not sure which type it would be; sigtrap is the one most
Andrey> closely resembling it I think but not quite it.

SIGTRAMP_FRAME has some special handling in stack.c, so stack traces
would be formatted differently.  I guess we could introduce a new
constant if we wanted to go this route.

Andrey> PS: One other thing that is needed for the fiber/coroutine use case is
Andrey> an ability to perform backtraces from a random starting point.
Andrey> Backtrace through the switch point is what's needed for active
Andrey> asymmetric coroutines like generators and such; however it would be
Andrey> nice to be able to see the current stack of suspended asymmetric
Andrey> coroutines, or to see the state of symmetric coroutines.

A while ago I wrote some initial support for "green threads" by
extending the Python API.  See this thread:

https://inbox.sourceware.org/gdb/YiCk+NNtAGQPhyK5@stefanha-x1.localdomain/

Your situation sounds somewhat similar -- the basic idea is to model
user-space threads, letting Python code replace the sentinel frame.
Then, unlike with 'select-frame', backtraces will work ok.

However maybe your case isn't really identical to this.  Like, do
coroutines store registers?  Maybe some more abstract approach is needed.

Tom

  reply	other threads:[~2023-12-11 17:46 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-08 17:50 Andrey Turkin
2023-12-10 22:30 ` Tom Tromey
2023-12-11  7:44   ` Andrey Turkin
2023-12-11 17:46     ` Tom Tromey [this message]
2023-12-20 14:18       ` Andrey Turkin
2023-12-22  0:30         ` Tom Tromey
2023-12-22 19:19           ` Tom Tromey
2024-01-04 10:00             ` Andrey Turkin
2024-01-21 16:57               ` Tom Tromey

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=87plzceio4.fsf@tromey.com \
    --to=tom@tromey.com \
    --cc=andrey.turkin@gmail.com \
    --cc=gdb@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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).