deivid-rodriguez / byebug

Debugging in Ruby 2
BSD 2-Clause "Simplified" License
3.34k stars 328 forks source link

Differentiate between class and instance methods #734

Open firelizzard18 opened 4 years ago

firelizzard18 commented 4 years ago

Problem description

I want to be able to set a function breakpoint on Foo.method(:bar) separately from Foo.instance_method(:bar). I don't have any strong feelings about how/if this is handled by byebug's frontend/interface, because I am implementing my own interface. For that, I just need some way to create a breakpoint that is instance-only or class/module-only.

class Foo
  def bar
    # ...
  end

  def self.bar
    # ...
  end
end

Expected behavior

When I set a breakpoint on Foo#bar, byebug breaks on the instance method. When I set a breakpoint on Foo.bar, byebug breaks on class method.

Actual behavior

When I set a breakpoint, I cannot specify instance vs class, I can only specify the class name and method name. Because of this and because Byebug's method breakpoint handling is agnostic of instance vs class method, byebug breaks on both methods when I set a method breakpoint.

Steps to reproduce the problem

  1. Include the above class and loop { Foo.new.bar; Foo.bar } in test.rb
  2. Debug test.rb with byebug
  3. Set a method breakpoint with Foo#bar or Foo.bar
  4. Byebug breaks on both the instance and class method, regardless of how the breakpoint is created