Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/debug/server_dap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -745,8 +745,8 @@ def process_dap args
break false
end
} and (message = "Error: Not defined global variable: #{expr.inspect}")
when /\A[A-Z]/
unless result = search_const(b, expr)
when /(\A[A-Z]\w*)/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just curious, why don't we use frame_eval to evaluate the expr directly but instead parsing them?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

frame_eval sometimes changes the value(FYI: #395).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think after 756a2ed#diff-4208807b6db8555c61e42002b3e9c879003c5cfdb32d2b1a285a614b22fdf9d5 the changes made by frame_eval doesn't affect the original program anymore. So in this case it won't reproduce the issue again.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think after 756a2ed#diff-4208807b6db8555c61e42002b3e9c879003c5cfdb32d2b1a285a614b22fdf9d5 the changes made by frame_eval doesn't affect the original program anymore. So in this case it won't reproduce the issue again.

Oh, I see. I didn't know that.
However, we can't use frame_eval for the following reasons:

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't get the example case. Are they different because they came from different frames? Or they're different but are evaluated from the same frame?
It looks like search_const may not benefit much from using frame_eval. But I think instance variables, global variables and normal expressions can be evaluated with frame_eval. And making frame_eval take arbitrary frame's binding shouldn't be an issue.

I also see that the CDP server uses a similar but slightly different implementation for evaluation. So if we can utilize it in both server implementation, we can largely simplify these parts and make sure we're aligned on features (such as special locals).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't use eval because expression can have side-effect.

unless result = search_const(b, $1)
message = "Error: Not defined constants: #{expr.inspect}"
end
else
Expand Down