Skip to content

Refactor (4/5): factor shared code out of hook.c/frame.c - #43

Open
yuuu wants to merge 2 commits into
refactor/dedupe-helpersfrom
refactor/c-hook
Open

yuuu wants to merge 2 commits into
refactor/dedupe-helpersfrom
refactor/c-hook

Conversation

@yuuu

@yuuu yuuu commented Oct 17, 2026

Copy link
Copy Markdown
Owner

Stacked on #42.

  • set_session / disarm replace reset code that was repeated in hook_s_install, hook_s_uninstall and mrb_mrdebug_gem_final. disarm still leaves in_callback alone, since uninstall can run mid-callback via MRDebug.detach. gem_final now also releases the session and the cached filename string; before, they stayed GC-registered.
  • invoke_on_line takes forced directly, so the invoke_on_line_forced wrapper is gone. report_position does the filename lookup and filename_value call that three call sites used to repeat.
  • Removed the mrb_nil_p(hook.deferred_bp) && !hook.in_callback guard before check_method_call. It was always true at that point: on_line never sets deferred_bp, and run_in_dbg_context has already cleared in_callback.
  • frame.c: paused_frame() does the paused-context + frame_at lookup that frame_position and frame_binding both repeated.

Tested:

  • rake test:unit: OK 3015, KO 0
  • rake test:smoke and rake picoruby:smoke: 0 failures each
  • Manual run of line + method breakpoints (b Foo#bar, b Array#sort, p, bt): same output as before

🤖 Generated with Claude Code

https://claude.ai/code/session_01CpfQQRdc3R13RafigfCNVk

- set_session/disarm replace the reset code repeated across install,
  uninstall and gem_final; gem_final now also releases the session and
  the cached filename string.
- invoke_on_line takes `forced` directly (invoke_on_line_forced is gone);
  report_position looks up the filename once for all three call sites.
- Drop the always-true deferred_bp/in_callback checks before
  check_method_call.
- frame.c: paused_frame for the context lookup frame_position and
  frame_binding both did.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CpfQQRdc3R13RafigfCNVk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant