byebug 4.0.5 → 5.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +72 -34
- data/CONTRIBUTING.md +26 -31
- data/README.md +3 -3
- data/lib/byebug/breakpoint.rb +2 -1
- data/lib/byebug/command.rb +27 -49
- data/lib/byebug/commands/break.rb +21 -15
- data/lib/byebug/commands/catch.rb +9 -15
- data/lib/byebug/commands/condition.rb +12 -15
- data/lib/byebug/commands/continue.rb +8 -11
- data/lib/byebug/commands/delete.rb +9 -12
- data/lib/byebug/commands/disable.rb +32 -0
- data/lib/byebug/commands/disable/breakpoints.rb +38 -0
- data/lib/byebug/commands/disable/display.rb +39 -0
- data/lib/byebug/commands/display.rb +18 -51
- data/lib/byebug/commands/down.rb +39 -0
- data/lib/byebug/commands/edit.rb +8 -14
- data/lib/byebug/commands/enable.rb +25 -0
- data/lib/byebug/commands/enable/breakpoints.rb +38 -0
- data/lib/byebug/commands/enable/display.rb +39 -0
- data/lib/byebug/commands/eval.rb +10 -192
- data/lib/byebug/commands/finish.rb +11 -12
- data/lib/byebug/commands/frame.rb +17 -182
- data/lib/byebug/commands/help.rb +18 -18
- data/lib/byebug/commands/history.rb +9 -10
- data/lib/byebug/commands/info.rb +17 -190
- data/lib/byebug/commands/info/args.rb +39 -0
- data/lib/byebug/commands/info/breakpoints.rb +59 -0
- data/lib/byebug/commands/info/catch.rb +39 -0
- data/lib/byebug/commands/info/display.rb +42 -0
- data/lib/byebug/commands/info/file.rb +81 -0
- data/lib/byebug/commands/info/line.rb +31 -0
- data/lib/byebug/commands/info/program.rb +51 -0
- data/lib/byebug/commands/interrupt.rb +5 -9
- data/lib/byebug/commands/irb.rb +5 -9
- data/lib/byebug/commands/kill.rb +6 -12
- data/lib/byebug/commands/list.rb +47 -19
- data/lib/byebug/commands/method.rb +8 -14
- data/lib/byebug/commands/next.rb +36 -0
- data/lib/byebug/commands/pp.rb +41 -0
- data/lib/byebug/commands/pry.rb +5 -9
- data/lib/byebug/commands/ps.rb +44 -0
- data/lib/byebug/commands/putl.rb +43 -0
- data/lib/byebug/commands/quit.rb +8 -12
- data/lib/byebug/commands/restart.rb +6 -12
- data/lib/byebug/commands/save.rb +30 -39
- data/lib/byebug/commands/set.rb +19 -21
- data/lib/byebug/commands/show.rb +10 -16
- data/lib/byebug/commands/source.rb +6 -12
- data/lib/byebug/commands/step.rb +36 -0
- data/lib/byebug/commands/thread.rb +13 -130
- data/lib/byebug/commands/thread/current.rb +35 -0
- data/lib/byebug/commands/thread/list.rb +41 -0
- data/lib/byebug/commands/thread/resume.rb +45 -0
- data/lib/byebug/commands/thread/stop.rb +41 -0
- data/lib/byebug/commands/thread/switch.rb +43 -0
- data/lib/byebug/commands/tracevar.rb +8 -14
- data/lib/byebug/commands/undisplay.rb +12 -15
- data/lib/byebug/commands/untracevar.rb +5 -11
- data/lib/byebug/commands/up.rb +39 -0
- data/lib/byebug/commands/var.rb +15 -94
- data/lib/byebug/commands/var/all.rb +37 -0
- data/lib/byebug/commands/var/const.rb +38 -0
- data/lib/byebug/commands/var/global.rb +33 -0
- data/lib/byebug/commands/var/instance.rb +35 -0
- data/lib/byebug/commands/var/local.rb +35 -0
- data/lib/byebug/commands/where.rb +47 -0
- data/lib/byebug/core.rb +10 -0
- data/lib/byebug/helpers/eval.rb +47 -0
- data/lib/byebug/helpers/file.rb +46 -0
- data/lib/byebug/helpers/frame.rb +76 -0
- data/lib/byebug/helpers/parse.rb +74 -0
- data/lib/byebug/helpers/string.rb +24 -0
- data/lib/byebug/helpers/thread.rb +53 -0
- data/lib/byebug/helpers/toggle.rb +56 -0
- data/lib/byebug/helpers/var.rb +45 -0
- data/lib/byebug/history.rb +2 -4
- data/lib/byebug/interface.rb +5 -3
- data/lib/byebug/interfaces/local_interface.rb +3 -1
- data/lib/byebug/interfaces/remote_interface.rb +3 -1
- data/lib/byebug/interfaces/test_interface.rb +6 -2
- data/lib/byebug/printers/plain.rb +1 -1
- data/lib/byebug/processors/command_processor.rb +9 -11
- data/lib/byebug/processors/control_command_processor.rb +1 -1
- data/lib/byebug/remote.rb +3 -0
- data/lib/byebug/runner.rb +5 -3
- data/lib/byebug/setting.rb +2 -18
- data/lib/byebug/settings/savefile.rb +21 -0
- data/lib/byebug/states/regular_state.rb +15 -6
- data/lib/byebug/subcommand_list.rb +33 -0
- data/lib/byebug/subcommands.rb +53 -0
- data/lib/byebug/version.rb +1 -1
- metadata +45 -6
- data/lib/byebug/commands/enable_disable.rb +0 -132
- data/lib/byebug/commands/stepping.rb +0 -75
- data/lib/byebug/helper.rb +0 -131
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'English'
|
2
|
+
require 'pp'
|
3
|
+
require 'byebug/command'
|
4
|
+
require 'byebug/helpers/eval'
|
5
|
+
|
6
|
+
module Byebug
|
7
|
+
#
|
8
|
+
# Evaluation and pretty printing from byebug's prompt.
|
9
|
+
#
|
10
|
+
class PpCommand < Command
|
11
|
+
include Helpers::EvalHelper
|
12
|
+
|
13
|
+
self.allow_in_control = true
|
14
|
+
|
15
|
+
def regexp
|
16
|
+
/^\s* pp \s+/x
|
17
|
+
end
|
18
|
+
|
19
|
+
def execute
|
20
|
+
out = StringIO.new
|
21
|
+
run_with_binding do |b|
|
22
|
+
if Setting[:stack_on_error]
|
23
|
+
PP.pp(bb_eval(@match.post_match, b), out)
|
24
|
+
else
|
25
|
+
PP.pp(bb_warning_eval(@match.post_match, b), out)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
puts out.string
|
29
|
+
rescue
|
30
|
+
out.puts $ERROR_INFO.message
|
31
|
+
end
|
32
|
+
|
33
|
+
def description
|
34
|
+
<<-EOD
|
35
|
+
pp <expression>
|
36
|
+
|
37
|
+
Evaluates <expression> and pretty-prints its value.
|
38
|
+
EOD
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
data/lib/byebug/commands/pry.rb
CHANGED
@@ -23,16 +23,12 @@ module Byebug
|
|
23
23
|
get_binding.pry
|
24
24
|
end
|
25
25
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
end
|
26
|
+
def description
|
27
|
+
<<-EOD
|
28
|
+
pry
|
30
29
|
|
31
|
-
|
32
|
-
|
33
|
-
pry Starts a Pry session.
|
34
|
-
EOD
|
35
|
-
end
|
30
|
+
Starts a Pry session.
|
31
|
+
EOD
|
36
32
|
end
|
37
33
|
end
|
38
34
|
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'English'
|
2
|
+
require 'pp'
|
3
|
+
require 'byebug/command'
|
4
|
+
require 'byebug/helpers/eval'
|
5
|
+
|
6
|
+
module Byebug
|
7
|
+
#
|
8
|
+
# Evaluation, pretty printing, columnizing and sorting from byebug's prompt
|
9
|
+
#
|
10
|
+
class PsCommand < Command
|
11
|
+
include Helpers::EvalHelper
|
12
|
+
include Columnize
|
13
|
+
|
14
|
+
self.allow_in_control = true
|
15
|
+
|
16
|
+
def regexp
|
17
|
+
/^\s* ps \s+/x
|
18
|
+
end
|
19
|
+
|
20
|
+
def execute
|
21
|
+
out = StringIO.new
|
22
|
+
run_with_binding do |b|
|
23
|
+
res = eval_with_setting(b, @match.post_match, Setting[:stack_on_error])
|
24
|
+
|
25
|
+
if res.is_a?(Array)
|
26
|
+
puts "#{columnize(res.map(&:to_s).sort!, Setting[:width])}"
|
27
|
+
else
|
28
|
+
PP.pp(res, out)
|
29
|
+
puts out.string
|
30
|
+
end
|
31
|
+
end
|
32
|
+
rescue
|
33
|
+
out.puts $ERROR_INFO.message
|
34
|
+
end
|
35
|
+
|
36
|
+
def description
|
37
|
+
<<-EOD
|
38
|
+
ps <expression>
|
39
|
+
|
40
|
+
Evaluates <expression>, an array, sort and columnize its value.
|
41
|
+
EOD
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'pp'
|
2
|
+
require 'byebug/command'
|
3
|
+
require 'byebug/helpers/eval'
|
4
|
+
|
5
|
+
module Byebug
|
6
|
+
#
|
7
|
+
# Evaluation, pretty printing and columnizing from byebug's prompt.
|
8
|
+
#
|
9
|
+
class PutlCommand < Command
|
10
|
+
include Helpers::EvalHelper
|
11
|
+
include Columnize
|
12
|
+
|
13
|
+
self.allow_in_control = true
|
14
|
+
|
15
|
+
def regexp
|
16
|
+
/^\s* putl (?:\s+ (.+))? \s*$/x
|
17
|
+
end
|
18
|
+
|
19
|
+
def execute
|
20
|
+
out = StringIO.new
|
21
|
+
run_with_binding do |b|
|
22
|
+
res = eval_with_setting(b, @match[1], Setting[:stack_on_error])
|
23
|
+
|
24
|
+
if res.is_a?(Array)
|
25
|
+
puts "#{columnize(res.map(&:to_s), Setting[:width])}"
|
26
|
+
else
|
27
|
+
PP.pp(res, out)
|
28
|
+
puts out.string
|
29
|
+
end
|
30
|
+
end
|
31
|
+
rescue
|
32
|
+
out.puts $ERROR_INFO.message
|
33
|
+
end
|
34
|
+
|
35
|
+
def description
|
36
|
+
<<-EOD
|
37
|
+
putl <expression>
|
38
|
+
|
39
|
+
Evaluates <expression>, an array, and columnize its value.
|
40
|
+
EOD
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
data/lib/byebug/commands/quit.rb
CHANGED
@@ -19,20 +19,16 @@ module Byebug
|
|
19
19
|
exit! # exit -> exit!: No graceful way to stop...
|
20
20
|
end
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
end
|
22
|
+
def description
|
23
|
+
<<-EOD
|
24
|
+
q[uit] [!|unconditionally]
|
26
25
|
|
27
|
-
|
28
|
-
prettify <<-EOD
|
29
|
-
q[uit] [!|unconditionally] Exits from byebug.
|
26
|
+
Exits from byebug.
|
30
27
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
end
|
28
|
+
Normally we prompt before exiting. However if the parameter
|
29
|
+
"unconditionally" is given or command is suffixed with !, we exit
|
30
|
+
without asking further questions.
|
31
|
+
EOD
|
36
32
|
end
|
37
33
|
end
|
38
34
|
end
|
@@ -29,19 +29,13 @@ module Byebug
|
|
29
29
|
exec(cmd)
|
30
30
|
end
|
31
31
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
end
|
36
|
-
|
37
|
-
def description
|
38
|
-
prettify <<-EOD
|
39
|
-
restart|R [args]
|
32
|
+
def description
|
33
|
+
<<-EOD
|
34
|
+
restart|R [args]
|
40
35
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
end
|
36
|
+
Restart the program. This is a re-exec - all byebug state
|
37
|
+
is lost. If command arguments are passed those are used.
|
38
|
+
EOD
|
45
39
|
end
|
46
40
|
end
|
47
41
|
end
|
data/lib/byebug/commands/save.rb
CHANGED
@@ -1,45 +1,18 @@
|
|
1
1
|
require 'byebug/command'
|
2
2
|
|
3
3
|
module Byebug
|
4
|
-
#
|
5
|
-
# Default file where commands are saved
|
6
|
-
#
|
7
|
-
RESTART_FILE = '.byebug-save'
|
8
|
-
|
9
4
|
#
|
10
5
|
# Save current settings to use them in another debug session.
|
11
6
|
#
|
12
7
|
class SaveCommand < Command
|
13
8
|
self.allow_in_control = true
|
14
9
|
|
15
|
-
def save_breakpoints(file)
|
16
|
-
Byebug.breakpoints.each do |b|
|
17
|
-
file.puts "break #{b.source}:#{b.pos}#{" if #{b.expr}" if b.expr}"
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def save_catchpoints(file)
|
22
|
-
Byebug.catchpoints.keys.each do |c|
|
23
|
-
file.puts "catch #{c}"
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def save_displays(file)
|
28
|
-
@state.display.each { |d| file.puts "display #{d[1]}" if d[0] }
|
29
|
-
end
|
30
|
-
|
31
|
-
def save_settings(file)
|
32
|
-
%w(autoeval autoirb autolist basename).each do |setting|
|
33
|
-
file.puts "set #{setting} #{Setting[setting.to_sym]}"
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
10
|
def regexp
|
38
11
|
/^\s* sa(?:ve)? (?:\s+(\S+))? \s*$/x
|
39
12
|
end
|
40
13
|
|
41
14
|
def execute
|
42
|
-
file = File.open(@match[1] ||
|
15
|
+
file = File.open(@match[1] || Setting[:savefile], 'w')
|
43
16
|
|
44
17
|
save_breakpoints(file)
|
45
18
|
save_catchpoints(file)
|
@@ -50,21 +23,39 @@ module Byebug
|
|
50
23
|
file.close
|
51
24
|
end
|
52
25
|
|
53
|
-
|
54
|
-
|
55
|
-
|
26
|
+
def description
|
27
|
+
<<-EOD
|
28
|
+
save[ FILE]
|
29
|
+
|
30
|
+
Saves current byebug state to FILE as a script file. This includes
|
31
|
+
breakpoints, catchpoints, display expressions and some settings. If no
|
32
|
+
filename is given, we will fabricate one.
|
33
|
+
|
34
|
+
Use the "source" command in another debug session to restore them.
|
35
|
+
EOD
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
def save_breakpoints(file)
|
41
|
+
Byebug.breakpoints.each do |b|
|
42
|
+
file.puts "break #{b.source}:#{b.pos}#{" if #{b.expr}" if b.expr}"
|
56
43
|
end
|
44
|
+
end
|
57
45
|
|
58
|
-
|
59
|
-
|
60
|
-
|
46
|
+
def save_catchpoints(file)
|
47
|
+
Byebug.catchpoints.keys.each do |c|
|
48
|
+
file.puts "catch #{c}"
|
49
|
+
end
|
50
|
+
end
|
61
51
|
|
62
|
-
|
63
|
-
|
64
|
-
|
52
|
+
def save_displays(file)
|
53
|
+
@state.display.each { |d| file.puts "display #{d[1]}" if d[0] }
|
54
|
+
end
|
65
55
|
|
66
|
-
|
67
|
-
|
56
|
+
def save_settings(file)
|
57
|
+
%w(autoeval autoirb autolist basename).each do |setting|
|
58
|
+
file.puts "set #{setting} #{Setting[setting.to_sym]}"
|
68
59
|
end
|
69
60
|
end
|
70
61
|
end
|
data/lib/byebug/commands/set.rb
CHANGED
@@ -1,10 +1,13 @@
|
|
1
1
|
require 'byebug/command'
|
2
|
+
require 'byebug/helpers/parse'
|
2
3
|
|
3
4
|
module Byebug
|
4
5
|
#
|
5
6
|
# Change byebug settings.
|
6
7
|
#
|
7
8
|
class SetCommand < Command
|
9
|
+
include Helpers::ParseHelper
|
10
|
+
|
8
11
|
self.allow_in_control = true
|
9
12
|
|
10
13
|
def regexp
|
@@ -12,14 +15,15 @@ module Byebug
|
|
12
15
|
end
|
13
16
|
|
14
17
|
def execute
|
15
|
-
key
|
16
|
-
|
18
|
+
key = @match[:setting]
|
19
|
+
value = @match[:value]
|
20
|
+
return puts(help) if key.nil? && value.nil?
|
17
21
|
|
18
22
|
setting = Setting.find(key)
|
19
23
|
return errmsg(pr('set.errors.unknown_setting', key: key)) unless setting
|
20
24
|
|
21
25
|
if !setting.boolean? && value.nil?
|
22
|
-
|
26
|
+
err = pr('set.errors.must_specify_value', key: key)
|
23
27
|
elsif setting.boolean?
|
24
28
|
value, err = get_onoff(value, key =~ /^no/ ? false : true)
|
25
29
|
elsif setting.integer?
|
@@ -45,28 +49,22 @@ module Byebug
|
|
45
49
|
end
|
46
50
|
end
|
47
51
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
end
|
52
|
-
|
53
|
-
def description
|
54
|
-
prettify <<-EOD
|
55
|
-
set <setting> <value>
|
52
|
+
def help
|
53
|
+
description + Setting.help_all
|
54
|
+
end
|
56
55
|
|
57
|
-
|
56
|
+
def description
|
57
|
+
<<-EOD
|
58
|
+
set <setting> <value>
|
58
59
|
|
59
|
-
|
60
|
-
don't specify a value, the boolean setting will be enabled.
|
61
|
-
Conversely, you can use "set no<setting> to disable them.
|
60
|
+
Modifies parts of byebug environment.
|
62
61
|
|
63
|
-
|
64
|
-
|
65
|
-
|
62
|
+
Boolean values take "on", "off", "true", "false", "1" or "0". If you
|
63
|
+
don't specify a value, the boolean setting will be enabled. Conversely,
|
64
|
+
you can use "set no<setting>" to disable them.
|
66
65
|
|
67
|
-
|
68
|
-
|
69
|
-
end
|
66
|
+
You can see these environment settings with the "show" command.
|
67
|
+
EOD
|
70
68
|
end
|
71
69
|
end
|
72
70
|
end
|
data/lib/byebug/commands/show.rb
CHANGED
@@ -13,7 +13,7 @@ module Byebug
|
|
13
13
|
|
14
14
|
def execute
|
15
15
|
key = @match[:setting]
|
16
|
-
return puts(
|
16
|
+
return puts(help) unless key
|
17
17
|
|
18
18
|
setting = Setting.find(key)
|
19
19
|
return errmsg(pr('show.errors.unknown_setting', key: key)) unless setting
|
@@ -21,23 +21,17 @@ module Byebug
|
|
21
21
|
puts Setting.settings[setting.to_sym]
|
22
22
|
end
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
end
|
28
|
-
|
29
|
-
def description
|
30
|
-
prettify <<-EOD
|
31
|
-
show <setting> <value>
|
24
|
+
def help
|
25
|
+
description + Setting.help_all
|
26
|
+
end
|
32
27
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
end
|
28
|
+
def description
|
29
|
+
<<-EOD
|
30
|
+
show <setting> <value>
|
37
31
|
|
38
|
-
|
39
|
-
|
40
|
-
|
32
|
+
Generic command for showing byebug settings. You can change them with
|
33
|
+
the "set" command.
|
34
|
+
EOD
|
41
35
|
end
|
42
36
|
end
|
43
37
|
end
|
@@ -14,7 +14,7 @@ module Byebug
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def execute
|
17
|
-
return puts(
|
17
|
+
return puts(help) unless @match[1]
|
18
18
|
|
19
19
|
unless @state && @state.interface
|
20
20
|
return errmsg(pr('source.errors.not_available'))
|
@@ -28,18 +28,12 @@ module Byebug
|
|
28
28
|
@state.interface.read_file(file)
|
29
29
|
end
|
30
30
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
end
|
35
|
-
|
36
|
-
def description
|
37
|
-
prettify <<-EOD
|
38
|
-
source <file>
|
31
|
+
def description
|
32
|
+
<<-EOD
|
33
|
+
source <file>
|
39
34
|
|
40
|
-
|
41
|
-
|
42
|
-
end
|
35
|
+
Executes file <file> containing byebug commands.
|
36
|
+
EOD
|
43
37
|
end
|
44
38
|
end
|
45
39
|
end
|