From: Andrey Turkin via Gdb <gdb@sourceware.org>
To: Tom Tromey <tom@tromey.com>
Cc: Andrey Turkin via Gdb <gdb@sourceware.org>
Subject: Re: "previous frame inner to this frame" error when unwinding fibers
Date: Wed, 20 Dec 2023 17:18:55 +0300 [thread overview]
Message-ID: <CAA7-ZoqVBcRrRVkBUJ0TBOQV=ES-pDqkYvmDLnT_V0rdR9SPww@mail.gmail.com> (raw)
In-Reply-To: <87plzceio4.fsf@tromey.com>
пн, 11 дек. 2023 г. в 20:46, Tom Tromey <tom@tromey.com>:
>
> 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
Stackful coroutines I've ever encountered are very close to
cooperative green threads - minus an underlying scheduler - in their
implementation (separate stack + ucontext to store ABI-saved
registers); a mental model is a bit different. I like the idea you
proposed in that thread, with a caveat that the green threads would be
more ephemeral. E.g. if I want to see the state of a coroutine, I'd
spin up a green thread for it, switch to it and do whatever I'd
usually do with a thread of execution; and then when I'm done I'd
switch over to another thread and wind the green thread down so it is
no more (or maybe I'd cache those threads and destroy them in bulk
upon debuggee resume). As long as there is a Python API to manage them
and as long as their model is similar enough to the OS threads' API,
I'm sure we'd be able to code whatever solution suits one's specific
needs.
Regards, Andrey
next prev parent reply other threads:[~2023-12-20 14:19 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-08 17:50 Andrey Turkin via Gdb
2023-12-10 22:30 ` Tom Tromey
2023-12-11 7:44 ` Andrey Turkin via Gdb
2023-12-11 17:46 ` Tom Tromey
2023-12-20 14:18 ` Andrey Turkin via Gdb [this message]
2023-12-22 0:30 ` Tom Tromey
2023-12-22 19:19 ` Tom Tromey
2024-01-04 10:00 ` Andrey Turkin via Gdb
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='CAA7-ZoqVBcRrRVkBUJ0TBOQV=ES-pDqkYvmDLnT_V0rdR9SPww@mail.gmail.com' \
--to=gdb@sourceware.org \
--cc=andrey.turkin@gmail.com \
--cc=tom@tromey.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