Re: GDB-JIT: why would my 'unwind' not be invoked on crash?
Tom Tromey <[email protected]> Tue, 11 Nov 2025 14:26:01 -0700
| Newsgroups | gmane.comp.gdb.devel |
|---|---|
| Message-ID | <[email protected]> |
>>>>> K via Gdb <[email protected]> writes: > I implemented this for the x86-64 build of my ocaml program and it works > fine. > I'm now working on a aarch64 version - the symtable/line and serde code is > the same, and I'm looking to complete the unwind functionality by > disovering how to obtain the PC (not in a general register). However, after > arranging for a segfault > the unwind function is not being invoked at first and I get 2 backtrace > listings > with appropriate function name and line numbers, and only then does gdb > decide to call my unwind function and it does so with garbage data. > This is understandable to the extent gdb doesn't know the ocaml stack usage. > But if that's true, why would it proceed to generate 2 lines of backtrace > before > consulting my unwinder to gather the correct data? > My expectation is it would consult my unwinder immediately. Could you say more about what exactly you're doing? Like are you writing an unwinder in gdb? Or writing one in Python? If so, what prompted this as opposed to using the existing unwinders? Like, does your compiler not generate DWARF unwind information? (If not why not, etc.) Anyway, there's no easy way to answer your question. Unwinding in gdb is complicated. You could try to enable frame debugging ("set debug frame 1") and see it says anything interesting. I think it at least mentions which unwinders it tries. Personally I guess if I was in your spot, I'd end up debugging the unwinding code in gdb. If I had to guess, your unwinder is ending up after one of the built-in ones, and one of those thinks it knows how to unwind the frame... which could even be kind of true, one of the difficulties in writing one is knowing when it ought to give up. Tom