The GDB JIT Interface
4 months ago
- #JIT
- #Debugging
- #GDB
- GDB uses debug information (DWARF format) from compilers like Clang, GCC, and rustc to provide debugging features.
- GDB struggles with JIT-compiled functions because the instruction pointer isn't in the debug info tables, leading to '???' in the output.
- GDB provides a JIT interface that requires implementing functions like `__jit_debug_register_code` and managing a linked list (`jit_code_entry`).
- The JIT interface involves creating ELF/Mach-O objects with DWARF info, which is complex and requires stable memory pointers.
- GDB also supports a newer, more flexible interface where custom binary formats can be used, requiring a reader plugin to be loaded into GDB.
- The newer interface involves implementing functions like `gdb_read_debug_info` and `gdb_unwind_frame`, but many runtimes leave these stubbed.
- There's a suggestion to reuse the Linux perf map interface in GDB for JIT symbols, though it would offer limited functionality.
- V8 notes performance issues with the JIT interface due to O(n²) behavior in the linked list and the need to disable moving GC for stability.
- ART handles dead code entries by treating the GDB JIT linked list as a weak reference and periodically cleaning it up.