Project

General

Profile

Bug #4583

trace doesn't work for methods set up by attr_*

Added by QaDeS (Michael Klaus) almost 10 years ago. Updated about 8 years ago.

Status:
Rejected
Priority:
Normal
Target version:
-
ruby -v:
-
Backport:
[ruby-core:35790]

Description

=begin
Methods set up with (({attr_accessor})) or alike are not traceable:

class Foo
attr_writer :bar
def baz=(value)
@baz = value
end
end

set_trace_func proc{|*args| puts args.inspect}
@foo = Foo.new # will be traced
@foo.bar = 'bar' # call to bar= will not be traced
@foo.baz = 'baz' # call to baz= will be traced

Expected behavior: "c-call" and "c-return" are traced.

=end


Files

eval.diff (2.29 KB) eval.diff trace events to attr_* generated methods. includes test QaDeS (Michael Klaus), 04/17/2011 04:17 PM
test_settracefunc.rb.diff (1.4 KB) test_settracefunc.rb.diff 1.9.2-head Testing trace events for attr_* generated methods QaDeS (Michael Klaus), 04/17/2011 07:05 PM
trace_attr_accessors.patch (2.32 KB) trace_attr_accessors.patch 1.9.2 Full working patch QaDeS (Michael Klaus), 04/18/2011 06:24 AM
test_settracefunc-1.8.7.patch (2.08 KB) test_settracefunc-1.8.7.patch 1.8.7 Test for correct binding - succeeds QaDeS (Michael Klaus), 04/18/2011 07:56 AM
test_settracefunc-1.9.2.patch (2.27 KB) test_settracefunc-1.9.2.patch 1.9.2 Test for correct binding - fails QaDeS (Michael Klaus), 04/18/2011 07:56 AM

Related issues

Related to Ruby 1.8 - Bug #4584: trace doesn't work for methods set up by attr_*Rejected04/17/2011Actions

Updated by QaDeS (Michael Klaus) almost 10 years ago

=begin
See also issue #4584 for Ruby 1.8.
=end

Updated by kosaki (Motohiro KOSAKI) almost 10 years ago

  • Status changed from Open to Assigned
  • Assignee set to ko1 (Koichi Sasada)

=begin
Hi Michael,

Interesting report. Assigned to ko1.
=end

Updated by QaDeS (Michael Klaus) almost 10 years ago

=begin
Thanks for the hint on reporting properly. Here's a working patch for 1.8.7
=end

Updated by QaDeS (Michael Klaus) almost 10 years ago

=begin
Added test for 1.9.2-head, but changes to vm_eval.c didn't make it work. Next suspect: vm_insnhelper.c
Actually, I have no clue what I'm doing :)
=end

Updated by QaDeS (Michael Klaus) almost 10 years ago

=begin
Working patch for 1.9.2-head
=end

Updated by QaDeS (Michael Klaus) almost 10 years ago

=begin
Actually, the binding passed to the trace_func is wrong. Should be of the object the attr_accessor is defined in.
=end

Updated by ko1 (Koichi Sasada) over 9 years ago

  • ruby -v changed from ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-linux] to -

Hi,

(2011/04/17 11:44), redmine@ruby-lang.org wrote:

Methods set up with (({attr_accessor})) or alike are not traceable:

class Foo
attr_writer :bar
def baz=(value)
@baz = value
end
end

set_trace_func proc{|*args| puts args.inspect}
@foo = Foo.new # will be traced
@foo.bar = 'bar' # call to bar= will not be traced
@foo.baz = 'baz' # call to baz= will be traced

Expected behavior: "c-call" and "c-return" are traced.

This is because performance issue. I want to ignore your request.
Any real problem?

--
// SASADA Koichi at atdot dot net

Updated by ko1 (Koichi Sasada) over 9 years ago

  • Status changed from Assigned to Feedback

Updated by ko1 (Koichi Sasada) about 8 years ago

  • Status changed from Feedback to Rejected

No feedback.

Also available in: Atom PDF