Hi,
On Tue, Jan 6, 2026 at 1:09 AM Thomas Munro <thomas.munro@gmail.com> wrote:
> jit_debugging_support may just be just a matter of calling
> LLVMOrcLLJITEnableDebugSupport()[1], though it looks like it might
> only work for ELF (the other interesting object format at this stage
> being macOS's MachO, and in the past/possible future AIX's COFF/XCOFF
> and eventually Windows COFF/PE), but I'm not sure. You can tell if
> it's working by making it crash/abort in JITed code and seeing if the
> stack is decodable by GDB I had been thinking we were going to have
> to write that function because I'd missed its arrival in LLVM 18[2],
> d'uh.
I've tested the patch while adding the call to
'LLVMOrcLLJITEnableDebugSupport(lljit);', and it works. I have full
backtraces with JIT function names:
* frame #0: 0x0000f4196f94a254 JIT(0xf4196f956000)`deform_1_2 + 28
frame #1: 0x0000f4196f94a14c JIT(0xf4196f956000)`evalexpr_1_1 + 172
frame #2: 0x0000bb2f132f3098
postgres`ExecEvalExprNoReturn(econtext=<unavailable>,
state=<unavailable>) at executor.h:423:13
frame #3: 0x0000bb2f132f3094
postgres`ExecEvalExprNoReturnSwitchContext(econtext=<unavailable>,
state=<unavailable>) at executor.h:464:2
> It sounds like we might need to wait for or write a similar
> function for perf support.
Yeah, there's no C api provided by LLVM yet. I've just opened a
tentative PR[1] to add it. With the modified LLVM and postgres calling
LLVMOrcLLJITEnablePerfSupport, I see the generated perf dumps in
~/.debug/jit/llvm-IR-jit-20260108-61640f/jit-38489.dump.
Though if I try to perf inject the dumps, I have the following errors
jitdump file contains invalid or unsupported flags 0xf5880666c26c
0x2b750 [0xa8]: failed to process type: 10 [Operation not permitted]
But that might be an issue with my setup, I would need to test it
further to understand the issue...
[1] https://github.com/llvm/llvm-project/pull/174973