[RFC PATCH v1] Support inspecting green threads

Tom Tromey tom@tromey.com
Thu Sep 10 21:24:40 GMT 2020


Botond> Now I started thinking whether we could extend this support to
Botond> stackless fibers.
...
Botond> These stackless fibers are made up of continuation objects, which form
Botond> an intrusive forward linked-list. Each continuation object is a
Botond> callable and a pointer to the next continuation that should be executed
Botond> next, with the value computed by this continuation.

Botond> These fibers are an absolute pain to debug in gdb. Backtracing of
Botond> course just takes you back to the event loop. As the continuations are
Botond> classes templated on lambdas, their type name (even if known based on
Botond> the vptr of the continuation object) is unreadable.

Botond> I'm wondering if we could piece together these continuations into a
Botond> pseudo backtrace, making at least lambda captures (those the optimizer
Botond> forgot to destroy) inspectable. AFAIK gdb already has a notion of
Botond> pseudo frames that it uses to render inline frames into backtraces.
Botond> We should of course allow this mode to be disabled because sometimes
Botond> you do want to look at the event loop frames.

Yeah, this might be somewhat doable today by writing a customer frame
filter and some helper code.  The idea would be to capture locations as
the chain of continuations progresses, then replay these locations in
the frame filter.

One problem with this sort of approach is that local variables would be
unavailable for these saved frames, but that's just generally an issue
with continuations I suppose.

Tom


More information about the Gdb-patches mailing list