pry-moves 0.1.10 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/Gemfile.lock +7 -5
- data/README.md +18 -8
- data/lib/commands/debug.rb +17 -0
- data/lib/commands/finish.rb +26 -0
- data/lib/commands/goto.rb +19 -0
- data/lib/commands/iterate.rb +22 -0
- data/lib/commands/next.rb +37 -0
- data/lib/commands/next_breakpoint.rb +22 -0
- data/lib/commands/step.rb +83 -0
- data/lib/commands/trace_command.rb +87 -0
- data/lib/commands/trace_helpers.rb +49 -0
- data/lib/commands/traced_method.rb +71 -0
- data/lib/debug_sugar.rb +72 -0
- data/lib/pry-moves/add_suffix.rb +87 -0
- data/lib/pry-moves/backtrace.rb +81 -50
- data/lib/pry-moves/bindings_stack.rb +97 -0
- data/lib/pry-moves/commands.rb +50 -7
- data/lib/pry-moves/formatter.rb +75 -0
- data/lib/pry-moves/painter.rb +5 -1
- data/lib/pry-moves/pry_ext.rb +64 -16
- data/lib/pry-moves/pry_wrapper.rb +30 -17
- data/lib/pry-moves/recursion_tracker.rb +94 -0
- data/lib/pry-moves/restartable.rb +38 -0
- data/lib/pry-moves/version.rb +1 -1
- data/lib/pry-moves/watch.rb +3 -0
- data/lib/pry-moves.rb +66 -4
- data/lib/pry-stack_explorer/VERSION +2 -0
- data/lib/pry-stack_explorer/frame_manager.rb +6 -9
- data/lib/pry-stack_explorer/pry-stack_explorer.rb +3 -17
- data/lib/pry-stack_explorer/{commands.rb → stack_commands.rb} +10 -6
- data/lib/pry-stack_explorer/when_started_hook.rb +17 -63
- data/playground/Gemfile.lock +9 -9
- data/playground/README.md +1 -0
- data/playground/playground.rb +94 -9
- data/playground/sand.rb +45 -12
- data/playground/test.rb +5 -1
- data/playground/test.sh +1 -0
- data/pry-moves.gemspec +3 -2
- data/publish.sh +3 -0
- data/spec/backtrace_spec.rb +11 -13
- data/spec/blocks_spec.rb +41 -8
- data/spec/commands_spec.rb +26 -25
- data/spec/pry_debugger.rb +5 -1
- data/spec/redirection_spec.rb +7 -0
- data/spec/spec_helper.rb +9 -4
- data/spec/step_spec.rb +51 -0
- metadata +44 -10
- data/lib/pry-moves/helpers.rb +0 -50
- data/lib/pry-moves/trace_commands.rb +0 -105
- data/lib/pry-moves/tracer.rb +0 -169
@@ -2,24 +2,24 @@ require 'pry' unless defined? Pry
|
|
2
2
|
|
3
3
|
module PryMoves
|
4
4
|
class PryWrapper
|
5
|
-
def initialize(binding_, pry_start_options
|
5
|
+
def initialize(binding_, pry_start_options, pry)
|
6
6
|
@init_binding = binding_
|
7
7
|
@pry_start_options = pry_start_options # Options to use for Pry.start
|
8
|
+
@pry = pry
|
8
9
|
end
|
9
10
|
|
10
|
-
def run
|
11
|
+
def run
|
11
12
|
PryMoves.lock
|
12
13
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
14
|
+
initial_frame = PryMoves::BindingsStack.new.initial_frame
|
15
|
+
if not @pry_start_options[:pry_moves_loop] and
|
16
|
+
initial_frame.local_variable_defined? :debug_redirect
|
17
|
+
debug_redirect = initial_frame.local_variable_get(:debug_redirect)
|
18
|
+
PryMoves.messages << "⏩ redirected to #{debug_redirect}"
|
19
|
+
@command = {action: :step, binding: initial_frame}
|
20
|
+
else
|
21
|
+
start_pry
|
20
22
|
end
|
21
|
-
PryMoves.is_open = false
|
22
|
-
Pry.config.marker = "=>"
|
23
23
|
|
24
24
|
if @command
|
25
25
|
trace_command
|
@@ -30,11 +30,24 @@ class PryWrapper
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
-
return_value
|
33
|
+
@return_value
|
34
34
|
end
|
35
35
|
|
36
36
|
private
|
37
37
|
|
38
|
+
def start_pry
|
39
|
+
Pry.config.marker = "⛔️" if @pry_start_options[:exit_from_method]
|
40
|
+
PryMoves.is_open = true
|
41
|
+
|
42
|
+
@command = catch(:breakout_nav) do # Coordinates with PryMoves::Commands
|
43
|
+
@return_value = @pry.pry_moves_origin_start(@init_binding, @pry_start_options)
|
44
|
+
nil # Nothing thrown == no navigational command
|
45
|
+
end
|
46
|
+
|
47
|
+
PryMoves.is_open = false
|
48
|
+
Pry.config.marker = "=>"
|
49
|
+
end
|
50
|
+
|
38
51
|
def trace_command
|
39
52
|
if @command[:action] == :debug
|
40
53
|
wrap_debug
|
@@ -61,9 +74,9 @@ class PryWrapper
|
|
61
74
|
tracer = start_tracing
|
62
75
|
begin
|
63
76
|
@command[:binding].eval @command[:param]
|
64
|
-
rescue => e
|
77
|
+
rescue StandardError, SyntaxError => e
|
65
78
|
Thread.current.set_trace_func nil
|
66
|
-
puts e
|
79
|
+
puts "❌️ #{e}"
|
67
80
|
end
|
68
81
|
tracer.stop_tracing
|
69
82
|
end.join
|
@@ -73,9 +86,9 @@ class PryWrapper
|
|
73
86
|
|
74
87
|
def start_tracing
|
75
88
|
@last_runtime_binding = @command[:binding]
|
76
|
-
|
77
|
-
|
78
|
-
|
89
|
+
PryMoves::TraceCommand.trace @command, @pry_start_options do |binding|
|
90
|
+
Pry.start(binding, @pry_start_options)
|
91
|
+
end
|
79
92
|
end
|
80
93
|
|
81
94
|
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
module PryMoves::Recursion
|
2
|
+
|
3
|
+
class Tracker
|
4
|
+
|
5
|
+
attr_reader :loops
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
@history = []
|
9
|
+
@loops = 0
|
10
|
+
@missing = 0
|
11
|
+
@currently_missing = []
|
12
|
+
@missing_lines = []
|
13
|
+
end
|
14
|
+
|
15
|
+
def track file, line_num, bt_index, binding_index
|
16
|
+
line = "#{file}:#{line_num}"
|
17
|
+
if @last_index
|
18
|
+
check_recursion line, bt_index, binding_index
|
19
|
+
elsif (prev_index = @history.rindex line)
|
20
|
+
@loops += 1
|
21
|
+
@last_index = prev_index
|
22
|
+
@recursion_size = 1
|
23
|
+
else
|
24
|
+
@history << line
|
25
|
+
@last_index = nil
|
26
|
+
end
|
27
|
+
|
28
|
+
@repetitions_start ||= bt_index if @loops == 2
|
29
|
+
end
|
30
|
+
|
31
|
+
def check_recursion line, bt_index, binding_index
|
32
|
+
prev_index = @history.rindex line
|
33
|
+
if prev_index == @last_index
|
34
|
+
@loops += 1
|
35
|
+
@missing = 0
|
36
|
+
@recursion_size = 0
|
37
|
+
@missing_lines.concat @currently_missing
|
38
|
+
@repetitions_end = bt_index
|
39
|
+
elsif prev_index && prev_index > @last_index
|
40
|
+
@last_index = prev_index + 1
|
41
|
+
@recursion_size += 1
|
42
|
+
# todo: finish tracking and debug multi-line recursions
|
43
|
+
elsif @missing <= @recursion_size
|
44
|
+
@missing += 1
|
45
|
+
@currently_missing << binding_index
|
46
|
+
false
|
47
|
+
else
|
48
|
+
# @missing_lines = nil
|
49
|
+
# @last_index = nil
|
50
|
+
@is_finished = true
|
51
|
+
false
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def finished?
|
56
|
+
@is_finished
|
57
|
+
end
|
58
|
+
|
59
|
+
def good?
|
60
|
+
@repetitions_start and @repetitions_end
|
61
|
+
end
|
62
|
+
|
63
|
+
def apply result
|
64
|
+
label = "♻️ recursion with #{@loops} loops"
|
65
|
+
label += " Ⓜ️ #{@missing} missing lines #{@missing_lines}" if @missing_lines.present?
|
66
|
+
label = "...(#{label})..."
|
67
|
+
# puts "#{@repetitions_start}..#{@repetitions_end}"
|
68
|
+
result[@repetitions_start..@repetitions_end] = [label]
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
class Holder < Array
|
74
|
+
|
75
|
+
def initialize(*args)
|
76
|
+
super
|
77
|
+
new_tracker
|
78
|
+
end
|
79
|
+
|
80
|
+
def new_tracker
|
81
|
+
@tracker = Tracker.new
|
82
|
+
end
|
83
|
+
|
84
|
+
def track *args
|
85
|
+
@tracker.track *args
|
86
|
+
if @tracker.finished?
|
87
|
+
self << @tracker if @tracker.good?
|
88
|
+
new_tracker
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module PryMoves::Restartable
|
2
|
+
|
3
|
+
attr_accessor :restart_requested, :reload_requested,
|
4
|
+
:reload_rake_tasks
|
5
|
+
|
6
|
+
def restartable
|
7
|
+
trigger :new_run
|
8
|
+
yield
|
9
|
+
re_execution
|
10
|
+
rescue PryMoves::Restart
|
11
|
+
self.restart_requested = false
|
12
|
+
PryMoves.reset
|
13
|
+
trigger :restart
|
14
|
+
retry
|
15
|
+
rescue PryMoves::Reload
|
16
|
+
puts "🔮 try to use @ with reload"
|
17
|
+
exit 3
|
18
|
+
end
|
19
|
+
|
20
|
+
def re_execution
|
21
|
+
raise PryMoves::Restart if restart_requested
|
22
|
+
raise PryMoves::Reload if reload_requested
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
class PryMoves::Restart < RuntimeError
|
29
|
+
end
|
30
|
+
class PryMoves::Reload < RuntimeError
|
31
|
+
end
|
32
|
+
RSpec::Support::AllExceptionsExceptOnesWeMustNotRescue::AVOID_RESCUING.concat [PryMoves::Restart, PryMoves::Reload] if defined? RSpec
|
33
|
+
|
34
|
+
Pry.config.hooks.add_hook(:after_eval, :exit_on_re_execution) do |_, _, _pry_|
|
35
|
+
if PryMoves.restart_requested or PryMoves.reload_requested
|
36
|
+
Pry.run_command 'exit-all'
|
37
|
+
end
|
38
|
+
end
|
data/lib/pry-moves/version.rb
CHANGED
data/lib/pry-moves/watch.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'singleton'
|
2
|
+
require 'set'
|
2
3
|
|
3
4
|
class PryMoves::Watch
|
4
5
|
|
@@ -44,6 +45,8 @@ class PryMoves::Watch
|
|
44
45
|
"\033[1m#{cmd}\033[0m: #{format binding_.eval(cmd)}"
|
45
46
|
rescue NameError
|
46
47
|
"\033[1m#{cmd}\033[0m: <undefined>"
|
48
|
+
rescue => e
|
49
|
+
"\033[1m#{cmd}\033[0m: <#{e}>"
|
47
50
|
end
|
48
51
|
|
49
52
|
def format(text)
|
data/lib/pry-moves.rb
CHANGED
@@ -1,17 +1,31 @@
|
|
1
1
|
require 'pry' unless defined? Pry
|
2
2
|
|
3
3
|
require 'pry-moves/version'
|
4
|
-
require 'pry-moves/trace_commands'
|
5
|
-
require 'pry-moves/tracer'
|
6
4
|
require 'pry-moves/pry_ext'
|
7
5
|
require 'pry-moves/commands'
|
6
|
+
require 'pry-moves/add_suffix'
|
8
7
|
require 'pry-moves/pry_wrapper'
|
8
|
+
require 'pry-moves/bindings_stack'
|
9
|
+
require 'pry-moves/formatter'
|
9
10
|
require 'pry-moves/backtrace'
|
10
11
|
require 'pry-moves/watch'
|
11
|
-
require 'pry-moves/helpers'
|
12
12
|
require 'pry-moves/painter'
|
13
|
+
require 'pry-moves/restartable'
|
14
|
+
require 'pry-moves/recursion_tracker'
|
15
|
+
|
16
|
+
require 'commands/traced_method'
|
17
|
+
require 'commands/trace_helpers'
|
18
|
+
require 'commands/trace_command'
|
19
|
+
require 'commands/debug'
|
20
|
+
require 'commands/finish'
|
21
|
+
require 'commands/goto'
|
22
|
+
require 'commands/iterate'
|
23
|
+
require 'commands/next'
|
24
|
+
require 'commands/next_breakpoint'
|
25
|
+
require 'commands/step'
|
13
26
|
|
14
27
|
require 'pry-stack_explorer/pry-stack_explorer'
|
28
|
+
require 'debug_sugar'
|
15
29
|
|
16
30
|
# Optionally load pry-remote monkey patches
|
17
31
|
require 'pry-moves/pry_remote_ext' if defined? PryRemote
|
@@ -20,8 +34,30 @@ module PryMoves
|
|
20
34
|
TRACE_IGNORE_FILES = Dir[File.join(File.dirname(__FILE__), '**', '*.rb')].map { |f| File.expand_path(f) }
|
21
35
|
|
22
36
|
extend self
|
37
|
+
extend PryMoves::Restartable
|
38
|
+
|
39
|
+
attr_accessor :is_open, :trace,
|
40
|
+
:stop_on_breakpoints, :launched_specs_examples, :debug_called_times
|
41
|
+
|
42
|
+
def reset
|
43
|
+
self.launched_specs_examples = 0
|
44
|
+
self.stop_on_breakpoints = true
|
45
|
+
self.debug_called_times = 0
|
46
|
+
end
|
23
47
|
|
24
|
-
|
48
|
+
def debug(message = nil, at: nil)
|
49
|
+
pry_moves_stack_root = true
|
50
|
+
PryMoves.re_execution
|
51
|
+
if PryMoves.stop_on_breakpoints
|
52
|
+
self.debug_called_times += 1
|
53
|
+
if at
|
54
|
+
return unless self.debug_called_times == at
|
55
|
+
end
|
56
|
+
PryMoves.messages << message if message
|
57
|
+
binding.pry
|
58
|
+
PryMoves.re_execution
|
59
|
+
end
|
60
|
+
end
|
25
61
|
|
26
62
|
# Checks that a binding is in a local file context. Extracted from
|
27
63
|
# https://github.com/pry/pry/blob/master/lib/pry/default_commands/context.rb
|
@@ -34,9 +70,18 @@ module PryMoves
|
|
34
70
|
@semaphore ||= Mutex.new
|
35
71
|
end
|
36
72
|
|
73
|
+
def messages
|
74
|
+
@messages ||= []
|
75
|
+
end
|
76
|
+
|
77
|
+
def add_command(command, &block)
|
78
|
+
Pry.commands.block_command command, "", &block
|
79
|
+
end
|
80
|
+
|
37
81
|
def locked?
|
38
82
|
semaphore.locked?
|
39
83
|
end
|
84
|
+
alias tracing? locked?
|
40
85
|
|
41
86
|
def lock
|
42
87
|
semaphore.lock unless semaphore.locked?
|
@@ -57,6 +102,23 @@ module PryMoves
|
|
57
102
|
true
|
58
103
|
end
|
59
104
|
|
105
|
+
def trigger(event)
|
106
|
+
triggers[event].each &:call
|
107
|
+
end
|
108
|
+
|
109
|
+
def triggers
|
110
|
+
@triggers ||= Hash.new do |hash, key|
|
111
|
+
hash[key] = []
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
def on(trigger, &block)
|
116
|
+
triggers[trigger] << block
|
117
|
+
end
|
118
|
+
|
60
119
|
# Reference to currently running pry-remote server. Used by the tracer.
|
61
120
|
attr_accessor :current_remote_server
|
62
121
|
end
|
122
|
+
|
123
|
+
PryMoves.reset
|
124
|
+
PryMoves.trace = true if ENV['TRACE_MOVES']
|
@@ -33,13 +33,6 @@ module PryStackExplorer
|
|
33
33
|
@prior_backtrace = _pry_.backtrace
|
34
34
|
end
|
35
35
|
|
36
|
-
def filter_bindings(vapid_frames: false)
|
37
|
-
bindings.reject do |binding|
|
38
|
-
!vapid_frames and
|
39
|
-
binding.local_variable_defined?(:vapid_frame)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
36
|
# Iterate over all frames
|
44
37
|
def each(&block)
|
45
38
|
bindings.each(&block)
|
@@ -61,14 +54,18 @@ module PryStackExplorer
|
|
61
54
|
# @param [Fixnum] index The index.
|
62
55
|
def set_binding_index_safely(index)
|
63
56
|
if index > bindings.size - 1
|
64
|
-
raise Pry::CommandError, "At top of stack, cannot go further"
|
57
|
+
raise Pry::CommandError, "Shouldn't happen: At top of stack, cannot go further"
|
65
58
|
elsif index < 0
|
66
|
-
raise Pry::CommandError, "At bottom of stack, cannot go further"
|
59
|
+
raise Pry::CommandError, "Shouldn't happen: At bottom of stack, cannot go further"
|
67
60
|
else
|
68
61
|
self.binding_index = index
|
69
62
|
end
|
70
63
|
end
|
71
64
|
|
65
|
+
def goto_index index
|
66
|
+
change_frame_to bindings.index {|b| b.index == index }
|
67
|
+
end
|
68
|
+
|
72
69
|
# Change active frame to the one indexed by `index`.
|
73
70
|
# Note that indexing base is `0`
|
74
71
|
# @param [Fixnum] index The index of the frame.
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# pry-stack_explorer.rb
|
2
2
|
# (C) John Mair (banisterfiend); MIT license
|
3
3
|
|
4
|
-
require "pry-stack_explorer/
|
4
|
+
require "pry-stack_explorer/stack_commands"
|
5
5
|
require "pry-stack_explorer/frame_manager"
|
6
6
|
require "pry-stack_explorer/when_started_hook"
|
7
7
|
require "binding_of_caller"
|
@@ -108,7 +108,7 @@ module PryStackExplorer
|
|
108
108
|
(b1.eval('self').equal?(b2.eval('self'))) &&
|
109
109
|
(b1.eval('__method__') == b2.eval('__method__')) &&
|
110
110
|
(b1.eval('local_variables').map { |v| b1.eval("#{v}") }.equal?(
|
111
|
-
|
111
|
+
b2.eval('local_variables').map { |v| b2.eval("#{v}") }))
|
112
112
|
end
|
113
113
|
end
|
114
114
|
end
|
@@ -117,23 +117,9 @@ Pry.config.hooks.add_hook(:after_session, :delete_frame_manager) do |_, _, _pry_
|
|
117
117
|
PryStackExplorer.clear_frame_managers(_pry_)
|
118
118
|
end
|
119
119
|
|
120
|
+
# Can be moved to start_with_pry_nav to isolate from other use cases of Pry
|
120
121
|
Pry.config.hooks.add_hook(:when_started, :save_caller_bindings, PryStackExplorer::WhenStartedHook.new)
|
121
122
|
|
122
123
|
# Import the StackExplorer commands
|
123
124
|
Pry.config.commands.import PryStackExplorer::Commands
|
124
125
|
|
125
|
-
# monkey-patch the whereami command to show some frame information,
|
126
|
-
# useful for navigating stack.
|
127
|
-
Pry.config.commands.before_command("whereami") do |num|
|
128
|
-
if PryStackExplorer.frame_manager(_pry_) && !internal_binding?(target)
|
129
|
-
bindings = PryStackExplorer.frame_manager(_pry_).bindings
|
130
|
-
binding_index = PryStackExplorer.frame_manager(_pry_).binding_index
|
131
|
-
|
132
|
-
info = "#{Pry::Helpers::Text.bold('Frame:')} "+
|
133
|
-
"#{binding_index}/#{bindings.size - 1} "+
|
134
|
-
"#{bindings[binding_index].frame_type}"
|
135
|
-
|
136
|
-
output.puts "\n"
|
137
|
-
output.puts info
|
138
|
-
end
|
139
|
-
end
|
@@ -49,7 +49,7 @@ module PryStackExplorer
|
|
49
49
|
b_self = b.eval('self')
|
50
50
|
type = b.frame_type ? "[#{b.frame_type}]".ljust(9) : ""
|
51
51
|
desc = b.frame_description ? "#{b.frame_description}" : "#{frame_description(b)}"
|
52
|
-
sig = PryMoves::
|
52
|
+
sig = PryMoves::Formatter.new.method_signature b
|
53
53
|
|
54
54
|
self_clipped = "#{Pry.view_clip(b_self)}"
|
55
55
|
path = "@ #{b.eval('__FILE__')}:#{b.eval('__LINE__')}"
|
@@ -87,14 +87,18 @@ module PryStackExplorer
|
|
87
87
|
frame_manager.bindings.index(new_frame)
|
88
88
|
end
|
89
89
|
|
90
|
-
def find_frame_by_direction(
|
91
|
-
frame_index = find_frame_by_block(
|
92
|
-
|
93
|
-
not
|
90
|
+
def find_frame_by_direction(dir, step_into_vapid: false)
|
91
|
+
frame_index = find_frame_by_block(dir) do |b|
|
92
|
+
step_into_vapid or
|
93
|
+
not frame_manager.bindings.vapid?(b)
|
94
94
|
end
|
95
95
|
|
96
|
+
if !frame_index and !step_into_vapid
|
97
|
+
frame_index = find_frame_by_block(dir) {true}
|
98
|
+
end
|
99
|
+
|
96
100
|
frame_index ||
|
97
|
-
raise(Pry::CommandError, "At #{
|
101
|
+
raise(Pry::CommandError, "At #{dir == :up ? 'top' : 'bottom'} of stack, cannot go further")
|
98
102
|
end
|
99
103
|
|
100
104
|
def move(direction, param)
|
@@ -2,84 +2,38 @@ module PryStackExplorer
|
|
2
2
|
class WhenStartedHook
|
3
3
|
include Pry::Helpers::BaseHelpers
|
4
4
|
|
5
|
-
def caller_bindings(target)
|
6
|
-
bindings = binding.callers
|
7
|
-
pre_callers = Thread.current[:pre_callers]
|
8
|
-
bindings = bindings + pre_callers if pre_callers
|
9
|
-
bindings = remove_internal_frames(bindings)
|
10
|
-
mark_vapid_frames(bindings)
|
11
|
-
bindings
|
12
|
-
end
|
13
|
-
|
14
5
|
def call(target, options, _pry_)
|
15
|
-
|
6
|
+
start_from_console = target.eval('__callee__').nil? &&
|
7
|
+
target.eval('__FILE__') == '<main>' &&
|
8
|
+
target.eval('__LINE__') == 0
|
9
|
+
return if start_from_console
|
10
|
+
|
16
11
|
options = {
|
17
|
-
:
|
18
|
-
:initial_frame => 0
|
12
|
+
call_stack: true
|
19
13
|
}.merge!(options)
|
20
14
|
|
21
|
-
return
|
15
|
+
return unless options[:call_stack]
|
16
|
+
initial_frame = options[:initial_frame]
|
22
17
|
|
23
18
|
if options[:call_stack].is_a?(Array)
|
24
19
|
bindings = options[:call_stack]
|
25
|
-
|
26
|
-
|
20
|
+
initial_frame ||= 0
|
21
|
+
unless valid_call_stack?(bindings)
|
27
22
|
raise ArgumentError, ":call_stack must be an array of bindings"
|
28
23
|
end
|
29
24
|
else
|
30
|
-
bindings =
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
private
|
37
|
-
|
38
|
-
def mark_vapid_frames(bindings)
|
39
|
-
stepped_out = false
|
40
|
-
actual_file, actual_method = nil, nil
|
41
|
-
|
42
|
-
bindings.each do |binding|
|
43
|
-
if stepped_out
|
44
|
-
if actual_file == binding.eval("__FILE__") and actual_method == binding.eval("__method__")
|
45
|
-
stepped_out = false
|
46
|
-
else
|
47
|
-
binding.local_variable_set :vapid_frame, true
|
48
|
-
end
|
49
|
-
elsif binding.frame_type == :block
|
50
|
-
stepped_out = true
|
51
|
-
actual_file = binding.eval("__FILE__")
|
52
|
-
actual_method = binding.eval("__method__")
|
53
|
-
end
|
54
|
-
|
55
|
-
if binding.local_variable_defined? :hide_from_stack
|
56
|
-
binding.local_variable_set :vapid_frame, true
|
25
|
+
bindings = PryMoves::BindingsStack.new
|
26
|
+
initial_frame ||= bindings.suggest_initial_frame_index
|
27
|
+
# if Thread.current[:pry_moves_debug] and initial_frame > 0
|
28
|
+
if initial_frame > 0
|
29
|
+
PryMoves.messages << "👽 Frames hidden: #{initial_frame}"
|
57
30
|
end
|
58
31
|
end
|
59
|
-
end
|
60
|
-
|
61
|
-
# remove internal frames related to setting up the session
|
62
|
-
def remove_internal_frames(bindings)
|
63
|
-
i = top_internal_frame_index(bindings)
|
64
|
-
# DEBUG:
|
65
|
-
#bindings.each_with_index do |b, index|
|
66
|
-
# puts "#{index}: #{b.eval("self.class")} #{b.eval("__method__")}"
|
67
|
-
#end
|
68
|
-
#puts "FOUND top internal frame: #{bindings.size} => #{i}"
|
69
32
|
|
70
|
-
|
33
|
+
PryStackExplorer.create_and_push_frame_manager bindings, _pry_, initial_frame: initial_frame
|
71
34
|
end
|
72
35
|
|
73
|
-
|
74
|
-
bindings.rindex do |b|
|
75
|
-
if b.frame_type == :method
|
76
|
-
self_, method = b.eval("self"), b.eval("__method__")
|
77
|
-
self_.equal?(Pry) && method == :start ||
|
78
|
-
self_.class == Binding && method == :pry ||
|
79
|
-
self_.class == PryMoves::Tracer && method == :tracing_func
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
36
|
+
private
|
83
37
|
|
84
38
|
def valid_call_stack?(bindings)
|
85
39
|
bindings.any? && bindings.all? { |v| v.is_a?(Binding) }
|
data/playground/Gemfile.lock
CHANGED
@@ -1,23 +1,23 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ..
|
3
3
|
specs:
|
4
|
-
pry-moves (0.
|
4
|
+
pry-moves (1.0.0)
|
5
5
|
binding_of_caller (~> 0.7)
|
6
|
-
|
6
|
+
colorize (~> 0.8)
|
7
|
+
pry (>= 0.10.4, < 0.13)
|
7
8
|
|
8
9
|
GEM
|
9
10
|
remote: https://rubygems.org/
|
10
11
|
specs:
|
11
12
|
binding_of_caller (0.8.0)
|
12
13
|
debug_inspector (>= 0.0.1)
|
13
|
-
coderay (1.1.
|
14
|
+
coderay (1.1.3)
|
15
|
+
colorize (0.8.1)
|
14
16
|
debug_inspector (0.0.3)
|
15
|
-
method_source (0.
|
16
|
-
pry (0.
|
17
|
+
method_source (0.9.2)
|
18
|
+
pry (0.12.2)
|
17
19
|
coderay (~> 1.1.0)
|
18
|
-
method_source (~> 0.
|
19
|
-
slop (~> 3.4)
|
20
|
-
slop (3.6.0)
|
20
|
+
method_source (~> 0.9.0)
|
21
21
|
|
22
22
|
PLATFORMS
|
23
23
|
ruby
|
@@ -26,4 +26,4 @@ DEPENDENCIES
|
|
26
26
|
pry-moves!
|
27
27
|
|
28
28
|
BUNDLED WITH
|
29
|
-
1.17.
|
29
|
+
1.17.3
|