Commit 00cc658f
00cc658fd7d3Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 1 file · ~1 modified
Description
Emit a #line for a method's prologue so gdb maps it to the .rb
A breakpoint on a compiled method (break sp_foo) landed in the generated C
prologue (the signature + SP_GC_SAVE + local decls, which carried no #line),
and since spinel deletes the temp .c after compiling, gdb reported
"out.c: No such file". Only the method body had #line directives, so you had to
step past the prologue before the Ruby source appeared.
Emit a #line at the def line just before the method signature, so the whole
function -- prologue included -- maps to the .rb. Now break sp_foo lands on the
def line and next/step walk the Ruby source directly; the generated C never
needs to be kept. So --line-map (default on) + -g/--debug is enough to debug
against the Ruby source -- no --save-temps needed (#1261).
The directive is gated on --line-map (g_line_map) and generates no code: --no-line-map output is byte-identical, optcarrot/bench/test unaffected.
Refs #1261
Co-Authored-By: Claude Opus 4.8 [email protected]
Details
- Commit
- 00cc658fd7d3
- Parent
- bd1ea603e462
src/codegen.cmodifiedView file
return; } inherit_transplant_locals(c, s); /* Map the whole function (signature + SP_GC_SAVE prologue + local decls, before the first body stmt) to the `def` line, so a breakpoint on the method lands on the .rb source rather than the generated C -- which is deleted after compile, so gdb couldn't find it. With this, --line-map / -g is enough to debug against the Ruby source; no need to keep the generated C (#1261). */ emit_line_directive(c, s->def_node, b); emit_method_signature(c, s, b); buf_puts(b, " {\n"); buf_puts(b, " SP_GC_SAVE();\n");