Skip to content

Commit 69d245a

Browse files
andrepiskeko1
authored andcommitted
Fix FrameInfo#block_identifier
Since ruby 3.4, not all cases match BLOCK_LABL_REGEXP anymore This fixes for those cases.
1 parent ba7c39d commit 69d245a

File tree

2 files changed

+61
-1
lines changed

2 files changed

+61
-1
lines changed

lib/debug/frame_info.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,9 @@ def frame_type
8686

8787
def block_identifier
8888
return unless frame_type == :block
89-
_, level, block_loc = location.label.match(BLOCK_LABL_REGEXP).to_a
89+
re_match = location.label.match(BLOCK_LABL_REGEXP)
90+
_, level, block_loc = re_match ? re_match.to_a : [nil, nil, location.label]
91+
9092
[level || "", block_loc]
9193
end
9294

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# frozen_string_literal: true
2+
3+
require_relative '../support/console_test_case'
4+
5+
module DEBUGGER__
6+
7+
class FrameBlockIdentifierTest < ConsoleTestCase
8+
def program
9+
<<~RUBY
10+
1|
11+
2| class Whatever
12+
3| def some_method
13+
4| will_exit = false
14+
5| loop do
15+
6| return if will_exit
16+
7| will_exit = true
17+
8|
18+
9| begin
19+
10| raise "foo"
20+
11| rescue => e
21+
12| puts "the end"
22+
13| end
23+
14| end
24+
15| end
25+
16| end
26+
17|
27+
18| Whatever.new.some_method
28+
RUBY
29+
end
30+
31+
def test_frame_block_identifier
32+
debug_code(program) do
33+
type 'b 12'
34+
type 'c'
35+
assert_line_num 12
36+
assert_line_text([
37+
/\[7, 16\] in .*/,
38+
/ 7\| will_exit = true/,
39+
/ 8\| /,
40+
/ 9\| begin/,
41+
/ 10\| raise "foo"/,
42+
/ 11\| rescue => e/,
43+
/=> 12\| puts "the end"/,
44+
/ 13\| end/,
45+
/ 14\| end/,
46+
/ 15\| end/,
47+
/ 16\| end/,
48+
/=>\#0\tWhatever\#some_method at .*/,
49+
/ \#1\tblock in Kernel\#loop at <internal:kernel>:168/,
50+
/ \# and 2 frames \(use `bt' command for all frames\)/,
51+
//,
52+
/Stop by \#0 BP \- Line .*/
53+
])
54+
type 'c'
55+
end
56+
end
57+
end
58+
end

0 commit comments

Comments
 (0)