Sha256: 9cabbb97c283e59c7938229c8c08f72718f47d00608c209615ae789a83bf73c8

Contents?: true

Size: 1.36 KB

Versions: 16

Compression:

Stored size: 1.36 KB

Contents

module PryMoves::TraceHelpers

  def redirect_step?(binding_)
    return false unless binding_.local_variable_defined? :debug_redirect

    debug_redirect = binding_.local_variable_get(:debug_redirect)
    @step_into_funcs = [debug_redirect] if debug_redirect
    true
  end

  def debug_info(file, line, id)
    puts "📽  call_depth:#{@call_depth} #{@method[:file]}:#{file}"
    puts "#{id} #{@method[:start]} > #{line} > #{@method[:end]}"
  end

  def current_frame_digest(upward: 0)
    # binding_ from tracing_func doesn't have @iseq,
    # therefore binding should  be re-retrieved using 'binding_of_caller' lib
    frame_digest(binding.of_caller(3 + upward))
  end

  def frame_digest(binding_)
    #puts "frame_digest for: #{binding_.eval '__callee__'}"
    iseq = binding_.instance_variable_get('@iseq')
    Digest::MD5.hexdigest iseq.disasm
  end

  def current_frame_type(upward: 0)
    # binding_ from tracing_func doesn't have @iseq,
    # therefore binding should  be re-retrieved using 'binding_of_caller' lib
    frame_type(binding.of_caller(3 + upward))
  end

  def frame_type(binding_)
    line = binding_.instance_variable_get('@iseq').disasm.split("\n").first
    m = line.match /\== disasm: #<ISeq:([\w ]+)@/
    if m
      str = m[1]
      if str.start_with? 'block in '
        :block
      else
        :method
      end
    else
      :unknown
    end
  end

end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
pry-moves-1.0.15 lib/commands/trace_helpers.rb
pry-moves-1.0.14 lib/commands/trace_helpers.rb
pry-moves-1.0.13 lib/commands/trace_helpers.rb
pry-moves-1.0.12 lib/commands/trace_helpers.rb
pry-moves-1.0.11 lib/commands/trace_helpers.rb
pry-moves-1.0.10 lib/commands/trace_helpers.rb
pry-moves-1.0.9 lib/commands/trace_helpers.rb
pry-moves-1.0.8 lib/commands/trace_helpers.rb
pry-moves-1.0.7 lib/commands/trace_helpers.rb
pry-moves-1.0.6 lib/commands/trace_helpers.rb
pry-moves-1.0.5 lib/commands/trace_helpers.rb
pry-moves-1.0.4 lib/commands/trace_helpers.rb
pry-moves-1.0.3 lib/commands/trace_helpers.rb
pry-moves-1.0.2 lib/commands/trace_helpers.rb
pry-moves-1.0.1 lib/commands/trace_helpers.rb
pry-moves-1.0.0 lib/commands/trace_helpers.rb