From: Simon Marchi via Gdb <gdb@sourceware.org>
To: K <cq.personal@gmail.com>, Tom Tromey <tom@tromey.com>
Cc: K via Gdb <gdb@sourceware.org>
Subject: Re: GDB-JIT: why would my 'unwind' not be invoked on crash?
Date: Wed, 12 Nov 2025 10:50:22 -0500 [thread overview]
Message-ID: <3057aed7-aa44-4d54-8d61-a324bc974bdb@simark.ca> (raw)
In-Reply-To: <CACTzTFBRsJ6Rv=D5aKdeKb9SqDByDOKN1VjqdYiSbyMVQgZgPQ@mail.gmail.com>
On 11/11/25 9:00 PM, K via Gdb wrote:
>>
>> Could you say more about what exactly you're doing?
>>
>> Like are you writing an unwinder in gdb? Or writing one in Python?
>>
>>
> I'm implementing an unwinder via the GDB-JIT C API for JIT code where
> generating custom ELF debug information is too onerous.
> The first article I read on it, by the implementor Sanjoy D(?) mentioned
> your name as originating the approach!
> So I'm just providing the functions called for by the struct in the API -
> unwind and get-frame-id (plus the function name/line number info
> separately).
>
> So gdb has no ELF info to look at (other than of the binary that is
> generating the JIT code), so I was expecting gdb to immediately defer
> to the jit-reader.so loaded into itself with the defined unwind function
> which has a few printf statements so I know when it runs ...
> and it isn't being called until 2 lines of backtrace have already been
> emitted, and only then on garbage data because it has already gone awry
> interpreting the stack contents/frame (with those first 2 lines above).
I don't have first hand experience in writing one of these, so I can't
help you directly. So as Tom said, I would probably end up debugging
GDB itself as well (which is an easy thing to say, given we're GDB
devs).
The functions involved in finding the appropriate unwinder are
frame_unwind_find_by_frame and frame_unwind_try_unwinder, here:
https://gitlab.com/gnutools/binutils-gdb/-/blob/30f6e34f1fad35f9e8a3230adf2b7268b2a5229f/gdb/frame-unwind.c#L187
The JIT support code prepends its unwinder here:
https://gitlab.com/gnutools/binutils-gdb/-/blob/30f6e34f1fad35f9e8a3230adf2b7268b2a5229f/gdb/jit.c#L1142
So when frame_unwind_try_unwinder runs with "set debug frame 1", trying
to find an unwinder for frame 0, I would expect to see a message like
`Trying unwinder "jit"`. And then your code should be called. This is
where I would start investigating.
Simon
next prev parent reply other threads:[~2025-11-12 15:51 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-11 21:43 K via Gdb
2025-11-11 21:26 ` Tom Tromey
2025-11-12 2:00 ` K via Gdb
2025-11-12 15:50 ` Simon Marchi via Gdb [this message]
2025-11-14 6:33 ` K via Gdb
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=3057aed7-aa44-4d54-8d61-a324bc974bdb@simark.ca \
--to=gdb@sourceware.org \
--cc=cq.personal@gmail.com \
--cc=simark@simark.ca \
--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