Skip to content

Add condition and command support to watch command#393

Merged
ko1 merged 5 commits intoruby:masterfrom
st0012:enhance-watch-command
Nov 25, 2021
Merged

Add condition and command support to watch command#393
ko1 merged 5 commits intoruby:masterfrom
st0012:enhance-watch-command

Conversation

@st0012
Copy link
Member

@st0012 st0012 commented Nov 15, 2021

watch is the only breakpoint command that doesn't support condition and command options (if, do, and pre). It's not by design and the inconsistency between it and other commands may confuse the users. So after discussing with @ko1, we're supporting those options on watch too.

@st0012 st0012 marked this pull request as draft November 16, 2021 00:25
@st0012
Copy link
Member Author

st0012 commented Nov 16, 2021

I think the binding for condition evaluation needs more work.

@ivar = ivar.to_sym
@object = object
@key = [:watch, @ivar].freeze
@key = [:watch, object.object_id, @ivar].freeze
Copy link
Member Author

Choose a reason for hiding this comment

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

WatchBreakpoint could be initialized for multiple instances, so we should take that into consideration when filtering duplicated bps.

@current = result
suspend

if @cond.nil? || @object.instance_eval(@cond)
Copy link
Member Author

Choose a reason for hiding this comment

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

IMO, the if condition of WatchBreakpoint should also be evaluated on the target object.

@st0012 st0012 marked this pull request as ready for review November 16, 2021 22:48
@ko1 ko1 merged commit 72b1069 into ruby:master Nov 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants