byebug 9.0.6 → 9.1.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 +17 -0
- data/GUIDE.md +19 -5
- data/README.md +18 -7
- data/bin/byebug +3 -1
- data/lib/byebug/breakpoint.rb +1 -1
- data/lib/byebug/commands/catch.rb +1 -1
- data/lib/byebug/commands/delete.rb +4 -2
- data/lib/byebug/commands/enable/breakpoints.rb +1 -1
- data/lib/byebug/commands/info/file.rb +2 -3
- data/lib/byebug/commands/irb.rb +5 -4
- data/lib/byebug/commands/kill.rb +1 -1
- data/lib/byebug/commands/restart.rb +22 -5
- data/lib/byebug/commands/save.rb +1 -1
- data/lib/byebug/core.rb +1 -1
- data/lib/byebug/frame.rb +3 -6
- data/lib/byebug/helpers/bin.rb +26 -0
- data/lib/byebug/helpers/file.rb +2 -2
- data/lib/byebug/helpers/path.rb +7 -11
- data/lib/byebug/helpers/string.rb +11 -1
- data/lib/byebug/helpers/toggle.rb +25 -24
- data/lib/byebug/helpers/var.rb +1 -1
- data/lib/byebug/interfaces/local_interface.rb +1 -0
- data/lib/byebug/printers/base.rb +2 -1
- data/lib/byebug/printers/plain.rb +1 -2
- data/lib/byebug/printers/texts/base.yml +4 -0
- data/lib/byebug/printers/texts/plain.yml +1 -1
- data/lib/byebug/runner.rb +21 -34
- data/lib/byebug/settings/callstyle.rb +1 -0
- data/lib/byebug/version.rb +2 -1
- metadata +11 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d998c99367586ad5a7f29f3bd5e22b2836f1d7c8
|
4
|
+
data.tar.gz: 32cf7615ad42d875e78c103e48c9a40dcde502be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2f5f3f1aec38feaa4a83fd97b9b09313a97ea5dd25daee3e9319d602e7268ca8fa6ade3995c8d8ccd4d68d5369e2f6511a3d8710562bc3204866bbc5ab20452b
|
7
|
+
data.tar.gz: 570436e9f4263fdc9191c666337e5a726854427932fa995fa4819417414a6160830d27ffa3d0a3acf9c1e23fa4d387ee8d6f0d4e50e4b6b583626443e31b2bd9
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,23 @@
|
|
2
2
|
|
3
3
|
## Master (Unreleased)
|
4
4
|
|
5
|
+
## 9.1.0 - 2016-08-22
|
6
|
+
|
7
|
+
### Added
|
8
|
+
|
9
|
+
* Better UI messages for breakpoint management.
|
10
|
+
|
11
|
+
### Fixed
|
12
|
+
|
13
|
+
* `where` command failing on instance_exec block stack frames.
|
14
|
+
* `restart` command crashing in certain cases because of a missing `require 'English'` (#321, @akaneko3).
|
15
|
+
* `restart` command crashing when debugged script is not executable or has no shebang (#321, @akaneko3).
|
16
|
+
|
17
|
+
### Removed
|
18
|
+
|
19
|
+
* Ruby 2.0 and Ruby 2.1 official & unofficial support. Byebug no longer installs
|
20
|
+
on these platforms.
|
21
|
+
|
5
22
|
## 9.0.6 - 2016-09-29
|
6
23
|
|
7
24
|
### Fixed
|
data/GUIDE.md
CHANGED
@@ -186,7 +186,21 @@ end
|
|
186
186
|
|
187
187
|
n_args = $ARGV.length
|
188
188
|
|
189
|
-
|
189
|
+
raise('*** Need number of disks or no parameter') if n_args > 1
|
190
|
+
|
191
|
+
n = 3
|
192
|
+
|
193
|
+
if n_args > 0
|
194
|
+
begin
|
195
|
+
n = $ARGV[0].to_i
|
196
|
+
rescue ValueError
|
197
|
+
raise("*** Expecting an integer, got: #{$ARGV[0]}")
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
raise('*** Number of disks should be between 1 and 100') if n < 1 || n > 100
|
202
|
+
|
203
|
+
hanoi(n, :a, :b, :c)
|
190
204
|
```
|
191
205
|
|
192
206
|
Recall in the first section it was stated that before the `def` is run, the
|
@@ -316,7 +330,7 @@ Now let's see what happens after stepping:
|
|
316
330
|
11:
|
317
331
|
=> 12: n_args = $ARGV.length
|
318
332
|
13:
|
319
|
-
14:
|
333
|
+
14: raise('*** Need number of disks or no parameter') if n_args > 1
|
320
334
|
(byebug) private_methods.member?(:hanoi)
|
321
335
|
true
|
322
336
|
(byebug)
|
@@ -442,15 +456,15 @@ NameError Exception: undefined local variable or method `n_args' for main:Object
|
|
442
456
|
19: begin
|
443
457
|
20: n = $ARGV[0].to_i
|
444
458
|
21: rescue ValueError
|
445
|
-
22: raise("
|
459
|
+
22: raise("*** Expecting an integer, got: #{$ARGV[0]}")
|
446
460
|
23: end
|
447
461
|
24: end
|
448
462
|
25:
|
449
|
-
26:
|
463
|
+
26: raise('*** Number of disks should be between 1 and 100') if n < 1 || n > 100
|
450
464
|
27:
|
451
465
|
=> 28: hanoi(n, :a, :b, :c)
|
452
466
|
(byebug) n_args
|
453
|
-
|
467
|
+
1
|
454
468
|
(byebug) eval n
|
455
469
|
3
|
456
470
|
(byebug) down 2
|
data/README.md
CHANGED
@@ -18,10 +18,10 @@
|
|
18
18
|
[tip_url]: https://gratipay.com/byebug
|
19
19
|
[irc_url]: https://gitter.im/deivid-rodriguez/byebug
|
20
20
|
|
21
|
-
Byebug is a simple to use, feature rich debugger for Ruby
|
22
|
-
TracePoint API for execution control and the
|
23
|
-
|
24
|
-
|
21
|
+
Byebug is a simple to use, feature rich debugger for Ruby. It uses the
|
22
|
+
TracePoint API for execution control and the Debug Inspector API for call stack
|
23
|
+
navigation, so it doesn't depend on internal core sources. It's developed as a C
|
24
|
+
extension, so it's fast. And it has a full test suite so it's reliable.
|
25
25
|
|
26
26
|
It allows you to see what is going on _inside_ a Ruby program while it executes
|
27
27
|
and offers many of the traditional debugging features such as:
|
@@ -48,12 +48,10 @@ Windows [![Vey][vey]][vey_url]
|
|
48
48
|
|
49
49
|
## Requirements
|
50
50
|
|
51
|
-
* Required: MRI 2.0.0 or higher. For debugging ruby 1.9.3 or older, use
|
52
|
-
[debugger].
|
53
51
|
* Recommended:
|
54
|
-
* MRI 2.1.8 or higher.
|
55
52
|
* MRI 2.2.4 or higher.
|
56
53
|
* MRI 2.3.0 or higher.
|
54
|
+
* MRI 2.4.0 or higher.
|
57
55
|
|
58
56
|
## Install
|
59
57
|
|
@@ -63,6 +61,8 @@ gem install byebug
|
|
63
61
|
|
64
62
|
## Usage
|
65
63
|
|
64
|
+
### From within the Ruby code
|
65
|
+
|
66
66
|
Simply drop
|
67
67
|
|
68
68
|
byebug
|
@@ -74,6 +74,7 @@ If you were debugging Rails, for example, you would add `byebug` to your code.
|
|
74
74
|
def index
|
75
75
|
byebug
|
76
76
|
@articles = Article.find_recent
|
77
|
+
end
|
77
78
|
```
|
78
79
|
|
79
80
|
And then start a Rails server.
|
@@ -84,6 +85,14 @@ bin/rails s
|
|
84
85
|
|
85
86
|
Once the execution gets to your `byebug` command you will get a debugging prompt.
|
86
87
|
|
88
|
+
### From the command line
|
89
|
+
|
90
|
+
If you want to debug a Ruby script without editing it, you can invoke byebug from the command line.
|
91
|
+
|
92
|
+
```shell
|
93
|
+
byebug myscript.rb
|
94
|
+
```
|
95
|
+
|
87
96
|
## Byebug's commands
|
88
97
|
|
89
98
|
Command | Aliases | Subcommands
|
@@ -145,6 +154,7 @@ started. Proper documentation will be eventually written.
|
|
145
154
|
connected.
|
146
155
|
* [minitest-byebug] starts a byebug session on minitest failures.
|
147
156
|
* [sublime_debugger] provides a plugin for ruby debugging on Sublime Text.
|
157
|
+
* [atom-byebug] provides integration with the Atom editor [EXPERIMENTAL].
|
148
158
|
|
149
159
|
## Contribute
|
150
160
|
|
@@ -168,3 +178,4 @@ software, especially:
|
|
168
178
|
[ruby-debug-passenger]: https://github.com/davejamesmiller/ruby-debug-passenger
|
169
179
|
[minitest-byebug]: https://github.com/kaspth/minitest-byebug
|
170
180
|
[sublime_debugger]: https://github.com/shuky19/sublime_debugger
|
181
|
+
[atom-byebug]: https://github.com/izaera/atom-byebug
|
data/bin/byebug
CHANGED
data/lib/byebug/breakpoint.rb
CHANGED
@@ -81,7 +81,7 @@ module Byebug
|
|
81
81
|
# Prints all information associated to the breakpoint
|
82
82
|
#
|
83
83
|
def inspect
|
84
|
-
meths = %w
|
84
|
+
meths = %w[id pos source expr hit_condition hit_count hit_value enabled?]
|
85
85
|
values = meths.map { |field| "#{field}: #{send(field)}" }.join(', ')
|
86
86
|
"#<Byebug::Breakpoint #{values}>"
|
87
87
|
end
|
@@ -36,7 +36,7 @@ module Byebug
|
|
36
36
|
def execute
|
37
37
|
return info unless @match[1]
|
38
38
|
|
39
|
-
return
|
39
|
+
return @match[1] == 'off' ? clear : add(@match[1]) unless @match[2]
|
40
40
|
|
41
41
|
return errmsg pr('catch.errors.off', off: cmd) unless @match[2] == 'off'
|
42
42
|
|
@@ -44,8 +44,10 @@ module Byebug
|
|
44
44
|
|
45
45
|
return errmsg(err) unless pos
|
46
46
|
|
47
|
-
|
48
|
-
|
47
|
+
if Breakpoint.remove(pos)
|
48
|
+
puts(pr('break.messages.breakpoint_deleted', pos: pos))
|
49
|
+
else
|
50
|
+
errmsg(pr('break.errors.no_breakpoint_delete', pos: pos))
|
49
51
|
end
|
50
52
|
end
|
51
53
|
end
|
@@ -10,6 +10,7 @@ module Byebug
|
|
10
10
|
#
|
11
11
|
class FileCommand < Command
|
12
12
|
include Helpers::FileHelper
|
13
|
+
include Helpers::StringHelper
|
13
14
|
|
14
15
|
self.allow_in_post_mortem = true
|
15
16
|
|
@@ -38,8 +39,7 @@ module Byebug
|
|
38
39
|
return errmsg(pr('info.errors.undefined_file', file: file))
|
39
40
|
end
|
40
41
|
|
41
|
-
puts <<-EOC
|
42
|
-
|
42
|
+
puts prettify <<-EOC
|
43
43
|
File #{info_file_basic(file)}
|
44
44
|
|
45
45
|
Breakpoint line numbers: #{info_file_breakpoints(file)}
|
@@ -47,7 +47,6 @@ module Byebug
|
|
47
47
|
Modification time: #{info_file_mtime(file)}
|
48
48
|
|
49
49
|
Sha1 Signature: #{info_file_sha1(file)}
|
50
|
-
|
51
50
|
EOC
|
52
51
|
end
|
53
52
|
|
data/lib/byebug/commands/irb.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'byebug/command'
|
2
2
|
require 'irb'
|
3
|
+
require 'English'
|
3
4
|
|
4
5
|
module Byebug
|
5
6
|
#
|
@@ -29,7 +30,7 @@ module Byebug
|
|
29
30
|
return errmsg(pr('base.errors.only_local'))
|
30
31
|
end
|
31
32
|
|
32
|
-
# @todo IRB tries to parse ARGV so we must clear it (see #197). Add a
|
33
|
+
# @todo IRB tries to parse $ARGV so we must clear it (see #197). Add a
|
33
34
|
# test case for it so we can remove this comment.
|
34
35
|
with_clean_argv { IRB.start }
|
35
36
|
end
|
@@ -37,12 +38,12 @@ module Byebug
|
|
37
38
|
private
|
38
39
|
|
39
40
|
def with_clean_argv
|
40
|
-
saved_argv = ARGV.dup
|
41
|
-
ARGV.clear
|
41
|
+
saved_argv = $ARGV.dup
|
42
|
+
$ARGV.clear
|
42
43
|
begin
|
43
44
|
yield
|
44
45
|
ensure
|
45
|
-
ARGV.concat(saved_argv)
|
46
|
+
$ARGV.concat(saved_argv)
|
46
47
|
end
|
47
48
|
end
|
48
49
|
end
|
data/lib/byebug/commands/kill.rb
CHANGED
@@ -1,12 +1,16 @@
|
|
1
1
|
require 'byebug/command'
|
2
|
+
require 'byebug/helpers/bin'
|
2
3
|
require 'byebug/helpers/path'
|
3
4
|
require 'shellwords'
|
5
|
+
require 'English'
|
6
|
+
require 'rbconfig'
|
4
7
|
|
5
8
|
module Byebug
|
6
9
|
#
|
7
10
|
# Restart debugged program from within byebug.
|
8
11
|
#
|
9
12
|
class RestartCommand < Command
|
13
|
+
include Helpers::BinHelper
|
10
14
|
include Helpers::PathHelper
|
11
15
|
|
12
16
|
self.allow_in_control = true
|
@@ -32,14 +36,27 @@ module Byebug
|
|
32
36
|
end
|
33
37
|
|
34
38
|
def execute
|
35
|
-
|
39
|
+
cmd = [$PROGRAM_NAME]
|
36
40
|
|
37
|
-
|
41
|
+
cmd = prepend_byebug_bin(cmd)
|
42
|
+
cmd = prepend_ruby_bin(cmd)
|
38
43
|
|
39
|
-
|
44
|
+
cmd += (@match[:args] ? @match[:args].shellsplit : $ARGV)
|
40
45
|
|
41
|
-
puts pr('restart.success', cmd:
|
42
|
-
Kernel.exec(*
|
46
|
+
puts pr('restart.success', cmd: cmd.shelljoin)
|
47
|
+
Kernel.exec(*cmd)
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
51
|
+
|
52
|
+
def prepend_byebug_bin(cmd)
|
53
|
+
cmd.unshift(bin_file) if Byebug.mode == :standalone
|
54
|
+
cmd
|
55
|
+
end
|
56
|
+
|
57
|
+
def prepend_ruby_bin(cmd)
|
58
|
+
cmd.unshift(RbConfig.ruby) if which('ruby') != which(cmd.first)
|
59
|
+
cmd
|
43
60
|
end
|
44
61
|
end
|
45
62
|
end
|
data/lib/byebug/commands/save.rb
CHANGED
data/lib/byebug/core.rb
CHANGED
data/lib/byebug/frame.rb
CHANGED
@@ -47,13 +47,10 @@ module Byebug
|
|
47
47
|
#
|
48
48
|
# Gets local variables for the frame.
|
49
49
|
#
|
50
|
-
# @todo Use `Binding#local_variables` directly once we drop 2.1 support
|
51
|
-
# since it's a public method since ruby 2.2
|
52
|
-
#
|
53
50
|
def locals
|
54
51
|
return [] unless _binding
|
55
52
|
|
56
|
-
_binding.
|
53
|
+
_binding.local_variables.each_with_object({}) do |e, a|
|
57
54
|
a[e] = _binding.local_variable_get(e)
|
58
55
|
a
|
59
56
|
end
|
@@ -161,14 +158,14 @@ module Byebug
|
|
161
158
|
def c_args
|
162
159
|
return [] unless _self.to_s != 'main'
|
163
160
|
|
164
|
-
|
161
|
+
_class.instance_method(_method).parameters
|
165
162
|
end
|
166
163
|
|
167
164
|
def ruby_args
|
168
165
|
meth_name = _binding.eval('__method__')
|
169
166
|
return [] unless meth_name
|
170
167
|
|
171
|
-
meth_obj =
|
168
|
+
meth_obj = _class.instance_method(meth_name)
|
172
169
|
return [] unless meth_obj
|
173
170
|
|
174
171
|
meth_obj.parameters
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Byebug
|
2
|
+
module Helpers
|
3
|
+
#
|
4
|
+
# Utilities for interaction with executables
|
5
|
+
#
|
6
|
+
module BinHelper
|
7
|
+
#
|
8
|
+
# Cross-platform way of finding an executable in the $PATH.
|
9
|
+
# Borrowed from: http://stackoverflow.com/questions/2108727
|
10
|
+
#
|
11
|
+
def which(cmd)
|
12
|
+
return File.expand_path(cmd) if File.exist?(cmd)
|
13
|
+
|
14
|
+
exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
|
15
|
+
ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
|
16
|
+
exts.each do |ext|
|
17
|
+
exe = File.join(path, "#{cmd}#{ext}")
|
18
|
+
return exe if File.executable?(exe) && !File.directory?(exe)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
nil
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/byebug/helpers/file.rb
CHANGED
@@ -8,7 +8,7 @@ module Byebug
|
|
8
8
|
# Reads lines of source file +filename+ into an array
|
9
9
|
#
|
10
10
|
def get_lines(filename)
|
11
|
-
File.foreach(filename).reduce([]) { |
|
11
|
+
File.foreach(filename).reduce([]) { |acc, elem| acc << elem.chomp }
|
12
12
|
end
|
13
13
|
|
14
14
|
#
|
@@ -26,7 +26,7 @@ module Byebug
|
|
26
26
|
# one-line-at-a-time way.
|
27
27
|
#
|
28
28
|
def n_lines(filename)
|
29
|
-
File.foreach(filename).reduce(0) { |
|
29
|
+
File.foreach(filename).reduce(0) { |acc, _elem| acc + 1 }
|
30
30
|
end
|
31
31
|
|
32
32
|
#
|
data/lib/byebug/helpers/path.rb
CHANGED
@@ -5,27 +5,23 @@ module Byebug
|
|
5
5
|
#
|
6
6
|
module PathHelper
|
7
7
|
def bin_file
|
8
|
-
@bin_file ||=
|
8
|
+
@bin_file ||= File.join(root_path, 'bin', 'byebug')
|
9
9
|
end
|
10
10
|
|
11
11
|
def root_path
|
12
|
-
@root_path ||= File.expand_path('
|
12
|
+
@root_path ||= File.expand_path(File.join('..', '..', '..'), __dir__)
|
13
13
|
end
|
14
14
|
|
15
15
|
def lib_files
|
16
|
-
@lib_files ||=
|
17
|
-
end
|
18
|
-
|
19
|
-
def ext_files
|
20
|
-
@ext_files ||= expand_from_root('ext/**/*.{c,h,rb}')
|
16
|
+
@lib_files ||= glob_for('lib')
|
21
17
|
end
|
22
18
|
|
23
19
|
def test_files
|
24
|
-
@test_files ||=
|
20
|
+
@test_files ||= glob_for('test')
|
25
21
|
end
|
26
22
|
|
27
23
|
def gem_files
|
28
|
-
@gem_files ||= [bin_file] + lib_files
|
24
|
+
@gem_files ||= [bin_file] + lib_files
|
29
25
|
end
|
30
26
|
|
31
27
|
def all_files
|
@@ -34,8 +30,8 @@ module Byebug
|
|
34
30
|
|
35
31
|
private
|
36
32
|
|
37
|
-
def
|
38
|
-
Dir.glob(File.
|
33
|
+
def glob_for(dir)
|
34
|
+
Dir.glob(File.join(root_path, dir, '**', '*.rb'))
|
39
35
|
end
|
40
36
|
end
|
41
37
|
end
|
@@ -17,7 +17,17 @@ module Byebug
|
|
17
17
|
# command prompt.
|
18
18
|
#
|
19
19
|
def prettify(str)
|
20
|
-
"\n" + str
|
20
|
+
"\n" + deindent(str) + "\n"
|
21
|
+
end
|
22
|
+
|
23
|
+
#
|
24
|
+
# Removes a number of leading whitespace for each input line.
|
25
|
+
#
|
26
|
+
# @note Might be unnecessary when Ruby 2.2 support is dropped and we can
|
27
|
+
# use squiggly heredoc's.
|
28
|
+
#
|
29
|
+
def deindent(str, leading_spaces: 6)
|
30
|
+
str.gsub(/^ {#{leading_spaces}}/, '')
|
21
31
|
end
|
22
32
|
end
|
23
33
|
end
|
@@ -9,50 +9,51 @@ module Byebug
|
|
9
9
|
include ParseHelper
|
10
10
|
|
11
11
|
def enable_disable_breakpoints(is_enable, args)
|
12
|
-
|
12
|
+
raise pr('toggle.errors.no_breakpoints') if Breakpoint.none?
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
selected_breakpoints = all_breakpoints
|
17
|
-
else
|
18
|
-
selected_ids = []
|
19
|
-
args.split(/ +/).each do |pos|
|
20
|
-
last_id = all_breakpoints.last.id
|
21
|
-
pos, err = get_int(pos, "#{is_enable} breakpoints", 1, last_id)
|
22
|
-
return errmsg(err) unless pos
|
23
|
-
|
24
|
-
selected_ids << pos
|
25
|
-
end
|
26
|
-
selected_breakpoints = all_breakpoints.select do |b|
|
27
|
-
selected_ids.include?(b.id)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
selected_breakpoints.each do |b|
|
32
|
-
enabled = ('enable' == is_enable)
|
14
|
+
select_breakpoints(is_enable, args).each do |b|
|
15
|
+
enabled = (is_enable == 'enable')
|
33
16
|
if enabled && !syntax_valid?(b.expr)
|
34
|
-
|
17
|
+
raise pr('toggle.errors.expression', expr: b.expr)
|
35
18
|
end
|
36
19
|
|
20
|
+
puts pr('toggle.messages.toggled', bpnum: b.id,
|
21
|
+
endis: enabled ? 'en' : 'dis')
|
37
22
|
b.enabled = enabled
|
38
23
|
end
|
39
24
|
end
|
40
25
|
|
41
26
|
def enable_disable_display(is_enable, args)
|
42
|
-
|
27
|
+
raise pr('toggle.errors.no_display') if n_displays.zero?
|
43
28
|
|
44
29
|
selected_displays = args ? args.split(/ +/) : [1..n_displays + 1]
|
45
30
|
|
46
31
|
selected_displays.each do |pos|
|
47
32
|
pos, err = get_int(pos, "#{is_enable} display", 1, n_displays)
|
48
|
-
|
33
|
+
raise err unless err.nil?
|
49
34
|
|
50
|
-
Byebug.displays[pos - 1][0] = ('enable'
|
35
|
+
Byebug.displays[pos - 1][0] = (is_enable == 'enable')
|
51
36
|
end
|
52
37
|
end
|
53
38
|
|
54
39
|
private
|
55
40
|
|
41
|
+
def select_breakpoints(is_enable, args)
|
42
|
+
all_breakpoints = Byebug.breakpoints.sort_by(&:id)
|
43
|
+
return all_breakpoints if args.nil?
|
44
|
+
|
45
|
+
selected_ids = []
|
46
|
+
args.split(/ +/).each do |pos|
|
47
|
+
last_id = all_breakpoints.last.id
|
48
|
+
pos, err = get_int(pos, "#{is_enable} breakpoints", 1, last_id)
|
49
|
+
raise(ArgumentError, err) unless pos
|
50
|
+
|
51
|
+
selected_ids << pos
|
52
|
+
end
|
53
|
+
|
54
|
+
all_breakpoints.select { |b| selected_ids.include?(b.id) }
|
55
|
+
end
|
56
|
+
|
56
57
|
def n_displays
|
57
58
|
Byebug.displays.size
|
58
59
|
end
|
data/lib/byebug/helpers/var.rb
CHANGED
data/lib/byebug/printers/base.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require 'yaml'
|
3
4
|
|
4
5
|
module Byebug
|
@@ -61,7 +62,7 @@ module Byebug
|
|
61
62
|
end
|
62
63
|
|
63
64
|
def contents_files
|
64
|
-
[File.
|
65
|
+
[File.join(__dir__, 'texts', 'base.yml')]
|
65
66
|
end
|
66
67
|
end
|
67
68
|
end
|
@@ -16,6 +16,8 @@ break:
|
|
16
16
|
not_changed: "Incorrect expression \"{expr}\", breakpoint not changed"
|
17
17
|
confirmations:
|
18
18
|
delete_all: "Delete all breakpoints?"
|
19
|
+
messages:
|
20
|
+
breakpoint_deleted: "Deleted breakpoint {pos}"
|
19
21
|
|
20
22
|
catch:
|
21
23
|
added: "Catching exception {exception}."
|
@@ -97,6 +99,8 @@ toggle:
|
|
97
99
|
no_display: "No display expressions have been set"
|
98
100
|
syntax: "\"{toggle}\" must be followed by \"display\", \"breakpoints\" or breakpoint ids"
|
99
101
|
expression: "Expression \"{expr}\" syntactically incorrect; breakpoint remains disabled."
|
102
|
+
messages:
|
103
|
+
toggled: "Breakpoint {bpnum} {endis}abled"
|
100
104
|
|
101
105
|
parse:
|
102
106
|
errors:
|
data/lib/byebug/runner.rb
CHANGED
@@ -2,7 +2,9 @@ require 'optparse'
|
|
2
2
|
require 'English'
|
3
3
|
require 'byebug/core'
|
4
4
|
require 'byebug/version'
|
5
|
+
require 'byebug/helpers/bin'
|
5
6
|
require 'byebug/helpers/parse'
|
7
|
+
require 'byebug/helpers/string'
|
6
8
|
require 'byebug/option_setter'
|
7
9
|
require 'byebug/processors/control_processor'
|
8
10
|
|
@@ -11,7 +13,9 @@ module Byebug
|
|
11
13
|
# Responsible for starting the debugger when started from the command line.
|
12
14
|
#
|
13
15
|
class Runner
|
16
|
+
include Helpers::BinHelper
|
14
17
|
include Helpers::ParseHelper
|
18
|
+
include Helpers::StringHelper
|
15
19
|
|
16
20
|
#
|
17
21
|
# Special working modes that don't actually start the debugger.
|
@@ -71,12 +75,10 @@ module Byebug
|
|
71
75
|
# Usage banner.
|
72
76
|
#
|
73
77
|
def banner
|
74
|
-
<<-EOB
|
75
|
-
|
78
|
+
prettify <<-EOB
|
76
79
|
byebug #{Byebug::VERSION}
|
77
80
|
|
78
81
|
Usage: byebug [options] <script.rb> -- <script.rb parameters>
|
79
|
-
|
80
82
|
EOB
|
81
83
|
end
|
82
84
|
|
@@ -84,9 +86,13 @@ module Byebug
|
|
84
86
|
# Starts byebug to debug a program.
|
85
87
|
#
|
86
88
|
def run
|
89
|
+
Byebug.mode = :standalone
|
90
|
+
|
87
91
|
option_parser.order!($ARGV)
|
88
92
|
return if non_script_option? || error_in_script?
|
89
93
|
|
94
|
+
$PROGRAM_NAME = program
|
95
|
+
|
90
96
|
Byebug.run_init_script if init_script
|
91
97
|
|
92
98
|
loop do
|
@@ -115,6 +121,13 @@ module Byebug
|
|
115
121
|
end
|
116
122
|
end
|
117
123
|
|
124
|
+
def program
|
125
|
+
@program ||= begin
|
126
|
+
candidate = which($ARGV.shift)
|
127
|
+
candidate == which('ruby') ? which($ARGV.shift) : candidate
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
118
131
|
#
|
119
132
|
# An option that doesn't need a script specified was given
|
120
133
|
#
|
@@ -143,25 +156,17 @@ module Byebug
|
|
143
156
|
# Extracts debugged program from command line args.
|
144
157
|
#
|
145
158
|
def non_existing_script?
|
146
|
-
|
147
|
-
|
148
|
-
program = which($ARGV.shift)
|
149
|
-
program = which($ARGV.shift) if program == which('ruby')
|
159
|
+
return false if program
|
150
160
|
|
151
|
-
|
152
|
-
|
153
|
-
false
|
154
|
-
else
|
155
|
-
print_error("The script doesn't exist")
|
156
|
-
true
|
157
|
-
end
|
161
|
+
print_error("The script doesn't exist")
|
162
|
+
true
|
158
163
|
end
|
159
164
|
|
160
165
|
#
|
161
166
|
# Checks the debugged script has correct syntax
|
162
167
|
#
|
163
168
|
def invalid_script?
|
164
|
-
return false if syntax_valid?(File.read(
|
169
|
+
return false if syntax_valid?(File.read(program))
|
165
170
|
|
166
171
|
print_error('The script has incorrect syntax')
|
167
172
|
true
|
@@ -171,28 +176,10 @@ module Byebug
|
|
171
176
|
# Debugs a script only if syntax checks okay.
|
172
177
|
#
|
173
178
|
def debug_program
|
174
|
-
error = Byebug.debug_load(
|
179
|
+
error = Byebug.debug_load(program, stop)
|
175
180
|
puts "#{error}\n#{error.backtrace}" if error
|
176
181
|
end
|
177
182
|
|
178
|
-
#
|
179
|
-
# Cross-platform way of finding an executable in the $PATH.
|
180
|
-
# Borrowed from: http://stackoverflow.com/questions/2108727
|
181
|
-
#
|
182
|
-
def which(cmd)
|
183
|
-
return File.expand_path(cmd) if File.exist?(cmd)
|
184
|
-
|
185
|
-
exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
|
186
|
-
ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
|
187
|
-
exts.each do |ext|
|
188
|
-
exe = File.join(path, "#{cmd}#{ext}")
|
189
|
-
return exe if File.executable?(exe) && !File.directory?(exe)
|
190
|
-
end
|
191
|
-
end
|
192
|
-
|
193
|
-
nil
|
194
|
-
end
|
195
|
-
|
196
183
|
#
|
197
184
|
# Prints an error message and a help string
|
198
185
|
#
|
data/lib/byebug/version.rb
CHANGED
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: 9.0
|
4
|
+
version: 9.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Rodriguez
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2017-08-22 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|
@@ -27,12 +27,11 @@ dependencies:
|
|
27
27
|
- !ruby/object:Gem::Version
|
28
28
|
version: '1.7'
|
29
29
|
description: |-
|
30
|
-
Byebug is a Ruby
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
line interface.
|
30
|
+
Byebug is a Ruby debugger. It's implemented using the
|
31
|
+
TracePoint C API for execution control and the Debug Inspector C API for
|
32
|
+
call stack navigation. The core component provides support that front-ends
|
33
|
+
can build on. It provides breakpoint handling and bindings for stack frames
|
34
|
+
among other things and it comes with an easy to use command line interface.
|
36
35
|
email: deivid.rodriguez@mail.com
|
37
36
|
executables:
|
38
37
|
- byebug
|
@@ -124,6 +123,7 @@ files:
|
|
124
123
|
- lib/byebug/core.rb
|
125
124
|
- lib/byebug/errors.rb
|
126
125
|
- lib/byebug/frame.rb
|
126
|
+
- lib/byebug/helpers/bin.rb
|
127
127
|
- lib/byebug/helpers/eval.rb
|
128
128
|
- lib/byebug/helpers/file.rb
|
129
129
|
- lib/byebug/helpers/frame.rb
|
@@ -181,7 +181,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
181
181
|
requirements:
|
182
182
|
- - ">="
|
183
183
|
- !ruby/object:Gem::Version
|
184
|
-
version: 2.
|
184
|
+
version: 2.2.0
|
185
185
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
186
186
|
requirements:
|
187
187
|
- - ">="
|
@@ -189,8 +189,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
189
189
|
version: '0'
|
190
190
|
requirements: []
|
191
191
|
rubyforge_project:
|
192
|
-
rubygems_version: 2.6.
|
192
|
+
rubygems_version: 2.6.12
|
193
193
|
signing_key:
|
194
194
|
specification_version: 4
|
195
|
-
summary: Ruby
|
195
|
+
summary: Ruby fast debugger - base + CLI
|
196
196
|
test_files: []
|