Skip to content

Commit bd8678c

Browse files
ono-maxko1
authored andcommitted
CDP: Support evaluating expression on non-current frame
1 parent f7e5791 commit bd8678c

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

lib/debug/server_cdp.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1059,7 +1059,7 @@ def process_cdp args
10591059
begin
10601060
orig_stdout = $stdout
10611061
$stdout = StringIO.new
1062-
result = current_frame.binding.eval(expr.to_s, '(DEBUG CONSOLE)')
1062+
result = b.eval(expr.to_s, '(DEBUG CONSOLE)')
10631063
rescue Exception => e
10641064
result = e
10651065
res[:exceptionDetails] = exceptionDetails(e, 'Uncaught')

test/protocol/eval_test.rb

+20
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,24 @@ def test_eval_evaluates_arithmetic_expressions
2424
end
2525
end
2626
end
27+
28+
class EvaluateOnSomeFramesTest < ProtocolTestCase
29+
PROGRAM = <<~RUBY
30+
1| a = 2
31+
2| def foo
32+
3| a = 4
33+
4| end
34+
5| foo
35+
RUBY
36+
37+
def test_eval_evaluates_arithmetic_expressions
38+
run_protocol_scenario PROGRAM do
39+
req_add_breakpoint 4
40+
req_continue
41+
assert_repl_result({value: '4', type: 'Integer'}, 'a', frame_idx: 0)
42+
assert_repl_result({value: '2', type: 'Integer'}, 'a', frame_idx: 1)
43+
req_terminate_debuggee
44+
end
45+
end
46+
end
2747
end

0 commit comments

Comments
 (0)