byebug 2.0.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bb2fb8a1795fb10ac0b9a08f34c9384590f2ed68
4
- data.tar.gz: ddcc06fdb4be593c69905dc4a0277ea5bf2d945e
3
+ metadata.gz: 16eb83030dd348fff8d681d7fc1cb7afdbbcfe93
4
+ data.tar.gz: c22e24de059a48c698e5fa8a68adef55902cfbb2
5
5
  SHA512:
6
- metadata.gz: bd5bec3e835cec6a85de603e4437e013f86fa5e9f239a243fcfa9540b17324a27a075b3a7c78520d2390d8a32e698f8939006e46fbe7f56e547bd008ceb73958
7
- data.tar.gz: de559dec1bf1265a8e8cacb7431b1617a53ad10dafb24c4ae728714116c5d80580d52e180665fe46632578e8bb198bc9fe8240f989e815f56a80240883c5cad9
6
+ metadata.gz: 06281b839a4a394cbf7eb4c1ea708fce8c2ba5754b0248b716e424a01843391da5e11545c255b9e6fa221f3c9c2d095fa3272150663b1044340767d6d1eb7bd3
7
+ data.tar.gz: f728e9648771220b3312224d8d31def9cfc9d1e6ad756ba6beff701a15ae434635378fc68b2c7f613cd939459afff9bc9fbc2ba44d10e32b68c514f3eeda24cb
@@ -1,3 +1,12 @@
1
+ # 2.1.0
2
+
3
+ * Fix bug in remote debugging display
4
+ * Fix bug where eval would crash when inspect raised an exception (reported by
5
+ @iblue)
6
+ * `enable breakpoints` now enables every breakpoint
7
+ * `disable breakpoints` now disables every breakpoint
8
+
9
+
1
10
  # 2.0.0
2
11
 
3
12
  * Various bug fixes
data/GUIDE.md CHANGED
@@ -1153,3 +1153,36 @@ available only if the nodewrap gem is installed_.
1153
1153
  * `method <class-or-module>`. Show methods of the class or module
1154
1154
  `<class-or-module>`. Basically this is the same as running
1155
1155
  `ps <class-or-module>.methods`.
1156
+
1157
+ ### Examining Program Source Files (`list`)
1158
+
1159
+ `byebug` can print parts of your script's source. When your script stops,
1160
+ `byebug` spontaneously lists the source code around the line where it stopped
1161
+ that line. It does that when you change the current stack frame as well.
1162
+ Implicitly there is a default line location. Each time a list command is run
1163
+ that implicit location is updated, so that running several list commands in
1164
+ succession shows a contiguous block of program text.
1165
+
1166
+ If you don't need code context displayed every time, you can issue the `set
1167
+ noautolist` command. Now whenever you want code listed, you can explicitly issue
1168
+ the `list` command or its abbreviation `l`. Notice that when a second listing is
1169
+ displayed, we continue listing from the place we last left off. When the
1170
+ beginning or end of the file is reached, the line range to be shown is adjusted
1171
+ so "it doesn't overflow". You can set the `noautolist` option by default by
1172
+ dropping `set noautolist` in byebug's startup file `.byebugrc`.
1173
+
1174
+ If you want to set how many lines to be printed by default rather than use the
1175
+ initial number of lines, 10, use the `set listsize` command ([listsize()). To
1176
+ see the entire program in one shot, give an explicit starting and ending line
1177
+ number. You can print other portions of source files by giving explicit position
1178
+ as a parameter to the list command.
1179
+
1180
+ There are several ways to specify what part of the file you want to print. `list
1181
+ nnn` prints lines centered around line number `nnn` in the current source file.
1182
+ `l` prints more lines, following the last lines printed. `list -` prints lines
1183
+ just before the lines last printed. `list nnn-mmm` prints lines between `nnn`
1184
+ and `mmm` inclusive. `list =` prints lines centered around where the script is
1185
+ stopped. Repeating a `list` command with `RET` discards the argument, so it is
1186
+ equivalent to typing just `list`. This is more useful than listing the same
1187
+ lines again. An exception is made for an argument of `-`: that argument is
1188
+ preserved in repetition so that each repetition moves up in the source file.
data/README.md CHANGED
@@ -23,13 +23,7 @@ effects of one bug and go on to learn about another.
23
23
 
24
24
  ## Install
25
25
 
26
- Just drop
27
-
28
- gem 'byebug'
29
-
30
- in your Gemfile and run
31
-
32
- bundle install
26
+ $ gem install byebug
33
27
 
34
28
  **Please upgrade your ruby to 2.0.0-p247 or higher** - a bug in ruby core was
35
29
  directly affecting byebug and a fix for it has been released with this
@@ -197,14 +197,15 @@ module Byebug
197
197
  eval(str, b)
198
198
  rescue StandardError, ScriptError => e
199
199
  if Command.settings[:stack_trace_on_error]
200
- at = eval("caller(1)", b)
201
- print "#{at.shift}:#{e.to_s.sub(/\(eval\):1:(in `.*?':)?/, '')}"
200
+ at = eval("Thread.current.backtrace_locations(1)", b)
201
+ print "#{at.shift}: #{e.class} Exception(#{e.message})\n"
202
202
  for i in at
203
203
  print "\tfrom #{i}\n"
204
204
  end
205
205
  else
206
206
  print "#{e.class} Exception: #{e.message}\n"
207
207
  end
208
+ nil
208
209
  end
209
210
  end
210
211
 
@@ -3,30 +3,29 @@ module Byebug
3
3
  # Mix-in module to assist in command parsing.
4
4
  module EnableDisableFunctions
5
5
  def enable_disable_breakpoints(is_enable, args)
6
- breakpoints = Byebug.breakpoints.sort_by{|b| b.id }
7
- largest = breakpoints.inject(0) do |tally, b|
8
- tally = b.id if b.id > tally
9
- end
10
- if 0 == largest
11
- errmsg "No breakpoints have been set.\n"
12
- return
6
+ return errmsg "No breakpoints have been set." if Byebug.breakpoints.empty?
7
+
8
+ all_breakpoints = Byebug.breakpoints.sort_by {|b| b.id }
9
+ if !args
10
+ selected_breakpoints = all_breakpoints
11
+ else
12
+ selected_ids = []
13
+ args.each do |pos|
14
+ pos = get_int(pos, "#{is_enable} breakpoints", 1, all_breakpoints.last.id)
15
+ return nil unless pos
16
+ selected_ids << pos
17
+ end
18
+ selected_breakpoints = all_breakpoints.select {
19
+ |b| selected_ids.include?(b.id) }
13
20
  end
14
- args.each do |pos|
15
- pos = get_int(pos, "#{is_enable} breakpoints", 1, largest)
16
- return nil unless pos
17
- breakpoints.each do |b|
18
- if b.id == pos
19
- enabled = ('enable' == is_enable)
20
- if enabled
21
- unless syntax_valid?(b.expr)
22
- errmsg "Expression \"#{b.expr}\" syntactically incorrect; " \
23
- "breakpoint remains disabled.\n"
24
- break
25
- end
26
- end
27
- b.enabled = ('enable' == is_enable)
28
- break
29
- end
21
+
22
+ selected_breakpoints.each do |b|
23
+ enabled = ('enable' == is_enable)
24
+ if enabled && !syntax_valid?(b.expr)
25
+ errmsg "Expression \"#{b.expr}\" syntactically incorrect; " \
26
+ "breakpoint remains disabled.\n"
27
+ else
28
+ b.enabled = enabled
30
29
  end
31
30
  end
32
31
  end
@@ -47,9 +46,10 @@ module Byebug
47
46
  class EnableCommand < Command
48
47
  Subcommands =
49
48
  [
50
- ['breakpoints', 2, 'Enable specified breakpoints',
51
- 'Give breakpoint numbers (separated by spaces) as arguments. This is ' \
52
- 'used to cancel the effect of the "disable" command.'],
49
+ ['breakpoints', 2, 'Enable breakpoints',
50
+ 'This is used to cancel the effect of the "disable" command. Give ' \
51
+ 'breakpoint numbers (separated by spaces) as arguments or no ' \
52
+ 'argument at all if you want to reenable every breakpoint'],
53
53
  ['display', 2,
54
54
  'Enable some expressions to be displayed when program stops',
55
55
  'Arguments are the code numbers of the expressions to resume ' \
@@ -93,8 +93,7 @@ module Byebug
93
93
  def description
94
94
  %{Enable breakpoints or displays.
95
95
 
96
- This is used to cancel the effect of the "disable" command.
97
- }
96
+ This is used to cancel the effect of the "disable" command.}
98
97
  end
99
98
  end
100
99
  end
@@ -102,11 +101,13 @@ module Byebug
102
101
  class DisableCommand < Command
103
102
  Subcommands =
104
103
  [
105
- ['breakpoints', 1, 'Disable some breakpoints',
106
- 'Arguments are breakpoint numbers with spaces in between. A disabled ' \
107
- 'breakpoint is not forgotten, but has no effect until reenabled.'],
104
+ ['breakpoints', 1, 'Disable breakpoints',
105
+ 'A disabled breakpoint is not forgotten, but has no effect until ' \
106
+ 'reenabled. Give breakpoint numbers (separated by spaces) as ' \
107
+ 'arguments or no argument at all if you want to disable every ' \
108
+ 'breakpoint'],
108
109
  ['display', 1, 'Disable some display expressions when program stops',
109
- 'Arguments are the code numbers of the expressions to stop ' \
110
+ 'Arguments are the code numbers of the expressions to stop ' \
110
111
  'displaying. Do "info display" to see the current list of code ' \
111
112
  'numbers.'],
112
113
  ].map do |name, min, short_help, long_help|
@@ -148,8 +149,7 @@ module Byebug
148
149
  %{Disable breakpoints or displays.
149
150
 
150
151
  A disabled item is not forgotten, but has no effect until reenabled.
151
- Use the "enable" command to have it take effect again.
152
- }
152
+ Use the "enable" command to have it take effect again.}
153
153
  end
154
154
  end
155
155
  end
@@ -51,6 +51,8 @@ module Byebug
51
51
  run_with_binding do |b|
52
52
  print "#{debug_eval(expr, b).inspect}\n"
53
53
  end
54
+ rescue
55
+ print "#{$!.class} Exception: #{$!.message}\n"
54
56
  end
55
57
 
56
58
  class << self
@@ -106,7 +106,7 @@ module Byebug
106
106
  if Byebug.post_mortem?
107
107
  realsize = @state.context.stack_size
108
108
  else
109
- realsize = Thread.current.backtrace_locations.
109
+ realsize = Thread.current.backtrace_locations(1).
110
110
  drop_while{ |l| IGNORED_FILES.include?(l.path) || l.path == '(eval)' }.
111
111
  take_while{ |l| !IGNORED_FILES.include?(l.path) }.size
112
112
  size = @state.context.stack_size
@@ -18,9 +18,10 @@ module Byebug
18
18
  file = @state.context.frame_file(0)
19
19
  line = @state.context.frame_line(0)
20
20
  else
21
- if context.thread.backtrace_locations && context.thread.backtrace_locations[0]
22
- file = context.thread.backtrace_locations[0].path
23
- line = context.thread.backtrace_locations[0].lineno
21
+ if context.thread.backtrace_locations(1) &&
22
+ context.thread.backtrace_locations(1)[0]
23
+ file = context.thread.backtrace_locations(1)[0].path
24
+ line = context.thread.backtrace_locations(1)[0].lineno
24
25
  end
25
26
  end
26
27
  file_line = "#{file}:#{line}"
@@ -157,7 +157,7 @@ module Byebug
157
157
  end
158
158
 
159
159
  def print(*args)
160
- @socket.printf(*args)
160
+ @socket.printf(escape(format(*args)))
161
161
  end
162
162
 
163
163
  private
@@ -1,3 +1,3 @@
1
1
  module Byebug
2
- VERSION = '2.0.0'
2
+ VERSION = '2.1.0'
3
3
  end
@@ -15,12 +15,13 @@ class TestBreakpoints < TestDsl::TestCase
15
15
  debug_file('breakpoint') { subject.send(field).must_equal value }
16
16
  end
17
17
 
18
- it('must have correct pos') { check_subject(:pos, 10) }
19
- it('must have correct source') { check_subject(:source, @tst_file) }
20
- it('must have correct expression') { check_subject(:expr, nil) }
21
- it('must have correct hit count') { check_subject(:hit_count, 0) }
22
- it('must have correct hit value') { check_subject(:hit_value, 0) }
23
- it('must be enabled') { check_subject(:enabled?, true) }
18
+ it('must have correct pos') { check_subject(:pos, 10) }
19
+ it('must have correct source') { check_subject(:source, @tst_file) }
20
+ it('must have correct expression') { check_subject(:expr, nil) }
21
+ it('must have correct hit count') { check_subject(:hit_count, 0) }
22
+ it('must have correct hit value') { check_subject(:hit_value, 0) }
23
+ it('must be enabled') { check_subject(:enabled?, true) }
24
+
24
25
  it('must return right response') do
25
26
  id = nil
26
27
  debug_file('breakpoint') { id = subject.id }
@@ -203,13 +204,12 @@ class TestBreakpoints < TestDsl::TestCase
203
204
  end
204
205
  end
205
206
 
206
- describe 'disabling a breakpoint' do
207
+ describe 'disabling breakpoints' do
207
208
  describe 'successfully' do
208
- before { enter 'break 14' }
209
+ before { enter 'break 14', 'break 15' }
209
210
 
210
211
  describe 'short syntax' do
211
- before { enter ->{"disable #{Byebug.breakpoints.first.id}"},
212
- 'break 15' }
212
+ before { enter ->{ "disable #{Byebug.breakpoints.first.id}" } }
213
213
 
214
214
  it 'must have a breakpoint with #enabled? returning false' do
215
215
  debug_file('breakpoint') {
@@ -223,17 +223,36 @@ class TestBreakpoints < TestDsl::TestCase
223
223
  end
224
224
 
225
225
  describe 'full syntax' do
226
- before { enter ->{"disable breakpoints #{Byebug.breakpoints.first.id}"},
227
- 'break 15' }
226
+ describe 'with no args' do
227
+ before { enter 'disable breakpoints' }
228
+
229
+ it 'must have all breakoints with #enabled? returning false' do
230
+ debug_file('breakpoint') do
231
+ Byebug.breakpoints.first.enabled?.must_equal false
232
+ Byebug.breakpoints.last.enabled?.must_equal false
233
+ end
234
+ end
235
+
236
+ it 'must not stop on any disabled breakpoint' do
237
+ enter 'cont'
238
+ debug_file('breakpoint') { $state.line.must_be nil }
239
+ end
240
+ end
228
241
 
229
- it 'must have a breakpoint with #enabled? returning false' do
230
- debug_file('breakpoint') {
231
- Byebug.breakpoints.first.enabled?.must_equal false }
242
+ describe 'with specific breakpoint' do
243
+ before do
244
+ enter ->{ "disable breakpoints #{Byebug.breakpoints.first.id}" }
245
+ end
246
+
247
+ it 'must have a breakpoint with #enabled? returning false' do
248
+ debug_file('breakpoint') {
249
+ Byebug.breakpoints.first.enabled?.must_equal false }
250
+ end
232
251
  end
233
252
  end
234
253
  end
235
254
 
236
- describe 'errors' do
255
+ describe 'unsuccesfully' do
237
256
  it 'must show an error if syntax is incorrect' do
238
257
  enter 'disable'
239
258
  debug_file('breakpoint')
@@ -241,7 +260,7 @@ class TestBreakpoints < TestDsl::TestCase
241
260
  '"breakpoints" or breakpoint numbers.'
242
261
  end
243
262
 
244
- it 'must show an error if no breakpoints is set' do
263
+ it 'must show an error if no breakpoints are set' do
245
264
  enter 'disable 1'
246
265
  debug_file('breakpoint')
247
266
  check_error_includes 'No breakpoints have been set.'
@@ -256,13 +275,12 @@ class TestBreakpoints < TestDsl::TestCase
256
275
  end
257
276
  end
258
277
 
259
- describe 'enabling a breakpoint' do
260
-
278
+ describe 'enabling breakpoints' do
261
279
  describe 'successfully' do
262
- before { enter 'break 14' }
280
+ before { enter 'break 14', 'break 15', 'disable breakpoints' }
263
281
 
264
282
  describe 'short syntax' do
265
- before { enter ->{"enable #{Byebug.breakpoints.first.id}"}, 'break 15' }
283
+ before { enter ->{ "enable #{Byebug.breakpoints.first.id}" } }
266
284
 
267
285
  it 'must have a breakpoint with #enabled? returning true' do
268
286
  debug_file('breakpoint') {
@@ -276,12 +294,41 @@ class TestBreakpoints < TestDsl::TestCase
276
294
  end
277
295
 
278
296
  describe 'full syntax' do
279
- before { enter ->{"enable breakpoints #{Byebug.breakpoints.first.id}"},
280
- 'break 15' }
297
+ describe 'with no args' do
298
+ before { enter 'enable breakpoints' }
299
+
300
+ it 'must have all breakoints with #enabled? returning true' do
301
+ debug_file('breakpoint') do
302
+ Byebug.breakpoints.first.enabled?.must_equal true
303
+ Byebug.breakpoints.last.enabled?.must_equal true
304
+ end
305
+ end
306
+
307
+ it 'must stop on the first breakpoint' do
308
+ enter 'cont'
309
+ debug_file('breakpoint') { $state.line.must_be 14 }
310
+ end
311
+
312
+ it 'must stop on the last breakpoint' do
313
+ enter 'cont', 'cont'
314
+ debug_file('breakpoint') { $state.line.must_be 15 }
315
+ end
316
+ end
281
317
 
282
- it 'must have a breakpoint with #enabled? returning true' do
283
- debug_file('breakpoint') {
284
- Byebug.breakpoints.first.enabled?.must_equal true }
318
+ describe 'with specific breakpoint' do
319
+ before do
320
+ enter ->{ "enable breakpoints #{Byebug.breakpoints.last.id}" }
321
+ end
322
+
323
+ it 'must have a breakpoint with #enabled? returning true' do
324
+ debug_file('breakpoint') {
325
+ Byebug.breakpoints.first.enabled?.must_equal true }
326
+ end
327
+
328
+ it 'must not stop on the enabled breakpoint' do
329
+ enter 'cont'
330
+ debug_file('breakpoint') { $state.line.must_be 15 }
331
+ end
285
332
  end
286
333
  end
287
334
  end
@@ -20,6 +20,12 @@ class TestEval < TestDsl::TestCase
20
20
  check_output_includes '5'
21
21
  end
22
22
 
23
+ it 'must work when inspect raises an exception' do
24
+ enter 'c 14', 'p @foo'
25
+ debug_file('eval') { $state.line.must_equal 14 }
26
+ check_output_includes 'RuntimeError Exception: Broken'
27
+ end
28
+
23
29
  describe 'autoeval' do
24
30
  it 'must be set by default' do
25
31
  enter '[5,6,7].inject(&:+)'
@@ -43,7 +49,7 @@ class TestEval < TestDsl::TestCase
43
49
  it 'must show a stack trace' do
44
50
  enter 'eval 2 / 0'
45
51
  debug_file 'eval'
46
- check_output_includes /\S+:\d+:in `eval':divided by 0/
52
+ check_output_includes /\s*from \S+:in \`eval\'/
47
53
  check_output_doesnt_include 'ZeroDivisionError Exception: divided by 0'
48
54
  end
49
55
  end
@@ -1,4 +1,14 @@
1
1
  byebug
2
+
2
3
  b = 5
3
4
  c = b + 5
4
5
  c
6
+
7
+ class EvalTest
8
+ def inspect
9
+ raise "Broken"
10
+ end
11
+ end
12
+
13
+ @foo = EvalTest.new
14
+ b = 6
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: 2.0.0
4
+ version: 2.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: 2013-08-30 00:00:00.000000000 Z
13
+ date: 2013-09-08 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: columnize