Commit 6d6ffd9d

6d6ffd9dc190Merged

Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 3 files · +2 added · ~1 modified

Description

codegen: wire Exception#backtrace to the live capture substrate

#1300 added the backtrace runtime (sp_backtrace_captured over the sp_bt_buf captured at each raise), but the Exception#backtrace dispatch was left hardcoded to an empty array ("spinel does not capture stack frames") -- so the merged feature returned [] in every build. With the substrate now live (sp_bt_enabled set in --debug main, instance/class methods external under -rdynamic; #1335), dispatch backtrace to sp_backtrace_captured() instead.

e.backtrace now yields the frames captured at the raise, method- granularity (no :lineno: yet -- the shared follow-up), matching CRuby's frame structure in --debug; release builds stay empty, same as caller.

Refs #1300

Details

Commit
6d6ffd9dc190
Parent
b84f2ca6ba06

src/codegen_call.cmodifiedView file

@@ -1324,8 +1324,9 @@
13241324 return;
13251325 }
13261326 if (!strcmp(name, "backtrace")) {
1327- /* spinel does not capture stack frames: an empty array */
1328- buf_puts(b, "((void)("); emit_expr(c, recv, b); buf_puts(b, "), sp_StrArray_new())");
1327+ /* the stack captured at the most recent raise (sp_bt_buf); the substrate
1328+ is live in --debug builds and empty in release, same as Kernel#caller. */
1329+ buf_puts(b, "((void)("); emit_expr(c, recv, b); buf_puts(b, "), sp_backtrace_captured())");
13291330 return;
13301331 }
13311332 if (argc == 1 && (!strcmp(name, "is_a?") || !strcmp(name, "kind_of?") || !strcmp(name, "instance_of?"))) {