byebug 2.1.1 → 2.2.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/.gitignore +1 -0
- data/CHANGELOG.md +9 -0
- data/CONTRIBUTING.md +13 -1
- data/GUIDE.md +181 -1
- data/README.md +67 -211
- data/Rakefile +1 -0
- data/bin/byebug +1 -8
- data/ext/byebug/byebug.c +66 -25
- data/ext/byebug/context.c +16 -20
- data/ext/byebug/extconf.rb +2 -1
- data/lib/byebug.rb +16 -9
- data/lib/byebug/command.rb +3 -3
- data/lib/byebug/commands/condition.rb +2 -2
- data/lib/byebug/commands/edit.rb +12 -9
- data/lib/byebug/commands/eval.rb +0 -16
- data/lib/byebug/commands/frame.rb +7 -17
- data/lib/byebug/commands/info.rb +2 -9
- data/lib/byebug/commands/list.rb +1 -1
- data/lib/byebug/commands/reload.rb +11 -0
- data/lib/byebug/commands/repl.rb +3 -6
- data/lib/byebug/commands/set.rb +5 -5
- data/lib/byebug/commands/show.rb +5 -0
- data/lib/byebug/commands/threads.rb +4 -4
- data/lib/byebug/commands/trace.rb +2 -1
- data/lib/byebug/context.rb +14 -5
- data/lib/byebug/interface.rb +1 -1
- data/lib/byebug/processor.rb +1 -1
- data/lib/byebug/remote.rb +1 -24
- data/lib/byebug/version.rb +1 -1
- data/old_doc/byebug.1 +0 -3
- data/old_doc/byebug.texi +2 -3
- data/test/breakpoints_test.rb +75 -52
- data/test/conditions_test.rb +2 -3
- data/test/continue_test.rb +6 -0
- data/test/edit_test.rb +3 -3
- data/test/eval_test.rb +14 -5
- data/test/examples/breakpoint.rb +4 -13
- data/test/examples/breakpoint_deep.rb +1 -21
- data/test/examples/conditions.rb +1 -1
- data/test/examples/continue.rb +2 -1
- data/test/examples/edit.rb +1 -0
- data/test/examples/eval.rb +1 -11
- data/test/examples/finish.rb +0 -17
- data/test/examples/frame.rb +2 -26
- data/test/examples/frame_deep.rb +0 -19
- data/test/examples/help.rb +0 -1
- data/test/examples/info.rb +4 -36
- data/test/examples/kill.rb +1 -1
- data/test/examples/list.rb +1 -1
- data/test/examples/method.rb +2 -13
- data/test/examples/post_mortem.rb +1 -16
- data/test/examples/quit.rb +1 -1
- data/test/examples/reload.rb +1 -1
- data/test/examples/restart.rb +1 -1
- data/test/examples/show.rb +0 -1
- data/test/examples/stepping.rb +2 -19
- data/test/examples/thread.rb +0 -27
- data/test/examples/variables.rb +0 -22
- data/test/finish_test.rb +22 -6
- data/test/frame_test.rb +89 -56
- data/test/info_test.rb +71 -46
- data/test/kill_test.rb +6 -1
- data/test/list_test.rb +1 -2
- data/test/method_test.rb +32 -13
- data/test/post_mortem_test.rb +34 -21
- data/test/quit_test.rb +0 -1
- data/test/restart_test.rb +6 -0
- data/test/set_test.rb +1 -1
- data/test/show_test.rb +17 -17
- data/test/source_test.rb +2 -3
- data/test/stepping_test.rb +31 -7
- data/test/support/test_dsl.rb +11 -1
- data/test/test_helper.rb +9 -0
- data/test/thread_test.rb +57 -23
- data/test/trace_test.rb +0 -1
- data/test/variables_test.rb +36 -17
- metadata +3 -9
- data/test/examples/breakpoint2.rb +0 -7
- data/test/examples/jump.rb +0 -14
- data/test/examples/set_annotate.rb +0 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f8478138d1bb0441775054b1f4ba7feb59429a60
|
4
|
+
data.tar.gz: 1404c249bcc849e2b9ae0240617ef590e88b8b96
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1cc5b019263bc58a174d59b5ad8829dc8781e53722b3742091e879122916484d3ef73e46be20f20cbb72359a0cee62843ca8cfde9676ff15a1101f0c27519914
|
7
|
+
data.tar.gz: 46c6792714d460d1aaaf99cc487da5a8d0f0a72c81253e3c6e0d98df1af90358be796ef1de87ce7f1e43f44e4f6d1f575896683acde1e4811325c5c5c0511236
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
# 2.2.0
|
2
|
+
|
3
|
+
* Small fixes in stack_size calculations
|
4
|
+
* Warning free byebug
|
5
|
+
* Add `verbose` setting for TracePoint API event inspection
|
6
|
+
* Fix setting `post_mortem` mode
|
7
|
+
* Allow `edit <filename>` without a line number
|
8
|
+
|
9
|
+
|
1
10
|
# 2.1.1
|
2
11
|
|
3
12
|
* Fix bug when debugging code inside '-e' flag
|
data/CONTRIBUTING.md
CHANGED
@@ -4,6 +4,18 @@ To make your changes, follow this steps:
|
|
4
4
|
|
5
5
|
* [Fork the project](https://help.github.com/fork-a-repo)
|
6
6
|
* Create a topic branch - `git checkout -b my_branch`
|
7
|
-
* Insert awesome code
|
7
|
+
* Insert awesome code - See below
|
8
8
|
* Push your branch to your forked repo - `git push origin my_branch`
|
9
9
|
* [Make a pull request](https://help.github.com/articles/using-pull-requests)
|
10
|
+
|
11
|
+
How to insert awesome code:
|
12
|
+
|
13
|
+
This gem uses `rake-compiler` to build native gems. You can use `rake compile` to build the native gem
|
14
|
+
and start the tests using `rake test`
|
15
|
+
|
16
|
+
```bash
|
17
|
+
rake compile
|
18
|
+
rake test
|
19
|
+
```
|
20
|
+
|
21
|
+
It's appreciated if you add tests for new functionality. Thanks!
|
data/GUIDE.md
CHANGED
@@ -1,3 +1,155 @@
|
|
1
|
+
### First Steps
|
2
|
+
|
3
|
+
A handful of commands are enough to get started using `byebug`. The following
|
4
|
+
session illustrates these commands.
|
5
|
+
|
6
|
+
```
|
7
|
+
$ byebug triangle.rb
|
8
|
+
[1, 10] in /home/davidr/Proyectos/byebug/old_doc/triangle.rb
|
9
|
+
1: # Compute the n'th triangle number: triangle(n) == (n*(n+1))/2
|
10
|
+
=> 2: def triangle(n)
|
11
|
+
3: tri = 0
|
12
|
+
4: 0.upto(n) do |i|
|
13
|
+
5: tri += i
|
14
|
+
6: end
|
15
|
+
7: tri
|
16
|
+
8: end
|
17
|
+
9:
|
18
|
+
10: t = triangle(3)
|
19
|
+
(byebug)
|
20
|
+
```
|
21
|
+
|
22
|
+
We are currently stopped before the first executable line of the program: line 2
|
23
|
+
of `triangle.rb`. If you are used to less dynamic languages and have used
|
24
|
+
debuggers for more statically compiled languages like C, C++, or Java, it may
|
25
|
+
seem odd to be stopped before a function definition but in Ruby line 2 is
|
26
|
+
executed.
|
27
|
+
|
28
|
+
Byebug's prompt is `(byebug)`. If the program has died and you are in
|
29
|
+
post-mortem debugging, `(byebug:post-mortem)` is used instead. If the program
|
30
|
+
has terminated normally, the string this position will be `(byebug:ctrl)`. The
|
31
|
+
commands available change depending on the program's state.
|
32
|
+
|
33
|
+
Byebug automatically lists 10 lines of code centered around the current line
|
34
|
+
everytime it is stopped. The current line is marked with `=>`, so the range
|
35
|
+
byebug would like to show is [-3..6]. However since there aren't 5 lines before
|
36
|
+
the current line, the range is moved _up_ so we can actually display 10 lines
|
37
|
+
of code.
|
38
|
+
|
39
|
+
Now let us step through the program.
|
40
|
+
|
41
|
+
```
|
42
|
+
(byebug) step
|
43
|
+
[2, 11] in /home/davidr/Proyectos/byebug/old_doc/triangle.rb
|
44
|
+
2: def triangle(n)
|
45
|
+
3: tri = 0
|
46
|
+
4: 0.upto(n) do |i|
|
47
|
+
5: tri += i
|
48
|
+
6: end
|
49
|
+
7: tri
|
50
|
+
8: end
|
51
|
+
9:
|
52
|
+
=> 10: t = triangle(3)
|
53
|
+
11: puts t
|
54
|
+
(byebug) <RET> # hit enter
|
55
|
+
[1, 10] in /home/davidr/Proyectos/byebug/old_doc/triangle.rb
|
56
|
+
1: # Compute the n'th triangle number: triangle(n) == (n*(n+1))/2
|
57
|
+
2: def triangle(n)
|
58
|
+
=> 3: tri = 0
|
59
|
+
4: 0.upto(n) do |i|
|
60
|
+
5: tri += i
|
61
|
+
6: end
|
62
|
+
7: tri
|
63
|
+
8: end
|
64
|
+
9:
|
65
|
+
10: t = triangle(3)
|
66
|
+
(byebug) p tri
|
67
|
+
nil
|
68
|
+
(byebug) step
|
69
|
+
[1, 10] in /home/davidr/Proyectos/byebug/old_doc/triangle.rb
|
70
|
+
1: # Compute the n'th triangle number: triangle(n) == (n*(n+1))/2
|
71
|
+
2: def triangle(n)
|
72
|
+
3: tri = 0
|
73
|
+
=> 4: 0.upto(n) do |i|
|
74
|
+
5: tri += i
|
75
|
+
6: end
|
76
|
+
7: tri
|
77
|
+
8: end
|
78
|
+
9:
|
79
|
+
10: t = triangle(3)
|
80
|
+
(byebug) p tri
|
81
|
+
0
|
82
|
+
```
|
83
|
+
|
84
|
+
The first `step` command runs the script one executable unit. The second command
|
85
|
+
we entered was just hitting the return key; `byebug` remembers the last command
|
86
|
+
you entered was `step` and it runs it again.
|
87
|
+
|
88
|
+
One way to print the values of variables is `p` (there are other ways). When we
|
89
|
+
look at the value of `tri` the first time, we see it is `nil`. Again we are
|
90
|
+
stopped _before_ the assignment on line 3, and this variable hasn't been set
|
91
|
+
previously. However after issuing another `step` command we see that the value
|
92
|
+
is 0 as expected. If every time we stop we want to see the value of `tri` to see
|
93
|
+
how things are going, there is a better way by setting a display expression:
|
94
|
+
|
95
|
+
```
|
96
|
+
(byebug) display tri
|
97
|
+
1: tri = 0
|
98
|
+
```
|
99
|
+
|
100
|
+
Now let us run the program until we return from the function. We'll want to see
|
101
|
+
which lines get run, so we turn on _line tracing_. If we don't want whole paths
|
102
|
+
to be displayed when tracing, we can turn on _basename_.
|
103
|
+
|
104
|
+
```
|
105
|
+
(byebug) display i
|
106
|
+
2: i =
|
107
|
+
(byebug) set linetrace on
|
108
|
+
line tracing is on.
|
109
|
+
(byebug) set basename on
|
110
|
+
basename is on.
|
111
|
+
(byebug) finish
|
112
|
+
Tracing: triangle.rb:5 tri += i
|
113
|
+
1: tri = 0
|
114
|
+
2: i = 0
|
115
|
+
Tracing: triangle.rb:5 tri += i
|
116
|
+
1: tri = 0
|
117
|
+
2: i = 1
|
118
|
+
Tracing: triangle.rb:5 tri += i
|
119
|
+
1: tri = 1
|
120
|
+
2: i = 2
|
121
|
+
Tracing: triangle.rb:5 tri += i
|
122
|
+
1: tri = 3
|
123
|
+
2: i = 3
|
124
|
+
Tracing: triangle.rb:7 tri
|
125
|
+
1: tri = 6
|
126
|
+
2: i =
|
127
|
+
Tracing: triangle.rb:11 puts t
|
128
|
+
1: tri =
|
129
|
+
2: i =
|
130
|
+
[2, 11] in /home/davidr/Proyectos/byebug/old_doc/triangle.rb
|
131
|
+
2: def triangle(n)
|
132
|
+
3: tri = 0
|
133
|
+
4: 0.upto(n) do |i|
|
134
|
+
5: tri += i
|
135
|
+
6: end
|
136
|
+
7: tri
|
137
|
+
8: end
|
138
|
+
9:
|
139
|
+
10: t = triangle(3)
|
140
|
+
=> 11: puts t
|
141
|
+
1: tri =
|
142
|
+
2: i =
|
143
|
+
(byebug) quit
|
144
|
+
Really quit? (y/n) y
|
145
|
+
```
|
146
|
+
|
147
|
+
So far, so good. As you can see from the above to get out of `byebug`, one
|
148
|
+
can issue a `quit` command (`q` and `exit` are just as good). If you want to
|
149
|
+
quit without being prompted, suffix the command with an exclamation mark, e.g.,
|
150
|
+
`q!`.
|
151
|
+
|
152
|
+
|
1
153
|
### Second Sample Session: Delving Deeper
|
2
154
|
|
3
155
|
In this section we'll introduce breakpoints, the call stack and restarting.
|
@@ -601,7 +753,6 @@ Options:
|
|
601
753
|
-x, --trace Turn on line tracing
|
602
754
|
|
603
755
|
Common options:
|
604
|
-
--verbose Turn on verbose mode
|
605
756
|
--help Show this message
|
606
757
|
--version Print program version
|
607
758
|
-v Print version number, then turn on verbose mode
|
@@ -1186,3 +1337,32 @@ stopped. Repeating a `list` command with `RET` discards the argument, so it is
|
|
1186
1337
|
equivalent to typing just `list`. This is more useful than listing the same
|
1187
1338
|
lines again. An exception is made for an argument of `-`: that argument is
|
1188
1339
|
preserved in repetition so that each repetition moves up in the source file.
|
1340
|
+
|
1341
|
+
### Editing Source files (`edit`)
|
1342
|
+
|
1343
|
+
To edit a source file, use the `edit` command. The editor of your choice is invoked
|
1344
|
+
with the current line set to the active line in the program. Alternatively, you can
|
1345
|
+
give a line specification to specify what part of the file you want to edit.
|
1346
|
+
|
1347
|
+
You can customize `byebug` to use any editor you want by using the `EDITOR`
|
1348
|
+
environment variable. The only restriction is that your editor (say `ex`) recognizes
|
1349
|
+
the following command-line syntax:
|
1350
|
+
```
|
1351
|
+
ex +nnn file
|
1352
|
+
```
|
1353
|
+
|
1354
|
+
The optional numeric value `+nnn` specifies the line number in the file where
|
1355
|
+
you want to start editing. For example, to configure `byebug` to use the `vi` editor,
|
1356
|
+
you could use these commands with the `sh` shell:
|
1357
|
+
|
1358
|
+
```bash
|
1359
|
+
EDITOR=/usr/bin/vi
|
1360
|
+
export EDITOR
|
1361
|
+
byebug ...
|
1362
|
+
```
|
1363
|
+
|
1364
|
+
or in the `csh` shell,
|
1365
|
+
```bash
|
1366
|
+
setenv EDITOR /usr/bin/vi
|
1367
|
+
byebug ...
|
1368
|
+
```
|
data/README.md
CHANGED
@@ -38,7 +38,7 @@ Simply drop
|
|
38
38
|
byebug
|
39
39
|
|
40
40
|
wherever you want to start debugging and the execution will stop there. If you
|
41
|
-
are debugging rails, start the server and once the execution
|
41
|
+
are debugging rails, start the server and once the execution gets to your
|
42
42
|
`byebug` command you will get a debugging prompt.
|
43
43
|
|
44
44
|
Former [debugger](https://github.com/cldwalker/debugger) or
|
@@ -58,15 +58,9 @@ no longer need to set them in the startup file.
|
|
58
58
|
|
59
59
|
* Works on 2.0.0 and it doesn't on 1.9.x.
|
60
60
|
* Has no MRI internal source code dependencies, just a clean API.
|
61
|
-
* Fixes
|
62
|
-
|
63
|
-
|
64
|
-
- Line tracing.
|
65
|
-
- Colon delimited include paths.
|
66
|
-
- Nice markdown guide.
|
67
|
-
- Ruby 2.0 support.
|
68
|
-
- where/bt does not in fact give a backtrace.
|
69
|
-
- `byebug` can now be placed at the end of a block or method call.
|
61
|
+
* Fixes all of debugger's open bugs in its issue tracker and provides some
|
62
|
+
enhancements, such as a markdown guide or the fact that `byebug` can now be
|
63
|
+
placed at the end of a block or method call.
|
70
64
|
* Very actively mantained.
|
71
65
|
* Editor agnostic: no external editor built-in support.
|
72
66
|
* Pry command is built-in. No need of external gem like debugger-pry.
|
@@ -82,211 +76,67 @@ changes.
|
|
82
76
|
|
83
77
|
Byebug's public API is determined by its set of commands
|
84
78
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
|
89
|
-
|
90
|
-
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
95
|
-
|
|
96
|
-
|
97
|
-
|
|
98
|
-
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
79
|
+
Command | Aliases | Subcommands
|
80
|
+
----------|----------|------------------------------------------------------
|
81
|
+
backtrace | bt,where |
|
82
|
+
break | |
|
83
|
+
catch | |
|
84
|
+
condition | |
|
85
|
+
continue | |
|
86
|
+
delete | |
|
87
|
+
disable | | breakpoints,display
|
88
|
+
display | |
|
89
|
+
down | |
|
90
|
+
edit | |
|
91
|
+
enable | | breakpoints,display
|
92
|
+
finish | |
|
93
|
+
frame | |
|
94
|
+
help | |
|
95
|
+
info | | args,breakpoints,catch,display,file,files,...
|
96
|
+
irb | |
|
97
|
+
kill | |
|
98
|
+
list | |
|
99
|
+
method | | instance,iv
|
100
|
+
next | |
|
101
|
+
p | eval |
|
102
|
+
pp | |
|
103
|
+
pry | |
|
104
|
+
ps | |
|
105
|
+
putl | |
|
106
|
+
quit | exit |
|
107
|
+
reload | |
|
108
|
+
restart | |
|
109
|
+
save | |
|
110
|
+
set | | args,autoeval,autoirb,autolist,autoreload,basename...
|
111
|
+
show | | args,autoeval,autoirb,autolist,autoreload,basename...
|
112
|
+
skip | |
|
113
|
+
source | |
|
114
|
+
step | |
|
115
|
+
thread | | current,list,resume,stop,switch
|
116
|
+
trace | |
|
117
|
+
undisplay | |
|
118
|
+
up | |
|
119
|
+
var | | class,constant,global,instance,local,ct
|
120
|
+
|
121
|
+
Full lists of subcommands:
|
122
|
+
|
123
|
+
* info: `args`,`breakpoints`,`catch`,`display`,`file`,`files`,
|
124
|
+
`global_variables`,`instance_variables`,`line`,`locals`,`program,stack`,
|
125
|
+
`variables`.
|
126
|
+
* set: `args`,`autoeval`,`autoirb`,`autolist`,`autoreload`,`basename`,
|
127
|
+
`callstyle`,`forcestep`,`fullpath`,`history`,`linetrace`,`linetrace_plus`,
|
128
|
+
`listsize`,`post_mortem`,`stack_trace_on_error`,`testing`,`verbose`,`width`.
|
129
|
+
* show: `args`,`autoeval`,`autoirb`,`autolist`,`autoreload`,`basename`,
|
130
|
+
`callstyle`,`commands`,`forcestep`,`fullpath`,`history`,`linetrace`,
|
131
|
+
`linetrace_plus`, `listsize`,`post_mortem`,`stack_trace_on_error`,`verbose`,
|
132
|
+
`width`.
|
136
133
|
|
137
134
|
|
138
135
|
## Getting Started
|
139
136
|
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
```
|
144
|
-
$ byebug triangle.rb
|
145
|
-
[1, 10] in /home/davidr/Proyectos/byebug/old_doc/triangle.rb
|
146
|
-
1: # Compute the n'th triangle number: triangle(n) == (n*(n+1))/2
|
147
|
-
=> 2: def triangle(n)
|
148
|
-
3: tri = 0
|
149
|
-
4: 0.upto(n) do |i|
|
150
|
-
5: tri += i
|
151
|
-
6: end
|
152
|
-
7: tri
|
153
|
-
8: end
|
154
|
-
9:
|
155
|
-
10: t = triangle(3)
|
156
|
-
(byebug)
|
157
|
-
```
|
158
|
-
|
159
|
-
We are currently stopped before the first executable line of the program: line 2
|
160
|
-
of `triangle.rb`. If you are used to less dynamic languages and have used
|
161
|
-
debuggers for more statically compiled languages like C, C++, or Java, it may
|
162
|
-
seem odd to be stopped before a function definition but in Ruby line 2 is
|
163
|
-
executed.
|
164
|
-
|
165
|
-
Byebug's prompt is `(byebug)`. If the program has died and you are in
|
166
|
-
post-mortem debugging, `(byebug:post-mortem)` is used instead. If the program
|
167
|
-
has terminated normally, the string this position will be `(byebug:ctrl)`. The
|
168
|
-
commands available change depending on the program's state.
|
169
|
-
|
170
|
-
Byebug automatically lists 10 lines of code centered around the current line
|
171
|
-
everytime it is stopped. The current line is marked with `=>`, so the range
|
172
|
-
byebug would like to show is [-3..6]. However since there aren't 5 lines before
|
173
|
-
the current line, the range is moved _up_ so we can actually display 10 lines
|
174
|
-
of code.
|
175
|
-
|
176
|
-
Now let us step through the program.
|
177
|
-
|
178
|
-
```
|
179
|
-
(byebug) step
|
180
|
-
[2, 11] in /home/davidr/Proyectos/byebug/old_doc/triangle.rb
|
181
|
-
2: def triangle(n)
|
182
|
-
3: tri = 0
|
183
|
-
4: 0.upto(n) do |i|
|
184
|
-
5: tri += i
|
185
|
-
6: end
|
186
|
-
7: tri
|
187
|
-
8: end
|
188
|
-
9:
|
189
|
-
=> 10: t = triangle(3)
|
190
|
-
11: puts t
|
191
|
-
(byebug) <RET> # hit enter
|
192
|
-
[1, 10] in /home/davidr/Proyectos/byebug/old_doc/triangle.rb
|
193
|
-
1: # Compute the n'th triangle number: triangle(n) == (n*(n+1))/2
|
194
|
-
2: def triangle(n)
|
195
|
-
=> 3: tri = 0
|
196
|
-
4: 0.upto(n) do |i|
|
197
|
-
5: tri += i
|
198
|
-
6: end
|
199
|
-
7: tri
|
200
|
-
8: end
|
201
|
-
9:
|
202
|
-
10: t = triangle(3)
|
203
|
-
(byebug) p tri
|
204
|
-
nil
|
205
|
-
(byebug) step
|
206
|
-
[1, 10] in /home/davidr/Proyectos/byebug/old_doc/triangle.rb
|
207
|
-
1: # Compute the n'th triangle number: triangle(n) == (n*(n+1))/2
|
208
|
-
2: def triangle(n)
|
209
|
-
3: tri = 0
|
210
|
-
=> 4: 0.upto(n) do |i|
|
211
|
-
5: tri += i
|
212
|
-
6: end
|
213
|
-
7: tri
|
214
|
-
8: end
|
215
|
-
9:
|
216
|
-
10: t = triangle(3)
|
217
|
-
(byebug) p tri
|
218
|
-
0
|
219
|
-
```
|
220
|
-
|
221
|
-
The first `step` command runs the script one executable unit. The second command
|
222
|
-
we entered was just hitting the return key; `byebug` remembers the last command
|
223
|
-
you entered was `step` and it runs it again.
|
224
|
-
|
225
|
-
One way to print the values of variables is `p` (there are other ways). When we
|
226
|
-
look at the value of `tri` the first time, we see it is `nil`. Again we are
|
227
|
-
stopped _before_ the assignment on line 3, and this variable hasn't been set
|
228
|
-
previously. However after issuing another `step` command we see that the value
|
229
|
-
is 0 as expected. If every time we stop we want to see the value of `tri` to see
|
230
|
-
how things are going, there is a better way by setting a display expression:
|
231
|
-
|
232
|
-
```
|
233
|
-
(byebug) display tri
|
234
|
-
1: tri = 0
|
235
|
-
```
|
236
|
-
|
237
|
-
Now let us run the program until we return from the function. We'll want to see
|
238
|
-
which lines get run, so we turn on _line tracing_. If we don't want whole paths
|
239
|
-
to be displayed when tracing, we can turn on _basename_.
|
240
|
-
|
241
|
-
```
|
242
|
-
(byebug) display i
|
243
|
-
2: i =
|
244
|
-
(byebug) set linetrace on
|
245
|
-
line tracing is on.
|
246
|
-
(byebug) set basename on
|
247
|
-
basename is on.
|
248
|
-
(byebug) finish
|
249
|
-
Tracing: triangle.rb:5 tri += i
|
250
|
-
1: tri = 0
|
251
|
-
2: i = 0
|
252
|
-
Tracing: triangle.rb:5 tri += i
|
253
|
-
1: tri = 0
|
254
|
-
2: i = 1
|
255
|
-
Tracing: triangle.rb:5 tri += i
|
256
|
-
1: tri = 1
|
257
|
-
2: i = 2
|
258
|
-
Tracing: triangle.rb:5 tri += i
|
259
|
-
1: tri = 3
|
260
|
-
2: i = 3
|
261
|
-
Tracing: triangle.rb:7 tri
|
262
|
-
1: tri = 6
|
263
|
-
2: i =
|
264
|
-
Tracing: triangle.rb:11 puts t
|
265
|
-
1: tri =
|
266
|
-
2: i =
|
267
|
-
[2, 11] in /home/davidr/Proyectos/byebug/old_doc/triangle.rb
|
268
|
-
2: def triangle(n)
|
269
|
-
3: tri = 0
|
270
|
-
4: 0.upto(n) do |i|
|
271
|
-
5: tri += i
|
272
|
-
6: end
|
273
|
-
7: tri
|
274
|
-
8: end
|
275
|
-
9:
|
276
|
-
10: t = triangle(3)
|
277
|
-
=> 11: puts t
|
278
|
-
1: tri =
|
279
|
-
2: i =
|
280
|
-
(byebug) quit
|
281
|
-
Really quit? (y/n) y
|
282
|
-
```
|
283
|
-
|
284
|
-
So far, so good. As you can see from the above to get out of `byebug`, one
|
285
|
-
can issue a `quit` command (`q` and `exit` are just as good). If you want to
|
286
|
-
quit without being prompted, suffix the command with an exclamation mark, e.g.,
|
287
|
-
`q!`.
|
288
|
-
|
289
|
-
### The rest of the tutorial is available [here](https://github.com/deivid-rodriguez/byebug/blob/master/GUIDE.md)
|
137
|
+
Read [byebug's markdown
|
138
|
+
guide](https://github.com/deivid-rodriguez/byebug/blob/master/GUIDE.md) to get
|
139
|
+
started. Proper documentation will be eventually written.
|
290
140
|
|
291
141
|
|
292
142
|
## Related projects
|
@@ -299,6 +149,12 @@ adds a rake task that restarts Passenger with byebug connected.
|
|
299
149
|
session on minitest failures.
|
300
150
|
|
301
151
|
|
152
|
+
## Future (possible) directions
|
153
|
+
|
154
|
+
* JRuby support.
|
155
|
+
* Libify and test byebug's executable.
|
156
|
+
|
157
|
+
|
302
158
|
## Credits
|
303
159
|
|
304
160
|
Everybody who has ever contributed to this forked and reforked piece of
|