Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: Andrey Turkin <andrey.turkin@gmail.com>
Cc: Tom Tromey <tom@tromey.com>,  Andrey Turkin via Gdb <gdb@sourceware.org>
Subject: Re: "previous frame inner to this frame" error when unwinding fibers
Date: Sun, 21 Jan 2024 09:57:48 -0700	[thread overview]
Message-ID: <878r4ivd2r.fsf@tromey.com> (raw)
In-Reply-To: <CAA7-Zor=G31aCV17Ro7nK4maBftU8eJq5YGRO_0HWZFcRZZk0Q@mail.gmail.com> (Andrey Turkin's message of "Thu, 4 Jan 2024 13:00:59 +0300")

>>>>> "Andrey" == Andrey Turkin <andrey.turkin@gmail.com> writes:

Andrey> Re stopping the unwind for green threads - callback makes sense I
Andrey> think; I guess most users would want to chop off some useless tail
Andrey> there. But also custom unwinders might want to have some clean way to
Andrey> do the same for whatever reason. I currently just do
Andrey> create_unwind_info() without filling any registers; that works but
Andrey> results in an ugly error message.

For unwinders I think we could add a more principled way to signal the
end of the stack.

Andrey> Re inner-than thing - this is orthogonal to green threads. This is
Andrey> something that happens because of unwinder stitching together
Andrey> different stacks; it doesn't have to be due to green threads. In fact,
Andrey> with the green threads support it might not be necessary to do the
Andrey> stiching; we might get away with doing several bts for the threads we
Andrey> want shown together, or something like a custom command to switch
Andrey> between callee/caller contexts etc. But anyway, if this is to be
Andrey> implemented, it seems to me this belongs to the unwinders domain.

I see what you mean, though stitching together stacks from different
threads is maybe a questionable procedure in gdb.

One issue is that the frame cache is global -- not per-thread.  So,
switching threads will flush it and cause it to be repopulated.  As long
as the inferior doesn't run, this will be "invisible" to the user,
though it may show up as a performance problem.

It'd be nice to fix this but there's some tricky business involving
vfork IIRC.  I think there's a bug open about it.

Also when stitching together stacks, I wonder about the semantics of
things like "finish".  But... maybe as long as selecting a frame also
selects its underlying thread, it could kinda work.

Andrey> Re PoC implementation on GH - I tried it out.

Thank you.

Andrey> There was an obvious bug (see attached patch),

I applied this to my branch.

Andrey> I can switch to it etc, but the registers don't get fetched
Andrey> and bt, info frame etc shows information of a native thread with id 1

I am not sure but I suspect this was this problem in a few methods in
green_thread_target -- they checked the green thread's ptid, but they
should have checked if the green thread has an underlying thread.

The idea here is that when a green thread is currently running on a
native thread, registers should simply come from that; but if the green
thread is inactive, then the Python code should be used.

I made this change on my branch & pushed it again, in case you want to
give it another try.

Tom

      reply	other threads:[~2024-01-21 16:58 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
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 [this message]

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=878r4ivd2r.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