byebug 5.0.0 → 6.0.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 +4 -4
- data/CHANGELOG.md +26 -1
- data/CONTRIBUTING.md +35 -13
- data/GUIDE.md +256 -198
- data/README.md +5 -11
- data/ext/byebug/byebug.c +5 -43
- data/ext/byebug/byebug.h +6 -1
- data/ext/byebug/context.c +4 -5
- data/lib/byebug/command.rb +64 -64
- data/lib/byebug/command_list.rb +32 -0
- data/lib/byebug/commands.rb +37 -0
- data/lib/byebug/commands/break.rb +45 -37
- data/lib/byebug/commands/catch.rb +52 -28
- data/lib/byebug/commands/condition.rb +19 -13
- data/lib/byebug/commands/continue.rb +15 -11
- data/lib/byebug/commands/delete.rb +18 -12
- data/lib/byebug/commands/disable.rb +9 -10
- data/lib/byebug/commands/disable/breakpoints.rb +13 -11
- data/lib/byebug/commands/disable/display.rb +13 -11
- data/lib/byebug/commands/display.rb +32 -24
- data/lib/byebug/commands/down.rb +18 -14
- data/lib/byebug/commands/edit.rb +42 -26
- data/lib/byebug/commands/enable.rb +9 -3
- data/lib/byebug/commands/enable/breakpoints.rb +13 -11
- data/lib/byebug/commands/enable/display.rb +13 -11
- data/lib/byebug/commands/finish.rb +23 -14
- data/lib/byebug/commands/frame.rb +21 -18
- data/lib/byebug/commands/help.rb +39 -16
- data/lib/byebug/commands/history.rb +16 -10
- data/lib/byebug/commands/info.rb +8 -5
- data/lib/byebug/commands/info/breakpoints.rb +16 -14
- data/lib/byebug/commands/info/display.rb +18 -18
- data/lib/byebug/commands/info/file.rb +22 -22
- data/lib/byebug/commands/info/line.rb +13 -11
- data/lib/byebug/commands/info/program.rb +13 -17
- data/lib/byebug/commands/interrupt.rb +13 -11
- data/lib/byebug/commands/irb.rb +16 -10
- data/lib/byebug/commands/kill.rb +19 -13
- data/lib/byebug/commands/list.rb +35 -24
- data/lib/byebug/commands/method.rb +25 -15
- data/lib/byebug/commands/next.rb +15 -13
- data/lib/byebug/commands/pry.rb +18 -11
- data/lib/byebug/commands/ps.rb +21 -23
- data/lib/byebug/commands/quit.rb +17 -11
- data/lib/byebug/commands/restart.rb +28 -24
- data/lib/byebug/commands/save.rb +23 -15
- data/lib/byebug/commands/set.rb +26 -19
- data/lib/byebug/commands/show.rb +20 -14
- data/lib/byebug/commands/source.rb +15 -14
- data/lib/byebug/commands/step.rb +15 -13
- data/lib/byebug/commands/thread.rb +8 -4
- data/lib/byebug/commands/thread/current.rb +11 -11
- data/lib/byebug/commands/thread/list.rb +14 -14
- data/lib/byebug/commands/thread/resume.rb +14 -14
- data/lib/byebug/commands/thread/stop.rb +14 -14
- data/lib/byebug/commands/thread/switch.rb +15 -14
- data/lib/byebug/commands/tracevar.rb +20 -16
- data/lib/byebug/commands/undisplay.rb +22 -18
- data/lib/byebug/commands/untracevar.rb +13 -11
- data/lib/byebug/commands/up.rb +18 -14
- data/lib/byebug/commands/var.rb +10 -3
- data/lib/byebug/commands/var/all.rb +15 -13
- data/lib/byebug/commands/var/args.rb +37 -0
- data/lib/byebug/commands/var/const.rb +25 -14
- data/lib/byebug/commands/var/global.rb +13 -11
- data/lib/byebug/commands/var/instance.rb +13 -11
- data/lib/byebug/commands/var/local.rb +13 -11
- data/lib/byebug/commands/where.rb +15 -11
- data/lib/byebug/context.rb +71 -73
- data/lib/byebug/core.rb +45 -26
- data/lib/byebug/errors.rb +27 -0
- data/lib/byebug/frame.rb +181 -0
- data/lib/byebug/helpers/eval.rb +67 -26
- data/lib/byebug/helpers/file.rb +18 -3
- data/lib/byebug/helpers/frame.rb +36 -39
- data/lib/byebug/helpers/parse.rb +15 -13
- data/lib/byebug/helpers/path.rb +21 -0
- data/lib/byebug/helpers/reflection.rb +17 -0
- data/lib/byebug/helpers/thread.rb +20 -14
- data/lib/byebug/helpers/toggle.rb +10 -5
- data/lib/byebug/helpers/var.rb +36 -15
- data/lib/byebug/interface.rb +27 -9
- data/lib/byebug/option_setter.rb +93 -0
- data/lib/byebug/printers/base.rb +3 -0
- data/lib/byebug/printers/plain.rb +4 -14
- data/lib/byebug/printers/texts/base.yml +2 -7
- data/lib/byebug/processors/command_processor.rb +101 -102
- data/lib/byebug/processors/control_processor.rb +20 -0
- data/lib/byebug/processors/post_mortem_processor.rb +16 -0
- data/lib/byebug/processors/script_processor.rb +49 -0
- data/lib/byebug/remote.rb +13 -7
- data/lib/byebug/runner.rb +39 -65
- data/lib/byebug/setting.rb +4 -1
- data/lib/byebug/settings/post_mortem.rb +0 -16
- data/lib/byebug/settings/savefile.rb +1 -4
- data/lib/byebug/subcommands.rb +27 -29
- data/lib/byebug/version.rb +4 -1
- metadata +14 -29
- data/lib/byebug/commands/eval.rb +0 -43
- data/lib/byebug/commands/info/args.rb +0 -39
- data/lib/byebug/commands/info/catch.rb +0 -39
- data/lib/byebug/commands/pp.rb +0 -41
- data/lib/byebug/commands/putl.rb +0 -43
- data/lib/byebug/processor.rb +0 -43
- data/lib/byebug/processors/control_command_processor.rb +0 -48
- data/lib/byebug/settings/verbose.rb +0 -20
- data/lib/byebug/state.rb +0 -12
- data/lib/byebug/states/control_state.rb +0 -26
- data/lib/byebug/states/regular_state.rb +0 -187
- data/lib/byebug/subcommand_list.rb +0 -33
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f0c3c3868ab03af89e252040738d248a93ee7fd5
|
4
|
+
data.tar.gz: 86c48afc3df76c6ad06f71e4f187cf7ebfb4d753
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f1afe8ff550a182da17c136b3a49030f8370974e3c9b5e818da6f8c5d3c6e4fbe78731ee1840d848e7fbac0baa0b87ea031df44f4c316f69c6ac162bcd523187
|
7
|
+
data.tar.gz: 4c1abe7a5407b9483ebdc7f7c14ac2f142434b699566a06127759593917b466b8986e4cff3b583206a5bd72ac56d9fc38c1dff6ff4b9421ca246885b251f7d74
|
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,29 @@
|
|
1
|
-
##
|
1
|
+
## 6.0.0 - 2015-08-17
|
2
|
+
### Removed
|
3
|
+
* `autoeval` setting. I haven't heard of anyone setting it to false.
|
4
|
+
* `pp`, `putl`, `eval`. People just want to evaluate Ruby code, so the less
|
5
|
+
magic the better. Most of the people probably were not aware that `byebug`
|
6
|
+
was overriding stuff like `pp` or `eval`. Only keeping `ps` as the single
|
7
|
+
"enhanced evaluation" command.
|
8
|
+
* `verbose` setting.
|
9
|
+
* `info catch` command. Use `catch` without arguments instead.
|
10
|
+
* `R` command alias for `restart`.
|
11
|
+
|
12
|
+
### Changed
|
13
|
+
* `info args` is now `var args`.
|
14
|
+
* `interrupt` is now aliased to `int`, not to `i`.
|
15
|
+
* API to define custom commands and subcommands (see the Command class).
|
16
|
+
|
17
|
+
### Fixed
|
18
|
+
* [#140](https://github.com/deivid-rodriguez/byebug/issues/140). `help` command
|
19
|
+
not showing the list of available commands and their descriptions.
|
20
|
+
* [#147](https://github.com/deivid-rodriguez/byebug/issues/147). Setting
|
21
|
+
breakpoints at symlinked files.
|
22
|
+
|
23
|
+
### Added
|
24
|
+
* API to define custom command processors (see the CommandProcessor class).
|
25
|
+
|
26
|
+
## 5.0.0 - 2015-05-18
|
2
27
|
### Fixed
|
3
28
|
* [#136](https://github.com/deivid-rodriguez/byebug/issues/136). `frame`
|
4
29
|
command not working with negative numbers (thanks @ark6).
|
data/CONTRIBUTING.md
CHANGED
@@ -1,30 +1,52 @@
|
|
1
1
|
## Getting started
|
2
2
|
|
3
|
-
|
3
|
+
### Development dependencies
|
4
4
|
|
5
|
-
* `Byebug` depends on
|
5
|
+
* `Byebug` depends on Ruby's TracePoint API provided by `ruby-core`. This is a
|
6
6
|
young API and a lot of bugs have been recently corrected, so make sure you
|
7
7
|
always have the lastest patch level release installed.
|
8
|
-
|
9
|
-
*
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
8
|
+
|
9
|
+
* The recommended tool to manage development dependencies is `bundler`. Run
|
10
|
+
`gem install bundler` to install it.
|
11
|
+
|
12
|
+
* Running `bundle install` inside a local clone of `byebug` will get development
|
13
|
+
dependencies installed.
|
14
|
+
|
15
|
+
|
16
|
+
### Running the test suite
|
17
|
+
|
16
18
|
* Make sure you compile the C-extension using `bundle exec rake compile`.
|
17
19
|
Otherwise you won't be able to use `byebug`.
|
20
|
+
|
18
21
|
* Run the test suite using the default rake task (`bundle exec rake`). This
|
19
22
|
task is composed of 2 subtasks: `bundle exec rake compile` && `bundle exec rake
|
20
23
|
test`.
|
21
24
|
|
22
|
-
|
23
|
-
|
25
|
+
* If you want to run specific tests, use the provided test runner, like so:
|
26
|
+
|
27
|
+
- Specific test files. For example,
|
28
|
+
`script/minitest_runner test/commands/break_test.rb`
|
29
|
+
|
30
|
+
- Specific test classes. For example,
|
31
|
+
`script/minitest_runner Byebug::BreakAtLinesTestCase`
|
32
|
+
|
33
|
+
- Specific tests. For example,
|
34
|
+
`script/minitest_runner test_catch_removes_specific_catchpoint`
|
35
|
+
|
36
|
+
- You can combine any of them and you will get the union of all filters. For
|
37
|
+
example: `script/minitest_runner Byebug::BreakAtLinesTestCase
|
38
|
+
test_catch_removes_specific_catchpoint`
|
39
|
+
|
40
|
+
|
41
|
+
### Code style
|
42
|
+
|
43
|
+
* Byebug uses [overcommit][] to enforce code style. Install the git hooks using
|
44
|
+
`bundle exec overcommit --install`. They will review your changes before they
|
45
|
+
are committed, checking they are consistent with the project's code style.
|
24
46
|
|
25
47
|
[overcommit]: https://github.com/brigade/overcommit/
|
26
48
|
|
27
|
-
|
49
|
+
### Byebug as a C-extension
|
28
50
|
|
29
51
|
Byebug is a gem developed as a C-extension. The debugger internal's
|
30
52
|
functionality is implemented in C (the interaction with the TracePoint API).
|
data/GUIDE.md
CHANGED
@@ -157,10 +157,9 @@ Really quit? (y/n)
|
|
157
157
|
y
|
158
158
|
```
|
159
159
|
|
160
|
-
So far, so good. As you can see from the above to get out of `byebug`, one
|
161
|
-
can issue a `quit` command (
|
162
|
-
|
163
|
-
`q!`.
|
160
|
+
So far, so good. As you can see from the above, to get out of `byebug`, one
|
161
|
+
can issue a `quit` command (or the abbreviation `q`). If you want to quit
|
162
|
+
without being prompted, suffix the command with an exclamation mark, e.g., `q!`.
|
164
163
|
|
165
164
|
|
166
165
|
### Second Sample Session: Delving Deeper
|
@@ -206,54 +205,194 @@ $ byebug path/to/hanoi.rb
|
|
206
205
|
9: hanoi(n - 1, c, b, a) if n - 1 > 0
|
207
206
|
10: end
|
208
207
|
(byebug) private_methods
|
209
|
-
|
208
|
+
public
|
209
|
+
private
|
210
|
+
include
|
211
|
+
using
|
212
|
+
define_method
|
213
|
+
default_src_encoding
|
214
|
+
DelegateClass
|
215
|
+
Digest
|
216
|
+
timeout
|
217
|
+
initialize_copy
|
218
|
+
initialize_dup
|
219
|
+
initialize_clone
|
220
|
+
sprintf
|
221
|
+
format
|
222
|
+
Integer
|
223
|
+
Float
|
224
|
+
String
|
225
|
+
Array
|
226
|
+
Hash
|
227
|
+
warn
|
228
|
+
raise
|
229
|
+
fail
|
230
|
+
global_variables
|
231
|
+
__method__
|
232
|
+
__callee__
|
233
|
+
__dir__
|
234
|
+
eval
|
235
|
+
local_variables
|
236
|
+
iterator?
|
237
|
+
block_given?
|
238
|
+
catch
|
239
|
+
throw
|
240
|
+
loop
|
241
|
+
respond_to_missing?
|
242
|
+
trace_var
|
243
|
+
untrace_var
|
244
|
+
at_exit
|
245
|
+
syscall
|
246
|
+
open
|
247
|
+
printf
|
248
|
+
print
|
249
|
+
putc
|
250
|
+
puts
|
251
|
+
gets
|
252
|
+
readline
|
253
|
+
select
|
254
|
+
readlines
|
255
|
+
`
|
256
|
+
p
|
257
|
+
test
|
258
|
+
srand
|
259
|
+
rand
|
260
|
+
trap
|
261
|
+
load
|
262
|
+
require
|
263
|
+
require_relative
|
264
|
+
autoload
|
265
|
+
autoload?
|
266
|
+
proc
|
267
|
+
lambda
|
268
|
+
binding
|
269
|
+
caller
|
270
|
+
caller_locations
|
271
|
+
exec
|
272
|
+
fork
|
273
|
+
exit!
|
274
|
+
system
|
275
|
+
spawn
|
276
|
+
sleep
|
277
|
+
exit
|
278
|
+
abort
|
279
|
+
Rational
|
280
|
+
Complex
|
281
|
+
set_trace_func
|
282
|
+
gem_original_require
|
283
|
+
Pathname
|
284
|
+
pp
|
285
|
+
y
|
286
|
+
URI
|
287
|
+
rubygems_require
|
288
|
+
initialize
|
289
|
+
singleton_method_added
|
290
|
+
singleton_method_removed
|
291
|
+
singleton_method_undefined
|
292
|
+
method_missing
|
293
|
+
(byebug) private_methods.member?(:hanoi)
|
294
|
+
false
|
210
295
|
```
|
211
296
|
|
212
297
|
`private_methods` is not a byebug command but a Ruby feature. By default, when
|
213
298
|
`byebug` doesn't understand a command, it will evaluate it as if it was a Ruby
|
214
|
-
command.
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
299
|
+
command. You can use any Ruby to inspect your program's state at the place it
|
300
|
+
is stopped. Additional, `byebug` provides a specific evaluation command, `ps`
|
301
|
+
that automatically enhances the evaluated results a bit. For example, it
|
302
|
+
automatically sorts arrays.
|
303
|
+
|
304
|
+
```
|
305
|
+
[:Array,
|
306
|
+
:Complex,
|
307
|
+
:DelegateClass,
|
308
|
+
:Digest,
|
309
|
+
:Float,
|
310
|
+
:Hash,
|
311
|
+
:Integer,
|
312
|
+
:Pathname,
|
313
|
+
:Rational,
|
314
|
+
:String,
|
315
|
+
:URI,
|
316
|
+
:__callee__,
|
317
|
+
:__dir__,
|
318
|
+
:__method__,
|
319
|
+
:`,
|
320
|
+
:abort,
|
321
|
+
:at_exit,
|
322
|
+
:autoload,
|
323
|
+
:autoload?,
|
324
|
+
:binding,
|
325
|
+
:block_given?,
|
326
|
+
:caller,
|
327
|
+
:caller_locations,
|
328
|
+
:catch,
|
329
|
+
:default_src_encoding,
|
330
|
+
:define_method,
|
331
|
+
:eval,
|
332
|
+
:exec,
|
333
|
+
:exit,
|
334
|
+
:exit!,
|
335
|
+
:fail,
|
336
|
+
:fork,
|
337
|
+
:format,
|
338
|
+
:gem_original_require,
|
339
|
+
:gets,
|
340
|
+
:global_variables,
|
341
|
+
:include,
|
342
|
+
:initialize,
|
343
|
+
:initialize_clone,
|
344
|
+
:initialize_copy,
|
345
|
+
:initialize_dup,
|
346
|
+
:iterator?,
|
347
|
+
:lambda,
|
348
|
+
:load,
|
349
|
+
:local_variables,
|
350
|
+
:loop,
|
351
|
+
:method_missing,
|
352
|
+
:open,
|
353
|
+
:p,
|
354
|
+
:pp,
|
355
|
+
:print,
|
356
|
+
:printf,
|
357
|
+
:private,
|
358
|
+
:proc,
|
359
|
+
:public,
|
360
|
+
:putc,
|
361
|
+
:puts,
|
362
|
+
:raise,
|
363
|
+
:rand,
|
364
|
+
:readline,
|
365
|
+
:readlines,
|
366
|
+
:require,
|
367
|
+
:require_relative,
|
368
|
+
:respond_to_missing?,
|
369
|
+
:rubygems_require,
|
370
|
+
:select,
|
371
|
+
:set_trace_func,
|
372
|
+
:singleton_method_added,
|
373
|
+
:singleton_method_removed,
|
374
|
+
:singleton_method_undefined,
|
375
|
+
:sleep,
|
376
|
+
:spawn,
|
377
|
+
:sprintf,
|
378
|
+
:srand,
|
379
|
+
:syscall,
|
380
|
+
:system,
|
381
|
+
:test,
|
382
|
+
:throw,
|
383
|
+
:timeout,
|
384
|
+
:trace_var,
|
385
|
+
:trap,
|
386
|
+
:untrace_var,
|
387
|
+
:using,
|
388
|
+
:warn,
|
389
|
+
:y]
|
221
390
|
|
222
|
-
```bash
|
223
|
-
(byebug) set width 80
|
224
|
-
Maximum width of byebug's output is 80
|
225
|
-
(byebug) ps private_methods
|
226
|
-
Array default_src_encoding open sleep
|
227
|
-
Complex define_method p spawn
|
228
|
-
Digest eval pp sprintf
|
229
|
-
Float exec print srand
|
230
|
-
Hash exit printf syscall
|
231
|
-
Integer exit! private system
|
232
|
-
Pathname fail proc test
|
233
|
-
Rational fork public throw
|
234
|
-
String format putc timeout
|
235
|
-
URI gem_original_require puts trace_var
|
236
|
-
__callee__ gets raise trap
|
237
|
-
__dir__ global_variables rand untrace_var
|
238
|
-
__method__ include readline using
|
239
|
-
` initialize readlines warn
|
240
|
-
abort initialize_clone require y
|
241
|
-
at_exit initialize_copy require_relative
|
242
|
-
autoload initialize_dup respond_to_missing?
|
243
|
-
autoload? iterator? rubygems_require
|
244
|
-
binding lambda select
|
245
|
-
block_given? load set_trace_func
|
246
|
-
caller local_variables singleton_method_added
|
247
|
-
caller_locations loop singleton_method_removed
|
248
|
-
catch method_missing singleton_method_undefined
|
249
|
-
(byebug)
|
250
391
|
```
|
251
392
|
|
252
393
|
Now let's see what happens after stepping:
|
253
394
|
|
254
395
|
```bash
|
255
|
-
(byebug) private_methods.member?(:hanoi)
|
256
|
-
false
|
257
396
|
(byebug) step
|
258
397
|
|
259
398
|
[5, 14] in /path/to/hanoi.rb
|
@@ -1146,7 +1285,7 @@ letter option name, such as `-h`. The list of options is detailed below:
|
|
1146
1285
|
|
1147
1286
|
#### -h | --help
|
1148
1287
|
|
1149
|
-
It causes `byebug` to print some basic help and exit
|
1288
|
+
It causes `byebug` to print some basic help and exit.
|
1150
1289
|
|
1151
1290
|
|
1152
1291
|
#### -v | --version
|
@@ -1233,12 +1372,14 @@ You can also request the execution of a command file with the `source` command
|
|
1233
1372
|
|
1234
1373
|
### Quitting byebug
|
1235
1374
|
|
1236
|
-
To exit `byebug`, use the `quit` command (abbreviated `q`
|
1237
|
-
|
1238
|
-
|
1239
|
-
|
1240
|
-
|
1241
|
-
|
1375
|
+
To exit `byebug`, use the `quit` command (abbreviated to `q`). Normally, if you
|
1376
|
+
are in an interactive session, this command will prompt to ask if you really
|
1377
|
+
want to quit. If you want to quit without being prompted, enter `quit
|
1378
|
+
unconditionally` (abbreviated to `q!`).
|
1379
|
+
|
1380
|
+
Another way to terminate byebug is to use the `kill` command. This does the
|
1381
|
+
more forceful `kill -9`. It can be used in cases where `quit` doesn't work (I
|
1382
|
+
haven't seen those yet).
|
1242
1383
|
|
1243
1384
|
|
1244
1385
|
### Calling byebug from inside your program
|
@@ -1335,8 +1476,8 @@ Multiple commands can be put on a line by separating each with a semicolon `;`.
|
|
1335
1476
|
You can disable the meaning of a semicolon to separate commands by escaping it
|
1336
1477
|
with a backslash.
|
1337
1478
|
|
1338
|
-
For example,
|
1339
|
-
|
1479
|
+
For example, you might want to enter the following code to compute the 5th
|
1480
|
+
Fibonacci number.
|
1340
1481
|
|
1341
1482
|
```bash
|
1342
1483
|
(byebug) fib1=0; fib2=1; 5.times {|temp| temp=fib1; fib1=fib2; fib2 += temp }
|
@@ -1389,26 +1530,61 @@ short list of named classes of commands
|
|
1389
1530
|
|
1390
1531
|
```bash
|
1391
1532
|
(byebug) help
|
1392
|
-
|
1393
|
-
|
1394
|
-
|
1395
|
-
|
1396
|
-
|
1397
|
-
|
1398
|
-
|
1399
|
-
|
1533
|
+
|
1534
|
+
break -- Sets breakpoints in the source code
|
1535
|
+
catch -- Handles exception catchpoints
|
1536
|
+
condition -- Sets conditions on breakpoints
|
1537
|
+
continue -- Runs until program ends, hits a breakpoint or reaches a line
|
1538
|
+
delete -- Deletes breakpoints
|
1539
|
+
disable -- Disables breakpoints or displays
|
1540
|
+
display -- Evaluates expressions every time the debugger stops
|
1541
|
+
down -- Moves to a lower frame in the stack trace
|
1542
|
+
edit -- Edits source files
|
1543
|
+
enable -- Enables breakpoints or displays
|
1544
|
+
finish -- Runs the program until frame returns
|
1545
|
+
frame -- Moves to a frame in the call stack
|
1546
|
+
help -- Helps you using byebug
|
1547
|
+
history -- Shows byebug's history of commands
|
1548
|
+
info -- Shows several informations about the program being debugged
|
1549
|
+
interrupt -- Interrupts the program
|
1550
|
+
irb -- Starts an IRB session
|
1551
|
+
kill -- Sends a signal to the current process
|
1552
|
+
list -- Lists lines of source code
|
1553
|
+
method -- Shows methods of an object, class or module
|
1554
|
+
next -- Runs one or more lines of code
|
1555
|
+
pry -- Starts a Pry session
|
1556
|
+
ps -- Evaluates an expression and prettyprints & sort the result
|
1557
|
+
quit -- Exits byebug
|
1558
|
+
restart -- Restarts the debugged program
|
1559
|
+
save -- Saves current byebug session to a file
|
1560
|
+
set -- Modifies byebug settings
|
1561
|
+
show -- Shows byebug settings
|
1562
|
+
source -- Restores a previously saved byebug session
|
1563
|
+
step -- Steps into blocks or methods one or more times
|
1564
|
+
thread -- Commands to manipulate threads
|
1565
|
+
tracevar -- Enables tracing of a global variable
|
1566
|
+
undisplay -- Stops displaying all or some expressions when program stops
|
1567
|
+
untracevar -- Stops tracing a global variable
|
1568
|
+
up -- Moves to a higher frame in the stack trace
|
1569
|
+
var -- Shows variables and its values
|
1570
|
+
where -- Displays the backtrace
|
1571
|
+
|
1400
1572
|
```
|
1401
1573
|
|
1402
|
-
With a command name
|
1403
|
-
use that command.
|
1574
|
+
With a command name, `help` displays information on how to use the command.
|
1404
1575
|
|
1405
1576
|
```bash
|
1406
1577
|
(byebug) help list
|
1407
|
-
|
1408
|
-
l[ist] -
|
1409
|
-
|
1410
|
-
|
1411
|
-
|
1578
|
+
|
1579
|
+
l[ist][[-=]][ nn-mm]
|
1580
|
+
|
1581
|
+
Lists lines of source code
|
1582
|
+
|
1583
|
+
Lists lines forward from current line or from the place where code was
|
1584
|
+
last listed. If "list-" is specified, lists backwards instead. If
|
1585
|
+
"list=" is specified, lists from current line regardless of where code
|
1586
|
+
was last listed. A line range can also be specified to list specific
|
1587
|
+
sections of code.
|
1412
1588
|
(byebug)
|
1413
1589
|
```
|
1414
1590
|
|
@@ -1461,10 +1637,10 @@ With an integer argument, list info on that breakpoint.
|
|
1461
1637
|
|
1462
1638
|
#### Quit
|
1463
1639
|
|
1464
|
-
To exit `byebug`, type `quit` (abbreviated `q`
|
1465
|
-
|
1466
|
-
|
1467
|
-
|
1640
|
+
To exit `byebug`, type `quit` (abbreviated to `q`). Normally, if you are in an
|
1641
|
+
interactive session, this command will prompt you to confirm you really want to
|
1642
|
+
quit. If you want to quit without being prompted, enter `quit unconditionally`
|
1643
|
+
(abbreviated to `q!`).
|
1468
1644
|
|
1469
1645
|
#### Restart
|
1470
1646
|
|
@@ -1529,135 +1705,17 @@ later. To do that, use `disable display` or `enable display` followed by the
|
|
1529
1705
|
expression number.
|
1530
1706
|
|
1531
1707
|
|
1532
|
-
###
|
1708
|
+
### Evaluation of expressions: display
|
1533
1709
|
|
1534
|
-
|
1535
|
-
|
1536
|
-
|
1537
|
-
|
1538
|
-
|
1710
|
+
To examine and change data in your script you can just evaluate any Ruby code
|
1711
|
+
from `byebug`'s prompt. Any input that is not recognized as a command will be
|
1712
|
+
evaluated, so `byebug` essentially works as a REPL. If you want to evaluate
|
1713
|
+
something that conflicts with a `byebug` command, just use Ruby's `eval`. For
|
1714
|
+
example, if you want to print a variable called `n `, type `eval n` because
|
1539
1715
|
typing just `n` will execute `byebug`'s command `next`.
|
1540
1716
|
|
1541
|
-
A similar command to `eval|p` is `pp` which tries to pretty print the result.
|
1542
|
-
|
1543
|
-
If the value you want to print is an array, sometimes a columnized list looks
|
1544
|
-
nicer. Use `putl` for that. Notice however that entries are sorted to run down
|
1545
|
-
first rather than across. If the value is not an array `putl` will just call
|
1546
|
-
pretty-print.
|
1547
|
-
|
1548
|
-
Sometimes you may want to print the array not only columnized, but sorted as
|
1549
|
-
well. The list of byebug help commands appears this way, and so does the output
|
1550
|
-
of the `method` commands. Use `ps` for that. If the value is not an array `ps`
|
1551
|
-
will just call pretty-print.
|
1552
|
-
|
1553
|
-
```bash
|
1554
|
-
(byebug) Kernel.instance_methods
|
1555
|
-
[:nil?, :===, :=~, :!~, :eql?, :hash, :<=>, :class, :singleton_class, :clone,
|
1556
|
-
:dup, :taint, :tainted?, :untaint, :untrust, :untrusted?, :trust, :freeze,
|
1557
|
-
:frozen?, :to_s, :inspect, :methods, :singleton_methods, :protected_methods,
|
1558
|
-
:private_methods, :public_methods, :instance_variables, :instance_variable_get,
|
1559
|
-
:instance_variable_set, :instance_variable_defined?, :remove_instance_variable,
|
1560
|
-
:instance_of?, :kind_of?, :is_a?, :tap, :send, :public_send, :respond_to?,
|
1561
|
-
:extend, :display, :method, :public_method, :define_singleton_method,
|
1562
|
-
:object_id, :to_enum, :enum_for, :gem, :pretty_inspect, :byebug]
|
1563
|
-
(byebug) p Kernel.instance_methods
|
1564
|
-
[:nil?, :===, :=~, :!~, :eql?, :hash, :<=>, :class, :singleton_class, :clone,
|
1565
|
-
:dup, :taint, :tainted?, :untaint, :untrust, :untrusted?, :trust, :freeze,
|
1566
|
-
:frozen?, :to_s, :inspect, :methods, :singleton_methods, :protected_methods,
|
1567
|
-
:private_methods, :public_methods, :instance_variables, :instance_variable_get,
|
1568
|
-
:instance_variable_set, :instance_variable_defined?, :remove_instance_variable,
|
1569
|
-
:instance_of?, :kind_of?, :is_a?, :tap, :send, :public_send, :respond_to?,
|
1570
|
-
:extend, :display, :method, :public_method, :define_singleton_method,
|
1571
|
-
:object_id, :to_enum, :enum_for, :gem, :pretty_inspect, :byebug]
|
1572
|
-
(byebug) pp Kernel.instance_methods
|
1573
|
-
[:nil?,
|
1574
|
-
:===,
|
1575
|
-
:=~,
|
1576
|
-
:!~,
|
1577
|
-
:eql?,
|
1578
|
-
:hash,
|
1579
|
-
:<=>,
|
1580
|
-
:class,
|
1581
|
-
:singleton_class,
|
1582
|
-
:clone,
|
1583
|
-
:dup,
|
1584
|
-
:taint,
|
1585
|
-
:tainted?,
|
1586
|
-
:untaint,
|
1587
|
-
:untrust,
|
1588
|
-
:untrusted?,
|
1589
|
-
:trust,
|
1590
|
-
:freeze,
|
1591
|
-
:frozen?,
|
1592
|
-
:to_s,
|
1593
|
-
:inspect,
|
1594
|
-
:methods,
|
1595
|
-
:singleton_methods,
|
1596
|
-
:protected_methods,
|
1597
|
-
:private_methods,
|
1598
|
-
:public_methods,
|
1599
|
-
:instance_variables,
|
1600
|
-
:instance_variable_get,
|
1601
|
-
:instance_variable_set,
|
1602
|
-
:instance_variable_defined?,
|
1603
|
-
:remove_instance_variable,
|
1604
|
-
:instance_of?,
|
1605
|
-
:kind_of?,
|
1606
|
-
:is_a?,
|
1607
|
-
:tap,
|
1608
|
-
:send,
|
1609
|
-
:public_send,
|
1610
|
-
:respond_to?,
|
1611
|
-
:extend,
|
1612
|
-
:display,
|
1613
|
-
:method,
|
1614
|
-
:public_method,
|
1615
|
-
:define_singleton_method,
|
1616
|
-
:object_id,
|
1617
|
-
:to_enum,
|
1618
|
-
:enum_for,
|
1619
|
-
:gem,
|
1620
|
-
:pretty_inspect,
|
1621
|
-
:byebug]
|
1622
|
-
(byebug) putl Kernel.instance_methods
|
1623
|
-
nil? trust is_a?
|
1624
|
-
=== freeze tap
|
1625
|
-
=~ frozen? send
|
1626
|
-
!~ to_s public_send
|
1627
|
-
eql? inspect respond_to?
|
1628
|
-
hash methods extend
|
1629
|
-
<=> singleton_methods display
|
1630
|
-
class protected_methods method
|
1631
|
-
singleton_class private_methods public_method
|
1632
|
-
clone public_methods singleton_method
|
1633
|
-
dup instance_variables define_singleton_method
|
1634
|
-
itself instance_variable_get object_id
|
1635
|
-
taint instance_variable_set to_enum
|
1636
|
-
tainted? instance_variable_defined? enum_for
|
1637
|
-
untaint remove_instance_variable gem
|
1638
|
-
untrust instance_of? pretty_inspect
|
1639
|
-
untrusted? kind_of?
|
1640
|
-
(byebug) ps Kernel.instance_methods
|
1641
|
-
!~ instance_of? public_send
|
1642
|
-
<=> instance_variable_defined? remove_instance_variable
|
1643
|
-
=== instance_variable_get respond_to?
|
1644
|
-
=~ instance_variable_set send
|
1645
|
-
class instance_variables singleton_class
|
1646
|
-
clone is_a? singleton_method
|
1647
|
-
define_singleton_method itself singleton_methods
|
1648
|
-
display kind_of? taint
|
1649
|
-
dup method tainted?
|
1650
|
-
enum_for methods tap
|
1651
|
-
eql? nil? to_enum
|
1652
|
-
extend object_id to_s
|
1653
|
-
freeze pretty_inspect trust
|
1654
|
-
frozen? private_methods untaint
|
1655
|
-
gem protected_methods untrust
|
1656
|
-
hash public_method untrusted?
|
1657
|
-
```
|
1658
|
-
|
1659
1717
|
Finally, if you need more advanced functionality from REPL's, you can enter
|
1660
|
-
`irb` or `pry` using `irb` or `pry` commands. The
|
1718
|
+
`irb` or `pry` using `irb` or `pry` commands. The binding's environment will be
|
1661
1719
|
set to the current state in the program. When you leave the repl and go back to
|
1662
1720
|
`byebug`'s command prompt we show the file, line and text position of the
|
1663
1721
|
program. If you issue a `list` without location information, the default
|
@@ -1698,7 +1756,7 @@ def triangle(n)
|
|
1698
1756
|
(byebug)
|
1699
1757
|
```
|
1700
1758
|
|
1701
|
-
### Printing variables
|
1759
|
+
### Printing variables: var
|
1702
1760
|
|
1703
1761
|
Byebug can print many different information about variables. Such as
|
1704
1762
|
* `var const <object>`. Show the constants of `<object>`. This is basically
|
@@ -1712,8 +1770,8 @@ basically listing `<object>.instance_variables`.
|
|
1712
1770
|
* `method instance <object>`. Show methods of `<object>`. Basically this is the
|
1713
1771
|
same as running `ps <object>.instance_methods(false)`.
|
1714
1772
|
* `method <class-or-module>`. Show methods of the class or module
|
1715
|
-
`<class-or-module>`. Basically this is the same as running
|
1716
|
-
|
1773
|
+
`<class-or-module>`. Basically this is the same as running `ps
|
1774
|
+
<class-or-module>.methods`.
|
1717
1775
|
|
1718
1776
|
### Examining Program Source Files: list
|
1719
1777
|
|