If method A
is called by other methods,
Is there any way to know which function call it at run time.
I can grep the whole project to list all the possible calling path,
But if I can know it at run time, it'll be more helpful.
How can I get it by embedded something in method A
for example, the calling flow maybe
C() -> B() -> A()
H()-> G()-> B()-> A()
I wanna know the recent 3,or 5 method calls,
I want to trace the flow in my controllers and helpers in Rails project But I require the tracer and it showed me.
Routing Error
undefined method `on' for Tracer:Class
Try running rake routes for more information on available routes.
Here's my code
Tracer.on
def generate_nonexisted_book(price)
~~~
end
Tracer.off
Ruby has one stdlib called Tracer
. I would demonstrate it with a small example s below :
require 'tracer'
Tracer.on
def a;end
def b; a ; end
def c; b ; end
c
Tracer.off
Let me now run the code :
(arup~>test)$ ruby -v c.rb
ruby 2.0.0p0 (2013-02-24 revision 39474) [i686-linux]
#0:c.rb:4::-: def a;end
#0:c.rb:5::-: def b; a ; end
#0:c.rb:6::-: def c; b ; end
#0:c.rb:7::-: c
#0:c.rb:6:Object:>: def c; b ; end
#0:c.rb:6:Object:-: def c; b ; end
#0:c.rb:5:Object:>: def b; a ; end
#0:c.rb:5:Object:-: def b; a ; end
#0:c.rb:4:Object:>: def a;end
#0:c.rb:4:Object:<: def a;end
#0:c.rb:5:Object:<: def b; a ; end
#0:c.rb:6:Object:<: def c; b ; end
#0:c.rb:8::-: Tracer.off
(arup~>test)$
Description of some symbolic notations here came in the output:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With