gitlab-pry-byebug 3.9.0
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 +7 -0
- data/CHANGELOG.md +214 -0
- data/LICENSE +20 -0
- data/README.md +192 -0
- data/lib/byebug/processors/pry_processor.rb +166 -0
- data/lib/byebug/processors/pry_remote_processor.rb +42 -0
- data/lib/pry-byebug.rb +4 -0
- data/lib/pry-byebug/base.rb +31 -0
- data/lib/pry-byebug/cli.rb +6 -0
- data/lib/pry-byebug/commands.rb +12 -0
- data/lib/pry-byebug/commands/backtrace.rb +31 -0
- data/lib/pry-byebug/commands/breakpoint.rb +137 -0
- data/lib/pry-byebug/commands/continue.rb +43 -0
- data/lib/pry-byebug/commands/down.rb +35 -0
- data/lib/pry-byebug/commands/exit_all.rb +19 -0
- data/lib/pry-byebug/commands/finish.rb +29 -0
- data/lib/pry-byebug/commands/frame.rb +35 -0
- data/lib/pry-byebug/commands/next.rb +39 -0
- data/lib/pry-byebug/commands/step.rb +34 -0
- data/lib/pry-byebug/commands/up.rb +35 -0
- data/lib/pry-byebug/control_d_handler.rb +9 -0
- data/lib/pry-byebug/helpers/breakpoints.rb +82 -0
- data/lib/pry-byebug/helpers/location.rb +24 -0
- data/lib/pry-byebug/helpers/multiline.rb +23 -0
- data/lib/pry-byebug/helpers/navigation.rb +19 -0
- data/lib/pry-byebug/pry_ext.rb +23 -0
- data/lib/pry-byebug/pry_remote_ext.rb +44 -0
- data/lib/pry-byebug/version.rb +8 -0
- data/lib/pry/byebug/breakpoints.rb +167 -0
- metadata +103 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 033fb16a7334f1e384315488a374de6609e12ae6e6ec092e80d56ee5d9e010ae
|
4
|
+
data.tar.gz: 1a6e8bc37cc14f84c8702fb5f48b826281814fa1580180c1dfb93ef65d12f1ef
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7146526d40e7946b7f8d9fd5662116ea1b444c201d535c27a09410c7b08933d85632e6ff921f6aebb15522c662ea06b6ca636576a4f1e7a591a06a6485a5e316
|
7
|
+
data.tar.gz: a9b0f0a259200f7675c4d7e70e4370ce2c54966f06f65c6ee965a0d77bfbae6f5b7eed1bb8b23b7abf667db6c71751b8be213f53c427d64e1ae421e06efcee99
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,214 @@
|
|
1
|
+
# CHANGELOG
|
2
|
+
|
3
|
+
## Master (Unreleased)
|
4
|
+
|
5
|
+
## 3.9.0 (2020-03-21)
|
6
|
+
|
7
|
+
### Fixed
|
8
|
+
|
9
|
+
* Dependency on pry being too loose. Now breaking minor releases of pry won't affect pry-byebug users (#289).
|
10
|
+
|
11
|
+
### Added
|
12
|
+
|
13
|
+
* Support for pry 0.13.0 (#266).
|
14
|
+
|
15
|
+
### Removed
|
16
|
+
|
17
|
+
* Support for pry older than 0.13.0 (#289).
|
18
|
+
|
19
|
+
## 3.8.0 (2020-01-22)
|
20
|
+
|
21
|
+
### Fixed
|
22
|
+
|
23
|
+
* Use `Binding#source_location` instead of evaluating `__FILE__` to avoid
|
24
|
+
warnings on Ruby 2.7 and on Ruby 2.6 in verbose mode (#221).
|
25
|
+
|
26
|
+
### Removed
|
27
|
+
|
28
|
+
* Support for Ruby 2.3. Pry-byebug no longer installs on this platform.
|
29
|
+
|
30
|
+
## 3.7.0 (2019-02-21)
|
31
|
+
|
32
|
+
* Byebug 11 compatibility, with ruby 2.6 support.
|
33
|
+
|
34
|
+
## 3.6.0 (2018-02-07)
|
35
|
+
|
36
|
+
### Added
|
37
|
+
|
38
|
+
* Byebug 10 compatibility, with ruby 2.5 support.
|
39
|
+
|
40
|
+
## 3.5.1 (2017-11-27)
|
41
|
+
|
42
|
+
### Fixed
|
43
|
+
|
44
|
+
* Allow other threads like Pry (#142).
|
45
|
+
|
46
|
+
## 3.5.0 (2017-08-23)
|
47
|
+
|
48
|
+
### Added
|
49
|
+
|
50
|
+
* Byebug 9.1 support. As a result, Ruby 2.0 & Ruby 2.1 support has been dropped.
|
51
|
+
Pry-byebug no longer installs on these platforms.
|
52
|
+
|
53
|
+
## 3.4.3 (2017-08-22)
|
54
|
+
|
55
|
+
### Fixed
|
56
|
+
|
57
|
+
* Installation on old rubies after byebug dropping support for them.
|
58
|
+
|
59
|
+
## 3.4.2 (2016-12-06)
|
60
|
+
|
61
|
+
### Fixed
|
62
|
+
|
63
|
+
* Byebug doesn't start after `disable-pry` command.
|
64
|
+
|
65
|
+
## 3.4.1 (2016-11-22)
|
66
|
+
|
67
|
+
### Fixed
|
68
|
+
|
69
|
+
* control_d handler not being required properly when `pry-byebug` loaded
|
70
|
+
as a `pry` plugin and not through explicit require.
|
71
|
+
|
72
|
+
## 3.4.0 (2016-05-15)
|
73
|
+
|
74
|
+
### Fixed
|
75
|
+
|
76
|
+
* Byebug 9 compatibility.
|
77
|
+
|
78
|
+
### Added
|
79
|
+
|
80
|
+
* A new `backtrace` command.
|
81
|
+
|
82
|
+
## 3.3.0 (2015-11-05)
|
83
|
+
|
84
|
+
### Fixed
|
85
|
+
|
86
|
+
* Byebug 8 compatibility.
|
87
|
+
* Fix encoding error in gemspec file (#70).
|
88
|
+
* Debugger being too slow (#80, thanks @k0kubun).
|
89
|
+
|
90
|
+
## 3.2.0 (2015-07-18)
|
91
|
+
|
92
|
+
### Added
|
93
|
+
|
94
|
+
* `continue` can now receive a line number argument (#56).
|
95
|
+
|
96
|
+
### Fixed
|
97
|
+
|
98
|
+
* Conflicts with `break` and `next` Ruby keywords inside multiline statements
|
99
|
+
(#44).
|
100
|
+
|
101
|
+
### Removed
|
102
|
+
|
103
|
+
* `breaks` command. It was broken anyways (#47).
|
104
|
+
|
105
|
+
## 3.1.0 (2015-04-14)
|
106
|
+
|
107
|
+
### Added
|
108
|
+
|
109
|
+
* Frame navigation commands `up`, `down` and `frame`.
|
110
|
+
|
111
|
+
## 3.0.1 (2015-04-02)
|
112
|
+
|
113
|
+
### Fixed
|
114
|
+
|
115
|
+
* Several formatting and alignment issues.
|
116
|
+
|
117
|
+
## 3.0.0 (2015-02-02)
|
118
|
+
|
119
|
+
### Fixed
|
120
|
+
|
121
|
+
* `binding.pry` would not stop at the correct place when called at the last
|
122
|
+
line of a method/block.
|
123
|
+
|
124
|
+
### Removed
|
125
|
+
|
126
|
+
* Stepping aliases for `next` (`n`), `step` (`s`), `finish` (`f`) and `continue`
|
127
|
+
(`c`). See #34.
|
128
|
+
|
129
|
+
## 2.0.0 (2014-01-09)
|
130
|
+
|
131
|
+
### Fixed
|
132
|
+
|
133
|
+
* Byebug 3 compatibility.
|
134
|
+
* Pry not starting at the first line after `binding.pry` but at `binding.pry`.
|
135
|
+
* `continue` not finishing pry instance (#13).
|
136
|
+
|
137
|
+
## 1.3.3 (2014-25-06)
|
138
|
+
|
139
|
+
### Fixed
|
140
|
+
|
141
|
+
* Pry 0.10 series and further minor version level releases compatibility.
|
142
|
+
|
143
|
+
## 1.3.2 (2014-24-02)
|
144
|
+
|
145
|
+
### Fixed
|
146
|
+
|
147
|
+
* Bug inherited from `byebug`.
|
148
|
+
|
149
|
+
## 1.3.1 (2014-08-02)
|
150
|
+
|
151
|
+
### Fixed
|
152
|
+
|
153
|
+
* Bug #22 (thanks @andreychernih).
|
154
|
+
|
155
|
+
## 1.3.0 (2014-05-02)
|
156
|
+
|
157
|
+
### Added
|
158
|
+
|
159
|
+
* Breakpoints on method names (thanks @andreychernih & @palkan).
|
160
|
+
|
161
|
+
### Fixed
|
162
|
+
|
163
|
+
* "Undefined method `interface`" error (huge thanks to @andreychernih).
|
164
|
+
|
165
|
+
## 1.2.1 (2013-30-12)
|
166
|
+
|
167
|
+
### Fixed
|
168
|
+
|
169
|
+
* "Uncaught throw :breakout_nav" error (thanks @lukebergen).
|
170
|
+
|
171
|
+
## 1.2.0 (2013-24-09)
|
172
|
+
|
173
|
+
### Fixed
|
174
|
+
|
175
|
+
* Compatibility with byebug's 2.x series
|
176
|
+
|
177
|
+
## 1.1.2 (2013-11-07)
|
178
|
+
|
179
|
+
### Fixed
|
180
|
+
|
181
|
+
* Compatibility with backwards compatible byebug versions.
|
182
|
+
|
183
|
+
## 1.1.1 (2013-02-07)
|
184
|
+
|
185
|
+
### Fixed
|
186
|
+
|
187
|
+
* Bug when doing `step n` or `next n` where n > 1 right after `binding.pry`.
|
188
|
+
|
189
|
+
## 1.1.0 (2013-06-06)
|
190
|
+
|
191
|
+
### Added
|
192
|
+
|
193
|
+
* `s`, `n`, `f` and `c` aliases (thanks @jgakos!).
|
194
|
+
|
195
|
+
## 1.0.1 (2013-05-07)
|
196
|
+
|
197
|
+
### Fixed
|
198
|
+
|
199
|
+
* Unwanted debugging printf.
|
200
|
+
|
201
|
+
## 1.0.0 (2013-05-07)
|
202
|
+
|
203
|
+
### Added
|
204
|
+
|
205
|
+
* Initial release forked from
|
206
|
+
[pry-debugger](https://github.com/nixme/pry-debugger) to support byebug.
|
207
|
+
|
208
|
+
### Removed
|
209
|
+
|
210
|
+
* pry-remote support.
|
211
|
+
|
212
|
+
## Older releases
|
213
|
+
|
214
|
+
* Check [pry-debugger](https://github.com/nixme/pry-debugger)'s CHANGELOG.
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2018 David Rodríguez <deivid.rodriguez@riseup.net>
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
7
|
+
the Software without restriction, including without limitation the rights to
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
10
|
+
subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,192 @@
|
|
1
|
+
# pry-byebug
|
2
|
+
|
3
|
+
[![Version][VersionBadge]][VersionURL]
|
4
|
+
[![Build][CIBadge]][CIURL]
|
5
|
+
[![Inline docs][InchCIBadge]][InchCIURL]
|
6
|
+
[![Coverage][CoverageBadge]][CoverageURL]
|
7
|
+
|
8
|
+
Adds step-by-step debugging and stack navigation capabilities to [pry] using
|
9
|
+
[byebug].
|
10
|
+
|
11
|
+
To use, invoke pry normally. No need to start your script or app differently.
|
12
|
+
Execution will stop in the first statement after your `binding.pry`.
|
13
|
+
|
14
|
+
```ruby
|
15
|
+
def some_method
|
16
|
+
puts 'Hello World' # Run 'step' in the console to move here
|
17
|
+
end
|
18
|
+
|
19
|
+
binding.pry
|
20
|
+
some_method # Execution will stop here.
|
21
|
+
puts 'Goodbye World' # Run 'next' in the console to move here.
|
22
|
+
```
|
23
|
+
|
24
|
+
## Requirements
|
25
|
+
|
26
|
+
MRI 2.4.0 or higher.
|
27
|
+
|
28
|
+
## Installation
|
29
|
+
|
30
|
+
Add
|
31
|
+
|
32
|
+
```ruby
|
33
|
+
gem 'pry-byebug'
|
34
|
+
```
|
35
|
+
|
36
|
+
to your Gemfile and run
|
37
|
+
|
38
|
+
```console
|
39
|
+
bundle install
|
40
|
+
```
|
41
|
+
|
42
|
+
Make sure you include the gem globally or inside the `:test` group if you plan
|
43
|
+
to use it to debug your tests!
|
44
|
+
|
45
|
+
## Commands
|
46
|
+
|
47
|
+
### Step-by-step debugging
|
48
|
+
|
49
|
+
**break:** Manage breakpoints.
|
50
|
+
|
51
|
+
**step:** Step execution into the next line or method. Takes an optional numeric
|
52
|
+
argument to step multiple times.
|
53
|
+
|
54
|
+
**next:** Step over to the next line within the same frame. Also takes an
|
55
|
+
optional numeric argument to step multiple lines.
|
56
|
+
|
57
|
+
**finish:** Execute until current stack frame returns.
|
58
|
+
|
59
|
+
**continue:** Continue program execution and end the Pry session.
|
60
|
+
|
61
|
+
### Callstack navigation
|
62
|
+
|
63
|
+
**backtrace:** Shows the current stack. You can use the numbers on the left
|
64
|
+
side with the `frame` command to navigate the stack.
|
65
|
+
|
66
|
+
**up:** Moves the stack frame up. Takes an optional numeric argument to move
|
67
|
+
multiple frames.
|
68
|
+
|
69
|
+
**down:** Moves the stack frame down. Takes an optional numeric argument to move
|
70
|
+
multiple frames.
|
71
|
+
|
72
|
+
**frame:** Moves to a specific frame. Called without arguments will show the
|
73
|
+
current frame.
|
74
|
+
|
75
|
+
## Matching Byebug Behaviour
|
76
|
+
|
77
|
+
If you're coming from Byebug or from Pry-Byebug versions previous to 3.0, you
|
78
|
+
may be lacking the 'n', 's', 'c' and 'f' aliases for the stepping commands.
|
79
|
+
These aliases were removed by default because they usually conflict with
|
80
|
+
scratch variable names. But it's very easy to reenable them if you still want
|
81
|
+
them, just add the following shortcuts to your `~/.pryrc` file:
|
82
|
+
|
83
|
+
```ruby
|
84
|
+
if defined?(PryByebug)
|
85
|
+
Pry.commands.alias_command 'c', 'continue'
|
86
|
+
Pry.commands.alias_command 's', 'step'
|
87
|
+
Pry.commands.alias_command 'n', 'next'
|
88
|
+
Pry.commands.alias_command 'f', 'finish'
|
89
|
+
end
|
90
|
+
```
|
91
|
+
|
92
|
+
Also, you might find useful as well the repeat the last command by just hitting
|
93
|
+
the `Enter` key (e.g., with `step` or `next`). To achieve that, add this to
|
94
|
+
your `~/.pryrc` file:
|
95
|
+
|
96
|
+
```ruby
|
97
|
+
# Hit Enter to repeat last command
|
98
|
+
Pry::Commands.command /^$/, "repeat last command" do
|
99
|
+
_pry_.run_command Pry.history.to_a.last
|
100
|
+
end
|
101
|
+
```
|
102
|
+
|
103
|
+
## Breakpoints
|
104
|
+
|
105
|
+
You can set and adjust breakpoints directly from a Pry session using the
|
106
|
+
`break` command:
|
107
|
+
|
108
|
+
**break:** Set a new breakpoint from a line number in the current file, a file
|
109
|
+
and line number, or a method. Pass an optional expression to create a
|
110
|
+
conditional breakpoint. Edit existing breakpoints via various flags.
|
111
|
+
|
112
|
+
Examples:
|
113
|
+
|
114
|
+
```ruby
|
115
|
+
break SomeClass#run # Break at the start of `SomeClass#run`.
|
116
|
+
break Foo#bar if baz? # Break at `Foo#bar` only if `baz?`.
|
117
|
+
break app/models/user.rb:15 # Break at line 15 in user.rb.
|
118
|
+
break 14 # Break at line 14 in the current file.
|
119
|
+
|
120
|
+
break --condition 4 x > 2 # Change condition on breakpoint #4 to 'x > 2'.
|
121
|
+
break --condition 3 # Remove the condition on breakpoint #3.
|
122
|
+
|
123
|
+
break --delete 5 # Delete breakpoint #5.
|
124
|
+
break --disable-all # Disable all breakpoints.
|
125
|
+
|
126
|
+
break # List all breakpoints.
|
127
|
+
break --show 2 # Show details about breakpoint #2.
|
128
|
+
```
|
129
|
+
|
130
|
+
Type `break --help` from a Pry session to see all available options.
|
131
|
+
|
132
|
+
## Alternatives
|
133
|
+
|
134
|
+
Note that all of the alternatives here are incompatible with pry-byebug. If
|
135
|
+
your platform is supported by pry-byebug, you should remove any of the gems
|
136
|
+
mentioned here if they are present in your Gemfile.
|
137
|
+
|
138
|
+
* [pry-debugger]: Provides step-by-step debugging for MRI 1.9.3 or older
|
139
|
+
rubies. If you're still using those and need a step-by-step debugger to help
|
140
|
+
with the upgrade, pry-debugger can be handy.
|
141
|
+
|
142
|
+
* [pry-stack_explorer]: Provides stack navigation capabilities for MRI 1.9.3 or
|
143
|
+
older rubies. If you're still using those and need to navigate your stack to
|
144
|
+
help with the upgrade, pry-stack_explorer can be handy.
|
145
|
+
|
146
|
+
* [pry-nav]: Provides step-by-step debugging for JRuby.
|
147
|
+
|
148
|
+
## Contribute
|
149
|
+
|
150
|
+
See [Getting Started with Development](CONTRIBUTING.md).
|
151
|
+
|
152
|
+
## Funding
|
153
|
+
|
154
|
+
Subscribe to [Tidelift] to ensure pry-byebug stays actively maintained, and at
|
155
|
+
the same time get licensing assurances and timely security notifications for
|
156
|
+
your open source dependencies.
|
157
|
+
|
158
|
+
You can also help `pry-byebug` by leaving a small (or big) tip through [Liberapay].
|
159
|
+
|
160
|
+
[Tidelift]: https://tidelift.com/subscription/pkg/rubygems-pry-byebug?utm_source=rubygems-pry-byebug&utm_medium=referral&utm_campaign=readme
|
161
|
+
[Liberapay]: https://liberapay.com/pry-byebug/donate
|
162
|
+
|
163
|
+
## Security contact information
|
164
|
+
|
165
|
+
Please use the Tidelift security contact to [report a security vulnerability].
|
166
|
+
Tidelift will coordinate the fix and disclosure.
|
167
|
+
|
168
|
+
[report a security vulnerability]: https://tidelift.com/security
|
169
|
+
|
170
|
+
## Credits
|
171
|
+
|
172
|
+
* Gopal Patel (@nixme), creator of [pry-debugger], and everybody who contributed
|
173
|
+
to it. pry-byebug is a fork of pry-debugger so it wouldn't exist as it is
|
174
|
+
without those contributions.
|
175
|
+
* John Mair (@banister), creator of [pry].
|
176
|
+
|
177
|
+
Patches and bug reports are welcome.
|
178
|
+
|
179
|
+
[pry]: http://pry.github.com
|
180
|
+
[byebug]: https://github.com/deivid-rodriguez/byebug
|
181
|
+
[pry-debugger]: https://github.com/nixme/pry-debugger
|
182
|
+
[pry-nav]: https://github.com/nixme/pry-nav
|
183
|
+
[pry-stack_explorer]: https://github.com/pry/pry-stack_explorer
|
184
|
+
|
185
|
+
[VersionBadge]: https://badge.fury.io/rb/pry-byebug.svg
|
186
|
+
[VersionURL]: http://badge.fury.io/rb/pry-byebug
|
187
|
+
[CIBadge]: https://github.com/deivid-rodriguez/pry-byebug/workflows/ubuntu/badge.svg?branch=master
|
188
|
+
[CIURL]: https://github.com/deivid-rodriguez/pry-byebug/actions?query=workflow%3Aubuntu
|
189
|
+
[InchCIBadge]: http://inch-ci.org/github/deivid-rodriguez/pry-byebug.svg?branch=master
|
190
|
+
[InchCIURL]: http://inch-ci.org/github/deivid-rodriguez/pry-byebug
|
191
|
+
[CoverageBadge]: https://api.codeclimate.com/v1/badges/a88e27809329c03af017/test_coverage
|
192
|
+
[CoverageURL]: https://codeclimate.com/github/deivid-rodriguez/pry-byebug/test_coverage
|
@@ -0,0 +1,166 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "byebug/core"
|
4
|
+
|
5
|
+
module Byebug
|
6
|
+
#
|
7
|
+
# Extends raw byebug's processor.
|
8
|
+
#
|
9
|
+
class PryProcessor < CommandProcessor
|
10
|
+
attr_accessor :pry
|
11
|
+
|
12
|
+
extend Forwardable
|
13
|
+
def_delegators :@pry, :output
|
14
|
+
def_delegators Pry::Helpers::Text, :bold
|
15
|
+
|
16
|
+
def self.start
|
17
|
+
Byebug.start
|
18
|
+
Setting[:autolist] = false
|
19
|
+
Context.processor = self
|
20
|
+
Byebug.current_context.step_out(4, true)
|
21
|
+
end
|
22
|
+
|
23
|
+
#
|
24
|
+
# Wrap a Pry REPL to catch navigational commands and act on them.
|
25
|
+
#
|
26
|
+
def run(&_block)
|
27
|
+
return_value = nil
|
28
|
+
|
29
|
+
command = catch(:breakout_nav) do # Throws from PryByebug::Commands
|
30
|
+
return_value = allowing_other_threads { yield }
|
31
|
+
{} # Nothing thrown == no navigational command
|
32
|
+
end
|
33
|
+
|
34
|
+
# Pry instance to resume after stepping
|
35
|
+
@pry = command[:pry]
|
36
|
+
|
37
|
+
perform(command[:action], command[:options])
|
38
|
+
|
39
|
+
return_value
|
40
|
+
end
|
41
|
+
|
42
|
+
#
|
43
|
+
# Set up a number of navigational commands to be performed by Byebug.
|
44
|
+
#
|
45
|
+
def perform(action, options = {})
|
46
|
+
return unless %i[
|
47
|
+
backtrace
|
48
|
+
down
|
49
|
+
finish
|
50
|
+
frame
|
51
|
+
next
|
52
|
+
step
|
53
|
+
up
|
54
|
+
].include?(action)
|
55
|
+
|
56
|
+
send("perform_#{action}", options)
|
57
|
+
end
|
58
|
+
|
59
|
+
# --- Callbacks from byebug C extension ---
|
60
|
+
|
61
|
+
#
|
62
|
+
# Called when the debugger wants to stop at a regular line
|
63
|
+
#
|
64
|
+
def at_line
|
65
|
+
resume_pry
|
66
|
+
end
|
67
|
+
|
68
|
+
#
|
69
|
+
# Called when the debugger wants to stop right before a method return
|
70
|
+
#
|
71
|
+
def at_return(_return_value)
|
72
|
+
resume_pry
|
73
|
+
end
|
74
|
+
|
75
|
+
#
|
76
|
+
# Called when the debugger wants to stop right before the end of a class
|
77
|
+
# definition
|
78
|
+
#
|
79
|
+
def at_end
|
80
|
+
resume_pry
|
81
|
+
end
|
82
|
+
|
83
|
+
#
|
84
|
+
# Called when a breakpoint is hit. Note that `at_line`` is called
|
85
|
+
# inmediately after with the context's `stop_reason == :breakpoint`, so we
|
86
|
+
# must not resume the pry instance here
|
87
|
+
#
|
88
|
+
def at_breakpoint(breakpoint)
|
89
|
+
@pry ||= Pry.new
|
90
|
+
|
91
|
+
output.puts bold("\n Breakpoint #{breakpoint.id}. ") + n_hits(breakpoint)
|
92
|
+
|
93
|
+
expr = breakpoint.expr
|
94
|
+
return unless expr
|
95
|
+
|
96
|
+
output.puts bold("Condition: ") + expr
|
97
|
+
end
|
98
|
+
|
99
|
+
private
|
100
|
+
|
101
|
+
def n_hits(breakpoint)
|
102
|
+
n_hits = breakpoint.hit_count
|
103
|
+
|
104
|
+
n_hits == 1 ? "First hit" : "Hit #{n_hits} times."
|
105
|
+
end
|
106
|
+
|
107
|
+
#
|
108
|
+
# Resume an existing Pry REPL at the paused point.
|
109
|
+
#
|
110
|
+
def resume_pry
|
111
|
+
new_binding = frame._binding
|
112
|
+
|
113
|
+
run do
|
114
|
+
if defined?(@pry) && @pry
|
115
|
+
@pry.repl(new_binding)
|
116
|
+
else
|
117
|
+
@pry = Pry.start_without_pry_byebug(new_binding)
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
def perform_backtrace(_options)
|
123
|
+
Byebug::WhereCommand.new(self, "backtrace").execute
|
124
|
+
|
125
|
+
resume_pry
|
126
|
+
end
|
127
|
+
|
128
|
+
def perform_next(options)
|
129
|
+
lines = (options[:lines] || 1).to_i
|
130
|
+
context.step_over(lines, frame.pos)
|
131
|
+
end
|
132
|
+
|
133
|
+
def perform_step(options)
|
134
|
+
times = (options[:times] || 1).to_i
|
135
|
+
context.step_into(times, frame.pos)
|
136
|
+
end
|
137
|
+
|
138
|
+
def perform_finish(*)
|
139
|
+
context.step_out(1)
|
140
|
+
end
|
141
|
+
|
142
|
+
def perform_up(options)
|
143
|
+
times = (options[:times] || 1).to_i
|
144
|
+
|
145
|
+
Byebug::UpCommand.new(self, "up #{times}").execute
|
146
|
+
|
147
|
+
resume_pry
|
148
|
+
end
|
149
|
+
|
150
|
+
def perform_down(options)
|
151
|
+
times = (options[:times] || 1).to_i
|
152
|
+
|
153
|
+
Byebug::DownCommand.new(self, "down #{times}").execute
|
154
|
+
|
155
|
+
resume_pry
|
156
|
+
end
|
157
|
+
|
158
|
+
def perform_frame(options)
|
159
|
+
index = options[:index] ? options[:index].to_i : ""
|
160
|
+
|
161
|
+
Byebug::FrameCommand.new(self, "frame #{index}").execute
|
162
|
+
|
163
|
+
resume_pry
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|