From ab8ee40a8fe3be3253efa2f8054821af6cb90807 Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Thu, 5 Jun 2025 02:24:46 +0900 Subject: [PATCH 1/2] Remove all internal frames from a backtrace In Ruby 3.5, the debug inspector API returns a raw backtrace, so irb/debug needs to remove not only `` but also all internal frames. --- lib/irb/debug.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/irb/debug.rb b/lib/irb/debug.rb index e429eaaff..0225a8a50 100644 --- a/lib/irb/debug.rb +++ b/lib/irb/debug.rb @@ -49,7 +49,7 @@ def setup(irb) def DEBUGGER__.capture_frames(*args) frames = capture_frames_without_irb(*args) frames.reject! do |frame| - frame.realpath&.start_with?(IRB_DIR) || frame.path == "" + frame.realpath&.start_with?(IRB_DIR) || frame.path.start_with?(" Date: Wed, 18 Jun 2025 12:48:35 +0900 Subject: [PATCH 2/2] Update the expected values of backtraces In ruby 3.5, `Kernel#caller_location` will not include `` frames. Instead, it will use its caller-side location for an internal frame. https://github.com/ruby/ruby/pull/13238 This change updates the expected values of backtraces in irb test to support the behavior change. --- test/irb/test_irb.rb | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/test/irb/test_irb.rb b/test/irb/test_irb.rb index f20045082..30f3ad5a0 100644 --- a/test/irb/test_irb.rb +++ b/test/irb/test_irb.rb @@ -879,7 +879,14 @@ def bar assert_match(/irbtest-.*\.rb:2:in (`|'Object#)foo': error \(RuntimeError\)/, output) frame_traces = output.split("\n").map(&:strip).grep(/from /) - expected_traces = if RUBY_VERSION >= "3.3.0" + expected_traces = if RUBY_VERSION >= "3.5.0" + [ + /from .*\/irbtest-.*.rb:6:in (`|'Object#)bar'/, + /from .*\/irbtest-.*.rb\(irb\):1:in [`']
'/, + /from .*\/irbtest-.*.rb:9:in (`|'Binding#)irb'/, + /from .*\/irbtest-.*.rb:9:in [`']
'/ + ] + elsif RUBY_VERSION >= "3.3.0" [ /from .*\/irbtest-.*.rb:6:in (`|'Object#)bar'/, /from .*\/irbtest-.*.rb\(irb\):1:in [`']
'/, @@ -934,11 +941,20 @@ def bar assert_match(/irbtest-.*\.rb:2:in (`|'Object#)foo': error \(RuntimeError\)/, output) frame_traces = output.split("\n").map(&:strip).grep(/from /) - expected_traces = [ - /from .*\/irbtest-.*.rb:6:in (`|'Object#)bar'/, - /from .*\/irbtest-.*.rb\(irb\):1:in [`']
'/, - /from .*\/irbtest-.*.rb:9:in [`']
'/ - ] + expected_traces = if RUBY_VERSION >= "3.5.0" + [ + /from .*\/irbtest-.*.rb:6:in (`|'Object#)bar'/, + /from .*\/irbtest-.*.rb\(irb\):1:in [`']
'/, + /from .*\/irbtest-.*.rb:9:in (`|'Binding#)irb'/, + /from .*\/irbtest-.*.rb:9:in [`']
'/ + ] + else + [ + /from .*\/irbtest-.*.rb:6:in (`|'Object#)bar'/, + /from .*\/irbtest-.*.rb\(irb\):1:in [`']
'/, + /from .*\/irbtest-.*.rb:9:in [`']
'/ + ] + end expected_traces.reverse! if RUBY_VERSION < "3.0.0"