Class: IRWebmachine::Tracer
- Inherits:
-
Object
- Object
- IRWebmachine::Tracer
- Defined in:
- lib/irwebmachine/tracer.rb
Instance Method Summary collapse
- #continue ⇒ IRwebmachine::Frame?
-
#events=(events) ⇒ void
The set_trace_func API documentation has a list of possible events.
-
#finished? ⇒ Boolean
Returns true when you cannot trace anymore(e.g: #continue returns nil).
-
#initialize ⇒ Tracer
constructor
A new instance of Tracer.
- #targets=(targets) ⇒ void
- #trace(&block) ⇒ void
Constructor Details
#initialize ⇒ Tracer
Returns a new instance of Tracer.
3 4 5 6 7 8 9 |
# File 'lib/irwebmachine/tracer.rb', line 3 def initialize @thread = nil @queue = SizedQueue.new(1) @targets = [BasicObject] @events = ["call", "c-call", "return", "c-return", "class", "end", "line", "raise"] end |
Instance Method Details
#continue ⇒ IRwebmachine::Frame?
75 76 77 78 79 80 81 |
# File 'lib/irwebmachine/tracer.rb', line 75 def continue while @queue.empty? sleep 0.01 return if finished? end @queue.deq end |
#events=(events) ⇒ void
This method returns an undefined value.
The set_trace_func API documentation has a list of possible events.
28 29 30 |
# File 'lib/irwebmachine/tracer.rb', line 28 def events=(events) @events = events end |
#finished? ⇒ Boolean
Returns true when you cannot trace anymore(e.g: #continue returns nil).
54 55 56 |
# File 'lib/irwebmachine/tracer.rb', line 54 def finished? @queue.empty? && [false, nil].include?(@thread.status) end |
#targets=(targets) ⇒ void
This method returns an undefined value.
46 47 48 |
# File 'lib/irwebmachine/tracer.rb', line 46 def targets=(targets) @targets = targets end |
#trace(&block) ⇒ void
98 99 100 101 102 103 104 105 |
# File 'lib/irwebmachine/tracer.rb', line 98 def trace @thread ||= Thread.new do Thread.current.set_trace_func method(:tracer).to_proc yield Thread.current.set_trace_func(nil) end end |