Class: TraceTree

Inherits:
Object
  • Object
show all
Defined in:
lib/trace_tree.rb,
lib/trace_tree/color.rb,
lib/trace_tree/point.rb,
lib/trace_tree/timer.rb,
lib/trace_tree/version.rb,
lib/trace_tree/tmp_file.rb,
lib/trace_tree/gem_paths.rb,
lib/trace_tree/point/common.rb,
lib/trace_tree/tree_htmlable.rb,
lib/trace_tree/short_gem_path.rb,
lib/trace_tree/tree_graphable.rb,
lib/trace_tree/point/threadend.rb,
lib/trace_tree/point/threadbegin.rb,
lib/trace_tree/point/ccall_kernel_extend.rb,
lib/trace_tree/point/ccall_module_include.rb,
lib/trace_tree/point/ccall_module_prepend.rb,
lib/trace_tree/point/ccall_classthread_new.rb,
lib/trace_tree/point/ccall_thread_initialize.rb,
lib/trace_tree/point/creturn_classthread_new.rb,
lib/trace_tree/point/ccall_module_extendobject.rb,
lib/trace_tree/point/creturn_thread_initialize.rb,
lib/trace_tree/point/ccall_module_appendfeatures.rb,
lib/trace_tree/point/creturn_module_extendobject.rb,
lib/trace_tree/point/ccall_module_prependfeatures.rb,
lib/trace_tree/point/creturn_module_appendfeatures.rb,
lib/trace_tree/point/call_modulemutexm_extendobject.rb,
lib/trace_tree/point/creturn_module_prependfeatures.rb,
lib/trace_tree/point/call_activesupportconcern_appendfeatures.rb

Defined Under Namespace

Modules: Color, ShortGemPath, TreeGraphable, TreeHtmlable Classes: Point, Timer, TmpFile

Constant Summary collapse

Events =
[:b_call, :b_return,
:c_call, :c_return,
:call, :return,
:class, :end,
:thread_begin, :thread_end]
VERSION =
"0.2.8"
GemPaths =
{}

Instance Method Summary collapse

Constructor Details

#initialize(bi) ⇒ TraceTree

Returns a new instance of TraceTree.



25
26
27
28
29
# File 'lib/trace_tree.rb', line 25

def initialize bi
  @bi = bi
  @trace_points = Queue.new
  @timer = Timer.new
end

Instance Method Details

#generate(*log, **opt, &to_do) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/trace_tree.rb', line 31

def generate *log, **opt, &to_do
  @opt = opt
  @log = dump_location *log
  enhance_point **opt
  @build_command = opt[:html] ? :tree_html_full : :tree_graph
  @ignore = opt[:ignore] || {}
  here = bi.eval('self')

  #start_trace
  timer[:trace]
  @tp = TracePoint.new(*Events) do |point|
    trace_points << point_loader.create(point) if wanted? point
  end
  @tp.enable

  here.instance_eval &to_do
ensure
  #stop_trace
  return unless @tp
  @tp.disable
  timer[:trace]
  dump_trace_tree
end