byebug 9.0.5 → 11.1.3

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.
Files changed (133) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +399 -264
  3. data/CONTRIBUTING.md +12 -19
  4. data/GUIDE.md +40 -26
  5. data/LICENSE +18 -18
  6. data/README.md +103 -74
  7. data/exe/byebug +6 -0
  8. data/ext/byebug/breakpoint.c +2 -2
  9. data/ext/byebug/byebug.c +26 -31
  10. data/ext/byebug/byebug.h +44 -28
  11. data/ext/byebug/context.c +45 -32
  12. data/ext/byebug/extconf.rb +7 -5
  13. data/ext/byebug/locker.c +4 -4
  14. data/ext/byebug/threads.c +12 -12
  15. data/lib/byebug/attacher.rb +18 -4
  16. data/lib/byebug/breakpoint.rb +26 -6
  17. data/lib/byebug/command.rb +20 -14
  18. data/lib/byebug/command_list.rb +3 -1
  19. data/lib/byebug/commands/break.rb +36 -22
  20. data/lib/byebug/commands/catch.rb +16 -18
  21. data/lib/byebug/commands/condition.rb +11 -11
  22. data/lib/byebug/commands/continue.rb +32 -12
  23. data/lib/byebug/commands/debug.rb +7 -5
  24. data/lib/byebug/commands/delete.rb +13 -11
  25. data/lib/byebug/commands/disable/breakpoints.rb +7 -5
  26. data/lib/byebug/commands/disable/display.rb +7 -5
  27. data/lib/byebug/commands/disable.rb +8 -6
  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 +11 -8
  31. data/lib/byebug/commands/enable/breakpoints.rb +7 -5
  32. data/lib/byebug/commands/enable/display.rb +7 -5
  33. data/lib/byebug/commands/enable.rb +8 -6
  34. data/lib/byebug/commands/finish.rb +9 -7
  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/breakpoints.rb +18 -14
  39. data/lib/byebug/commands/info/display.rb +16 -9
  40. data/lib/byebug/commands/info/file.rb +13 -14
  41. data/lib/byebug/commands/info/line.rb +5 -3
  42. data/lib/byebug/commands/info/program.rb +8 -6
  43. data/lib/byebug/commands/info.rb +11 -9
  44. data/lib/byebug/commands/interrupt.rb +8 -4
  45. data/lib/byebug/commands/irb.rb +13 -12
  46. data/lib/byebug/commands/kill.rb +11 -11
  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 -10
  51. data/lib/byebug/commands/quit.rb +10 -8
  52. data/lib/byebug/commands/restart.rb +30 -11
  53. data/lib/byebug/commands/save.rb +10 -8
  54. data/lib/byebug/commands/set.rb +13 -11
  55. data/lib/byebug/commands/show.rb +7 -5
  56. data/lib/byebug/commands/skip.rb +85 -0
  57. data/lib/byebug/commands/source.rb +7 -7
  58. data/lib/byebug/commands/step.rb +8 -6
  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 -7
  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/thread.rb +11 -9
  65. data/lib/byebug/commands/tracevar.rb +10 -11
  66. data/lib/byebug/commands/undisplay.rb +12 -11
  67. data/lib/byebug/commands/untracevar.rb +8 -6
  68. data/lib/byebug/commands/up.rb +10 -8
  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 -9
  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/var.rb +12 -10
  76. data/lib/byebug/commands/where.rb +9 -7
  77. data/lib/byebug/commands.rb +40 -37
  78. data/lib/byebug/context.rb +7 -5
  79. data/lib/byebug/core.rb +26 -25
  80. data/lib/byebug/errors.rb +4 -2
  81. data/lib/byebug/frame.rb +19 -22
  82. data/lib/byebug/helpers/bin.rb +47 -0
  83. data/lib/byebug/helpers/eval.rb +15 -13
  84. data/lib/byebug/helpers/file.rb +6 -4
  85. data/lib/byebug/helpers/frame.rb +7 -5
  86. data/lib/byebug/helpers/parse.rb +5 -5
  87. data/lib/byebug/helpers/path.rb +9 -11
  88. data/lib/byebug/helpers/reflection.rb +2 -0
  89. data/lib/byebug/helpers/string.rb +11 -2
  90. data/lib/byebug/helpers/thread.rb +10 -8
  91. data/lib/byebug/helpers/toggle.rb +28 -27
  92. data/lib/byebug/helpers/var.rb +9 -7
  93. data/lib/byebug/history.rb +20 -11
  94. data/lib/byebug/interface.rb +13 -11
  95. data/lib/byebug/interfaces/local_interface.rb +25 -7
  96. data/lib/byebug/interfaces/remote_interface.rb +21 -9
  97. data/lib/byebug/interfaces/script_interface.rb +4 -1
  98. data/lib/byebug/interfaces/test_interface.rb +5 -3
  99. data/lib/byebug/option_setter.rb +14 -12
  100. data/lib/byebug/printers/base.rb +10 -10
  101. data/lib/byebug/printers/plain.rb +9 -8
  102. data/lib/byebug/printers/texts/base.yml +7 -3
  103. data/lib/byebug/printers/texts/plain.yml +1 -1
  104. data/lib/byebug/processors/command_processor.rb +11 -12
  105. data/lib/byebug/processors/control_processor.rb +4 -6
  106. data/lib/byebug/processors/post_mortem_processor.rb +4 -2
  107. data/lib/byebug/processors/script_processor.rb +7 -3
  108. data/lib/byebug/remote/client.rb +57 -0
  109. data/lib/byebug/remote/server.rb +47 -0
  110. data/lib/byebug/remote.rb +46 -66
  111. data/lib/byebug/runner.rb +43 -49
  112. data/lib/byebug/setting.rb +11 -5
  113. data/lib/byebug/settings/autoirb.rb +7 -5
  114. data/lib/byebug/settings/autolist.rb +7 -5
  115. data/lib/byebug/settings/autopry.rb +7 -5
  116. data/lib/byebug/settings/autosave.rb +4 -2
  117. data/lib/byebug/settings/basename.rb +4 -2
  118. data/lib/byebug/settings/callstyle.rb +4 -3
  119. data/lib/byebug/settings/fullpath.rb +4 -2
  120. data/lib/byebug/settings/histfile.rb +5 -3
  121. data/lib/byebug/settings/histsize.rb +4 -2
  122. data/lib/byebug/settings/linetrace.rb +6 -4
  123. data/lib/byebug/settings/listsize.rb +4 -2
  124. data/lib/byebug/settings/post_mortem.rb +6 -4
  125. data/lib/byebug/settings/savefile.rb +4 -2
  126. data/lib/byebug/settings/stack_on_error.rb +4 -2
  127. data/lib/byebug/settings/width.rb +3 -1
  128. data/lib/byebug/source_file_formatter.rb +71 -0
  129. data/lib/byebug/subcommands.rb +6 -4
  130. data/lib/byebug/version.rb +2 -1
  131. data/lib/byebug.rb +3 -1
  132. metadata +22 -20
  133. data/bin/byebug +0 -7
@@ -1,5 +1,7 @@
1
- require 'byebug/command'
2
- require 'byebug/helpers/parse'
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../command"
4
+ require_relative "../helpers/parse"
3
5
 
4
6
  module Byebug
5
7
  #
@@ -15,7 +17,7 @@ module Byebug
15
17
  end
16
18
 
17
19
  def self.description
18
- <<-EOD
20
+ <<-DESCRIPTION
19
21
  undisp[lay][ nnn]
20
22
 
21
23
  #{short_description}
@@ -23,25 +25,24 @@ module Byebug
23
25
  Arguments are the code numbers of the expressions to stop displaying. No
24
26
  argument means cancel all automatic-display expressions. Type "info
25
27
  display" to see the current list of code numbers.
26
- EOD
28
+ DESCRIPTION
27
29
  end
28
30
 
29
31
  def self.short_description
30
- 'Stops displaying all or some expressions when program stops'
32
+ "Stops displaying all or some expressions when program stops"
31
33
  end
32
34
 
33
35
  def execute
34
36
  if @match[1]
35
- pos, err = get_int(@match[1], 'Undisplay', 1, Byebug.displays.size)
37
+ pos, err = get_int(@match[1], "Undisplay", 1, Byebug.displays.size)
36
38
  return errmsg(err) unless err.nil?
37
39
 
38
- unless Byebug.displays[pos - 1]
39
- return errmsg(pr('display.errors.undefined', expr: pos))
40
- end
40
+ last_display = Byebug.displays[pos - 1]
41
+ return errmsg(pr("display.errors.undefined", expr: pos)) unless last_display
41
42
 
42
- Byebug.displays[pos - 1][0] = nil
43
+ last_display[0] = nil
43
44
  else
44
- return unless confirm(pr('display.confirmations.clear_all'))
45
+ return unless confirm(pr("display.confirmations.clear_all"))
45
46
 
46
47
  Byebug.displays.each { |d| d[0] = false }
47
48
  end
@@ -1,4 +1,6 @@
1
- require 'byebug/command'
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../command"
2
4
 
3
5
  module Byebug
4
6
  #
@@ -10,24 +12,24 @@ module Byebug
10
12
  end
11
13
 
12
14
  def self.description
13
- <<-EOD
15
+ <<-DESCRIPTION
14
16
  untr[acevar] <variable>
15
17
 
16
18
  #{short_description}
17
- EOD
19
+ DESCRIPTION
18
20
  end
19
21
 
20
22
  def self.short_description
21
- 'Stops tracing a global variable'
23
+ "Stops tracing a global variable"
22
24
  end
23
25
 
24
26
  def execute
25
27
  var = @match[1]
26
28
  if global_variables.include?(:"#{var}")
27
29
  untrace_var(:"#{var}")
28
- puts pr('trace.messages.undo', var: var)
30
+ puts pr("trace.messages.undo", var: var)
29
31
  else
30
- errmsg pr('trace.errors.not_global', var: var)
32
+ errmsg pr("trace.errors.not_global", var: var)
31
33
  end
32
34
  end
33
35
  end
@@ -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_relative "../command"
5
+ require_relative "../helpers/frame"
6
+ require_relative "../helpers/parse"
5
7
 
6
8
  module Byebug
7
9
  #
@@ -18,21 +20,21 @@ module Byebug
18
20
  end
19
21
 
20
22
  def self.description
21
- <<-EOD
23
+ <<-DESCRIPTION
22
24
  up[ count]
23
25
 
24
26
  #{short_description}
25
27
 
26
28
  Use the "bt" command to find out where you want to go.
27
- EOD
29
+ DESCRIPTION
28
30
  end
29
31
 
30
32
  def self.short_description
31
- 'Moves to a higher frame in the stack trace'
33
+ "Moves to a higher frame in the stack trace"
32
34
  end
33
35
 
34
36
  def execute
35
- pos, err = parse_steps(@match[1], 'Up')
37
+ pos, err = parse_steps(@match[1], "Up")
36
38
  return errmsg(err) unless pos
37
39
 
38
40
  jump_frames(pos)
@@ -1,4 +1,6 @@
1
- require 'byebug/helpers/var'
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../../helpers/var"
2
4
 
3
5
  module Byebug
4
6
  #
@@ -18,20 +20,20 @@ module Byebug
18
20
  end
19
21
 
20
22
  def self.description
21
- <<-EOD
23
+ <<-DESCRIPTION
22
24
  v[ar] a[ll]
23
25
 
24
26
  #{short_description}
25
- EOD
27
+ DESCRIPTION
26
28
  end
27
29
 
28
30
  def self.short_description
29
- 'Shows local, global and instance variables of self.'
31
+ "Shows local, global and instance variables of self."
30
32
  end
31
33
 
32
34
  def execute
33
35
  var_global
34
- var_instance('self')
36
+ var_instance("self")
35
37
  var_local
36
38
  end
37
39
  end
@@ -1,4 +1,6 @@
1
- require 'byebug/helpers/var'
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../../helpers/var"
2
4
 
3
5
  module Byebug
4
6
  #
@@ -18,15 +20,15 @@ module Byebug
18
20
  end
19
21
 
20
22
  def self.description
21
- <<-EOD
23
+ <<-DESCRIPTION
22
24
  v[ar] a[args]
23
25
 
24
26
  #{short_description}
25
- EOD
27
+ DESCRIPTION
26
28
  end
27
29
 
28
30
  def self.short_description
29
- 'Information about arguments of the current scope'
31
+ "Information about arguments of the current scope"
30
32
  end
31
33
 
32
34
  def execute
@@ -1,4 +1,6 @@
1
- require 'byebug/helpers/eval'
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../../helpers/eval"
2
4
 
3
5
  module Byebug
4
6
  #
@@ -18,31 +20,29 @@ module Byebug
18
20
  end
19
21
 
20
22
  def self.description
21
- <<-EOD
23
+ <<-DESCRIPTION
22
24
  v[ar] c[onstant]
23
25
 
24
26
  #{short_description}
25
- EOD
27
+ DESCRIPTION
26
28
  end
27
29
 
28
30
  def self.short_description
29
- 'Shows constants of an object.'
31
+ "Shows constants of an object."
30
32
  end
31
33
 
32
34
  def execute
33
35
  obj = warning_eval(str_obj)
34
- unless obj.is_a?(Module)
35
- return errmsg(pr('variable.errors.not_module', object: str_obj))
36
- end
36
+ return errmsg(pr("variable.errors.not_module", object: str_obj)) unless obj.is_a?(Module)
37
37
 
38
38
  constants = warning_eval("#{str_obj}.constants")
39
- puts prv(constants.sort.map { |c| [c, obj.const_get(c)] }, 'constant')
39
+ puts prv(constants.sort.map { |c| [c, obj.const_get(c)] }, "constant")
40
40
  end
41
41
 
42
42
  private
43
43
 
44
44
  def str_obj
45
- @str_obj ||= @match[1] || 'self.class'
45
+ @str_obj ||= @match[1] || "self.class"
46
46
  end
47
47
  end
48
48
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Byebug
2
4
  #
3
5
  # Reopens the +var+ command to define the +global+ subcommand
@@ -16,15 +18,15 @@ module Byebug
16
18
  end
17
19
 
18
20
  def self.description
19
- <<-EOD
21
+ <<-DESCRIPTION
20
22
  v[ar] g[lobal]
21
23
 
22
24
  #{short_description}
23
- EOD
25
+ DESCRIPTION
24
26
  end
25
27
 
26
28
  def self.short_description
27
- 'Shows global variables.'
29
+ "Shows global variables."
28
30
  end
29
31
 
30
32
  def execute
@@ -1,4 +1,6 @@
1
- require 'byebug/helpers/var'
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../../helpers/var"
2
4
 
3
5
  module Byebug
4
6
  #
@@ -18,15 +20,15 @@ module Byebug
18
20
  end
19
21
 
20
22
  def self.description
21
- <<-EOD
23
+ <<-DESCRIPTION
22
24
  v[ar] i[nstance][ <object>]
23
25
 
24
26
  #{short_description}
25
- EOD
27
+ DESCRIPTION
26
28
  end
27
29
 
28
30
  def self.short_description
29
- 'Shows instance variables of self or a specific object.'
31
+ "Shows instance variables of self or a specific object."
30
32
  end
31
33
 
32
34
  def execute
@@ -1,4 +1,6 @@
1
- require 'byebug/helpers/var'
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../../helpers/var"
2
4
 
3
5
  module Byebug
4
6
  #
@@ -18,15 +20,15 @@ module Byebug
18
20
  end
19
21
 
20
22
  def self.description
21
- <<-EOD
23
+ <<-DESCRIPTION
22
24
  v[ar] l[ocal]
23
25
 
24
26
  #{short_description}
25
- EOD
27
+ DESCRIPTION
26
28
  end
27
29
 
28
30
  def self.short_description
29
- 'Shows local variables in current scope.'
31
+ "Shows local variables in current scope."
30
32
  end
31
33
 
32
34
  def execute
@@ -1,11 +1,13 @@
1
- require 'byebug/subcommands'
1
+ # frozen_string_literal: true
2
2
 
3
- require 'byebug/commands/var/all'
4
- require 'byebug/commands/var/args'
5
- require 'byebug/commands/var/const'
6
- require 'byebug/commands/var/instance'
7
- require 'byebug/commands/var/local'
8
- require 'byebug/commands/var/global'
3
+ require_relative "../subcommands"
4
+
5
+ require_relative "var/all"
6
+ require_relative "var/args"
7
+ require_relative "var/const"
8
+ require_relative "var/instance"
9
+ require_relative "var/local"
10
+ require_relative "var/global"
9
11
 
10
12
  module Byebug
11
13
  #
@@ -21,15 +23,15 @@ module Byebug
21
23
  end
22
24
 
23
25
  def self.description
24
- <<-EOD
26
+ <<-DESCRIPTION
25
27
  [v]ar <subcommand>
26
28
 
27
29
  #{short_description}
28
- EOD
30
+ DESCRIPTION
29
31
  end
30
32
 
31
33
  def self.short_description
32
- 'Shows variables and its values'
34
+ "Shows variables and its values"
33
35
  end
34
36
  end
35
37
  end
@@ -1,6 +1,8 @@
1
- require 'pathname'
2
- require 'byebug/command'
3
- require 'byebug/helpers/frame'
1
+ # frozen_string_literal: true
2
+
3
+ require "pathname"
4
+ require_relative "../command"
5
+ require_relative "../helpers/frame"
4
6
 
5
7
  module Byebug
6
8
  #
@@ -16,7 +18,7 @@ module Byebug
16
18
  end
17
19
 
18
20
  def self.description
19
- <<-EOD
21
+ <<-DESCRIPTION
20
22
  w[here]|bt|backtrace
21
23
 
22
24
  #{short_description}
@@ -27,11 +29,11 @@ module Byebug
27
29
  The position of the current frame is marked with -->. C-frames hang
28
30
  from their most immediate Ruby frame to indicate that they are not
29
31
  navigable.
30
- EOD
32
+ DESCRIPTION
31
33
  end
32
34
 
33
35
  def self.short_description
34
- 'Displays the backtrace'
36
+ "Displays the backtrace"
35
37
  end
36
38
 
37
39
  def execute
@@ -41,7 +43,7 @@ module Byebug
41
43
  private
42
44
 
43
45
  def print_backtrace
44
- bt = prc('frame.line', (0...context.stack_size)) do |_, index|
46
+ bt = prc("frame.line", (0...context.stack_size)) do |_, index|
45
47
  Frame.new(context, index).to_hash
46
48
  end
47
49
 
@@ -1,37 +1,40 @@
1
- require 'byebug/commands/break'
2
- require 'byebug/commands/catch'
3
- require 'byebug/commands/condition'
4
- require 'byebug/commands/continue'
5
- require 'byebug/commands/debug'
6
- require 'byebug/commands/delete'
7
- require 'byebug/commands/disable'
8
- require 'byebug/commands/display'
9
- require 'byebug/commands/down'
10
- require 'byebug/commands/edit'
11
- require 'byebug/commands/enable'
12
- require 'byebug/commands/finish'
13
- require 'byebug/commands/frame'
14
- require 'byebug/commands/help'
15
- require 'byebug/commands/history'
16
- require 'byebug/commands/info'
17
- require 'byebug/commands/interrupt'
18
- require 'byebug/commands/irb'
19
- require 'byebug/commands/kill'
20
- require 'byebug/commands/list'
21
- require 'byebug/commands/method'
22
- require 'byebug/commands/next'
23
- require 'byebug/commands/pry'
24
- require 'byebug/commands/quit'
25
- require 'byebug/commands/restart'
26
- require 'byebug/commands/save'
27
- require 'byebug/commands/set'
28
- require 'byebug/commands/show'
29
- require 'byebug/commands/source'
30
- require 'byebug/commands/step'
31
- require 'byebug/commands/thread'
32
- require 'byebug/commands/tracevar'
33
- require 'byebug/commands/undisplay'
34
- require 'byebug/commands/untracevar'
35
- require 'byebug/commands/up'
36
- require 'byebug/commands/var'
37
- require 'byebug/commands/where'
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "commands/break"
4
+ require_relative "commands/catch"
5
+ require_relative "commands/condition"
6
+ require_relative "commands/continue"
7
+ require_relative "commands/debug"
8
+ require_relative "commands/delete"
9
+ require_relative "commands/disable"
10
+ require_relative "commands/display"
11
+ require_relative "commands/down"
12
+ require_relative "commands/edit"
13
+ require_relative "commands/enable"
14
+ require_relative "commands/finish"
15
+ require_relative "commands/frame"
16
+ require_relative "commands/help"
17
+ require_relative "commands/history"
18
+ require_relative "commands/info"
19
+ require_relative "commands/interrupt"
20
+ require_relative "commands/irb"
21
+ require_relative "commands/kill"
22
+ require_relative "commands/list"
23
+ require_relative "commands/method"
24
+ require_relative "commands/next"
25
+ require_relative "commands/pry"
26
+ require_relative "commands/quit"
27
+ require_relative "commands/restart"
28
+ require_relative "commands/save"
29
+ require_relative "commands/set"
30
+ require_relative "commands/show"
31
+ require_relative "commands/skip"
32
+ require_relative "commands/source"
33
+ require_relative "commands/step"
34
+ require_relative "commands/thread"
35
+ require_relative "commands/tracevar"
36
+ require_relative "commands/undisplay"
37
+ require_relative "commands/untracevar"
38
+ require_relative "commands/up"
39
+ require_relative "commands/var"
40
+ require_relative "commands/where"
@@ -1,7 +1,9 @@
1
- require 'byebug/frame'
2
- require 'byebug/helpers/path'
3
- require 'byebug/helpers/file'
4
- require 'byebug/processors/command_processor'
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "frame"
4
+ require_relative "helpers/path"
5
+ require_relative "helpers/file"
6
+ require_relative "processors/command_processor"
5
7
 
6
8
  module Byebug
7
9
  #
@@ -140,7 +142,7 @@ module Byebug
140
142
  private
141
143
 
142
144
  def processor
143
- @processor ||= self.class.processor.new(self)
145
+ @processor ||= self.class.processor.new(self, self.class.interface)
144
146
  end
145
147
 
146
148
  #
data/lib/byebug/core.rb CHANGED
@@ -1,13 +1,15 @@
1
- require 'byebug/helpers/reflection'
2
- require 'byebug/byebug'
3
- require 'byebug/context'
4
- require 'byebug/breakpoint'
5
- require 'byebug/interface'
6
- require 'byebug/processors/script_processor'
7
- require 'byebug/processors/post_mortem_processor'
8
- require 'byebug/commands'
9
- require 'byebug/remote'
10
- require 'byebug/printers/plain'
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "helpers/reflection"
4
+ require "byebug/byebug"
5
+ require_relative "context"
6
+ require_relative "breakpoint"
7
+ require_relative "interface"
8
+ require_relative "processors/script_processor"
9
+ require_relative "processors/post_mortem_processor"
10
+ require_relative "commands"
11
+ require_relative "remote"
12
+ require_relative "printers/plain"
11
13
 
12
14
  #
13
15
  # Main debugger's container module. Everything is defined under this module
@@ -21,7 +23,7 @@ module Byebug
21
23
  # Configuration file used for startup commands. Default value is .byebugrc
22
24
  #
23
25
  attr_accessor :init_file
24
- self.init_file = '.byebugrc'
26
+ self.init_file = ".byebugrc"
25
27
 
26
28
  #
27
29
  # Debugger's display expressions
@@ -33,7 +35,8 @@ module Byebug
33
35
  # Running mode of the debugger. Can be either:
34
36
  #
35
37
  # * :attached => Attached to a running program through the `byebug` method.
36
- # * :standalone => Started through `bin/byebug` script.
38
+ # * :standalone => Started through `byebug` script.
39
+ # * :off => Ignoring any `byebug` method calls.
37
40
  #
38
41
  attr_accessor :mode
39
42
 
@@ -47,11 +50,16 @@ module Byebug
47
50
  # are debugging, in the directory where you invoke byebug.
48
51
  #
49
52
  def run_init_script
50
- rc_dirs.each { |dir| run_rc_file(dir) }
53
+ rc_dirs.each do |dir|
54
+ rc_file = File.expand_path(File.join(dir, init_file))
55
+ next unless File.exist?(rc_file)
56
+
57
+ run_rc_file(rc_file)
58
+ end
51
59
  end
52
60
 
53
61
  def self.load_settings
54
- Dir.glob(File.expand_path('../settings/*.rb', __FILE__)).each do |file|
62
+ Dir.glob(File.join(__dir__, "settings", "*.rb")).each do |file|
55
63
  require file
56
64
  end
57
65
 
@@ -80,17 +88,10 @@ module Byebug
80
88
  #
81
89
  # Runs a initialization script file
82
90
  #
83
- def run_rc_file(base_path)
84
- old_interface = Context.interface
85
-
86
- rc_file = File.expand_path(File.join(base_path, init_file))
87
- return unless File.exist?(rc_file)
88
-
89
- Context.interface = ScriptInterface.new(rc_file)
91
+ def run_rc_file(rc_file)
92
+ interface = ScriptInterface.new(rc_file)
90
93
 
91
- ScriptProcessor.new(nil).process_commands
92
- ensure
93
- Context.interface = old_interface
94
+ ScriptProcessor.new(nil, interface).process_commands
94
95
  end
95
96
 
96
97
  #
@@ -99,7 +100,7 @@ module Byebug
99
100
  # @note Files will be loaded in the order specified here.
100
101
  #
101
102
  def rc_dirs
102
- [ENV['HOME'], Dir.pwd].compact.uniq
103
+ [ENV["HOME"], Dir.pwd].compact.uniq
103
104
  end
104
105
  end
105
106
 
data/lib/byebug/errors.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Byebug
2
4
  #
3
5
  # Custom exception exception to signal "command not found" errors
@@ -17,11 +19,11 @@ module Byebug
17
19
  end
18
20
 
19
21
  def help
20
- build_cmd('help', @parent)
22
+ build_cmd("help", @parent)
21
23
  end
22
24
 
23
25
  def build_cmd(*args)
24
- args.compact.join(' ')
26
+ args.compact.join(" ")
25
27
  end
26
28
  end
27
29
  end