Skip to content

Commit

Permalink
CDP: Support evaluating expression on non-current frame
Browse files Browse the repository at this point in the history
  • Loading branch information
ono-max authored and ko1 committed Mar 7, 2023
1 parent f7e5791 commit bd8678c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/debug/server_cdp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1059,7 +1059,7 @@ def process_cdp args
begin
orig_stdout = $stdout
$stdout = StringIO.new
result = current_frame.binding.eval(expr.to_s, '(DEBUG CONSOLE)')
result = b.eval(expr.to_s, '(DEBUG CONSOLE)')
rescue Exception => e
result = e
res[:exceptionDetails] = exceptionDetails(e, 'Uncaught')
Expand Down
20 changes: 20 additions & 0 deletions test/protocol/eval_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,24 @@ def test_eval_evaluates_arithmetic_expressions
end
end
end

class EvaluateOnSomeFramesTest < ProtocolTestCase
PROGRAM = <<~RUBY
1| a = 2
2| def foo
3| a = 4
4| end
5| foo
RUBY

def test_eval_evaluates_arithmetic_expressions
run_protocol_scenario PROGRAM do
req_add_breakpoint 4
req_continue
assert_repl_result({value: '4', type: 'Integer'}, 'a', frame_idx: 0)
assert_repl_result({value: '2', type: 'Integer'}, 'a', frame_idx: 1)
req_terminate_debuggee
end
end
end
end

0 comments on commit bd8678c

Please sign in to comment.