Module RubyRunTracer__
In: lib/rubyrun/rubyrun_tracer__.rb

Methods

Included Modules

RubyRunGlobals RubyRunUtils__ RubyRunHTML__

Public Instance methods

The stack trace global hash is printed out in the rubyrun log in thread id order, also showing the top stack of all these threads before they were interrupted.

[Source]

    # File lib/rubyrun/rubyrun_tracer__.rb, line 63
63:   def back_trace_all(th_data_hash)
64:     $rubyrun_thread_dump_reporter.info "----- RubyRun Thread Dump STARTS-----"
65:     $rubyrun_thread_stack.each {|th, stack|
66:       $rubyrun_thread_dump_reporter.info
67:       thread_id = get_thread_id(th)
68:       $rubyrun_thread_dump_reporter.info "Thread ID = #{thread_id}"
69:       $rubyrun_thread_dump_reporter.info "    Last line before interrupt: #{get_top_stack(th_data_hash, thread_id)}"
70:       $rubyrun_thread_dump_reporter.info "    Stack trace at interrupt"
71:       stack.each {|line|
72:         $rubyrun_thread_dump_reporter.info "\t#{line}"
73:       }
74:     }
75:     $rubyrun_thread_dump_reporter.info
76:     $rubyrun_thread_dump_reporter.info "----- RubyRun Thread Dump ENDS -----"
77:     $rubyrun_thread_stack.clear
78:   end
  1. If arguments are required to trace, try using kernel inspect to print it
  2. If obejct is required to trace, try using kernel inspect to print it.

Otherwise print class name, The inspect can cause recursion and blow up ruby. Rescue only delays the issue hence not used here.

  1. Show the last caller and line

[Source]

    # File lib/rubyrun/rubyrun_tracer__.rb, line 33
33:   def enter_trace(tid, type, obj, invoker, klass, mid, *args)
34:     @rubyrun_trace_odd_row = true if @rubyrun_trace_odd_row == nil
35:     cur_time = Time.now
36:     html_content = sprintf("#{@rubyrun_trace_odd_row ? METHOD_TRACE_ODD_ROW : METHOD_TRACE_EVEN_ROW}",
37:                            "#{cur_time.strftime("%H:%M:%S")}.#{("%.3f" % cur_time.to_f).split('.')[1]} #{cur_time.strftime("%m/%d/%y")}",
38:                            get_thread_id,
39:                            "#{type.split(' ').reverse.first}",
40:                            "#{type.split(' ').length == 3 ? '#3B9C9C' : (@rubyrun_trace_odd_row ? '#AFDCEC' : 'white')}",
41:                            "#{type.split(' ').length == 1 ? '' : (type.split(' ').length == 3 ? '*'+type.split(' ').reverse[1]+'s' : type.split(' ').reverse[1]+'s')}",
42:                            klass.to_s,
43:                            return_method_name(mid),
44:                            "#{args.each {|arg| arg.inspect} if $rubyrun_debug_args || is_in_hash?($rubyrun_adapter_hash, klass, mid)}",
45:                            "#{$rubyrun_debug_obj && obj ? obj.inspect : obj.class if obj}",
46:                            "#{invoker if invoker}")
47:     write_trace(html_content)
48:     @rubyrun_trace_odd_row = !@rubyrun_trace_odd_row
49:   end

Write a trace entry to the trace destination

[Source]

    # File lib/rubyrun/rubyrun_tracer__.rb, line 52
52:   def write_trace(html_content)
53:     begin
54:       $rubyrun_tracer.info(html_content)
55:     rescue Exception => e
56:       $rubyrun_logger.warn(e.to_s)
57:     end
58:   end

[Validate]