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/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

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

Instance Method Summary collapse

Constructor Details

#initialize(bi) ⇒ TraceTree

Returns a new instance of TraceTree.



27
28
29
30
31
# File 'lib/trace_tree.rb', line 27

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

Instance Method Details

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



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

def generate *log, **opt, &to_do
  @opt = opt
  @log = dump_location *log
  @debug = TmpFile.new opt[:debug] if opt[:debug]
  enhance_point
  @build_command = (opt[:html] || opt[:htmp]) ? :tree_html_full : :tree_graph
  make_filter
  @__file__, @__line__, there = bi.eval('[__FILE__, __LINE__, self]')

  #start_trace
  timer[:trace]
  @tp = TracePoint.new *Events, &@deal
  @tp.enable

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