Feature #3809

allow multiple set_trace_func() calls

Added by Suraj Kurapati over 3 years ago. Updated over 1 year ago.

Assignee:Yukihiro Matsumoto
Target version:next minor



The current settracefunc() method in Ruby 1.8 and 1.9 cannot be safely
called multiple times because each call overwrites the current trace_func.

Please consider adding a mechanism, such as the multitrace library1, to
allow users to attach multiple tracing functions simultaneously to Ruby.

An alternative to the multitrace library1 is to add some new methods:

  • attachtracefunc(proc) #=> proc
  • detachtracefunc(proc) #=> proc

    When you call attachtracefunc(), it will register your tracing
    function and return it. You can pass the same tracing function
    later to detachtracefunc() to unregister it.

    Here is a convoluted example:

    detachtracefunc(attachtracefunc(proc {}))

    Here is a more realistic example:

    foo = proc {}
    bar = proc {}
    attachtracefunc foo


    attachtracefunc bar


    detachtracefunc foo
    detachtracefunc bar

    Thanks for your consideration.



#1 Updated by Shyouhei Urabe over 3 years ago

  • Status changed from Open to Assigned



#2 Updated by Yusuke Endoh over 1 year ago

  • Description updated (diff)
  • Target version set to next minor

#3 Updated by Thomas Sawyer over 1 year ago

Isn't this taken care of by the new TracePoint API?

Also available in: Atom PDF