Skip to content

Support functional setFunctionBreakpoints command#3

Open
st0012 wants to merge 3 commits intoruby-tooling:masterfrom
st0012:set-function-breakpoints
Open

Support functional setFunctionBreakpoints command#3
st0012 wants to merge 3 commits intoruby-tooling:masterfrom
st0012:set-function-breakpoints

Conversation

@st0012
Copy link

@st0012 st0012 commented Jul 5, 2022

Currently, DAP server responds to setFunctionBreakpoints command but it doesn't really do anything. This PR enables adding/removing method breakpoints.

Supported breakpoint types:

class Foo
  def foo
  end

  def self.bar
  end
end

foo = Foo.new
  • Foo#foo - will stop at Foo's instance method foo
  • Foo.bar - will stop at Foo's singleton method bar

This is not intentionally supported but currently it works:

  • foo.foo - will stop at foo object's #foo method call

Condition is also supported:

截圖 2022-05-04 11 04 22

Demos

Function Breakpoint

Function.breakpoints.mov

Function Breakpoint with Conditions

Function.breakpoints.with.condition.mov

@st0012 st0012 added the enhancement New feature or request label Jul 5, 2022
@st0012 st0012 self-assigned this Jul 5, 2022
@st0012 st0012 requested a review from peterzhu2118 July 5, 2022 11:13

breakpoints = bps.map do |bp|
if bp["name"]&.match(Session::METHOD_SIGNATURE_REGEXP)
make_breakpoint [:method, $1, $2, $3, bp["condition"]]

Choose a reason for hiding this comment

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

bp["condition"] here could be the empty string if the user first creates a condition, then deletes the condition. We should treat an empty string like nil (i.e. no condition) instead of like a false condition, so we should turn the empty string into nil.

Comment on lines +1346 to +1350
def add_method_breakpoint(method_signature)
if method_signature.match(METHOD_SIGNATURE_REGEXP)
@tc << [:breakpoint, :method, $1, $2, $3]
end
end

Choose a reason for hiding this comment

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

Is this method used anywhere?

end
end

def test_set_function_breakpoints_sets_breakpoint_with_condition

Choose a reason for hiding this comment

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

This test doesn't really test when condition evaluates to true.


def test_set_function_breakpoints_unsets_method_breakpoints
run_protocol_scenario PROGRAM, cdp: false do
res_set_function_breakpoints([{ name: "Foo::Bar.a" }])

Choose a reason for hiding this comment

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

This breakpoint wouldn't have triggered anyways since it doesn't match anything in the code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants