byebug 9.1.0 → 10.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (129) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +24 -3
  3. data/CONTRIBUTING.md +39 -18
  4. data/GUIDE.md +16 -17
  5. data/README.md +64 -52
  6. data/exe/byebug +6 -0
  7. data/ext/byebug/breakpoint.c +1 -1
  8. data/ext/byebug/byebug.c +16 -16
  9. data/ext/byebug/byebug.h +40 -26
  10. data/ext/byebug/context.c +26 -26
  11. data/ext/byebug/extconf.rb +7 -5
  12. data/ext/byebug/threads.c +8 -8
  13. data/lib/byebug.rb +3 -1
  14. data/lib/byebug/attacher.rb +17 -3
  15. data/lib/byebug/breakpoint.rb +25 -3
  16. data/lib/byebug/command.rb +20 -14
  17. data/lib/byebug/command_list.rb +3 -1
  18. data/lib/byebug/commands.rb +39 -37
  19. data/lib/byebug/commands/break.rb +33 -15
  20. data/lib/byebug/commands/catch.rb +16 -14
  21. data/lib/byebug/commands/condition.rb +11 -9
  22. data/lib/byebug/commands/continue.rb +9 -7
  23. data/lib/byebug/commands/debug.rb +7 -5
  24. data/lib/byebug/commands/delete.rb +11 -9
  25. data/lib/byebug/commands/disable.rb +8 -6
  26. data/lib/byebug/commands/disable/breakpoints.rb +7 -5
  27. data/lib/byebug/commands/disable/display.rb +7 -5
  28. data/lib/byebug/commands/display.rb +11 -9
  29. data/lib/byebug/commands/down.rb +10 -8
  30. data/lib/byebug/commands/edit.rb +10 -8
  31. data/lib/byebug/commands/enable.rb +8 -6
  32. data/lib/byebug/commands/enable/breakpoints.rb +7 -5
  33. data/lib/byebug/commands/enable/display.rb +7 -5
  34. data/lib/byebug/commands/finish.rb +8 -6
  35. data/lib/byebug/commands/frame.rb +11 -9
  36. data/lib/byebug/commands/help.rb +7 -5
  37. data/lib/byebug/commands/history.rb +7 -5
  38. data/lib/byebug/commands/info.rb +11 -9
  39. data/lib/byebug/commands/info/breakpoints.rb +17 -11
  40. data/lib/byebug/commands/info/display.rb +16 -7
  41. data/lib/byebug/commands/info/file.rb +12 -10
  42. data/lib/byebug/commands/info/line.rb +5 -3
  43. data/lib/byebug/commands/info/program.rb +8 -6
  44. data/lib/byebug/commands/interrupt.rb +8 -4
  45. data/lib/byebug/commands/irb.rb +9 -7
  46. data/lib/byebug/commands/kill.rb +9 -7
  47. data/lib/byebug/commands/list.rb +41 -46
  48. data/lib/byebug/commands/method.rb +10 -8
  49. data/lib/byebug/commands/next.rb +8 -6
  50. data/lib/byebug/commands/pry.rb +10 -8
  51. data/lib/byebug/commands/quit.rb +7 -5
  52. data/lib/byebug/commands/restart.rb +13 -11
  53. data/lib/byebug/commands/save.rb +9 -7
  54. data/lib/byebug/commands/set.rb +12 -10
  55. data/lib/byebug/commands/show.rb +7 -5
  56. data/lib/byebug/commands/source.rb +7 -5
  57. data/lib/byebug/commands/step.rb +8 -6
  58. data/lib/byebug/commands/thread.rb +11 -9
  59. data/lib/byebug/commands/thread/current.rb +6 -4
  60. data/lib/byebug/commands/thread/list.rb +7 -5
  61. data/lib/byebug/commands/thread/resume.rb +7 -5
  62. data/lib/byebug/commands/thread/stop.rb +6 -4
  63. data/lib/byebug/commands/thread/switch.rb +6 -4
  64. data/lib/byebug/commands/tracevar.rb +10 -8
  65. data/lib/byebug/commands/undisplay.rb +10 -8
  66. data/lib/byebug/commands/untracevar.rb +8 -6
  67. data/lib/byebug/commands/up.rb +10 -8
  68. data/lib/byebug/commands/var.rb +12 -10
  69. data/lib/byebug/commands/var/all.rb +7 -5
  70. data/lib/byebug/commands/var/args.rb +6 -4
  71. data/lib/byebug/commands/var/const.rb +9 -7
  72. data/lib/byebug/commands/var/global.rb +5 -3
  73. data/lib/byebug/commands/var/instance.rb +6 -4
  74. data/lib/byebug/commands/var/local.rb +6 -4
  75. data/lib/byebug/commands/where.rb +9 -7
  76. data/lib/byebug/context.rb +7 -5
  77. data/lib/byebug/core.rb +25 -25
  78. data/lib/byebug/errors.rb +4 -2
  79. data/lib/byebug/frame.rb +16 -16
  80. data/lib/byebug/helpers/bin.rb +28 -7
  81. data/lib/byebug/helpers/eval.rb +8 -6
  82. data/lib/byebug/helpers/file.rb +4 -2
  83. data/lib/byebug/helpers/frame.rb +5 -3
  84. data/lib/byebug/helpers/parse.rb +5 -3
  85. data/lib/byebug/helpers/path.rb +7 -5
  86. data/lib/byebug/helpers/reflection.rb +2 -0
  87. data/lib/byebug/helpers/string.rb +4 -2
  88. data/lib/byebug/helpers/thread.rb +10 -8
  89. data/lib/byebug/helpers/toggle.rb +10 -8
  90. data/lib/byebug/helpers/var.rb +8 -6
  91. data/lib/byebug/history.rb +7 -5
  92. data/lib/byebug/interface.rb +13 -11
  93. data/lib/byebug/interfaces/local_interface.rb +4 -4
  94. data/lib/byebug/interfaces/remote_interface.rb +21 -9
  95. data/lib/byebug/interfaces/script_interface.rb +2 -0
  96. data/lib/byebug/interfaces/test_interface.rb +5 -3
  97. data/lib/byebug/option_setter.rb +14 -12
  98. data/lib/byebug/printers/base.rb +6 -6
  99. data/lib/byebug/printers/plain.rb +8 -6
  100. data/lib/byebug/printers/texts/base.yml +3 -3
  101. data/lib/byebug/processors/command_processor.rb +11 -12
  102. data/lib/byebug/processors/control_processor.rb +4 -6
  103. data/lib/byebug/processors/post_mortem_processor.rb +4 -2
  104. data/lib/byebug/processors/script_processor.rb +7 -3
  105. data/lib/byebug/remote.rb +45 -65
  106. data/lib/byebug/remote/client.rb +55 -0
  107. data/lib/byebug/remote/server.rb +47 -0
  108. data/lib/byebug/runner.rb +26 -19
  109. data/lib/byebug/setting.rb +10 -4
  110. data/lib/byebug/settings/autoirb.rb +5 -3
  111. data/lib/byebug/settings/autolist.rb +5 -3
  112. data/lib/byebug/settings/autopry.rb +5 -3
  113. data/lib/byebug/settings/autosave.rb +4 -2
  114. data/lib/byebug/settings/basename.rb +4 -2
  115. data/lib/byebug/settings/callstyle.rb +3 -3
  116. data/lib/byebug/settings/fullpath.rb +4 -2
  117. data/lib/byebug/settings/histfile.rb +5 -3
  118. data/lib/byebug/settings/histsize.rb +4 -2
  119. data/lib/byebug/settings/linetrace.rb +4 -2
  120. data/lib/byebug/settings/listsize.rb +4 -2
  121. data/lib/byebug/settings/post_mortem.rb +4 -2
  122. data/lib/byebug/settings/savefile.rb +4 -2
  123. data/lib/byebug/settings/stack_on_error.rb +4 -2
  124. data/lib/byebug/settings/width.rb +3 -1
  125. data/lib/byebug/source_file_formatter.rb +71 -0
  126. data/lib/byebug/subcommands.rb +6 -4
  127. data/lib/byebug/version.rb +1 -1
  128. metadata +8 -5
  129. data/bin/byebug +0 -9
@@ -1,4 +1,6 @@
1
- require 'byebug/helpers/toggle'
1
+ # frozen_string_literal: true
2
+
3
+ require "byebug/helpers/toggle"
2
4
 
3
5
  module Byebug
4
6
  #
@@ -18,7 +20,7 @@ module Byebug
18
20
  end
19
21
 
20
22
  def self.description
21
- <<-EOD
23
+ <<-DESCRIPTION
22
24
  en[able] d[isplay][ <id1> <id2> .. <idn>]
23
25
 
24
26
  #{short_description}
@@ -26,15 +28,15 @@ module Byebug
26
28
  Arguments are the code numbers of the expressions to enable. Do "info
27
29
  display" to see the current list of code numbers. If no arguments are
28
30
  specified, all displays are enabled.
29
- EOD
31
+ DESCRIPTION
30
32
  end
31
33
 
32
34
  def self.short_description
33
- 'Enables expressions to be displayed when program stops.'
35
+ "Enables expressions to be displayed when program stops."
34
36
  end
35
37
 
36
38
  def execute
37
- enable_disable_display('enable', @match[1])
39
+ enable_disable_display("enable", @match[1])
38
40
  end
39
41
  end
40
42
  end
@@ -1,5 +1,7 @@
1
- require 'byebug/command'
2
- require 'byebug/helpers/parse'
1
+ # frozen_string_literal: true
2
+
3
+ require "byebug/command"
4
+ require "byebug/helpers/parse"
3
5
 
4
6
  module Byebug
5
7
  #
@@ -17,7 +19,7 @@ module Byebug
17
19
  end
18
20
 
19
21
  def self.description
20
- <<-EOD
22
+ <<-DESCRIPTION
21
23
  fin[ish][ n_frames]
22
24
 
23
25
  #{short_description}
@@ -25,16 +27,16 @@ module Byebug
25
27
  If no number is given, we run until the current frame returns. If a
26
28
  number of frames `n_frames` is given, then we run until `n_frames`
27
29
  return from the current position.
28
- EOD
30
+ DESCRIPTION
29
31
  end
30
32
 
31
33
  def self.short_description
32
- 'Runs the program until frame returns'
34
+ "Runs the program until frame returns"
33
35
  end
34
36
 
35
37
  def execute
36
38
  if @match[1]
37
- n_frames, err = get_int(@match[1], 'finish', 0, max_frames - 1)
39
+ n_frames, err = get_int(@match[1], "finish", 0, max_frames - 1)
38
40
  return errmsg(err) unless n_frames
39
41
  else
40
42
  n_frames = 1
@@ -1,7 +1,9 @@
1
- require 'pathname'
2
- require 'byebug/command'
3
- require 'byebug/helpers/frame'
4
- require 'byebug/helpers/parse'
1
+ # frozen_string_literal: true
2
+
3
+ require "pathname"
4
+ require "byebug/command"
5
+ require "byebug/helpers/frame"
6
+ require "byebug/helpers/parse"
5
7
 
6
8
  module Byebug
7
9
  #
@@ -18,7 +20,7 @@ module Byebug
18
20
  end
19
21
 
20
22
  def self.description
21
- <<-EOD
23
+ <<-DESCRIPTION
22
24
  f[rame][ frame-number]
23
25
 
24
26
  #{short_description}
@@ -34,17 +36,17 @@ module Byebug
34
36
  if there is a front end also watching over things.
35
37
 
36
38
  Use the "bt" command to find out where you want to go.
37
- EOD
39
+ DESCRIPTION
38
40
  end
39
41
 
40
42
  def self.short_description
41
- 'Moves to a frame in the call stack'
43
+ "Moves to a frame in the call stack"
42
44
  end
43
45
 
44
46
  def execute
45
- return print(pr('frame.line', context.frame.to_hash)) unless @match[1]
47
+ return print(pr("frame.line", context.frame.to_hash)) unless @match[1]
46
48
 
47
- pos, err = get_int(@match[1], 'Frame')
49
+ pos, err = get_int(@match[1], "Frame")
48
50
  return errmsg(err) unless pos
49
51
 
50
52
  switch_to_frame(pos)
@@ -1,5 +1,7 @@
1
- require 'byebug/command'
2
- require 'byebug/errors'
1
+ # frozen_string_literal: true
2
+
3
+ require "byebug/command"
4
+ require "byebug/errors"
3
5
 
4
6
  module Byebug
5
7
  #
@@ -14,7 +16,7 @@ module Byebug
14
16
  end
15
17
 
16
18
  def self.description
17
- <<-EOD
19
+ <<-DESCRIPTION
18
20
  h[elp][ <cmd>[ <subcmd>]]
19
21
 
20
22
  #{short_description}
@@ -22,11 +24,11 @@ module Byebug
22
24
  help -- prints a summary of all commands
23
25
  help <cmd> -- prints help on command <cmd>
24
26
  help <cmd> <subcmd> -- prints help on <cmd>'s subcommand <subcmd>
25
- EOD
27
+ DESCRIPTION
26
28
  end
27
29
 
28
30
  def self.short_description
29
- 'Helps you using byebug'
31
+ "Helps you using byebug"
30
32
  end
31
33
 
32
34
  def execute
@@ -1,5 +1,7 @@
1
- require 'byebug/command'
2
- require 'byebug/helpers/parse'
1
+ # frozen_string_literal: true
2
+
3
+ require "byebug/command"
4
+ require "byebug/helpers/parse"
3
5
 
4
6
  module Byebug
5
7
  #
@@ -15,11 +17,11 @@ module Byebug
15
17
  end
16
18
 
17
19
  def self.description
18
- <<-EOD
20
+ <<-DESCRIPTION
19
21
  hist[ory][ num_cmds]
20
22
 
21
23
  #{short_description}
22
- EOD
24
+ DESCRIPTION
23
25
  end
24
26
 
25
27
  def self.short_description
@@ -29,7 +31,7 @@ module Byebug
29
31
  def execute
30
32
  history = processor.interface.history
31
33
 
32
- size, = get_int(@match[:num_cmds], 'history', 1) if @match[:num_cmds]
34
+ size, = get_int(@match[:num_cmds], "history", 1) if @match[:num_cmds]
33
35
 
34
36
  puts history.to_s(size)
35
37
  end
@@ -1,10 +1,12 @@
1
- require 'byebug/subcommands'
1
+ # frozen_string_literal: true
2
2
 
3
- require 'byebug/commands/info/breakpoints'
4
- require 'byebug/commands/info/display'
5
- require 'byebug/commands/info/file'
6
- require 'byebug/commands/info/line'
7
- require 'byebug/commands/info/program'
3
+ require "byebug/subcommands"
4
+
5
+ require "byebug/commands/info/breakpoints"
6
+ require "byebug/commands/info/display"
7
+ require "byebug/commands/info/file"
8
+ require "byebug/commands/info/line"
9
+ require "byebug/commands/info/program"
8
10
 
9
11
  module Byebug
10
12
  #
@@ -21,15 +23,15 @@ module Byebug
21
23
  end
22
24
 
23
25
  def self.description
24
- <<-EOD
26
+ <<-DESCRIPTION
25
27
  info[ subcommand]
26
28
 
27
29
  #{short_description}
28
- EOD
30
+ DESCRIPTION
29
31
  end
30
32
 
31
33
  def self.short_description
32
- 'Shows several informations about the program being debugged'
34
+ "Shows several informations about the program being debugged"
33
35
  end
34
36
  end
35
37
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Byebug
2
4
  #
3
5
  # Reopens the +info+ command to define the +breakpoints+ subcommand
@@ -14,19 +16,19 @@ module Byebug
14
16
  end
15
17
 
16
18
  def self.description
17
- <<-EOD
19
+ <<-DESCRIPTION
18
20
  inf[o] b[reakpoints]
19
21
 
20
22
  #{short_description}
21
- EOD
23
+ DESCRIPTION
22
24
  end
23
25
 
24
26
  def self.short_description
25
- 'Status of user settable breakpoints'
27
+ "Status of user settable breakpoints"
26
28
  end
27
29
 
28
30
  def execute
29
- return puts('No breakpoints.') if Byebug.breakpoints.empty?
31
+ return puts("No breakpoints.") if Byebug.breakpoints.empty?
30
32
 
31
33
  breakpoints = Byebug.breakpoints.sort_by(&:id)
32
34
 
@@ -34,26 +36,30 @@ module Byebug
34
36
  indices = @match[1].split(/ +/).map(&:to_i)
35
37
  breakpoints = breakpoints.select { |b| indices.member?(b.id) }
36
38
  if breakpoints.empty?
37
- return errmsg('No breakpoints found among list given')
39
+ return errmsg("No breakpoints found among list given")
38
40
  end
39
41
  end
40
42
 
41
- puts 'Num Enb What'
43
+ puts "Num Enb What"
42
44
  breakpoints.each { |b| info_breakpoint(b) }
43
45
  end
44
46
 
45
47
  private
46
48
 
47
49
  def info_breakpoint(brkpt)
48
- expr = brkpt.expr.nil? ? '' : " if #{brkpt.expr}"
49
- y_n = brkpt.enabled? ? 'y' : 'n'
50
- interp = format('%-3d %-3s at %s:%s%s',
51
- brkpt.id, y_n, brkpt.source, brkpt.pos, expr)
50
+ interp = format(
51
+ "%-<id>3d %-<status>3s at %<file>s:%<line>s%<expression>s",
52
+ id: brkpt.id,
53
+ status: brkpt.enabled? ? "y" : "n",
54
+ file: brkpt.source,
55
+ line: brkpt.pos,
56
+ expression: brkpt.expr.nil? ? "" : " if #{brkpt.expr}"
57
+ )
52
58
  puts interp
53
59
  hits = brkpt.hit_count
54
60
  return unless hits > 0
55
61
 
56
- s = hits > 1 ? 's' : ''
62
+ s = hits > 1 ? "s" : ""
57
63
  puts " breakpoint already hit #{hits} time#{s}"
58
64
  end
59
65
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Byebug
2
4
  #
3
5
  # Reopens the +info+ command to define the +display+ subcommand
@@ -14,27 +16,34 @@ module Byebug
14
16
  end
15
17
 
16
18
  def self.description
17
- <<-EOD
19
+ <<-DESCRIPTION
18
20
  inf[o] d[display]
19
21
 
20
22
  #{short_description}
21
- EOD
23
+ DESCRIPTION
22
24
  end
23
25
 
24
26
  def self.short_description
25
- 'List of expressions to display when program stops'
27
+ "List of expressions to display when program stops"
26
28
  end
27
29
 
28
30
  def execute
29
31
  unless Byebug.displays.find { |d| d[0] }
30
- return puts('There are no auto-display expressions now.')
32
+ return puts("There are no auto-display expressions now.")
31
33
  end
32
34
 
33
- puts 'Auto-display expressions now in effect:'
34
- puts 'Num Enb Expression'
35
+ puts "Auto-display expressions now in effect:"
36
+ puts "Num Enb Expression"
35
37
 
36
38
  Byebug.displays.each_with_index do |d, i|
37
- puts(format('%3d: %s %s', i + 1, d[0] ? 'y' : 'n', d[1]))
39
+ interp = format(
40
+ "%<number>3d: %<status>s %<expression>s",
41
+ number: i + 1,
42
+ status: d[0] ? "y" : "n",
43
+ expression: d[1]
44
+ )
45
+
46
+ puts(interp)
38
47
  end
39
48
  end
40
49
  end
@@ -1,4 +1,6 @@
1
- require 'byebug/helpers/file'
1
+ # frozen_string_literal: true
2
+
3
+ require "byebug/helpers/file"
2
4
 
3
5
  module Byebug
4
6
  #
@@ -19,27 +21,27 @@ module Byebug
19
21
  end
20
22
 
21
23
  def self.description
22
- <<-EOD
24
+ <<-DESCRIPTION
23
25
  inf[o] f[ile]
24
26
 
25
27
  #{short_description}
26
28
 
27
29
  It informs about file name, number of lines, possible breakpoints in
28
30
  the file, last modification time and sha1 digest.
29
- EOD
31
+ DESCRIPTION
30
32
  end
31
33
 
32
34
  def self.short_description
33
- 'Information about a particular source file.'
35
+ "Information about a particular source file."
34
36
  end
35
37
 
36
38
  def execute
37
39
  file = @match[1] || frame.file
38
40
  unless File.exist?(file)
39
- return errmsg(pr('info.errors.undefined_file', file: file))
41
+ return errmsg(pr("info.errors.undefined_file", file: file))
40
42
  end
41
43
 
42
- puts prettify <<-EOC
44
+ puts prettify <<-RUBY
43
45
  File #{info_file_basic(file)}
44
46
 
45
47
  Breakpoint line numbers: #{info_file_breakpoints(file)}
@@ -47,7 +49,7 @@ module Byebug
47
49
  Modification time: #{info_file_mtime(file)}
48
50
 
49
51
  Sha1 Signature: #{info_file_sha1(file)}
50
- EOC
52
+ RUBY
51
53
  end
52
54
 
53
55
  private
@@ -56,7 +58,7 @@ module Byebug
56
58
  path = File.expand_path(file)
57
59
  return unless File.exist?(path)
58
60
 
59
- s = n_lines(path) == 1 ? '' : 's'
61
+ s = n_lines(path) == 1 ? "" : "s"
60
62
  "#{path} (#{n_lines(path)} line#{s})"
61
63
  end
62
64
 
@@ -64,7 +66,7 @@ module Byebug
64
66
  breakpoints = Breakpoint.potential_lines(file)
65
67
  return unless breakpoints
66
68
 
67
- breakpoints.to_a.sort.join(' ')
69
+ breakpoints.to_a.sort.join(" ")
68
70
  end
69
71
 
70
72
  def info_file_mtime(file)
@@ -72,7 +74,7 @@ module Byebug
72
74
  end
73
75
 
74
76
  def info_file_sha1(file)
75
- require 'digest/sha1'
77
+ require "digest/sha1"
76
78
  Digest::SHA1.hexdigest(file)
77
79
  end
78
80
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Byebug
2
4
  #
3
5
  # Reopens the +info+ command to define the +line+ subcommand
@@ -14,15 +16,15 @@ module Byebug
14
16
  end
15
17
 
16
18
  def self.description
17
- <<-EOD
19
+ <<-DESCRIPTION
18
20
  inf[o] l[ine]
19
21
 
20
22
  #{short_description}
21
- EOD
23
+ DESCRIPTION
22
24
  end
23
25
 
24
26
  def self.short_description
25
- 'Line number and file name of current position in source file.'
27
+ "Line number and file name of current position in source file."
26
28
  end
27
29
 
28
30
  def execute
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Byebug
2
4
  #
3
5
  # Reopens the +info+ command to define the +args+ subcommand
@@ -14,19 +16,19 @@ module Byebug
14
16
  end
15
17
 
16
18
  def self.description
17
- <<-EOD
19
+ <<-DESCRIPTION
18
20
  inf[o] p[rogram]
19
21
 
20
22
  #{short_description}
21
- EOD
23
+ DESCRIPTION
22
24
  end
23
25
 
24
26
  def self.short_description
25
- 'Information about the current status of the debugged program.'
27
+ "Information about the current status of the debugged program."
26
28
  end
27
29
 
28
30
  def execute
29
- puts 'Program stopped. '
31
+ puts "Program stopped. "
30
32
  format_stop_reason context.stop_reason
31
33
  end
32
34
 
@@ -37,9 +39,9 @@ module Byebug
37
39
  when :step
38
40
  puts "It stopped after stepping, next'ing or initial start."
39
41
  when :breakpoint
40
- puts 'It stopped at a breakpoint.'
42
+ puts "It stopped at a breakpoint."
41
43
  when :catchpoint
42
- puts 'It stopped at a catchpoint.'
44
+ puts "It stopped at a catchpoint."
43
45
  end
44
46
  end
45
47
  end