Class: DEBUGGER__::CallTracer

Inherits:
Tracer show all
Defined in:
lib/debug/tracer.rb

Instance Attribute Summary

Attributes inherited from Tracer

#key, #type

Instance Method Summary collapse

Methods inherited from Tracer

#colorize, #description, #disable, #enable, #enabled?, #header, #initialize, #minfo, #out, #skip?, #to_s

Methods included from Color

#color_pp, #colored_inspect, #colorize, #colorize_blue, #colorize_code, #colorize_cyan, #colorize_dim, #colorize_magenta, #irb_colorize, #with_inspection_error_guard

Methods included from SkipPathHelper

#skip_config_skip_path?, #skip_internal_path?, #skip_location?, #skip_path?

Constructor Details

This class inherits a constructor from DEBUGGER__::Tracer

Instance Method Details

#setupObject



116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# File 'lib/debug/tracer.rb', line 116

def setup
  @tracer = TracePoint.new(:a_call, :a_return){|tp|
    next if skip?(tp)

    depth = caller.size

    call_identifier_str =
      if tp.defined_class
        minfo(tp)
      else
        "block"
      end

    call_identifier_str = colorize_blue(call_identifier_str)

    case tp.event
    when :call, :c_call, :b_call
      depth += 1 if tp.event == :c_call
      sp = ' ' * depth
      out tp, ">#{sp}#{call_identifier_str}", depth
    when :return, :c_return, :b_return
      depth += 1 if tp.event == :c_return
      sp = ' ' * depth
      return_str = colorize_magenta(DEBUGGER__.safe_inspect(tp.return_value, short: true))
      out tp, "<#{sp}#{call_identifier_str} #=> #{return_str}", depth
    end
  }
end

#skip_with_pattern?(tp) ⇒ Boolean

Returns:

  • (Boolean)


145
146
147
# File 'lib/debug/tracer.rb', line 145

def skip_with_pattern?(tp)
  super && !tp.method_id&.match?(@pattern)
end