class TraceTree::Point

Constants

Interfaces
NativeThreadCall

Attributes

proto[R]
config[RW]
current[R]
frame_env[R]
terminal[RW]
thread[R]

Public Class Methods

bases() click to toggle source
# File lib/trace_tree/point.rb, line 22
def bases
  @bases ||= []
end
cache_event_class_method!() click to toggle source
# File lib/trace_tree/point.rb, line 52
      def cache_event_class_method!
        bases.each do |base|
          base.class_eval <<-EOM
            class << self
              alias_method :_event_class_method, :event_class_method
              def self.event_class_method
                @ecm ||= _event_class_method.freeze
              end
            end
EOM
        end
      end
class_of?(point) click to toggle source
# File lib/trace_tree/point.rb, line 39
def class_of? point
  e, c, m = event_class_method
  point.method_id == m && point.event == e && point.defined_class == c
end
hashify(point) click to toggle source
# File lib/trace_tree/point.rb, line 26
def hashify point
  h = {}
  h[:event] = point.event
  h[:defined_class] = point.defined_class
  h[:method_id] = point.method_id
  h[:frame_env] = point.frame_env unless point.thread?
  h[:path] = point.path
  h[:lineno] = point.lineno
  h[:thread] = point.thread
  h[:return_value] = point.return_value if point.event =~ /return/
  h
end
inherited(base) click to toggle source
# File lib/trace_tree/point.rb, line 18
def inherited base
  bases << base
end
initialize_clone(proto) click to toggle source
Calls superclass method
# File lib/trace_tree/point.rb, line 44
def initialize_clone proto
  super.tap do
    instance_variable_set :@proto, proto
  end
end
new(trace_point) click to toggle source
# File lib/trace_tree/point.rb, line 71
def initialize trace_point
  assign_trace_point_values(trace_point)

  @return_value = trace_point.return_value if x_return?
  @thread = Thread.current

  unless thread?
    there = trace_point.binding.of_caller(3)
    @current = BindingOfCallers::Revealed.new there
    @frame_env = current.frame_env.to_sym
  end
rescue => e
  puts e
end

Public Instance Methods

<<(node) click to toggle source
# File lib/trace_tree/point.rb, line 144
def << node
  callees << node
end
_class_and_method() click to toggle source
# File lib/trace_tree/point.rb, line 156
def _class_and_method
  @km ||= "#{class_name}#{call_symbol}#{method_name}"
end
arg() click to toggle source
# File lib/trace_tree/point.rb, line 180
def arg
  respond_to?(:parameters) ? "(#{parameters})" : nil
end
arguments() click to toggle source
# File lib/trace_tree/point.rb, line 113
def arguments
  {}.tap do |args|
    if event == :call
      defined_class.instance_method(method_id).parameters.
        each{ |role, name| args[name] = current.lv(name) unless name.nil? && role == :rest }
    end
  end
end
b_call?() click to toggle source
# File lib/trace_tree/point.rb, line 86
def b_call?
  event == :b_call
end
c_call?() click to toggle source
# File lib/trace_tree/point.rb, line 90
def c_call?
  event == :c_call
end
call_symbol() click to toggle source
# File lib/trace_tree/point.rb, line 172
def call_symbol
  c_call? ? '#' : current.call_symbol
end
callees() click to toggle source
# File lib/trace_tree/point.rb, line 148
def callees
  @callees ||= []
end
class?() click to toggle source
# File lib/trace_tree/point.rb, line 94
def class?
  event == :class
end
class_and_method() click to toggle source
# File lib/trace_tree/point.rb, line 152
def class_and_method
  "#{_class_and_method}#{arg}"
end
class_name() click to toggle source
# File lib/trace_tree/point.rb, line 160
def class_name
  c_call? ? defined_class : current.klass
rescue
  puts event
end
end_of_trace?() click to toggle source
# File lib/trace_tree/point.rb, line 106
def end_of_trace?
  MainFile == path && (
    (:c_return == event && :instance_eval == method_id) ||
      (:c_call == event && :disable == method_id)
  )
end
inspect() click to toggle source
# File lib/trace_tree/point.rb, line 126
def inspect
  to_h.inspect
end
method_defined_by_define_method?() click to toggle source
# File lib/trace_tree/point.rb, line 251
def method_defined_by_define_method?
  (event == :call || event == :return) &&
    method_id != frame_env
end
method_missing(method_id, *args, &blk) click to toggle source
# File lib/trace_tree/point.rb, line 66
def method_missing method_id, *args, &blk
  raise NoMethodError, "NoMethodError: undefined method `#{method_id}' "\
    "for #<#{self.class.proto or self.class.name}#{inspect}>"
end
method_name() click to toggle source
# File lib/trace_tree/point.rb, line 166
def method_name
  return method_id if c_call?
  return frame_env if b_call? || class?
  (method_id == frame_env) ? method_id : "#{method_id} -> #{frame_env}"
end
return_value() click to toggle source
# File lib/trace_tree/point.rb, line 122
def return_value
  x_return? ? @return_value : (terminal.nil? ? nil : terminal.return_value)
end
source_location() click to toggle source
# File lib/trace_tree/point.rb, line 176
def source_location
  "#{path}:#{lineno}"
end
terminate?(point) click to toggle source
# File lib/trace_tree/point.rb, line 134
def terminate? point
  (point.defined_class == defined_class && point.method_id == method_id) && (
    (event == :return && point.event == :call) ||
    (event == :b_return && point.event == :b_call) ||
    (event == :c_return && point.event == :c_call) ||
    (event == :end && point.event == :class) ||
    (event == :thread_end && point.event == :thread_begin)
  )
end
thread?() click to toggle source
# File lib/trace_tree/point.rb, line 102
def thread?
  event =~ /thread/
end
thread_relative?() click to toggle source
# File lib/trace_tree/point.rb, line 246
def thread_relative?
  NativeThreadCall.any?{ |k| k.class_of? self } ||
    Thread == defined_class
end
to_h() click to toggle source
# File lib/trace_tree/point.rb, line 130
def to_h
  self.class.hashify(self)
end
x_return?() click to toggle source
# File lib/trace_tree/point.rb, line 98
def x_return?
  event =~ /return/
end