byebug 8.2.5 → 9.1.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 (50) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +77 -0
  3. data/CONTRIBUTING.md +6 -6
  4. data/GUIDE.md +26 -26
  5. data/README.md +18 -7
  6. data/bin/byebug +3 -1
  7. data/ext/byebug/breakpoint.c +3 -3
  8. data/ext/byebug/byebug.c +7 -4
  9. data/ext/byebug/byebug.h +0 -4
  10. data/ext/byebug/locker.c +1 -1
  11. data/ext/byebug/threads.c +2 -2
  12. data/lib/byebug/breakpoint.rb +2 -4
  13. data/lib/byebug/commands/catch.rb +1 -1
  14. data/lib/byebug/commands/delete.rb +4 -2
  15. data/lib/byebug/commands/edit.rb +1 -1
  16. data/lib/byebug/commands/enable/breakpoints.rb +1 -1
  17. data/lib/byebug/commands/finish.rb +1 -1
  18. data/lib/byebug/commands/info/breakpoints.rb +1 -1
  19. data/lib/byebug/commands/info/file.rb +2 -3
  20. data/lib/byebug/commands/irb.rb +8 -6
  21. data/lib/byebug/commands/kill.rb +1 -1
  22. data/lib/byebug/commands/pry.rb +3 -3
  23. data/lib/byebug/commands/restart.rb +22 -5
  24. data/lib/byebug/commands/save.rb +1 -1
  25. data/lib/byebug/core.rb +11 -4
  26. data/lib/byebug/frame.rb +6 -6
  27. data/lib/byebug/helpers/bin.rb +26 -0
  28. data/lib/byebug/helpers/file.rb +3 -3
  29. data/lib/byebug/helpers/parse.rb +1 -1
  30. data/lib/byebug/helpers/path.rb +7 -11
  31. data/lib/byebug/helpers/string.rb +11 -1
  32. data/lib/byebug/helpers/thread.rb +7 -5
  33. data/lib/byebug/helpers/toggle.rb +25 -24
  34. data/lib/byebug/helpers/var.rb +1 -1
  35. data/lib/byebug/history.rb +9 -2
  36. data/lib/byebug/interface.rb +3 -0
  37. data/lib/byebug/interfaces/local_interface.rb +5 -6
  38. data/lib/byebug/interfaces/script_interface.rb +4 -3
  39. data/lib/byebug/printers/base.rb +2 -1
  40. data/lib/byebug/printers/plain.rb +1 -2
  41. data/lib/byebug/printers/texts/base.yml +4 -0
  42. data/lib/byebug/printers/texts/plain.yml +1 -1
  43. data/lib/byebug/processors/command_processor.rb +15 -15
  44. data/lib/byebug/processors/script_processor.rb +6 -12
  45. data/lib/byebug/remote.rb +19 -19
  46. data/lib/byebug/runner.rb +65 -56
  47. data/lib/byebug/setting.rb +1 -1
  48. data/lib/byebug/settings/callstyle.rb +1 -0
  49. data/lib/byebug/version.rb +2 -1
  50. metadata +12 -13
data/lib/byebug/runner.rb CHANGED
@@ -2,7 +2,9 @@ require 'optparse'
2
2
  require 'English'
3
3
  require 'byebug/core'
4
4
  require 'byebug/version'
5
+ require 'byebug/helpers/bin'
5
6
  require 'byebug/helpers/parse'
7
+ require 'byebug/helpers/string'
6
8
  require 'byebug/option_setter'
7
9
  require 'byebug/processors/control_processor'
8
10
 
@@ -11,22 +13,9 @@ module Byebug
11
13
  # Responsible for starting the debugger when started from the command line.
12
14
  #
13
15
  class Runner
16
+ include Helpers::BinHelper
14
17
  include Helpers::ParseHelper
15
-
16
- #
17
- # Error class signaling absence of a script to debug.
18
- #
19
- class NoScript < StandardError; end
20
-
21
- #
22
- # Error class signaling a non existent script to debug.
23
- #
24
- class NonExistentScript < StandardError; end
25
-
26
- #
27
- # Error class signaling a script with invalid Ruby syntax.
28
- #
29
- class InvalidScript < StandardError; end
18
+ include Helpers::StringHelper
30
19
 
31
20
  #
32
21
  # Special working modes that don't actually start the debugger.
@@ -63,7 +52,7 @@ module Byebug
63
52
  def help=(text)
64
53
  @help ||= text
65
54
 
66
- interface.puts("\n#{text}\n")
55
+ interface.puts("#{text}\n")
67
56
  end
68
57
 
69
58
  def version=(number)
@@ -74,6 +63,8 @@ module Byebug
74
63
 
75
64
  def remote=(host_and_port)
76
65
  @remote ||= Byebug.parse_host_and_port(host_and_port)
66
+
67
+ Byebug.start_client(*@remote)
77
68
  end
78
69
 
79
70
  def init_script
@@ -84,12 +75,10 @@ module Byebug
84
75
  # Usage banner.
85
76
  #
86
77
  def banner
87
- <<-EOB.gsub(/^ {8}/, '')
88
-
89
- byebug #{Byebug::VERSION}
90
-
91
- Usage: byebug [options] <script.rb> -- <script.rb parameters>
78
+ prettify <<-EOB
79
+ byebug #{Byebug::VERSION}
92
80
 
81
+ Usage: byebug [options] <script.rb> -- <script.rb parameters>
93
82
  EOB
94
83
  end
95
84
 
@@ -97,17 +86,14 @@ module Byebug
97
86
  # Starts byebug to debug a program.
98
87
  #
99
88
  def run
100
- prepare_options.order!($ARGV)
101
- return if version || help
89
+ Byebug.mode = :standalone
102
90
 
103
- if remote
104
- Byebug.start_client(*remote)
105
- return
106
- end
91
+ option_parser.order!($ARGV)
92
+ return if non_script_option? || error_in_script?
107
93
 
108
- Byebug.run_init_script if init_script
94
+ $PROGRAM_NAME = program
109
95
 
110
- setup_cmd_line_args
96
+ Byebug.run_init_script if init_script
111
97
 
112
98
  loop do
113
99
  debug_program
@@ -127,56 +113,79 @@ module Byebug
127
113
  #
128
114
  # Processes options passed from the command line.
129
115
  #
130
- def prepare_options
131
- OptionParser.new(banner, 25) do |opts|
116
+ def option_parser
117
+ @option_parser ||= OptionParser.new(banner, 25) do |opts|
132
118
  opts.banner = banner
133
119
 
134
120
  OptionSetter.new(self, opts).setup
135
121
  end
136
122
  end
137
123
 
124
+ def program
125
+ @program ||= begin
126
+ candidate = which($ARGV.shift)
127
+ candidate == which('ruby') ? which($ARGV.shift) : candidate
128
+ end
129
+ end
130
+
131
+ #
132
+ # An option that doesn't need a script specified was given
133
+ #
134
+ def non_script_option?
135
+ version || help || remote
136
+ end
137
+
138
+ #
139
+ # There is an error with the specified script
140
+ #
141
+ def error_in_script?
142
+ no_script? || non_existing_script? || invalid_script?
143
+ end
144
+
145
+ #
146
+ # No script to debug specified
147
+ #
148
+ def no_script?
149
+ return false unless $ARGV.empty?
150
+
151
+ print_error('You must specify a program to debug')
152
+ true
153
+ end
154
+
138
155
  #
139
156
  # Extracts debugged program from command line args.
140
157
  #
141
- def setup_cmd_line_args
142
- Byebug.mode = :standalone
158
+ def non_existing_script?
159
+ return false if program
143
160
 
144
- raise(NoScript, 'You must specify a program to debug...') if $ARGV.empty?
161
+ print_error("The script doesn't exist")
162
+ true
163
+ end
145
164
 
146
- program = which($ARGV.shift)
147
- program = which($ARGV.shift) if program == which('ruby')
148
- raise(NonExistentScript, "The script doesn't exist") unless program
165
+ #
166
+ # Checks the debugged script has correct syntax
167
+ #
168
+ def invalid_script?
169
+ return false if syntax_valid?(File.read(program))
149
170
 
150
- $PROGRAM_NAME = program
171
+ print_error('The script has incorrect syntax')
172
+ true
151
173
  end
152
174
 
153
175
  #
154
176
  # Debugs a script only if syntax checks okay.
155
177
  #
156
178
  def debug_program
157
- ok = syntax_valid?(File.read($PROGRAM_NAME))
158
- raise(InvalidScript, 'The script has incorrect syntax') unless ok
159
-
160
- error = Byebug.debug_load($PROGRAM_NAME, stop)
179
+ error = Byebug.debug_load(program, stop)
161
180
  puts "#{error}\n#{error.backtrace}" if error
162
181
  end
163
182
 
164
183
  #
165
- # Cross-platform way of finding an executable in the $PATH.
166
- # Borrowed from: http://stackoverflow.com/questions/2108727
184
+ # Prints an error message and a help string
167
185
  #
168
- def which(cmd)
169
- return File.expand_path(cmd) if File.exist?(cmd)
170
-
171
- exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
172
- ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
173
- exts.each do |ext|
174
- exe = File.join(path, "#{cmd}#{ext}")
175
- return exe if File.executable?(exe) && !File.directory?(exe)
176
- end
177
- end
178
-
179
- nil
186
+ def print_error(msg)
187
+ interface.errmsg(msg)
188
+ interface.puts(option_parser.help)
180
189
  end
181
190
  end
182
191
  end
@@ -58,7 +58,7 @@ module Byebug
58
58
  end
59
59
 
60
60
  #
61
- # TODO: DRY this up. Very similar code exists in the CommandList class
61
+ # @todo DRY this up. Very similar code exists in the CommandList class
62
62
  #
63
63
  def help_all
64
64
  output = " List of supported settings:\n\n"
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'byebug/setting'
3
4
 
4
5
  module Byebug
@@ -1,7 +1,8 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  #
3
4
  # Reopen main module to define the library version
4
5
  #
5
6
  module Byebug
6
- VERSION = '8.2.5'.freeze
7
+ VERSION = '9.1.0'.freeze
7
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: byebug
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.2.5
4
+ version: 9.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Rodriguez
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2016-04-27 00:00:00.000000000 Z
13
+ date: 2017-08-22 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler
@@ -27,12 +27,11 @@ dependencies:
27
27
  - !ruby/object:Gem::Version
28
28
  version: '1.7'
29
29
  description: |-
30
- Byebug is a Ruby 2 debugger. It's implemented using the
31
- Ruby 2 TracePoint C API for execution control and the Debug Inspector C API
32
- for call stack navigation. The core component provides support that
33
- front-ends can build on. It provides breakpoint handling and bindings for
34
- stack frames among other things and it comes with an easy to use command
35
- line interface.
30
+ Byebug is a Ruby debugger. It's implemented using the
31
+ TracePoint C API for execution control and the Debug Inspector C API for
32
+ call stack navigation. The core component provides support that front-ends
33
+ can build on. It provides breakpoint handling and bindings for stack frames
34
+ among other things and it comes with an easy to use command line interface.
36
35
  email: deivid.rodriguez@mail.com
37
36
  executables:
38
37
  - byebug
@@ -124,6 +123,7 @@ files:
124
123
  - lib/byebug/core.rb
125
124
  - lib/byebug/errors.rb
126
125
  - lib/byebug/frame.rb
126
+ - lib/byebug/helpers/bin.rb
127
127
  - lib/byebug/helpers/eval.rb
128
128
  - lib/byebug/helpers/file.rb
129
129
  - lib/byebug/helpers/frame.rb
@@ -171,7 +171,7 @@ files:
171
171
  - lib/byebug/version.rb
172
172
  homepage: http://github.com/deivid-rodriguez/byebug
173
173
  licenses:
174
- - BSD
174
+ - BSD-2-Clause
175
175
  metadata: {}
176
176
  post_install_message:
177
177
  rdoc_options: []
@@ -181,7 +181,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
181
181
  requirements:
182
182
  - - ">="
183
183
  - !ruby/object:Gem::Version
184
- version: 2.0.0
184
+ version: 2.2.0
185
185
  required_rubygems_version: !ruby/object:Gem::Requirement
186
186
  requirements:
187
187
  - - ">="
@@ -189,9 +189,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
189
189
  version: '0'
190
190
  requirements: []
191
191
  rubyforge_project:
192
- rubygems_version: 2.6.3
192
+ rubygems_version: 2.6.12
193
193
  signing_key:
194
194
  specification_version: 4
195
- summary: Ruby 2.0 fast debugger - base + CLI
195
+ summary: Ruby fast debugger - base + CLI
196
196
  test_files: []
197
- has_rdoc: