debug icon indicating copy to clipboard operation
debug copied to clipboard

`break /foo/` for matched method

Open ko1 opened this issue 3 years ago • 4 comments

gdb has rbreak regexp (https://sourceware.org/gdb/onlinedocs/gdb/Set-Breaks.html) and maybe debug.gem can provide similar feature.

related to: https://github.com/ruby/debug/issues/655

Questions:

  • Notation:
    • break /foo/ all methods which names contains foo.
      • C1#foo, C2#foobar, C3#bazfoo, ...
    • break C#/foo/: C's methods which contains foo.
      • C#foo, C#foobar, ...
      • Seem's ugly...
    • break /C/#foo: Method foo of classes which names contain C.
      • C1#foo C2#foo, ...
      • Seems ugly too.
    • Only allow break /C#foo/ or break /C\.foo/ and so on?
    • Only allow to match method name?
      • It seems simple. We can extend it later.
  • Behavior:
    • Set breakpoints for existing matched methods (no problem)
    • Set breakpoints for future defined matched methods?
      • break /initialize/ means all initialize methods (and defined in future) can be trapped.
      • maybe it is convenient to support it.
    • Can we support break /obj.foo/ style?
      • maybe no if we allow future defined methods.

So current idea is:

  • break /regexp/ set method breakpoints where the method name matched with Class/Module/method name.
    • break /foo/ should be matched with:
      • C#foo
      • D.foo
      • E.bazfooboo
      • We can not match on class/module names (at least now).
  • It leaves as a pending breakpoint and set breakpoint in future definitions. User needs to del it if you don't need more.

ko1 avatar Jul 05 '22 19:07 ko1

For the dynamic typing language, pending feature is important I think but I'm not sure how to handle it on the other debuggers.

ko1 avatar Jul 05 '22 19:07 ko1

On the lldb:

(lldb) breakpoint set --func-regex regular-expression
(lldb) br s -r regular-expression

ko1 avatar Jul 05 '22 19:07 ko1

What happens on method_missing and so on...

ko1 avatar Nov 02 '22 19:11 ko1

step into name checks all method invocation and it is slow. Maybe break /xxx/ users don't expect it, I think.

ko1 avatar Nov 02 '22 19:11 ko1