Module: PryMoves::TraceHelpers

Included in:
TraceCommand
Defined in:
lib/commands/trace_helpers.rb

Instance Method Summary collapse

Instance Method Details

#current_frame_digest(upward: 0) ⇒ Object



16
17
18
19
20
# File 'lib/commands/trace_helpers.rb', line 16

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

#current_frame_type(upward: 0) ⇒ Object



28
29
30
31
32
# File 'lib/commands/trace_helpers.rb', line 28

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

#debug_info(file, line, id) ⇒ Object



11
12
13
14
# File 'lib/commands/trace_helpers.rb', line 11

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

#frame_digest(binding_) ⇒ Object



22
23
24
25
26
# File 'lib/commands/trace_helpers.rb', line 22

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

#frame_type(binding_) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/commands/trace_helpers.rb', line 34

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

#redirect_step?(binding_) ⇒ Boolean

Returns:

  • (Boolean)


3
4
5
6
7
8
9
# File 'lib/commands/trace_helpers.rb', line 3

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