#231 JIT DWARF builder: handle SYMBOL fn-names (gensym lambda-lift defuns) instead of skipping the batch

open
Opened by atgreen

Summary

The JIT DWARF debug-info builder (ag-jit-build-elf-object / ag-dwarf-build-*, src/cold/jit-dwarf.lisp + dwarf.lisp) assumes fn-table names are byte-vectors. Since ag-macro-gensym now returns symbols (7ae9c0d), gensym-named lambda-lifted defuns appear in the batch fn-table with SYMBOL names, which the builder mis-handles (a stray arithmetic on a misread cons → not of type NUMBER).

Current mitigation

ag-jit-register-since wraps the per-batch build in handler-case (7ae9c0d), so a failing batch is skipped and the mutator keeps running — but that means EVERY function in an affected batch loses its gdb symbol/line info, not just the gensym one.

Ask

Make the JIT DWARF builders fully symbol-name-aware — route every fn-name through ag-norm-to-name before byte-vector/offset ops (most already do; find the one that doesn't — likely in the fn-list length/str-offset walk or emit-debug-str/symtab). Then gensym-named lambda-lift defuns get proper (uninterned) names in .debug_info/.symtab and the handler-case becomes a true belt-and-suspenders rather than the thing keeping loads alive.

Repro

Load asdf.lisp on build/funcl-stage2; without the handler-case guard it cores in AG-JIT-BUILD-ELF-OBJECT. Walkable bt in cave#229.

Priority

Low — debug-info quality only; correctness is unaffected (the guard holds).

Comments (2)

atgreen3992785829

ASSESSMENT 2026-07-11: still open; gensym lambda-lift defuns (SYMBOL fn-names) skip the whole DWARF batch, so JIT'd closure code (much more of it now, post-ADR-0028) shows as ?? in gdb backtraces. The fix is small: jit-dwarf name extraction should accept a symbol and use its name bv (the __G names are fine for backtraces). Value went UP today: closure-record entry functions are exactly these gensym defuns.

atgreen3992808469

FIXED at the perf-map layer (commit 'fix(perf-map): include ag-fn-table'): save-perf-map now emits every ag-fn-table entry (baked + gensym lambda-lift functions), not just the fn-cell-installed named ones. Map 1KB->254KB / ~8000 symbols; the AG-FILE-IS-FCO-P phantom (~27% self-time in the ADR-0028 closure profile, a sparse-map attribution artifact) drops off the profile entirely. NOTE: the JIT DWARF/gdb side (this issue's original title) is still open — gdb backtraces of gensym closure frames still show ??. Reopen scope narrowed to jit-dwarf.lisp: accept a SYMBOL/bv fn-name and use its bytes for the .debug_line/.debug_str entry instead of skipping the batch.