Project

General

Profile

Bug #16383 » trace_point_issue.rb

contains code sample to demonstrate issue - AndyMaleh (Andy Maleh), 11/30/2019 03:16 AM

 
class Person
attr_accessor :first_name
attr_accessor :last_name
def name
"#{self.last_name}, #{self.first_name}"
end
end

person = Person.new
person.first_name = 'Josh'
person.last_name = 'McGibbon'
trace = TracePoint.new(:call) do |tp|
p [tp.path, tp.lineno, tp.defined_class, tp.event, tp.method_id]
end
trace.enable
person.name
trace.disable

class Person
attr_writer :first_name
attr_writer :last_name
def name
"#{self.last_name}, #{self.first_name}"
end
def first_name
@first_name
end
def last_name
@last_name
end
end

person = Person.new
person.first_name = 'Josh'
person.last_name = 'McGibbon'
trace = TracePoint.new(:call) do |tp|
p [tp.path, tp.lineno, tp.defined_class, tp.event, tp.method_id]
end
trace.enable
person.name
trace.disable
(1-1/2)