runger_byebug 11.2.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.
Files changed (132) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +954 -0
  3. data/CONTRIBUTING.md +58 -0
  4. data/GUIDE.md +1806 -0
  5. data/LICENSE +23 -0
  6. data/README.md +199 -0
  7. data/exe/byebug +6 -0
  8. data/ext/byebug/breakpoint.c +521 -0
  9. data/ext/byebug/byebug.c +900 -0
  10. data/ext/byebug/byebug.h +145 -0
  11. data/ext/byebug/context.c +687 -0
  12. data/ext/byebug/extconf.rb +12 -0
  13. data/ext/byebug/locker.c +96 -0
  14. data/ext/byebug/threads.c +241 -0
  15. data/lib/byebug/attacher.rb +48 -0
  16. data/lib/byebug/breakpoint.rb +94 -0
  17. data/lib/byebug/command.rb +111 -0
  18. data/lib/byebug/command_list.rb +34 -0
  19. data/lib/byebug/commands/break.rb +114 -0
  20. data/lib/byebug/commands/catch.rb +78 -0
  21. data/lib/byebug/commands/condition.rb +55 -0
  22. data/lib/byebug/commands/continue.rb +68 -0
  23. data/lib/byebug/commands/debug.rb +38 -0
  24. data/lib/byebug/commands/delete.rb +55 -0
  25. data/lib/byebug/commands/disable/breakpoints.rb +42 -0
  26. data/lib/byebug/commands/disable/display.rb +43 -0
  27. data/lib/byebug/commands/disable.rb +33 -0
  28. data/lib/byebug/commands/display.rb +66 -0
  29. data/lib/byebug/commands/down.rb +45 -0
  30. data/lib/byebug/commands/edit.rb +69 -0
  31. data/lib/byebug/commands/enable/breakpoints.rb +42 -0
  32. data/lib/byebug/commands/enable/display.rb +43 -0
  33. data/lib/byebug/commands/enable.rb +33 -0
  34. data/lib/byebug/commands/finish.rb +57 -0
  35. data/lib/byebug/commands/frame.rb +57 -0
  36. data/lib/byebug/commands/help.rb +64 -0
  37. data/lib/byebug/commands/history.rb +39 -0
  38. data/lib/byebug/commands/info/breakpoints.rb +65 -0
  39. data/lib/byebug/commands/info/display.rb +49 -0
  40. data/lib/byebug/commands/info/file.rb +80 -0
  41. data/lib/byebug/commands/info/line.rb +35 -0
  42. data/lib/byebug/commands/info/program.rb +49 -0
  43. data/lib/byebug/commands/info.rb +37 -0
  44. data/lib/byebug/commands/interrupt.rb +34 -0
  45. data/lib/byebug/commands/irb.rb +50 -0
  46. data/lib/byebug/commands/kill.rb +45 -0
  47. data/lib/byebug/commands/list.rb +159 -0
  48. data/lib/byebug/commands/method.rb +53 -0
  49. data/lib/byebug/commands/next.rb +40 -0
  50. data/lib/byebug/commands/pry.rb +41 -0
  51. data/lib/byebug/commands/quit.rb +42 -0
  52. data/lib/byebug/commands/restart.rb +64 -0
  53. data/lib/byebug/commands/save.rb +72 -0
  54. data/lib/byebug/commands/set.rb +79 -0
  55. data/lib/byebug/commands/show.rb +45 -0
  56. data/lib/byebug/commands/skip.rb +85 -0
  57. data/lib/byebug/commands/source.rb +40 -0
  58. data/lib/byebug/commands/step.rb +40 -0
  59. data/lib/byebug/commands/thread/current.rb +37 -0
  60. data/lib/byebug/commands/thread/list.rb +43 -0
  61. data/lib/byebug/commands/thread/resume.rb +45 -0
  62. data/lib/byebug/commands/thread/stop.rb +43 -0
  63. data/lib/byebug/commands/thread/switch.rb +46 -0
  64. data/lib/byebug/commands/thread.rb +34 -0
  65. data/lib/byebug/commands/tracevar.rb +54 -0
  66. data/lib/byebug/commands/undisplay.rb +51 -0
  67. data/lib/byebug/commands/untracevar.rb +36 -0
  68. data/lib/byebug/commands/up.rb +45 -0
  69. data/lib/byebug/commands/var/all.rb +41 -0
  70. data/lib/byebug/commands/var/args.rb +39 -0
  71. data/lib/byebug/commands/var/const.rb +49 -0
  72. data/lib/byebug/commands/var/global.rb +37 -0
  73. data/lib/byebug/commands/var/instance.rb +39 -0
  74. data/lib/byebug/commands/var/local.rb +39 -0
  75. data/lib/byebug/commands/var.rb +37 -0
  76. data/lib/byebug/commands/where.rb +64 -0
  77. data/lib/byebug/commands.rb +40 -0
  78. data/lib/byebug/context.rb +157 -0
  79. data/lib/byebug/core.rb +115 -0
  80. data/lib/byebug/errors.rb +29 -0
  81. data/lib/byebug/frame.rb +185 -0
  82. data/lib/byebug/helpers/bin.rb +47 -0
  83. data/lib/byebug/helpers/eval.rb +134 -0
  84. data/lib/byebug/helpers/file.rb +63 -0
  85. data/lib/byebug/helpers/frame.rb +75 -0
  86. data/lib/byebug/helpers/parse.rb +80 -0
  87. data/lib/byebug/helpers/path.rb +40 -0
  88. data/lib/byebug/helpers/reflection.rb +19 -0
  89. data/lib/byebug/helpers/string.rb +33 -0
  90. data/lib/byebug/helpers/thread.rb +67 -0
  91. data/lib/byebug/helpers/toggle.rb +62 -0
  92. data/lib/byebug/helpers/var.rb +70 -0
  93. data/lib/byebug/history.rb +130 -0
  94. data/lib/byebug/interface.rb +146 -0
  95. data/lib/byebug/interfaces/local_interface.rb +63 -0
  96. data/lib/byebug/interfaces/remote_interface.rb +50 -0
  97. data/lib/byebug/interfaces/script_interface.rb +33 -0
  98. data/lib/byebug/interfaces/test_interface.rb +67 -0
  99. data/lib/byebug/option_setter.rb +95 -0
  100. data/lib/byebug/printers/base.rb +68 -0
  101. data/lib/byebug/printers/plain.rb +44 -0
  102. data/lib/byebug/printers/texts/base.yml +115 -0
  103. data/lib/byebug/printers/texts/plain.yml +33 -0
  104. data/lib/byebug/processors/command_processor.rb +173 -0
  105. data/lib/byebug/processors/control_processor.rb +24 -0
  106. data/lib/byebug/processors/post_mortem_processor.rb +18 -0
  107. data/lib/byebug/processors/script_processor.rb +49 -0
  108. data/lib/byebug/remote/client.rb +57 -0
  109. data/lib/byebug/remote/server.rb +47 -0
  110. data/lib/byebug/remote.rb +85 -0
  111. data/lib/byebug/runner.rb +198 -0
  112. data/lib/byebug/setting.rb +79 -0
  113. data/lib/byebug/settings/autoirb.rb +29 -0
  114. data/lib/byebug/settings/autolist.rb +29 -0
  115. data/lib/byebug/settings/autopry.rb +29 -0
  116. data/lib/byebug/settings/autosave.rb +17 -0
  117. data/lib/byebug/settings/basename.rb +16 -0
  118. data/lib/byebug/settings/callstyle.rb +20 -0
  119. data/lib/byebug/settings/fullpath.rb +16 -0
  120. data/lib/byebug/settings/histfile.rb +20 -0
  121. data/lib/byebug/settings/histsize.rb +20 -0
  122. data/lib/byebug/settings/linetrace.rb +22 -0
  123. data/lib/byebug/settings/listsize.rb +21 -0
  124. data/lib/byebug/settings/post_mortem.rb +27 -0
  125. data/lib/byebug/settings/savefile.rb +20 -0
  126. data/lib/byebug/settings/stack_on_error.rb +15 -0
  127. data/lib/byebug/settings/width.rb +20 -0
  128. data/lib/byebug/source_file_formatter.rb +71 -0
  129. data/lib/byebug/subcommands.rb +54 -0
  130. data/lib/byebug/version.rb +8 -0
  131. data/lib/byebug.rb +3 -0
  132. metadata +194 -0
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "socket"
4
+
5
+ module Byebug
6
+ module Remote
7
+ #
8
+ # Server for remote debugging
9
+ #
10
+ class Server
11
+ attr_reader :actual_port, :wait_connection
12
+
13
+ def initialize(wait_connection:, &block)
14
+ @thread = nil
15
+ @wait_connection = wait_connection
16
+ @main_loop = block
17
+ end
18
+
19
+ #
20
+ # Start the remote debugging server
21
+ #
22
+ def start(host, port)
23
+ return if @thread
24
+
25
+ if wait_connection
26
+ mutex = Mutex.new
27
+ proceed = ConditionVariable.new
28
+ end
29
+
30
+ server = TCPServer.new(host, port)
31
+ @actual_port = server.addr[1]
32
+
33
+ yield if block_given?
34
+
35
+ @thread = DebugThread.new do
36
+ while (session = server.accept)
37
+ @main_loop.call(session)
38
+
39
+ mutex.synchronize { proceed.signal } if wait_connection
40
+ end
41
+ end
42
+
43
+ mutex.synchronize { proceed.wait(mutex) } if wait_connection
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,85 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "socket"
4
+ require_relative "processors/control_processor"
5
+ require_relative "remote/server"
6
+ require_relative "remote/client"
7
+
8
+ #
9
+ # Remote debugging functionality.
10
+ #
11
+ module Byebug
12
+ # Port number used for remote debugging
13
+ PORT = 8989 unless defined?(PORT)
14
+
15
+ class << self
16
+ # If in remote mode, wait for the remote connection
17
+ attr_accessor :wait_connection
18
+
19
+ # The actual port that the server is started at
20
+ def actual_port
21
+ server.actual_port
22
+ end
23
+
24
+ # The actual port that the control server is started at
25
+ def actual_control_port
26
+ control.actual_port
27
+ end
28
+
29
+ #
30
+ # Interrupts the current thread
31
+ #
32
+ def interrupt
33
+ current_context.interrupt
34
+ end
35
+
36
+ #
37
+ # Starts the remote server main thread
38
+ #
39
+ def start_server(host = nil, port = PORT)
40
+ start_control(host, port.zero? ? 0 : port + 1)
41
+
42
+ server.start(host, port)
43
+ end
44
+
45
+ #
46
+ # Starts the remote server control thread
47
+ #
48
+ def start_control(host = nil, port = PORT + 1)
49
+ control.start(host, port)
50
+ end
51
+
52
+ #
53
+ # Connects to the remote byebug
54
+ #
55
+ def start_client(host = "localhost", port = PORT)
56
+ client.start(host, port)
57
+ end
58
+
59
+ def parse_host_and_port(host_port_spec)
60
+ location = host_port_spec.split(":")
61
+ location[1] ? [location[0], location[1].to_i] : ["localhost", location[0]]
62
+ end
63
+
64
+ private
65
+
66
+ def client
67
+ @client ||= Remote::Client.new(Context.interface)
68
+ end
69
+
70
+ def server
71
+ @server ||= Remote::Server.new(wait_connection: wait_connection) do |s|
72
+ Context.interface = RemoteInterface.new(s)
73
+ end
74
+ end
75
+
76
+ def control
77
+ @control ||= Remote::Server.new(wait_connection: false) do |s|
78
+ context = Byebug.current_context
79
+ interface = RemoteInterface.new(s)
80
+
81
+ ControlProcessor.new(context, interface).process_commands
82
+ end
83
+ end
84
+ end
85
+ end
@@ -0,0 +1,198 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "optparse"
4
+ require "English"
5
+ require_relative "core"
6
+ require_relative "version"
7
+ require_relative "helpers/bin"
8
+ require_relative "helpers/parse"
9
+ require_relative "helpers/string"
10
+ require_relative "option_setter"
11
+ require_relative "processors/control_processor"
12
+
13
+ module Byebug
14
+ #
15
+ # Responsible for starting the debugger when started from the command line.
16
+ #
17
+ class Runner
18
+ include Helpers::BinHelper
19
+ include Helpers::ParseHelper
20
+ include Helpers::StringHelper
21
+
22
+ #
23
+ # Special working modes that don't actually start the debugger.
24
+ #
25
+ attr_reader :help, :version, :remote
26
+
27
+ #
28
+ # Signals that we should exit after the debugged program is finished.
29
+ #
30
+ attr_accessor :quit
31
+
32
+ #
33
+ # Signals that we should stop before program starts
34
+ #
35
+ attr_accessor :stop
36
+
37
+ #
38
+ # Signals that we should run rc scripts before program starts
39
+ #
40
+ attr_writer :init_script
41
+
42
+ #
43
+ # @param stop [Boolean] Whether the runner should stop right before
44
+ # starting the program.
45
+ #
46
+ # @param quit [Boolean] Whether the runner should quit right after
47
+ # finishing the program.
48
+ #
49
+ def initialize(stop = true, quit = true)
50
+ @stop = stop
51
+ @quit = quit
52
+ end
53
+
54
+ def help=(text)
55
+ @help ||= text
56
+
57
+ interface.puts("#{text}\n")
58
+ end
59
+
60
+ def version=(number)
61
+ @version ||= number
62
+
63
+ interface.puts prettify <<-VERSION
64
+ Running byebug #{number}
65
+ VERSION
66
+ end
67
+
68
+ def remote=(host_and_port)
69
+ @remote ||= Byebug.parse_host_and_port(host_and_port)
70
+
71
+ Byebug.start_client(*@remote)
72
+ end
73
+
74
+ def init_script
75
+ defined?(@init_script) ? @init_script : true
76
+ end
77
+
78
+ #
79
+ # Usage banner.
80
+ #
81
+ def banner
82
+ prettify <<-BANNER
83
+ byebug #{Byebug::VERSION}
84
+
85
+ Usage: byebug [options] <script.rb> -- <script.rb parameters>
86
+ BANNER
87
+ end
88
+
89
+ #
90
+ # Starts byebug to debug a program.
91
+ #
92
+ def run
93
+ Byebug.mode = :standalone
94
+
95
+ option_parser.order!($ARGV)
96
+ return if non_script_option? || error_in_script?
97
+
98
+ $PROGRAM_NAME = program
99
+
100
+ Byebug.run_init_script if init_script
101
+
102
+ loop do
103
+ debug_program
104
+
105
+ break if quit
106
+
107
+ ControlProcessor.new(nil, interface).process_commands
108
+ end
109
+ end
110
+
111
+ def interface
112
+ @interface ||= Context.interface
113
+ end
114
+
115
+ #
116
+ # Processes options passed from the command line.
117
+ #
118
+ def option_parser
119
+ @option_parser ||= OptionParser.new(banner, 25) do |opts|
120
+ opts.banner = banner
121
+
122
+ OptionSetter.new(self, opts).setup
123
+ end
124
+ end
125
+
126
+ def program
127
+ @program ||= begin
128
+ candidate = which($ARGV.shift)
129
+
130
+ if [which("ruby"), RbConfig.ruby].include?(candidate)
131
+ which($ARGV.shift)
132
+ else
133
+ candidate
134
+ end
135
+ end
136
+ end
137
+
138
+ #
139
+ # An option that doesn't need a script specified was given
140
+ #
141
+ def non_script_option?
142
+ version || help || remote
143
+ end
144
+
145
+ #
146
+ # There is an error with the specified script
147
+ #
148
+ def error_in_script?
149
+ no_script? || non_existing_script? || invalid_script?
150
+ end
151
+
152
+ #
153
+ # No script to debug specified
154
+ #
155
+ def no_script?
156
+ return false unless $ARGV.empty?
157
+
158
+ print_error("You must specify a program to debug")
159
+ true
160
+ end
161
+
162
+ #
163
+ # Extracts debugged program from command line args.
164
+ #
165
+ def non_existing_script?
166
+ return false if program
167
+
168
+ print_error("The script doesn't exist")
169
+ true
170
+ end
171
+
172
+ #
173
+ # Checks the debugged script has correct syntax
174
+ #
175
+ def invalid_script?
176
+ return false if syntax_valid?(File.read(program))
177
+
178
+ print_error("The script has incorrect syntax")
179
+ true
180
+ end
181
+
182
+ #
183
+ # Debugs a script only if syntax checks okay.
184
+ #
185
+ def debug_program
186
+ error = Byebug.debug_load(program, stop)
187
+ puts "#{error}\n#{error.backtrace}" if error
188
+ end
189
+
190
+ #
191
+ # Prints an error message and a help string
192
+ #
193
+ def print_error(msg)
194
+ interface.errmsg(msg)
195
+ interface.puts(option_parser.help)
196
+ end
197
+ end
198
+ end
@@ -0,0 +1,79 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "helpers/string"
4
+
5
+ module Byebug
6
+ #
7
+ # Parent class for all byebug settings.
8
+ #
9
+ class Setting
10
+ attr_accessor :value
11
+
12
+ DEFAULT = false
13
+
14
+ def initialize
15
+ @value = self.class::DEFAULT
16
+ end
17
+
18
+ def boolean?
19
+ [true, false].include?(value)
20
+ end
21
+
22
+ def integer?
23
+ Integer(value) ? true : false
24
+ rescue ArgumentError
25
+ false
26
+ end
27
+
28
+ def help
29
+ prettify(banner)
30
+ end
31
+
32
+ def to_sym
33
+ name = self.class.name.gsub(/^Byebug::/, "").gsub(/Setting$/, "")
34
+ name.gsub(/(.)([A-Z])/, '\1_\2').downcase.to_sym
35
+ end
36
+
37
+ def to_s
38
+ "#{to_sym} is #{value ? 'on' : 'off'}\n"
39
+ end
40
+
41
+ class << self
42
+ def settings
43
+ @settings ||= {}
44
+ end
45
+
46
+ def [](name)
47
+ settings[name].value
48
+ end
49
+
50
+ def []=(name, value)
51
+ settings[name].value = value
52
+ end
53
+
54
+ def find(shortcut)
55
+ abbr = /^no/.match?(shortcut) ? shortcut[2..-1] : shortcut
56
+ matches = settings.select do |key, value|
57
+ key =~ (value.boolean? ? /#{abbr}/ : /#{shortcut}/)
58
+ end
59
+ matches.size == 1 ? matches.values.first : nil
60
+ end
61
+
62
+ #
63
+ # @todo DRY this up. Very similar code exists in the CommandList class
64
+ #
65
+ def help_all
66
+ output = " List of supported settings:\n\n"
67
+ width = settings.keys.max_by(&:size).size
68
+ settings.each_value do |sett|
69
+ output += format(
70
+ " %<name>-#{width}s -- %<description>s\n",
71
+ name: sett.to_sym,
72
+ description: sett.banner
73
+ )
74
+ end
75
+ output + "\n"
76
+ end
77
+ end
78
+ end
79
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../setting"
4
+ require_relative "../commands/irb"
5
+
6
+ module Byebug
7
+ #
8
+ # Setting for automatically invoking IRB on every stop.
9
+ #
10
+ class AutoirbSetting < Setting
11
+ DEFAULT = 0
12
+
13
+ def initialize
14
+ IrbCommand.always_run = DEFAULT
15
+ end
16
+
17
+ def banner
18
+ "Invoke IRB on every stop"
19
+ end
20
+
21
+ def value=(val)
22
+ IrbCommand.always_run = val ? 1 : 0
23
+ end
24
+
25
+ def value
26
+ IrbCommand.always_run == 1
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../setting"
4
+ require_relative "../commands/list"
5
+
6
+ module Byebug
7
+ #
8
+ # Setting for automatically listing source code on every stop.
9
+ #
10
+ class AutolistSetting < Setting
11
+ DEFAULT = 1
12
+
13
+ def initialize
14
+ ListCommand.always_run = DEFAULT
15
+ end
16
+
17
+ def banner
18
+ "Invoke list command on every stop"
19
+ end
20
+
21
+ def value=(val)
22
+ ListCommand.always_run = val ? 1 : 0
23
+ end
24
+
25
+ def value
26
+ ListCommand.always_run == 1
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../setting"
4
+ require_relative "../commands/pry"
5
+
6
+ module Byebug
7
+ #
8
+ # Setting for automatically invoking Pry on every stop.
9
+ #
10
+ class AutoprySetting < Setting
11
+ DEFAULT = 0
12
+
13
+ def initialize
14
+ PryCommand.always_run = DEFAULT
15
+ end
16
+
17
+ def banner
18
+ "Invoke Pry on every stop"
19
+ end
20
+
21
+ def value=(val)
22
+ PryCommand.always_run = val ? 1 : 0
23
+ end
24
+
25
+ def value
26
+ PryCommand.always_run == 1
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../setting"
4
+
5
+ module Byebug
6
+ #
7
+ # Setting for automatically saving previously entered commands to history
8
+ # when exiting the debugger.
9
+ #
10
+ class AutosaveSetting < Setting
11
+ DEFAULT = true
12
+
13
+ def banner
14
+ "Automatically save command history record on exit"
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../setting"
4
+
5
+ module Byebug
6
+ #
7
+ # Command to display short paths in file names.
8
+ #
9
+ # For example, when displaying source code information.
10
+ #
11
+ class BasenameSetting < Setting
12
+ def banner
13
+ "<file>:<line> information after every stop uses short paths"
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../setting"
4
+
5
+ module Byebug
6
+ #
7
+ # Setting to customize the verbosity level for stack frames.
8
+ #
9
+ class CallstyleSetting < Setting
10
+ DEFAULT = "long"
11
+
12
+ def banner
13
+ "Set how you want method call parameters to be displayed"
14
+ end
15
+
16
+ def to_s
17
+ "Frame display callstyle is '#{value}'"
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../setting"
4
+
5
+ module Byebug
6
+ #
7
+ # Setting to display full paths in backtraces.
8
+ #
9
+ class FullpathSetting < Setting
10
+ DEFAULT = true
11
+
12
+ def banner
13
+ "Display full file names in backtraces"
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../setting"
4
+
5
+ module Byebug
6
+ #
7
+ # Setting to customize the file where byebug's history is saved.
8
+ #
9
+ class HistfileSetting < Setting
10
+ DEFAULT = File.expand_path(".byebug_history")
11
+
12
+ def banner
13
+ "File where cmd history is saved to. Default: ./.byebug_history"
14
+ end
15
+
16
+ def to_s
17
+ "The command history file is #{value}\n"
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../setting"
4
+
5
+ module Byebug
6
+ #
7
+ # Setting to customize the number of byebug commands to be saved in history.
8
+ #
9
+ class HistsizeSetting < Setting
10
+ DEFAULT = 256
11
+
12
+ def banner
13
+ "Maximum number of commands that can be stored in byebug history"
14
+ end
15
+
16
+ def to_s
17
+ "Maximum size of byebug's command history is #{value}"
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../setting"
4
+
5
+ module Byebug
6
+ #
7
+ # Setting to enable/disable linetracing.
8
+ #
9
+ class LinetraceSetting < Setting
10
+ def banner
11
+ "Enable line execution tracing"
12
+ end
13
+
14
+ def value=(val)
15
+ Byebug.tracing = val
16
+ end
17
+
18
+ def value
19
+ Byebug.tracing?
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../setting"
4
+
5
+ module Byebug
6
+ #
7
+ # Setting to customize the number of source code lines to be displayed every
8
+ # time the "list" command is invoked.
9
+ #
10
+ class ListsizeSetting < Setting
11
+ DEFAULT = 10
12
+
13
+ def banner
14
+ "Set number of source lines to list by default"
15
+ end
16
+
17
+ def to_s
18
+ "Number of source lines to list is #{value}\n"
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../setting"
4
+
5
+ module Byebug
6
+ #
7
+ # Setting to enable/disable post_mortem mode, i.e., a debugger prompt after
8
+ # program termination by unhandled exception.
9
+ #
10
+ class PostMortemSetting < Setting
11
+ def initialize
12
+ Byebug.post_mortem = DEFAULT
13
+ end
14
+
15
+ def banner
16
+ "Enable/disable post-mortem mode"
17
+ end
18
+
19
+ def value=(val)
20
+ Byebug.post_mortem = val
21
+ end
22
+
23
+ def value
24
+ Byebug.post_mortem?
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../setting"
4
+
5
+ module Byebug
6
+ #
7
+ # Setting to customize the file where byebug's settings are saved.
8
+ #
9
+ class SavefileSetting < Setting
10
+ DEFAULT = File.expand_path("#{ENV['HOME'] || '.'}/.byebug_save")
11
+
12
+ def banner
13
+ "File where settings are saved to. Default: ~/.byebug_save"
14
+ end
15
+
16
+ def to_s
17
+ "The settings file is #{value}\n"
18
+ end
19
+ end
20
+ end