byebug 5.0.0 → 6.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (110) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +26 -1
  3. data/CONTRIBUTING.md +35 -13
  4. data/GUIDE.md +256 -198
  5. data/README.md +5 -11
  6. data/ext/byebug/byebug.c +5 -43
  7. data/ext/byebug/byebug.h +6 -1
  8. data/ext/byebug/context.c +4 -5
  9. data/lib/byebug/command.rb +64 -64
  10. data/lib/byebug/command_list.rb +32 -0
  11. data/lib/byebug/commands.rb +37 -0
  12. data/lib/byebug/commands/break.rb +45 -37
  13. data/lib/byebug/commands/catch.rb +52 -28
  14. data/lib/byebug/commands/condition.rb +19 -13
  15. data/lib/byebug/commands/continue.rb +15 -11
  16. data/lib/byebug/commands/delete.rb +18 -12
  17. data/lib/byebug/commands/disable.rb +9 -10
  18. data/lib/byebug/commands/disable/breakpoints.rb +13 -11
  19. data/lib/byebug/commands/disable/display.rb +13 -11
  20. data/lib/byebug/commands/display.rb +32 -24
  21. data/lib/byebug/commands/down.rb +18 -14
  22. data/lib/byebug/commands/edit.rb +42 -26
  23. data/lib/byebug/commands/enable.rb +9 -3
  24. data/lib/byebug/commands/enable/breakpoints.rb +13 -11
  25. data/lib/byebug/commands/enable/display.rb +13 -11
  26. data/lib/byebug/commands/finish.rb +23 -14
  27. data/lib/byebug/commands/frame.rb +21 -18
  28. data/lib/byebug/commands/help.rb +39 -16
  29. data/lib/byebug/commands/history.rb +16 -10
  30. data/lib/byebug/commands/info.rb +8 -5
  31. data/lib/byebug/commands/info/breakpoints.rb +16 -14
  32. data/lib/byebug/commands/info/display.rb +18 -18
  33. data/lib/byebug/commands/info/file.rb +22 -22
  34. data/lib/byebug/commands/info/line.rb +13 -11
  35. data/lib/byebug/commands/info/program.rb +13 -17
  36. data/lib/byebug/commands/interrupt.rb +13 -11
  37. data/lib/byebug/commands/irb.rb +16 -10
  38. data/lib/byebug/commands/kill.rb +19 -13
  39. data/lib/byebug/commands/list.rb +35 -24
  40. data/lib/byebug/commands/method.rb +25 -15
  41. data/lib/byebug/commands/next.rb +15 -13
  42. data/lib/byebug/commands/pry.rb +18 -11
  43. data/lib/byebug/commands/ps.rb +21 -23
  44. data/lib/byebug/commands/quit.rb +17 -11
  45. data/lib/byebug/commands/restart.rb +28 -24
  46. data/lib/byebug/commands/save.rb +23 -15
  47. data/lib/byebug/commands/set.rb +26 -19
  48. data/lib/byebug/commands/show.rb +20 -14
  49. data/lib/byebug/commands/source.rb +15 -14
  50. data/lib/byebug/commands/step.rb +15 -13
  51. data/lib/byebug/commands/thread.rb +8 -4
  52. data/lib/byebug/commands/thread/current.rb +11 -11
  53. data/lib/byebug/commands/thread/list.rb +14 -14
  54. data/lib/byebug/commands/thread/resume.rb +14 -14
  55. data/lib/byebug/commands/thread/stop.rb +14 -14
  56. data/lib/byebug/commands/thread/switch.rb +15 -14
  57. data/lib/byebug/commands/tracevar.rb +20 -16
  58. data/lib/byebug/commands/undisplay.rb +22 -18
  59. data/lib/byebug/commands/untracevar.rb +13 -11
  60. data/lib/byebug/commands/up.rb +18 -14
  61. data/lib/byebug/commands/var.rb +10 -3
  62. data/lib/byebug/commands/var/all.rb +15 -13
  63. data/lib/byebug/commands/var/args.rb +37 -0
  64. data/lib/byebug/commands/var/const.rb +25 -14
  65. data/lib/byebug/commands/var/global.rb +13 -11
  66. data/lib/byebug/commands/var/instance.rb +13 -11
  67. data/lib/byebug/commands/var/local.rb +13 -11
  68. data/lib/byebug/commands/where.rb +15 -11
  69. data/lib/byebug/context.rb +71 -73
  70. data/lib/byebug/core.rb +45 -26
  71. data/lib/byebug/errors.rb +27 -0
  72. data/lib/byebug/frame.rb +181 -0
  73. data/lib/byebug/helpers/eval.rb +67 -26
  74. data/lib/byebug/helpers/file.rb +18 -3
  75. data/lib/byebug/helpers/frame.rb +36 -39
  76. data/lib/byebug/helpers/parse.rb +15 -13
  77. data/lib/byebug/helpers/path.rb +21 -0
  78. data/lib/byebug/helpers/reflection.rb +17 -0
  79. data/lib/byebug/helpers/thread.rb +20 -14
  80. data/lib/byebug/helpers/toggle.rb +10 -5
  81. data/lib/byebug/helpers/var.rb +36 -15
  82. data/lib/byebug/interface.rb +27 -9
  83. data/lib/byebug/option_setter.rb +93 -0
  84. data/lib/byebug/printers/base.rb +3 -0
  85. data/lib/byebug/printers/plain.rb +4 -14
  86. data/lib/byebug/printers/texts/base.yml +2 -7
  87. data/lib/byebug/processors/command_processor.rb +101 -102
  88. data/lib/byebug/processors/control_processor.rb +20 -0
  89. data/lib/byebug/processors/post_mortem_processor.rb +16 -0
  90. data/lib/byebug/processors/script_processor.rb +49 -0
  91. data/lib/byebug/remote.rb +13 -7
  92. data/lib/byebug/runner.rb +39 -65
  93. data/lib/byebug/setting.rb +4 -1
  94. data/lib/byebug/settings/post_mortem.rb +0 -16
  95. data/lib/byebug/settings/savefile.rb +1 -4
  96. data/lib/byebug/subcommands.rb +27 -29
  97. data/lib/byebug/version.rb +4 -1
  98. metadata +14 -29
  99. data/lib/byebug/commands/eval.rb +0 -43
  100. data/lib/byebug/commands/info/args.rb +0 -39
  101. data/lib/byebug/commands/info/catch.rb +0 -39
  102. data/lib/byebug/commands/pp.rb +0 -41
  103. data/lib/byebug/commands/putl.rb +0 -43
  104. data/lib/byebug/processor.rb +0 -43
  105. data/lib/byebug/processors/control_command_processor.rb +0 -48
  106. data/lib/byebug/settings/verbose.rb +0 -20
  107. data/lib/byebug/state.rb +0 -12
  108. data/lib/byebug/states/control_state.rb +0 -26
  109. data/lib/byebug/states/regular_state.rb +0 -187
  110. data/lib/byebug/subcommand_list.rb +0 -33
@@ -5,14 +5,28 @@ module Byebug
5
5
  # Show (and possibily stop) at every line that changes a global variable.
6
6
  #
7
7
  class TracevarCommand < Command
8
- self.allow_in_post_mortem = false
9
-
10
- def regexp
8
+ def self.regexp
11
9
  /^\s* tr(?:acevar)? (?: \s+ (\S+))? # (variable-name)?
12
10
  (?: \s+ (stop|nostop))?
13
11
  \s*$/x
14
12
  end
15
13
 
14
+ def self.description
15
+ <<-EOD
16
+ tr[acevar] <variable> [[no]stop]
17
+
18
+ #{short_description}
19
+
20
+ If "stop" is specified, execution will stop every time the variable
21
+ changes its value. If nothing or "nostop" is specified, execution won't
22
+ stop, changes will just be logged in byebug's output.
23
+ EOD
24
+ end
25
+
26
+ def self.short_description
27
+ 'Enables tracing of a global variable'
28
+ end
29
+
16
30
  def execute
17
31
  var = @match[1]
18
32
  return errmsg(pr('trace.errors.needs_global_variable')) unless var
@@ -30,22 +44,12 @@ module Byebug
30
44
  puts pr('trace.messages.success', var: var)
31
45
  end
32
46
 
47
+ private
48
+
33
49
  def on_change(name, value, stop)
34
50
  puts pr('trace.messages.on_change', name: name, value: value)
35
51
 
36
- @state.context.step_out(1, false) if stop
37
- end
38
-
39
- def description
40
- <<-EOD
41
- tr[acevar] <variable> [[no]stop]
42
-
43
- Start tracing variable <variable>.
44
-
45
- If "stop" is specified, execution will stop every time the variable
46
- changes its value. If nothing or "nostop" is specified, execution won't
47
- stop, changes will just be logged in byebug's output.
48
- EOD
52
+ context.step_out(1, false) if stop
49
53
  end
50
54
  end
51
55
  end
@@ -8,39 +8,43 @@ module Byebug
8
8
  class UndisplayCommand < Command
9
9
  include Helpers::ParseHelper
10
10
 
11
- self.allow_in_post_mortem = false
11
+ self.allow_in_post_mortem = true
12
12
 
13
- def regexp
13
+ def self.regexp
14
14
  /^\s* undisp(?:lay)? (?:\s+(\S+))? \s*$/x
15
15
  end
16
16
 
17
+ def self.description
18
+ <<-EOD
19
+ undisp[lay][ nnn]
20
+
21
+ #{short_description}
22
+
23
+ Arguments are the code numbers of the expressions to stop displaying. No
24
+ argument means cancel all automatic-display expressions. Type "info
25
+ display" to see the current list of code numbers.
26
+ EOD
27
+ end
28
+
29
+ def self.short_description
30
+ 'Stops displaying all or some expressions when program stops'
31
+ end
32
+
17
33
  def execute
18
34
  if @match[1]
19
- pos, err = get_int(@match[1], 'Undisplay', 1, @state.display.size)
35
+ pos, err = get_int(@match[1], 'Undisplay', 1, Byebug.displays.size)
20
36
  return errmsg(err) unless err.nil?
21
37
 
22
- unless @state.display[pos - 1]
38
+ unless Byebug.displays[pos - 1]
23
39
  return errmsg(pr('display.errors.undefined', expr: pos))
24
40
  end
25
41
 
26
- @state.display[pos - 1][0] = nil
42
+ Byebug.displays[pos - 1][0] = nil
27
43
  else
28
44
  return unless confirm(pr('display.confirmations.clear_all'))
29
45
 
30
- @state.display.each { |d| d[0] = false }
46
+ Byebug.displays.each { |d| d[0] = false }
31
47
  end
32
48
  end
33
-
34
- def description
35
- <<-EOD
36
- undisp[lay][ nnn]
37
-
38
- Cancel some expressions to be displayed when program stops. Arguments
39
- are the code numbers of the expressions to stop displaying. No argument
40
- means cancel all automatic-display expressions. "delete display" has the
41
- same effect as this command. Do "info display" to see the current list
42
- of code numbers.
43
- EOD
44
- end
45
49
  end
46
50
  end
@@ -5,12 +5,22 @@ module Byebug
5
5
  # Stop tracing a global variable.
6
6
  #
7
7
  class UntracevarCommand < Command
8
- self.allow_in_post_mortem = false
9
-
10
- def regexp
8
+ def self.regexp
11
9
  /^\s* untr(?:acevar)? (?:\s+ (\S+))? \s*$/x
12
10
  end
13
11
 
12
+ def self.description
13
+ <<-EOD
14
+ untr[acevar] <variable>
15
+
16
+ #{short_description}
17
+ EOD
18
+ end
19
+
20
+ def self.short_description
21
+ 'Stops tracing a global variable'
22
+ end
23
+
14
24
  def execute
15
25
  var = @match[1]
16
26
  if global_variables.include?(:"#{var}")
@@ -20,13 +30,5 @@ module Byebug
20
30
  errmsg pr('trace.errors.not_global', var: var)
21
31
  end
22
32
  end
23
-
24
- def description
25
- <<-EOD
26
- untr[acevar] <variable>
27
-
28
- Stop tracing global variable <variable>.
29
- EOD
30
- end
31
33
  end
32
34
  end
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  require 'pathname'
4
2
  require 'byebug/command'
5
3
  require 'byebug/helpers/frame'
@@ -13,27 +11,33 @@ module Byebug
13
11
  include Helpers::FrameHelper
14
12
  include Helpers::ParseHelper
15
13
 
16
- def regexp
17
- /^\s* u(?:p)? (?:\s+(\S+))? \s*$/x
18
- end
14
+ self.allow_in_post_mortem = true
19
15
 
20
- def execute
21
- pos, err = parse_steps(@match[1], 'Up')
22
- return errmsg(err) unless pos
23
-
24
- adjust_frame(pos, false)
25
-
26
- ListCommand.new(@state).execute if Setting[:autolist]
16
+ def self.regexp
17
+ /^\s* u(?:p)? (?:\s+(\S+))? \s*$/x
27
18
  end
28
19
 
29
- def description
20
+ def self.description
30
21
  <<-EOD
31
22
  up[ count]
32
23
 
33
- Move to a higher frame in the stack trace.
24
+ #{short_description}
34
25
 
35
26
  Use the "bt" command to find out where you want to go.
36
27
  EOD
37
28
  end
29
+
30
+ def self.short_description
31
+ 'Moves to a higher frame in the stack trace'
32
+ end
33
+
34
+ def execute
35
+ pos, err = parse_steps(@match[1], 'Up')
36
+ return errmsg(err) unless pos
37
+
38
+ jump_frames(pos)
39
+
40
+ ListCommand.new(processor).execute if Setting[:autolist]
41
+ end
38
42
  end
39
43
  end
@@ -1,6 +1,7 @@
1
1
  require 'byebug/subcommands'
2
2
 
3
3
  require 'byebug/commands/var/all'
4
+ require 'byebug/commands/var/args'
4
5
  require 'byebug/commands/var/const'
5
6
  require 'byebug/commands/var/instance'
6
7
  require 'byebug/commands/var/local'
@@ -13,16 +14,22 @@ module Byebug
13
14
  class VarCommand < Command
14
15
  include Subcommands
15
16
 
16
- def regexp
17
+ self.allow_in_post_mortem = true
18
+
19
+ def self.regexp
17
20
  /^\s* v(?:ar)? (?:\s+ (.+))? \s*$/x
18
21
  end
19
22
 
20
- def description
23
+ def self.description
21
24
  <<-EOD
22
25
  [v]ar <subcommand>
23
26
 
24
- Shows variables and its values.
27
+ #{short_description}
25
28
  EOD
26
29
  end
30
+
31
+ def self.short_description
32
+ 'Shows variables and its values'
33
+ end
27
34
  end
28
35
  end
@@ -8,30 +8,32 @@ module Byebug
8
8
  #
9
9
  # Shows global, instance and local variables
10
10
  #
11
- class AllSubcommand < Command
11
+ class AllCommand < Command
12
12
  include Helpers::VarHelper
13
13
 
14
- def regexp
15
- /^\s* a(?:ll)? \s*$/x
16
- end
17
-
18
- def execute
19
- var_global
20
- var_instance('self')
21
- var_local
22
- end
14
+ self.allow_in_post_mortem = true
23
15
 
24
- def short_description
25
- 'Shows local, global and instance variables of self.'
16
+ def self.regexp
17
+ /^\s* a(?:ll)? \s*$/x
26
18
  end
27
19
 
28
- def description
20
+ def self.description
29
21
  <<-EOD
30
22
  v[ar] a[ll]
31
23
 
32
24
  #{short_description}
33
25
  EOD
34
26
  end
27
+
28
+ def self.short_description
29
+ 'Shows local, global and instance variables of self.'
30
+ end
31
+
32
+ def execute
33
+ var_global
34
+ var_instance('self')
35
+ var_local
36
+ end
35
37
  end
36
38
  end
37
39
  end
@@ -0,0 +1,37 @@
1
+ require 'byebug/helpers/var'
2
+
3
+ module Byebug
4
+ #
5
+ # Reopens the +var+ command to define the +args+ subcommand
6
+ #
7
+ class VarCommand < Command
8
+ #
9
+ # Information about arguments of the current method/block
10
+ #
11
+ class ArgsCommand < Command
12
+ include Helpers::VarHelper
13
+
14
+ self.allow_in_post_mortem = true
15
+
16
+ def self.regexp
17
+ /^\s* a(?:rgs)? \s*$/x
18
+ end
19
+
20
+ def self.description
21
+ <<-EOD
22
+ v[ar] a[args]
23
+
24
+ #{short_description}
25
+ EOD
26
+ end
27
+
28
+ def self.short_description
29
+ 'Information about arguments of the current scope'
30
+ end
31
+
32
+ def execute
33
+ var_args
34
+ end
35
+ end
36
+ end
37
+ end
@@ -1,3 +1,5 @@
1
+ require 'byebug/helpers/eval'
2
+
1
3
  module Byebug
2
4
  #
3
5
  # Reopens the +var+ command to define the +const+ subcommand
@@ -6,32 +8,41 @@ module Byebug
6
8
  #
7
9
  # Shows constants
8
10
  #
9
- class ConstSubcommand < Command
10
- def regexp
11
+ class ConstCommand < Command
12
+ include Helpers::EvalHelper
13
+
14
+ self.allow_in_post_mortem = true
15
+
16
+ def self.regexp
11
17
  /^\s* c(?:onst)? (?:\s+ (.+))? \s*$/x
12
18
  end
13
19
 
20
+ def self.description
21
+ <<-EOD
22
+ v[ar] c[onstant]
23
+
24
+ #{short_description}
25
+ EOD
26
+ end
27
+
28
+ def self.short_description
29
+ 'Shows constants of an object.'
30
+ end
31
+
14
32
  def execute
15
- str_obj = @match[1] || 'self.class'
16
- obj = bb_warning_eval(str_obj)
33
+ obj = single_thread_eval(str_obj)
17
34
  unless obj.is_a?(Module)
18
35
  return errmsg(pr('variable.errors.not_module', object: str_obj))
19
36
  end
20
37
 
21
- constants = bb_eval("#{str_obj}.constants")
38
+ constants = single_thread_eval("#{str_obj}.constants")
22
39
  puts prv(constants.sort.map { |c| [c, obj.const_get(c)] }, 'constant')
23
40
  end
24
41
 
25
- def short_description
26
- 'Shows constants of an object.'
27
- end
28
-
29
- def description
30
- <<-EOD
31
- v[ar] c[onstant]
42
+ private
32
43
 
33
- #{short_description}
34
- EOD
44
+ def str_obj
45
+ @str_obj ||= @match[1] || 'self.class'
35
46
  end
36
47
  end
37
48
  end
@@ -6,28 +6,30 @@ module Byebug
6
6
  #
7
7
  # Shows global variables
8
8
  #
9
- class GlobalSubcommand < Command
9
+ class GlobalCommand < Command
10
10
  include Helpers::VarHelper
11
11
 
12
- def regexp
13
- /^\s* g(?:lobal)? \s*$/x
14
- end
15
-
16
- def execute
17
- var_global
18
- end
12
+ self.allow_in_post_mortem = true
19
13
 
20
- def short_description
21
- 'Shows global variables.'
14
+ def self.regexp
15
+ /^\s* g(?:lobal)? \s*$/x
22
16
  end
23
17
 
24
- def description
18
+ def self.description
25
19
  <<-EOD
26
20
  v[ar] g[lobal]
27
21
 
28
22
  #{short_description}
29
23
  EOD
30
24
  end
25
+
26
+ def self.short_description
27
+ 'Shows global variables.'
28
+ end
29
+
30
+ def execute
31
+ var_global
32
+ end
31
33
  end
32
34
  end
33
35
  end
@@ -8,28 +8,30 @@ module Byebug
8
8
  #
9
9
  # Shows instance variables
10
10
  #
11
- class InstanceSubcommand < Command
11
+ class InstanceCommand < Command
12
12
  include Helpers::VarHelper
13
13
 
14
- def regexp
15
- /^\s* i(?:nstance)? (?:\s+ (.+))? \s*$/x
16
- end
17
-
18
- def execute
19
- var_instance(@match[1])
20
- end
14
+ self.allow_in_post_mortem = true
21
15
 
22
- def short_description
23
- 'Shows instance variables of self or a specific object.'
16
+ def self.regexp
17
+ /^\s* i(?:nstance)? (?:\s+ (.+))? \s*$/x
24
18
  end
25
19
 
26
- def description
20
+ def self.description
27
21
  <<-EOD
28
22
  v[ar] i[nstance][ <object>]
29
23
 
30
24
  #{short_description}
31
25
  EOD
32
26
  end
27
+
28
+ def self.short_description
29
+ 'Shows instance variables of self or a specific object.'
30
+ end
31
+
32
+ def execute
33
+ var_instance(@match[1])
34
+ end
33
35
  end
34
36
  end
35
37
  end