byebug 3.4.0 → 3.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/CONTRIBUTING.md +1 -0
- data/GUIDE.md +1 -1
- data/README.md +45 -25
- data/ext/byebug/byebug.c +43 -30
- data/ext/byebug/context.c +1 -1
- data/lib/byebug/attacher.rb +10 -9
- data/lib/byebug/commands/list.rb +11 -14
- data/lib/byebug/commands/restart.rb +3 -6
- data/lib/byebug/commands/variables.rb +1 -1
- data/lib/byebug/core.rb +8 -0
- data/lib/byebug/runner.rb +25 -18
- data/lib/byebug/version.rb +1 -1
- data/test/commands/eval_test.rb +0 -1
- data/test/commands/list_test.rb +20 -27
- data/test/commands/restart_test.rb +12 -14
- data/test/commands/variables_test.rb +1 -1
- data/test/runner_test.rb +7 -0
- data/test/test_helper.rb +1 -5
- metadata +13 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7001ae9053bb3dff2ca95eee6b105c0b1e75b06b
|
4
|
+
data.tar.gz: f1d8c6f4b00f51f1460f6833bdc28dcf84f28a4d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8360f244410378f4b11caae0eabcd6dcc18cacd66562fd7a460d99c5861c03ff5a92a08f027bb9dc5fc25ae3527518e8ac45ed3e5643389fd0cfd9eac2354f75
|
7
|
+
data.tar.gz: f9bba361d8ace23476c667df962e610fe1a054de7224c8ae8cf392fa8ee930656d5d6ac7f3f6ddfceb863cdb3f9926c808f785476c3833123a021bbb7d24889d
|
data/CHANGELOG.md
CHANGED
data/CONTRIBUTING.md
CHANGED
@@ -4,6 +4,7 @@ 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
|
+
* Make sure the latest patch level of Ruby 2.0.0 or higher is installed.
|
7
8
|
* Insert awesome code - See below
|
8
9
|
* Push your branch to your forked repo - `git push origin my_branch`
|
9
10
|
* [Make a pull request](https://help.github.com/articles/using-pull-requests)
|
data/GUIDE.md
CHANGED
@@ -537,7 +537,7 @@ this way finishes, byebug is turned off and the application proceeds at regular
|
|
537
537
|
speed.
|
538
538
|
|
539
539
|
Of course, inside the block you will probably want to enter the byebug using
|
540
|
-
`Byebug.byebug
|
540
|
+
`Byebug.byebug`, otherwise there would be little point in using the `start`.
|
541
541
|
For example, you can do this in `irb`:
|
542
542
|
|
543
543
|
```bash
|
data/README.md
CHANGED
@@ -12,18 +12,32 @@ Byebug is a simple to use, feature rich debugger for Ruby 2. It uses the new
|
|
12
12
|
TracePoint API for execution control and the new Debug Inspector API for call
|
13
13
|
stack navigation, so it doesn't depend on internal core sources. It's developed
|
14
14
|
as a C extension, so it's fast. And it has a full test suite so it's reliable.
|
15
|
-
Note that byebug works only for ruby 2.0.0 or newer. For debugging ruby 1.9.3 or
|
16
|
-
older, use [debugger](https://github.com/cldwalker/debugger).
|
17
15
|
|
18
16
|
It allows you to see what is going on _inside_ a Ruby program while it executes
|
19
|
-
and
|
17
|
+
and offers many of the traditional debugging features such as:
|
20
18
|
|
21
|
-
*
|
22
|
-
|
23
|
-
|
24
|
-
*
|
25
|
-
|
26
|
-
|
19
|
+
* Stepping: Running your program one line at a time.
|
20
|
+
* Breaking: Pausing the program at some event or specified instruction, to
|
21
|
+
examine the current state.
|
22
|
+
* Evaluating: Basic REPL functionality, although [pry][] does a better job at
|
23
|
+
that.
|
24
|
+
* Tracking: Keeping track of the different values of your variables or the
|
25
|
+
different lines executed by your program.
|
26
|
+
|
27
|
+
|
28
|
+
## Ruby Version Support
|
29
|
+
|
30
|
+
Byebug works only for Ruby 2.0.0 or newer. For debugging ruby 1.9.3 or older,
|
31
|
+
use [debugger][].
|
32
|
+
|
33
|
+
Furthermore, Byebug uses the TracePoint API which was just first developed for
|
34
|
+
Ruby 2.0.0. Since it was released, a lot of bugs directly impacting Byebug have
|
35
|
+
been corrected, so for the best debugging experience, the following Ruby
|
36
|
+
versions are recommended:
|
37
|
+
|
38
|
+
* Ruby 2.0.0-p576 or higher.
|
39
|
+
* Ruby 2.1.3 or higher.
|
40
|
+
* Ruby 2.2.0-preview1 or higher.
|
27
41
|
|
28
42
|
|
29
43
|
## Install
|
@@ -41,8 +55,7 @@ wherever you want to start debugging and the execution will stop there. If you
|
|
41
55
|
are debugging rails, start the server and once the execution gets to your
|
42
56
|
`byebug` command you will get a debugging prompt.
|
43
57
|
|
44
|
-
Former [debugger]
|
45
|
-
[ruby-debug](https://github.com/mark-moseley/ruby-debug) users, notice:
|
58
|
+
Former [debugger][] or [ruby-debug][] users, notice:
|
46
59
|
|
47
60
|
* Some gems (rails, rspec) implement debugging flags (-d, --debugger) that early
|
48
61
|
require and start the debugger. These flags are a performance penalty and byebug
|
@@ -102,9 +115,8 @@ both rails and rspec have deprecated these flags in their latest versions.
|
|
102
115
|
|
103
116
|
Byebug tries to follow [semantic versioning](http://semver.org) and tries to
|
104
117
|
bump major version only when backwards incompatible changes are released.
|
105
|
-
Backwards compatibility is targeted to
|
106
|
-
|
107
|
-
plugins relying on `byebug`.
|
118
|
+
Backwards compatibility is targeted to [pry-byebug][] and any other plugins
|
119
|
+
relying on `byebug`.
|
108
120
|
|
109
121
|
|
110
122
|
## Getting Started
|
@@ -116,14 +128,12 @@ started. Proper documentation will be eventually written.
|
|
116
128
|
|
117
129
|
## Related projects
|
118
130
|
|
119
|
-
* [pry-byebug]
|
120
|
-
|
121
|
-
* [ruby-debug-passenger]
|
122
|
-
|
123
|
-
* [minitest-byebug]
|
124
|
-
|
125
|
-
* [sublime-debugger](https://github.com/shuky19/sublime_debugger) provides a plugin
|
126
|
-
for ruby debugging on Sublime Text.
|
131
|
+
* [pry-byebug][] adds `next`, `step`, `finish`, `continue` and `break` commands
|
132
|
+
to `pry` using `byebug`.
|
133
|
+
* [ruby-debug-passenger][] adds a rake task that restarts Passenger with Byebug
|
134
|
+
connected.
|
135
|
+
* [minitest-byebug][] starts a byebug session on minitest failures.
|
136
|
+
* [sublime_debugger][] provides a plugin for ruby debugging on Sublime Text.
|
127
137
|
|
128
138
|
|
129
139
|
## TODO List (by priority)
|
@@ -132,15 +142,16 @@ for ruby debugging on Sublime Text.
|
|
132
142
|
* Add printers support.
|
133
143
|
* Support rubies other than MRI.
|
134
144
|
|
145
|
+
[Getting Started with Development](CONTRIBUTING.md)
|
146
|
+
|
135
147
|
## Credits
|
136
148
|
|
137
149
|
Everybody who has ever contributed to this forked and reforked piece of
|
138
150
|
software, specially:
|
139
151
|
|
140
152
|
* @ko1, author of the awesome TracePoint API for Ruby.
|
141
|
-
* @cldwalker, [debugger]
|
142
|
-
* @denofevil, author of [debase]
|
143
|
-
starting point of this.
|
153
|
+
* @cldwalker, [debugger][]'s mantainer.
|
154
|
+
* @denofevil, author of [debase][], the starting point of this.
|
144
155
|
* @kevjames3 for testing, bug reports and the interest in the project.
|
145
156
|
* @FooBarWidget for working and helping with remote debugging.
|
146
157
|
|
@@ -156,3 +167,12 @@ starting point of this.
|
|
156
167
|
[CoverageURL]: https://codeclimate.com/github/deivid-rodriguez/byebug
|
157
168
|
[GittipBadge]: http://img.shields.io/gittip/deivid-rodriguez.svg
|
158
169
|
[GittipURL]: https://www.gittip.com/deivid-rodriguez
|
170
|
+
|
171
|
+
[debugger]: https://github.com/cldwalker/debugger
|
172
|
+
[pry]: https://github.com/pry/pry
|
173
|
+
[ruby-debug]: https://github.com/mark-moseley/ruby-debug
|
174
|
+
[debase]: https://github.com/denofevil/debase
|
175
|
+
[pry-byebug]: https://github.com/deivid-rodriguez/pry-byebug
|
176
|
+
[ruby-debug-passenger]: https://github.com/davejamesmiller/ruby-debug-passenger
|
177
|
+
[minitest-byebug]: https://github.com/kaspth/minitest-byebug
|
178
|
+
[sublime_debugger]: https://github.com/shuky19/sublime_debugger
|
data/ext/byebug/byebug.c
CHANGED
@@ -316,6 +316,16 @@ c_return_event(VALUE trace_point, void *data)
|
|
316
316
|
cleanup(dc);
|
317
317
|
}
|
318
318
|
|
319
|
+
static void
|
320
|
+
thread_event(VALUE trace_point, void *data)
|
321
|
+
{
|
322
|
+
EVENT_SETUP
|
323
|
+
|
324
|
+
EVENT_COMMON
|
325
|
+
|
326
|
+
cleanup(dc);
|
327
|
+
}
|
328
|
+
|
319
329
|
static void
|
320
330
|
raise_event(VALUE trace_point, void *data)
|
321
331
|
{
|
@@ -387,19 +397,21 @@ register_tracepoints(VALUE self)
|
|
387
397
|
|
388
398
|
if (NIL_P(traces))
|
389
399
|
{
|
390
|
-
int line_msk
|
391
|
-
int call_msk
|
392
|
-
int return_msk
|
393
|
-
int c_call_msk
|
394
|
-
int
|
395
|
-
int raise_msk
|
396
|
-
|
397
|
-
|
398
|
-
VALUE
|
399
|
-
VALUE
|
400
|
-
VALUE
|
401
|
-
VALUE
|
402
|
-
VALUE
|
400
|
+
int line_msk = RUBY_EVENT_LINE;
|
401
|
+
int call_msk = RUBY_EVENT_CALL | RUBY_EVENT_B_CALL | RUBY_EVENT_CLASS;
|
402
|
+
int return_msk = RUBY_EVENT_RETURN | RUBY_EVENT_B_RETURN | RUBY_EVENT_END;
|
403
|
+
int c_call_msk = RUBY_EVENT_C_CALL;
|
404
|
+
int c_ret_msk = RUBY_EVENT_C_RETURN;
|
405
|
+
int raise_msk = RUBY_EVENT_RAISE;
|
406
|
+
int thread_msk = RUBY_EVENT_THREAD_BEGIN | RUBY_EVENT_THREAD_END;
|
407
|
+
|
408
|
+
VALUE tpLine = rb_tracepoint_new(Qnil, line_msk , line_event , 0);
|
409
|
+
VALUE tpCall = rb_tracepoint_new(Qnil, call_msk , call_event , 0);
|
410
|
+
VALUE tpReturn = rb_tracepoint_new(Qnil, return_msk, return_event , 0);
|
411
|
+
VALUE tpCCall = rb_tracepoint_new(Qnil, c_call_msk, c_call_event , 0);
|
412
|
+
VALUE tpCReturn = rb_tracepoint_new(Qnil, c_ret_msk , c_return_event, 0);
|
413
|
+
VALUE tpRaise = rb_tracepoint_new(Qnil, raise_msk , raise_event , 0);
|
414
|
+
VALUE tpThread = rb_tracepoint_new(Qnil, thread_msk, thread_event , 0);
|
403
415
|
|
404
416
|
traces = rb_ary_new();
|
405
417
|
rb_ary_push(traces, tpLine);
|
@@ -408,6 +420,7 @@ register_tracepoints(VALUE self)
|
|
408
420
|
rb_ary_push(traces, tpCCall);
|
409
421
|
rb_ary_push(traces, tpCReturn);
|
410
422
|
rb_ary_push(traces, tpRaise);
|
423
|
+
rb_ary_push(traces, tpThread);
|
411
424
|
|
412
425
|
tracepoints = traces;
|
413
426
|
}
|
@@ -768,23 +781,23 @@ Init_byebug()
|
|
768
781
|
{
|
769
782
|
mByebug = rb_define_module("Byebug");
|
770
783
|
|
771
|
-
rb_define_module_function(mByebug, "add_catchpoint"
|
772
|
-
rb_define_module_function(mByebug, "breakpoints"
|
773
|
-
rb_define_module_function(mByebug, "catchpoints"
|
774
|
-
rb_define_module_function(mByebug, "contexts"
|
775
|
-
rb_define_module_function(mByebug, "current_context"
|
776
|
-
rb_define_module_function(mByebug, "debug_load"
|
777
|
-
rb_define_module_function(mByebug, "post_mortem?"
|
778
|
-
rb_define_module_function(mByebug, "post_mortem="
|
779
|
-
rb_define_module_function(mByebug, "raised_exception"
|
780
|
-
rb_define_module_function(mByebug, "start"
|
781
|
-
rb_define_module_function(mByebug, "started?"
|
782
|
-
rb_define_module_function(mByebug, "stop"
|
783
|
-
rb_define_module_function(mByebug, "thread_context"
|
784
|
-
rb_define_module_function(mByebug, "tracing?"
|
785
|
-
rb_define_module_function(mByebug, "tracing="
|
786
|
-
rb_define_module_function(mByebug, "verbose?"
|
787
|
-
rb_define_module_function(mByebug, "verbose="
|
784
|
+
rb_define_module_function(mByebug, "add_catchpoint" , bb_add_catchpoint , 1);
|
785
|
+
rb_define_module_function(mByebug, "breakpoints" , bb_breakpoints , 0);
|
786
|
+
rb_define_module_function(mByebug, "catchpoints" , bb_catchpoints , 0);
|
787
|
+
rb_define_module_function(mByebug, "contexts" , bb_contexts , 0);
|
788
|
+
rb_define_module_function(mByebug, "current_context" , bb_current_context , 0);
|
789
|
+
rb_define_module_function(mByebug, "debug_load" , bb_load , -1);
|
790
|
+
rb_define_module_function(mByebug, "post_mortem?" , bb_post_mortem , 0);
|
791
|
+
rb_define_module_function(mByebug, "post_mortem=" , bb_set_post_mortem , 1);
|
792
|
+
rb_define_module_function(mByebug, "raised_exception", bb_raised_exception, 0);
|
793
|
+
rb_define_module_function(mByebug, "start" , bb_start , 0);
|
794
|
+
rb_define_module_function(mByebug, "started?" , bb_started , 0);
|
795
|
+
rb_define_module_function(mByebug, "stop" , bb_stop , 0);
|
796
|
+
rb_define_module_function(mByebug, "thread_context" , bb_thread_context , 1);
|
797
|
+
rb_define_module_function(mByebug, "tracing?" , bb_tracing , 0);
|
798
|
+
rb_define_module_function(mByebug, "tracing=" , bb_set_tracing , 1);
|
799
|
+
rb_define_module_function(mByebug, "verbose?" , bb_verbose , 0);
|
800
|
+
rb_define_module_function(mByebug, "verbose=" , bb_set_verbose , 1);
|
788
801
|
|
789
802
|
Init_threads_table(mByebug);
|
790
803
|
Init_context(mByebug);
|
data/ext/byebug/context.c
CHANGED
@@ -431,7 +431,7 @@ Context_step_out(int argc, VALUE *argv, VALUE self)
|
|
431
431
|
|
432
432
|
Data_Get_Struct(self, debug_context_t, context);
|
433
433
|
|
434
|
-
if (n_frames < 0 || n_frames
|
434
|
+
if (n_frames < 0 || n_frames > context->calced_stack_size)
|
435
435
|
rb_raise(rb_eRuntimeError,
|
436
436
|
"You wan't to finish %d frames, but stack size is only %d",
|
437
437
|
n_frames, context->calced_stack_size);
|
data/lib/byebug/attacher.rb
CHANGED
@@ -1,6 +1,13 @@
|
|
1
1
|
module Byebug
|
2
|
-
#
|
3
|
-
|
2
|
+
#
|
3
|
+
# Enters byebug right before (or right after if _before_ is false) return
|
4
|
+
# events occur. Before entering byebug the init script is read.
|
5
|
+
#
|
6
|
+
def self.attach(steps_out, before)
|
7
|
+
start
|
8
|
+
run_init_script(StringIO.new)
|
9
|
+
current_context.step_out(steps_out, before)
|
10
|
+
end
|
4
11
|
end
|
5
12
|
|
6
13
|
#
|
@@ -9,14 +16,8 @@ end
|
|
9
16
|
# Dropping a `byebug` call anywhere in your code, you get a debug prompt.
|
10
17
|
#
|
11
18
|
module Kernel
|
12
|
-
#
|
13
|
-
# Enters byebug right before (or right after if _before_ is false) return
|
14
|
-
# events occur. Before entering byebug the init script is read.
|
15
|
-
#
|
16
19
|
def byebug(steps_out = 1, before = true)
|
17
|
-
Byebug.
|
18
|
-
Byebug.run_init_script(StringIO.new)
|
19
|
-
Byebug.current_context.step_out(steps_out, before)
|
20
|
+
Byebug.attach(steps_out + 1, before)
|
20
21
|
end
|
21
22
|
|
22
23
|
alias_method :debugger, :byebug
|
data/lib/byebug/commands/list.rb
CHANGED
@@ -19,8 +19,9 @@ module Byebug
|
|
19
19
|
b, e = set_line_range(Setting[:listsize], lines.size)
|
20
20
|
return @state.previous_line if b < 0
|
21
21
|
|
22
|
-
|
23
|
-
|
22
|
+
display_lines(b, e, lines)
|
23
|
+
|
24
|
+
@state.previous_line = b > lines.size ? @previous_line : b
|
24
25
|
end
|
25
26
|
|
26
27
|
class << self
|
@@ -94,20 +95,16 @@ module Byebug
|
|
94
95
|
[b, e]
|
95
96
|
end
|
96
97
|
|
97
|
-
##
|
98
|
-
# Show file lines in LINES from line B to line E where CURRENT is the
|
99
|
-
# current line number. If we can show from B to E then we return B,
|
100
|
-
# otherwise we return the previous line @state.previous_line.
|
101
98
|
#
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
99
|
+
# Show file lines in <lines> from line number <min> to line number <max>.
|
100
|
+
#
|
101
|
+
def display_lines(min, max, lines)
|
102
|
+
puts "\n[#{min}, #{max}] in #{@state.file}"
|
103
|
+
|
104
|
+
(min..max).to_a.zip(lines[min-1..max-1]).map do |l|
|
105
|
+
mark = l[0] == @state.line ? '=> ' : ' '
|
106
|
+
puts format("#{mark}%#{max.to_s.size}d: %s", l[0], l[1])
|
109
107
|
end
|
110
|
-
e == lines.size ? @state.previous_line : b
|
111
108
|
end
|
112
109
|
end
|
113
110
|
end
|
@@ -10,17 +10,14 @@ module Byebug
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def execute
|
13
|
-
prog =
|
14
|
-
byebug_script = BYEBUG_SCRIPT if defined?(BYEBUG_SCRIPT)
|
15
|
-
|
16
|
-
return errmsg("Don't know name of debugged program") unless prog
|
13
|
+
prog = Byebug.debugged_program
|
17
14
|
|
18
15
|
unless File.exist?(File.expand_path(prog))
|
19
16
|
return errmsg("Ruby program #{prog} doesn't exist")
|
20
17
|
end
|
21
18
|
|
22
|
-
if
|
23
|
-
cmd = "#{
|
19
|
+
if defined?(BYEBUG_SCRIPT)
|
20
|
+
cmd = "#{BYEBUG_SCRIPT} #{prog}"
|
24
21
|
else
|
25
22
|
puts 'Byebug was not called from the outset...'
|
26
23
|
if File.executable?(prog)
|
data/lib/byebug/core.rb
CHANGED
@@ -20,10 +20,18 @@ module Byebug
|
|
20
20
|
|
21
21
|
class << self
|
22
22
|
attr_accessor :handler
|
23
|
+
attr_writer :debugged_program
|
23
24
|
end
|
24
25
|
|
25
26
|
Byebug.handler = CommandProcessor.new
|
26
27
|
|
28
|
+
#
|
29
|
+
# Program being debugged (or a default one if not set yet)
|
30
|
+
#
|
31
|
+
def self.debugged_program
|
32
|
+
@debugged_program ||= $PROGRAM_NAME
|
33
|
+
end
|
34
|
+
|
27
35
|
def self.source_reload
|
28
36
|
hsh = 'SCRIPT_LINES__'
|
29
37
|
Object.send(:remove_const, hsh) if Object.const_defined?(hsh)
|
data/lib/byebug/runner.rb
CHANGED
@@ -16,13 +16,15 @@ module Byebug
|
|
16
16
|
# Debug a script only if syntax checks okay.
|
17
17
|
#
|
18
18
|
def debug_program(options)
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
19
|
+
unless File.executable?(Byebug.debugged_program)
|
20
|
+
output = `ruby -c "#{Byebug.debugged_program}" 2>&1`
|
21
|
+
if $CHILD_STATUS.exitstatus != 0
|
22
|
+
Byebug.puts output
|
23
|
+
exit $CHILD_STATUS.exitstatus
|
24
|
+
end
|
23
25
|
end
|
24
26
|
|
25
|
-
status = Byebug.debug_load(Byebug
|
27
|
+
status = Byebug.debug_load(Byebug.debugged_program, options[:stop])
|
26
28
|
Byebug.puts "#{status}\n#{status.backtrace}" if status
|
27
29
|
end
|
28
30
|
|
@@ -45,6 +47,23 @@ module Byebug
|
|
45
47
|
prog_script
|
46
48
|
end
|
47
49
|
|
50
|
+
#
|
51
|
+
# Save path to program to be debugged
|
52
|
+
#
|
53
|
+
# Used for restarts.
|
54
|
+
#
|
55
|
+
def save_debugged_program
|
56
|
+
if ARGV.empty?
|
57
|
+
Byebug.puts 'You must specify a program to debug...'
|
58
|
+
abort
|
59
|
+
end
|
60
|
+
|
61
|
+
prog_script = ARGV.first
|
62
|
+
prog_script = whence_file(prog_script) unless File.exist?(prog_script)
|
63
|
+
|
64
|
+
Byebug.debugged_program = File.expand_path(prog_script)
|
65
|
+
end
|
66
|
+
|
48
67
|
#
|
49
68
|
# Starts byebug to debug a program
|
50
69
|
#
|
@@ -61,19 +80,7 @@ module Byebug
|
|
61
80
|
return
|
62
81
|
end
|
63
82
|
|
64
|
-
|
65
|
-
Byebug.puts 'You must specify a program to debug...'
|
66
|
-
abort
|
67
|
-
end
|
68
|
-
|
69
|
-
# Save debugged program
|
70
|
-
prog_script = ARGV.pop
|
71
|
-
prog_script = whence_file(prog_script) unless File.exist?(prog_script)
|
72
|
-
|
73
|
-
if Byebug.const_defined?('PROG_SCRIPT')
|
74
|
-
Byebug.send(:remove_const, 'PROG_SCRIPT')
|
75
|
-
end
|
76
|
-
Byebug.const_set('PROG_SCRIPT', File.expand_path(prog_script))
|
83
|
+
save_debugged_program
|
77
84
|
|
78
85
|
# Set up trace hook for byebug
|
79
86
|
Byebug.start
|
data/lib/byebug/version.rb
CHANGED
data/test/commands/eval_test.rb
CHANGED
data/test/commands/list_test.rb
CHANGED
@@ -29,17 +29,6 @@ module Byebug
|
|
29
29
|
super
|
30
30
|
end
|
31
31
|
|
32
|
-
def lines_between(min, max, mark_current = true)
|
33
|
-
lines = [*File.open(__FILE__)][min-1..max-1]
|
34
|
-
numbers = (min..max).to_a
|
35
|
-
output = numbers.zip(lines).map { |l| format("%2d: %s", l[0], l[1]) }
|
36
|
-
if mark_current
|
37
|
-
middle = (output.size/2.0).ceil
|
38
|
-
output[middle] = "=> #{output[middle]}"
|
39
|
-
end
|
40
|
-
output
|
41
|
-
end
|
42
|
-
|
43
32
|
def test_lists_source_code_lines
|
44
33
|
Setting[:listsize] = 10
|
45
34
|
enter 'list'
|
@@ -61,7 +50,10 @@ module Byebug
|
|
61
50
|
end
|
62
51
|
|
63
52
|
def test_moves_range_down_when_it_goes_after_the_end_of_file
|
64
|
-
|
53
|
+
n_lines = %x{wc -l #{__FILE__}}.split.first.to_i
|
54
|
+
enter 'break 18', 'cont', "list #{n_lines-3}-#{n_lines+6}"
|
55
|
+
debug_proc(@example)
|
56
|
+
check_output_includes "[#{n_lines-9}, #{n_lines}] in #{__FILE__}"
|
65
57
|
end
|
66
58
|
|
67
59
|
def test_lists_the_whole_file_if_number_of_lines_is_smaller_than_listsize
|
@@ -75,47 +67,50 @@ module Byebug
|
|
75
67
|
def test_lists_surrounding_lines_after_the_first_call_to_list
|
76
68
|
enter 'break 8', 'cont', 'list'
|
77
69
|
debug_proc(@example)
|
78
|
-
check_output_includes
|
70
|
+
check_output_includes "[3, 12] in #{__FILE__}"
|
79
71
|
end
|
80
72
|
|
81
73
|
def test_lists_forwards_after_the_second_call_to_list
|
82
74
|
enter 'break 8', 'cont', 'list', 'list'
|
83
75
|
debug_proc(@example)
|
84
|
-
check_output_includes
|
85
|
-
*lines_between(13, 22, false))
|
76
|
+
check_output_includes "[13, 22] in #{__FILE__}"
|
86
77
|
end
|
87
78
|
|
88
79
|
def test_lists_surrounding_lines_after_the_first_call_to_list_minus
|
89
80
|
enter 'break 18', 'cont', 'list -'
|
90
81
|
debug_proc(@example)
|
91
|
-
check_output_includes
|
82
|
+
check_output_includes "[13, 22] in #{__FILE__}"
|
92
83
|
end
|
93
84
|
|
94
85
|
def test_lists_backwards_after_the_second_call_to_list_minus
|
95
86
|
enter 'break 18', 'cont', 'list -', 'list -'
|
96
87
|
debug_proc(@example)
|
97
|
-
check_output_includes
|
98
|
-
|
88
|
+
check_output_includes "[3, 12] in #{__FILE__}"
|
89
|
+
end
|
90
|
+
|
91
|
+
def test_lists_backwards_from_end_of_file
|
92
|
+
n_lines = %x{wc -l #{__FILE__}}.split.first.to_i
|
93
|
+
enter 'break 18', 'cont', "list #{n_lines-9}-#{n_lines}", 'list -'
|
94
|
+
debug_proc(@example)
|
95
|
+
check_output_includes "[#{n_lines-19}, #{n_lines-10}] in #{__FILE__}"
|
99
96
|
end
|
100
97
|
|
101
98
|
def test_lists_surrounding_lines_when_list_equals_is_called
|
102
99
|
enter 'break 8', 'cont', 'list ='
|
103
100
|
debug_proc(@example)
|
104
|
-
check_output_includes
|
101
|
+
check_output_includes "[3, 12] in #{__FILE__}"
|
105
102
|
end
|
106
103
|
|
107
104
|
def test_lists_specific_range_when_requested_in_hyphen_format
|
108
105
|
enter 'list 7-9'
|
109
106
|
debug_proc(@example)
|
110
|
-
check_output_includes
|
111
|
-
*lines_between(7, 9, false))
|
107
|
+
check_output_includes "[7, 9] in #{__FILE__}"
|
112
108
|
end
|
113
109
|
|
114
110
|
def test_lists_specific_range_when_requested_in_comma_format
|
115
111
|
enter 'list 7,9'
|
116
112
|
debug_proc(@example)
|
117
|
-
check_output_includes
|
118
|
-
*lines_between(7, 9, false))
|
113
|
+
check_output_includes "[7, 9] in #{__FILE__}"
|
119
114
|
end
|
120
115
|
|
121
116
|
def test_lists_nothing_if_unexistent_range_is_specified
|
@@ -135,15 +130,13 @@ module Byebug
|
|
135
130
|
def test_list_proper_lines_when_range_around_specific_line_with_hyphen
|
136
131
|
enter 'list 17-'
|
137
132
|
debug_proc(@example)
|
138
|
-
check_output_includes
|
139
|
-
*lines_between(12, 21, false))
|
133
|
+
check_output_includes "[12, 21] in #{__FILE__}"
|
140
134
|
end
|
141
135
|
|
142
136
|
def test_list_proper_lines_when_range_around_specific_line_with_comma
|
143
137
|
enter 'list 17,'
|
144
138
|
debug_proc(@example)
|
145
|
-
check_output_includes
|
146
|
-
*lines_between(12, 21, false))
|
139
|
+
check_output_includes "[12, 21] in #{__FILE__}"
|
147
140
|
end
|
148
141
|
|
149
142
|
def test_shows_an_error_when_the_file_to_list_does_not_exist
|
@@ -15,15 +15,9 @@ module Byebug
|
|
15
15
|
RestartExample.new.concat_args(a, b, c)
|
16
16
|
end
|
17
17
|
|
18
|
-
@old_prog_script = Byebug::PROG_SCRIPT if defined?(Byebug::PROG_SCRIPT)
|
19
|
-
|
20
18
|
super
|
21
19
|
end
|
22
20
|
|
23
|
-
def after
|
24
|
-
force_set_const(Byebug, 'PROG_SCRIPT', @old_prog_script)
|
25
|
-
end
|
26
|
-
|
27
21
|
def must_restart(cmd = nil)
|
28
22
|
expectation = RestartCommand.any_instance.expects(:exec)
|
29
23
|
expectation = expectation.with(cmd) if cmd
|
@@ -32,23 +26,26 @@ module Byebug
|
|
32
26
|
|
33
27
|
def test_restarts_with_manual_arguments
|
34
28
|
force_set_const(Byebug, 'BYEBUG_SCRIPT', 'byebug_script')
|
35
|
-
cmd = "#{BYEBUG_SCRIPT} #{
|
29
|
+
cmd = "#{BYEBUG_SCRIPT} #{Byebug.debugged_program} 1 2 3"
|
36
30
|
must_restart(cmd)
|
31
|
+
|
37
32
|
enter 'restart 1 2 3'
|
38
33
|
debug_proc(@example)
|
39
34
|
check_output_includes "Re exec'ing:\n\t#{cmd}"
|
40
35
|
end
|
41
36
|
|
42
|
-
def
|
43
|
-
|
44
|
-
|
37
|
+
def test_restart_with_a_default_script_if_nil_script_specified
|
38
|
+
force_set_const(Byebug, 'BYEBUG_SCRIPT', 'byebug_script')
|
39
|
+
Byebug.debugged_program = nil
|
40
|
+
must_restart
|
41
|
+
|
45
42
|
enter 'restart'
|
46
43
|
debug_proc(@example)
|
47
|
-
|
44
|
+
check_output_includes(/Re exec'ing:\s*#{BYEBUG_SCRIPT} #{$PROGRAM_NAME}/)
|
48
45
|
end
|
49
46
|
|
50
47
|
def test_does_not_restart_when_script_specified_does_not_exist
|
51
|
-
|
48
|
+
Byebug.debugged_program = 'blabla'
|
52
49
|
must_restart.never
|
53
50
|
enter 'restart'
|
54
51
|
debug_proc(@example)
|
@@ -61,8 +58,9 @@ module Byebug
|
|
61
58
|
enter 'restart'
|
62
59
|
debug_proc(@example)
|
63
60
|
check_output_includes 'Byebug was not called from the outset...'
|
64
|
-
check_output_includes
|
65
|
-
|
61
|
+
check_output_includes \
|
62
|
+
"Ruby program #{Byebug.debugged_program} not executable... " \
|
63
|
+
"We'll wrap it in a ruby call"
|
66
64
|
end
|
67
65
|
end
|
68
66
|
end
|
data/test/runner_test.rb
CHANGED
@@ -63,6 +63,13 @@ module Byebug
|
|
63
63
|
Byebug::Runner.new.run
|
64
64
|
end
|
65
65
|
|
66
|
+
def test_saved_debugged_program
|
67
|
+
ARGV.replace(%w(my_script -opt value))
|
68
|
+
|
69
|
+
Byebug::Runner.new.save_debugged_program
|
70
|
+
assert_match 'my_script', Byebug.debugged_program
|
71
|
+
end
|
72
|
+
|
66
73
|
def test_run_with_no_rc_option
|
67
74
|
ARGV.replace(%w(--no-rc my_script))
|
68
75
|
Byebug.expects(:start)
|
data/test/test_helper.rb
CHANGED
@@ -33,22 +33,18 @@ module Byebug
|
|
33
33
|
|
34
34
|
byebug_bin = File.expand_path('../../../bin/byebug', __FILE__)
|
35
35
|
force_set_const(Byebug, 'BYEBUG_SCRIPT', byebug_bin)
|
36
|
+
Byebug.debugged_program = $PROGRAM_NAME
|
36
37
|
|
37
38
|
# include test files as ignored files
|
38
39
|
glob_exp = File.expand_path('../../{lib,test/support}/**/*.rb', __FILE__)
|
39
40
|
ignored_files = Dir.glob(glob_exp) + ['test/test_helper.rb']
|
40
41
|
force_set_const(Byebug, 'IGNORED_FILES', ignored_files)
|
41
|
-
|
42
|
-
force_set_const(Byebug, 'PROG_SCRIPT', $PROGRAM_NAME)
|
43
42
|
end
|
44
43
|
|
45
44
|
include Byebug::TestUtils
|
46
45
|
end
|
47
46
|
end
|
48
47
|
|
49
|
-
# Init globals to avoid warnings
|
50
|
-
$binding = binding # this is from irb...
|
51
|
-
|
52
48
|
# Load the test files from the command line.
|
53
49
|
argv = ARGV.select do |argument|
|
54
50
|
case argument
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: byebug
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.4.
|
4
|
+
version: 3.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Rodriguez
|
@@ -10,48 +10,48 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2014-09-
|
13
|
+
date: 2014-09-25 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: columnize
|
17
17
|
requirement: !ruby/object:Gem::Requirement
|
18
18
|
requirements:
|
19
|
-
- - ~>
|
19
|
+
- - "~>"
|
20
20
|
- !ruby/object:Gem::Version
|
21
21
|
version: '0.8'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
requirements:
|
26
|
-
- - ~>
|
26
|
+
- - "~>"
|
27
27
|
- !ruby/object:Gem::Version
|
28
28
|
version: '0.8'
|
29
29
|
- !ruby/object:Gem::Dependency
|
30
30
|
name: slop
|
31
31
|
requirement: !ruby/object:Gem::Requirement
|
32
32
|
requirements:
|
33
|
-
- - ~>
|
33
|
+
- - "~>"
|
34
34
|
- !ruby/object:Gem::Version
|
35
35
|
version: '3.6'
|
36
36
|
type: :runtime
|
37
37
|
prerelease: false
|
38
38
|
version_requirements: !ruby/object:Gem::Requirement
|
39
39
|
requirements:
|
40
|
-
- - ~>
|
40
|
+
- - "~>"
|
41
41
|
- !ruby/object:Gem::Version
|
42
42
|
version: '3.6'
|
43
43
|
- !ruby/object:Gem::Dependency
|
44
44
|
name: debugger-linecache
|
45
45
|
requirement: !ruby/object:Gem::Requirement
|
46
46
|
requirements:
|
47
|
-
- - ~>
|
47
|
+
- - "~>"
|
48
48
|
- !ruby/object:Gem::Version
|
49
49
|
version: '1.2'
|
50
50
|
type: :runtime
|
51
51
|
prerelease: false
|
52
52
|
version_requirements: !ruby/object:Gem::Requirement
|
53
53
|
requirements:
|
54
|
-
- - ~>
|
54
|
+
- - "~>"
|
55
55
|
- !ruby/object:Gem::Version
|
56
56
|
version: '1.2'
|
57
57
|
description: |-
|
@@ -70,9 +70,9 @@ extra_rdoc_files:
|
|
70
70
|
- README.md
|
71
71
|
- GUIDE.md
|
72
72
|
files:
|
73
|
-
- .gitignore
|
74
|
-
- .rubocop.yml
|
75
|
-
- .travis.yml
|
73
|
+
- ".gitignore"
|
74
|
+
- ".rubocop.yml"
|
75
|
+
- ".travis.yml"
|
76
76
|
- CHANGELOG.md
|
77
77
|
- CONTRIBUTING.md
|
78
78
|
- GUIDE.md
|
@@ -207,12 +207,12 @@ require_paths:
|
|
207
207
|
- lib
|
208
208
|
required_ruby_version: !ruby/object:Gem::Requirement
|
209
209
|
requirements:
|
210
|
-
- -
|
210
|
+
- - ">="
|
211
211
|
- !ruby/object:Gem::Version
|
212
212
|
version: 2.0.0
|
213
213
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
214
214
|
requirements:
|
215
|
-
- -
|
215
|
+
- - ">="
|
216
216
|
- !ruby/object:Gem::Version
|
217
217
|
version: '0'
|
218
218
|
requirements: []
|