byebug 11.1.3 → 13.0.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 (40) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +46 -0
  3. data/CONTRIBUTING.md +9 -9
  4. data/GUIDE.md +38 -38
  5. data/README.md +2 -4
  6. data/ext/byebug/breakpoint.c +51 -46
  7. data/ext/byebug/byebug.c +32 -26
  8. data/ext/byebug/byebug.h +2 -0
  9. data/ext/byebug/context.c +48 -52
  10. data/ext/byebug/threads.c +33 -9
  11. data/lib/byebug/breakpoint.rb +1 -18
  12. data/lib/byebug/commands/break.rb +7 -5
  13. data/lib/byebug/commands/enable/breakpoints.rb +1 -1
  14. data/lib/byebug/commands/finish.rb +1 -1
  15. data/lib/byebug/commands/help.rb +1 -1
  16. data/lib/byebug/commands/info.rb +1 -1
  17. data/lib/byebug/commands/irb.rb +2 -1
  18. data/lib/byebug/commands/set.rb +1 -1
  19. data/lib/byebug/commands/step.rb +1 -1
  20. data/lib/byebug/commands/thread/current.rb +1 -1
  21. data/lib/byebug/commands/thread/list.rb +1 -1
  22. data/lib/byebug/commands/thread/resume.rb +1 -1
  23. data/lib/byebug/commands/thread/stop.rb +1 -1
  24. data/lib/byebug/commands/tracevar.rb +1 -1
  25. data/lib/byebug/commands/untracevar.rb +2 -2
  26. data/lib/byebug/commands/var/args.rb +1 -1
  27. data/lib/byebug/commands/where.rb +14 -3
  28. data/lib/byebug/context.rb +1 -1
  29. data/lib/byebug/helpers/eval.rb +4 -6
  30. data/lib/byebug/helpers/file.rb +5 -1
  31. data/lib/byebug/helpers/parse.rb +9 -2
  32. data/lib/byebug/helpers/reflection.rb +1 -1
  33. data/lib/byebug/helpers/var.rb +17 -1
  34. data/lib/byebug/history.rb +14 -24
  35. data/lib/byebug/interface.rb +1 -1
  36. data/lib/byebug/interfaces/local_interface.rb +8 -8
  37. data/lib/byebug/option_setter.rb +1 -1
  38. data/lib/byebug/settings/savefile.rb +2 -2
  39. data/lib/byebug/version.rb +1 -1
  40. metadata +21 -7
@@ -28,7 +28,7 @@ module Byebug
28
28
  end
29
29
 
30
30
  def self.short_description
31
- "Information about arguments of the current scope"
31
+ "Information about arguments of the current scope."
32
32
  end
33
33
 
34
34
  def execute
@@ -14,12 +14,12 @@ module Byebug
14
14
  self.allow_in_post_mortem = true
15
15
 
16
16
  def self.regexp
17
- /^\s* (?:w(?:here)?|bt|backtrace) \s*$/x
17
+ /^\s* (?:w(?:here)?|bt|backtrace) (?:\s+(\S+))? \s*$/x
18
18
  end
19
19
 
20
20
  def self.description
21
21
  <<-DESCRIPTION
22
- w[here]|bt|backtrace
22
+ w[here]|bt|backtrace[ maximum-frame]
23
23
 
24
24
  #{short_description}
25
25
 
@@ -29,6 +29,10 @@ module Byebug
29
29
  The position of the current frame is marked with -->. C-frames hang
30
30
  from their most immediate Ruby frame to indicate that they are not
31
31
  navigable.
32
+
33
+ Without an argument, the command prints all the frames. With an argument,
34
+ the command prints the nth first frames, where n is the largest between
35
+ the argument or the maximum stack frame.
32
36
  DESCRIPTION
33
37
  end
34
38
 
@@ -43,7 +47,14 @@ module Byebug
43
47
  private
44
48
 
45
49
  def print_backtrace
46
- bt = prc("frame.line", (0...context.stack_size)) do |_, index|
50
+ max_frame =
51
+ if @match[1] && @match[1].to_i <= context.stack_size
52
+ @match[1].to_i
53
+ else
54
+ context.stack_size
55
+ end
56
+
57
+ bt = prc("frame.line", 0...max_frame) do |_, index|
47
58
  Frame.new(context, index).to_hash
48
59
  end
49
60
 
@@ -7,7 +7,7 @@ require_relative "processors/command_processor"
7
7
 
8
8
  module Byebug
9
9
  #
10
- # Mantains context information for the debugger and it's the main
10
+ # Maintains context information for the debugger and it's the main
11
11
  # communication point between the library and the C-extension through the
12
12
  # at_breakpoint, at_catchpoint, at_tracing, at_line and at_return callbacks
13
13
  #
@@ -33,7 +33,7 @@ module Byebug
33
33
 
34
34
  #
35
35
  # Evaluates a string containing Ruby code in a specific binding,
36
- # returning nil in an error happens.
36
+ # returning nil if an error happens.
37
37
  #
38
38
  def silent_eval(str, binding = frame._binding)
39
39
  safe_eval(str, binding) { |_e| nil }
@@ -88,14 +88,12 @@ module Byebug
88
88
  # creating new threads won't be properly evaluated because new threads
89
89
  # will get blocked by byebug's main thread.
90
90
  #
91
- def allowing_other_threads
91
+ def allowing_other_threads(&block)
92
92
  Byebug.unlock
93
93
 
94
- res = yield
95
-
94
+ TracePoint.allow_reentry(&block)
95
+ ensure
96
96
  Byebug.lock
97
-
98
- res
99
97
  end
100
98
 
101
99
  #
@@ -56,7 +56,11 @@ module Byebug
56
56
  # True for special files like -e, false otherwise
57
57
  #
58
58
  def virtual_file?(name)
59
- ["(irb)", "-e", "(byebug)", "(eval)"].include?(name)
59
+ if Gem.ruby_version >= Gem::Version.new("3.3.a")
60
+ ["(irb)", "-e", "(byebug)"].include?(name) || name.start_with?("(eval ")
61
+ else
62
+ ["(irb)", "-e", "(byebug)", "(eval)"].include?(name)
63
+ end
60
64
  end
61
65
  end
62
66
  end
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "stringio"
4
+
3
5
  module Byebug
4
6
  module Helpers
5
7
  #
@@ -35,13 +37,18 @@ module Byebug
35
37
  def syntax_valid?(code)
36
38
  return true unless code
37
39
 
38
- without_stderr do
39
- begin
40
+ if defined?(RubyVM::InstructionSequence.compile)
41
+ without_stderr do
40
42
  RubyVM::InstructionSequence.compile(code)
41
43
  true
42
44
  rescue SyntaxError
43
45
  false
44
46
  end
47
+ else
48
+ require "ripper" unless defined?(Ripper)
49
+ without_stderr do
50
+ !Ripper.sexp(code).nil?
51
+ end
45
52
  end
46
53
  end
47
54
 
@@ -3,7 +3,7 @@
3
3
  module Byebug
4
4
  module Helpers
5
5
  #
6
- # Reflection utilitie
6
+ # Reflection utility
7
7
  #
8
8
  module ReflectionHelper
9
9
  #
@@ -12,7 +12,23 @@ module Byebug
12
12
 
13
13
  def var_list(ary, binding = context.frame._binding)
14
14
  vars = ary.sort.map do |name|
15
- [name, safe_inspect(silent_eval(name.to_s, binding))]
15
+ code = name.to_s
16
+
17
+ if code == "$SAFE"
18
+ code = <<~RUBY
19
+ original_stderr = $stderr
20
+
21
+ begin
22
+ $stderr = StringIO.new
23
+
24
+ #{code}
25
+ ensure
26
+ $stderr = original_stderr
27
+ end
28
+ RUBY
29
+ end
30
+
31
+ [name, safe_inspect(silent_eval(code, binding))]
16
32
  end
17
33
 
18
34
  puts prv(vars, "instance")
@@ -1,33 +1,23 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- begin
4
- require "readline"
5
- rescue LoadError
6
- warn <<-MESSAGE
7
- Sorry, you can't use byebug without Readline. To solve this, you need to
8
- rebuild Ruby with Readline support. If using Ubuntu, try `sudo apt-get
9
- install libreadline-dev` and then reinstall your Ruby.
10
- MESSAGE
11
-
12
- raise
13
- end
3
+ require "reline"
14
4
 
15
5
  module Byebug
16
6
  #
17
7
  # Handles byebug's history of commands.
18
8
  #
19
9
  class History
20
- attr_accessor :size
10
+ attr_reader :size
21
11
 
22
12
  def initialize
23
- self.size = 0
13
+ @size = 0
24
14
  end
25
15
 
26
16
  #
27
17
  # Array holding the list of commands in history
28
18
  #
29
19
  def buffer
30
- Readline::HISTORY.to_a
20
+ Reline::HISTORY.to_a
31
21
  end
32
22
 
33
23
  #
@@ -60,21 +50,21 @@ module Byebug
60
50
  end
61
51
 
62
52
  #
63
- # Adds a new command to Readline's history.
53
+ # Adds a new command to Reline's history.
64
54
  #
65
55
  def push(cmd)
66
56
  return if ignore?(cmd)
67
57
 
68
- self.size += 1
69
- Readline::HISTORY.push(cmd)
58
+ @size += 1
59
+ Reline::HISTORY.push(cmd)
70
60
  end
71
61
 
72
62
  #
73
- # Removes a command from Readline's history.
63
+ # Removes a command from Reline's history.
74
64
  #
75
65
  def pop
76
- self.size -= 1
77
- Readline::HISTORY.pop
66
+ @size -= 1
67
+ Reline::HISTORY.pop
78
68
  end
79
69
 
80
70
  #
@@ -103,7 +93,7 @@ module Byebug
103
93
  # Never more than Setting[:histsize].
104
94
  #
105
95
  def default_max_size
106
- [Setting[:histsize], self.size].min
96
+ [Setting[:histsize], size].min
107
97
  end
108
98
 
109
99
  #
@@ -112,7 +102,7 @@ module Byebug
112
102
  # The only bound here is not showing more items than available.
113
103
  #
114
104
  def specific_max_size(number)
115
- [self.size, number].min
105
+ [size, number].min
116
106
  end
117
107
 
118
108
  #
@@ -122,9 +112,9 @@ module Byebug
122
112
  #
123
113
  def ignore?(buf)
124
114
  return true if /^\s*$/.match?(buf)
125
- return false if Readline::HISTORY.empty?
115
+ return false if Reline::HISTORY.empty?
126
116
 
127
- buffer[Readline::HISTORY.length - 1] == buf
117
+ buffer[Reline::HISTORY.length - 1] == buf
128
118
  end
129
119
  end
130
120
  end
@@ -129,7 +129,7 @@ module Byebug
129
129
  return [""] if cmd_line.empty?
130
130
 
131
131
  cmd_line.split(/;/).each_with_object([]) do |v, m|
132
- if m.empty? || m.last[-1] != '\\'
132
+ if m.empty? || m.last[-1] != "\\"
133
133
  m << v.strip
134
134
  next
135
135
  end
@@ -15,13 +15,13 @@ module Byebug
15
15
  end
16
16
 
17
17
  #
18
- # Reads a single line of input using Readline. If Ctrl-D is pressed, it
18
+ # Reads a single line of input using Reline. If Ctrl-D is pressed, it
19
19
  # returns "continue", meaning that program's execution will go on.
20
20
  #
21
21
  # @param prompt Prompt to be displayed.
22
22
  #
23
23
  def readline(prompt)
24
- with_repl_like_sigint { without_readline_completion { Readline.readline(prompt) || EOF_ALIAS } }
24
+ with_repl_like_sigint { without_reline_completion { Reline.readline(prompt) || EOF_ALIAS } }
25
25
  end
26
26
 
27
27
  #
@@ -42,21 +42,21 @@ module Byebug
42
42
  end
43
43
 
44
44
  #
45
- # Disable any Readline completion procs.
45
+ # Disable any Reline completion procs.
46
46
  #
47
47
  # Other gems, for example, IRB could've installed completion procs that are
48
48
  # dependent on them being loaded. Disable those while byebug is the REPL
49
- # making use of Readline.
49
+ # making use of Reline.
50
50
  #
51
- def without_readline_completion
52
- orig_completion = Readline.completion_proc
51
+ def without_reline_completion
52
+ orig_completion = Reline.completion_proc
53
53
  return yield unless orig_completion
54
54
 
55
55
  begin
56
- Readline.completion_proc = ->(_) { nil }
56
+ Reline.completion_proc = ->(_) { nil }
57
57
  yield
58
58
  ensure
59
- Readline.completion_proc = orig_completion
59
+ Reline.completion_proc = orig_completion
60
60
  end
61
61
  end
62
62
  end
@@ -33,7 +33,7 @@ module Byebug
33
33
  end
34
34
 
35
35
  def include_flag
36
- @opts.on "-I", "--include list", "Add to paths to $LOAD_PATH" do |list|
36
+ @opts.on "-I", "--include list", "Add paths to $LOAD_PATH" do |list|
37
37
  $LOAD_PATH.push(list.split(":")).flatten!
38
38
  end
39
39
  end
@@ -4,7 +4,7 @@ require_relative "../setting"
4
4
 
5
5
  module Byebug
6
6
  #
7
- # Setting to customize the file where byebug's history is saved.
7
+ # Setting to customize the file where byebug's settings are saved.
8
8
  #
9
9
  class SavefileSetting < Setting
10
10
  DEFAULT = File.expand_path("#{ENV['HOME'] || '.'}/.byebug_save")
@@ -14,7 +14,7 @@ module Byebug
14
14
  end
15
15
 
16
16
  def to_s
17
- "The command history file is #{value}\n"
17
+ "The settings file is #{value}\n"
18
18
  end
19
19
  end
20
20
  end
@@ -4,5 +4,5 @@
4
4
  # Reopen main module to define the library version
5
5
  #
6
6
  module Byebug
7
- VERSION = "11.1.3"
7
+ VERSION = "13.0.0"
8
8
  end
metadata CHANGED
@@ -1,17 +1,31 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: byebug
3
3
  version: !ruby/object:Gem::Version
4
- version: 11.1.3
4
+ version: 13.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Rodriguez
8
8
  - Kent Sibilev
9
9
  - Mark Moseley
10
- autorequire:
10
+ autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2020-04-23 00:00:00.000000000 Z
13
+ date: 2026-01-15 00:00:00.000000000 Z
14
14
  dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: reline
17
+ requirement: !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - ">="
20
+ - !ruby/object:Gem::Version
21
+ version: 0.6.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ version: 0.6.0
15
29
  - !ruby/object:Gem::Dependency
16
30
  name: bundler
17
31
  requirement: !ruby/object:Gem::Requirement
@@ -177,7 +191,7 @@ homepage: https://github.com/deivid-rodriguez/byebug
177
191
  licenses:
178
192
  - BSD-2-Clause
179
193
  metadata: {}
180
- post_install_message:
194
+ post_install_message:
181
195
  rdoc_options: []
182
196
  require_paths:
183
197
  - lib
@@ -185,15 +199,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
185
199
  requirements:
186
200
  - - ">="
187
201
  - !ruby/object:Gem::Version
188
- version: 2.4.0
202
+ version: 3.2.0
189
203
  required_rubygems_version: !ruby/object:Gem::Requirement
190
204
  requirements:
191
205
  - - ">="
192
206
  - !ruby/object:Gem::Version
193
207
  version: '0'
194
208
  requirements: []
195
- rubygems_version: 3.2.0.pre1
196
- signing_key:
209
+ rubygems_version: 3.5.22
210
+ signing_key:
197
211
  specification_version: 4
198
212
  summary: Ruby fast debugger - base + CLI
199
213
  test_files: []