byebug 2.1.1 → 2.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 (81) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/CHANGELOG.md +9 -0
  4. data/CONTRIBUTING.md +13 -1
  5. data/GUIDE.md +181 -1
  6. data/README.md +67 -211
  7. data/Rakefile +1 -0
  8. data/bin/byebug +1 -8
  9. data/ext/byebug/byebug.c +66 -25
  10. data/ext/byebug/context.c +16 -20
  11. data/ext/byebug/extconf.rb +2 -1
  12. data/lib/byebug.rb +16 -9
  13. data/lib/byebug/command.rb +3 -3
  14. data/lib/byebug/commands/condition.rb +2 -2
  15. data/lib/byebug/commands/edit.rb +12 -9
  16. data/lib/byebug/commands/eval.rb +0 -16
  17. data/lib/byebug/commands/frame.rb +7 -17
  18. data/lib/byebug/commands/info.rb +2 -9
  19. data/lib/byebug/commands/list.rb +1 -1
  20. data/lib/byebug/commands/reload.rb +11 -0
  21. data/lib/byebug/commands/repl.rb +3 -6
  22. data/lib/byebug/commands/set.rb +5 -5
  23. data/lib/byebug/commands/show.rb +5 -0
  24. data/lib/byebug/commands/threads.rb +4 -4
  25. data/lib/byebug/commands/trace.rb +2 -1
  26. data/lib/byebug/context.rb +14 -5
  27. data/lib/byebug/interface.rb +1 -1
  28. data/lib/byebug/processor.rb +1 -1
  29. data/lib/byebug/remote.rb +1 -24
  30. data/lib/byebug/version.rb +1 -1
  31. data/old_doc/byebug.1 +0 -3
  32. data/old_doc/byebug.texi +2 -3
  33. data/test/breakpoints_test.rb +75 -52
  34. data/test/conditions_test.rb +2 -3
  35. data/test/continue_test.rb +6 -0
  36. data/test/edit_test.rb +3 -3
  37. data/test/eval_test.rb +14 -5
  38. data/test/examples/breakpoint.rb +4 -13
  39. data/test/examples/breakpoint_deep.rb +1 -21
  40. data/test/examples/conditions.rb +1 -1
  41. data/test/examples/continue.rb +2 -1
  42. data/test/examples/edit.rb +1 -0
  43. data/test/examples/eval.rb +1 -11
  44. data/test/examples/finish.rb +0 -17
  45. data/test/examples/frame.rb +2 -26
  46. data/test/examples/frame_deep.rb +0 -19
  47. data/test/examples/help.rb +0 -1
  48. data/test/examples/info.rb +4 -36
  49. data/test/examples/kill.rb +1 -1
  50. data/test/examples/list.rb +1 -1
  51. data/test/examples/method.rb +2 -13
  52. data/test/examples/post_mortem.rb +1 -16
  53. data/test/examples/quit.rb +1 -1
  54. data/test/examples/reload.rb +1 -1
  55. data/test/examples/restart.rb +1 -1
  56. data/test/examples/show.rb +0 -1
  57. data/test/examples/stepping.rb +2 -19
  58. data/test/examples/thread.rb +0 -27
  59. data/test/examples/variables.rb +0 -22
  60. data/test/finish_test.rb +22 -6
  61. data/test/frame_test.rb +89 -56
  62. data/test/info_test.rb +71 -46
  63. data/test/kill_test.rb +6 -1
  64. data/test/list_test.rb +1 -2
  65. data/test/method_test.rb +32 -13
  66. data/test/post_mortem_test.rb +34 -21
  67. data/test/quit_test.rb +0 -1
  68. data/test/restart_test.rb +6 -0
  69. data/test/set_test.rb +1 -1
  70. data/test/show_test.rb +17 -17
  71. data/test/source_test.rb +2 -3
  72. data/test/stepping_test.rb +31 -7
  73. data/test/support/test_dsl.rb +11 -1
  74. data/test/test_helper.rb +9 -0
  75. data/test/thread_test.rb +57 -23
  76. data/test/trace_test.rb +0 -1
  77. data/test/variables_test.rb +36 -17
  78. metadata +3 -9
  79. data/test/examples/breakpoint2.rb +0 -7
  80. data/test/examples/jump.rb +0 -14
  81. data/test/examples/set_annotate.rb +0 -12
@@ -1,7 +1,12 @@
1
1
  require_relative 'test_helper'
2
2
 
3
- class TestKill < TestDsl::TestCase
3
+ class KillExample
4
+ def self.kill_me
5
+ 'dieeee'
6
+ end
7
+ end
4
8
 
9
+ class TestKill < TestDsl::TestCase
5
10
  it 'must send signal to some pid' do
6
11
  Process.expects(:kill).with('USR1', Process.pid)
7
12
  enter 'kill USR1'
@@ -1,7 +1,6 @@
1
1
  require_relative 'test_helper'
2
2
 
3
3
  class TestList < TestDsl::TestCase
4
-
5
4
  describe 'listsize' do
6
5
  it 'must show lines according to :listsize setting' do
7
6
  enter 'break 5', 'cont'
@@ -108,7 +107,7 @@ class TestList < TestDsl::TestCase
108
107
  debug_file 'list'
109
108
  check_error_includes 'Invalid line range'
110
109
  check_output_doesnt_include "[44, 44] in #{fullpath('list')}"
111
- check_output_doesnt_include /^44 \S/
110
+ check_output_doesnt_include(/^44 \S/)
112
111
  end
113
112
 
114
113
  it 'must show nothing if range is incorrect' do
@@ -1,41 +1,58 @@
1
1
  require_relative 'test_helper'
2
2
 
3
+ class MethodExample
4
+ def initialize
5
+ @a = 'b'
6
+ @c = 'd'
7
+ end
8
+ def self.foo
9
+ "asdf"
10
+ end
11
+ def bla
12
+ "asdf"
13
+ end
14
+ end
15
+
3
16
  class TestMethod < TestDsl::TestCase
4
17
  temporary_change_hash Byebug.settings, :autolist, 0
5
18
 
6
19
  describe 'show instance method of a class' do
20
+ before { enter 'break 4', 'cont' }
21
+
7
22
  it 'must show using full command name' do
8
- enter 'break 15', 'cont', 'method MethodExample'
23
+ enter 'method MethodExample'
9
24
  debug_file 'method'
10
- check_output_includes /bla/
11
- check_output_doesnt_include /foo/
25
+ check_output_includes(/bla/)
26
+ check_output_doesnt_include(/foo/)
12
27
  end
13
28
 
14
29
  it 'must show using shortcut' do
15
- enter 'break 15', 'cont', 'm MethodExample'
30
+ enter 'm MethodExample'
16
31
  debug_file 'method'
17
- check_output_includes /bla/
32
+ check_output_includes(/bla/)
18
33
  end
19
34
 
20
35
  it 'must show an error if specified object is not a class or module' do
21
- enter 'break 15', 'cont', 'm a'
36
+ enter 'm a'
22
37
  debug_file 'method'
23
38
  check_output_includes 'Should be Class/Module: a'
24
39
  end
25
40
  end
26
41
 
27
42
  describe 'show methods of an object' do
43
+ before { enter 'break 4', 'cont' }
44
+
28
45
  it 'must show using full command name' do
29
- enter 'break 15', 'cont', 'method instance a'
46
+ enter 'method instance a'
30
47
  debug_file 'method'
31
- check_output_includes /bla/
32
- check_output_doesnt_include /foo/
48
+ check_output_includes(/bla/)
49
+ check_output_doesnt_include(/foo/)
33
50
  end
34
51
 
35
52
  it 'must show using shortcut' do
36
- enter 'break 15', 'cont', 'm i a'
53
+ enter 'm i a'
37
54
  debug_file 'method'
38
- check_output_includes /bla/
55
+ check_output_includes(/bla/)
39
56
  end
40
57
  end
41
58
 
@@ -46,14 +63,16 @@ class TestMethod < TestDsl::TestCase
46
63
  end
47
64
 
48
65
  describe 'show instance variables of an object' do
66
+ before { enter 'break 4', 'cont' }
67
+
49
68
  it 'must show using full name command' do
50
- enter 'break 15', 'cont', 'method iv a'
69
+ enter 'method iv a'
51
70
  debug_file 'method'
52
71
  check_output_includes '@a = "b"', '@c = "d"'
53
72
  end
54
73
 
55
74
  it 'must show using shortcut' do
56
- enter 'break 15', 'cont', 'm iv a'
75
+ enter 'm iv a'
57
76
  debug_file 'method'
58
77
  check_output_includes '@a = "b"', '@c = "d"'
59
78
  end
@@ -1,25 +1,38 @@
1
1
  require_relative 'test_helper'
2
2
 
3
- class TestPostMortem < TestDsl::TestCase
3
+ class PostMortemExample
4
+ def a
5
+ begin
6
+ Byebug.post_mortem do
7
+ z = 4
8
+ raise 'blabla'
9
+ x = 6
10
+ x + z
11
+ end
12
+ rescue => e
13
+ e
14
+ end
15
+ end
16
+ end
4
17
 
18
+ class TestPostMortem < TestDsl::TestCase
5
19
  describe 'Features' do
20
+ before { enter 'cont' }
21
+
6
22
  it 'must enter into post-mortem mode' do
7
- enter 'cont'
8
23
  debug_file('post_mortem') { Byebug.post_mortem?.must_equal true }
9
24
  end
10
25
 
11
26
  it 'must stop at the correct line' do
12
- enter 'cont'
13
27
  debug_file('post_mortem') { $state.line.must_equal 8 }
14
28
  end
15
29
 
16
30
  it 'must exit from post-mortem mode after stepping command' do
17
- enter 'cont', 'break 12', 'cont'
31
+ enter "break #{__FILE__}:13", 'cont'
18
32
  debug_file('post_mortem') { Byebug.post_mortem?.must_equal false }
19
33
  end
20
34
 
21
35
  it 'must save the raised exception' do
22
- enter 'cont'
23
36
  debug_file('post_mortem') {
24
37
  Byebug.last_exception.must_be_kind_of RuntimeError }
25
38
  end
@@ -76,23 +89,23 @@ class TestPostMortem < TestDsl::TestCase
76
89
  it 'must work in post-mortem mode' do
77
90
  enter 'cont', 'frame'
78
91
  debug_file('post_mortem') { $state.line.must_equal 8 }
79
- check_output_includes \
80
- /--> #0 block in CatchExample\.a\s+at #{@tst_file}:8/
92
+ check_output_includes(
93
+ /--> #0 block in PostMortemExample\.a\s+at #{__FILE__}:8/)
81
94
  end
82
95
  end
83
96
 
84
97
  describe 'condition' do
85
98
  it 'must be able to set conditions in post-mortem mode' do
86
- enter 'cont', 'break 12',
99
+ enter 'cont', "break #{__FILE__}:13",
87
100
  ->{ "cond #{Byebug.breakpoints.first.id} true" }, 'cont'
88
- debug_file('post_mortem') { $state.line.must_equal 12 }
101
+ debug_file('post_mortem') { $state.line.must_equal 13 }
89
102
  end
90
103
  end
91
104
 
92
105
  describe 'break' do
93
106
  it 'must be able to set breakpoints in post-mortem mode' do
94
- enter 'cont', 'break 12', 'cont'
95
- debug_file('post_mortem') { $state.line.must_equal 12 }
107
+ enter 'cont', "break #{__FILE__}:13",
108
+ debug_file('post_mortem') { $state.line.must_equal 13 }
96
109
  end
97
110
  end
98
111
 
@@ -105,15 +118,15 @@ class TestPostMortem < TestDsl::TestCase
105
118
  end
106
119
 
107
120
  describe 'reload' do
108
- after { change_line_in_file(@tst_file, 7, ' z = 4') }
121
+ after { change_line_in_file(@tst_file, 4, 'c.a') }
109
122
 
110
123
  it 'must work in post-mortem mode' do
111
124
  enter 'cont', -> do
112
- change_line_in_file(@tst_file, 7, 'z = 100')
125
+ change_line_in_file(@tst_file, 4, 'bo = BasicObject.new')
113
126
  'reload'
114
- end, 'l 7-7'
127
+ end, 'up 3', 'l 4-4'
115
128
  debug_file 'post_mortem'
116
- check_output_includes '7: z = 100'
129
+ check_output_includes '=> 4: bo = BasicObject.new'
117
130
  end
118
131
  end
119
132
 
@@ -132,7 +145,7 @@ class TestPostMortem < TestDsl::TestCase
132
145
  it 'must work in post-mortem mode' do
133
146
  enter 'cont', 'info line'
134
147
  debug_file 'post_mortem'
135
- check_output_includes "Line 8 of \"#{@tst_file}\""
148
+ check_output_includes "Line 8 of \"#{__FILE__}\""
136
149
  end
137
150
  end
138
151
 
@@ -141,8 +154,8 @@ class TestPostMortem < TestDsl::TestCase
141
154
 
142
155
  it 'must work in post-mortem mode' do
143
156
  irb.stubs(:eval_input).throws(:IRB_EXIT, :cont)
144
- enter 'cont', 'break 12', 'irb'
145
- debug_file('post_mortem') { $state.line.must_equal 12 }
157
+ enter 'cont', 'break 13', 'irb'
158
+ debug_file('post_mortem') { $state.line.must_equal 13 }
146
159
  end
147
160
  end
148
161
 
@@ -181,7 +194,7 @@ class TestPostMortem < TestDsl::TestCase
181
194
  it 'must work in post-mortem mode' do
182
195
  enter 'cont'
183
196
  debug_file 'post_mortem'
184
- check_output_includes "[3, 12] in #{@tst_file}"
197
+ check_output_includes "[3, 12] in #{__FILE__}"
185
198
  end
186
199
  end
187
200
 
@@ -189,7 +202,7 @@ class TestPostMortem < TestDsl::TestCase
189
202
  it 'must work in post-mortem mode' do
190
203
  enter 'cont', 'm i self'
191
204
  debug_file 'post_mortem'
192
- check_output_includes /to_s/
205
+ check_output_includes(/to_s/)
193
206
  end
194
207
  end
195
208
 
@@ -251,7 +264,7 @@ class TestPostMortem < TestDsl::TestCase
251
264
  it "must work in post-mortem mode" do
252
265
  enter 'cont', 'thread list'
253
266
  debug_file('post_mortem')
254
- check_output_includes /\+ \d+ #<Thread:(\S+) run/
267
+ check_output_includes(/\+ \d+ #<Thread:(\S+) run/)
255
268
  end
256
269
  end
257
270
  end
@@ -1,7 +1,6 @@
1
1
  require_relative 'test_helper'
2
2
 
3
3
  class TestQuit < TestDsl::TestCase
4
-
5
4
  it 'must quit if user confirmed' do
6
5
  Byebug::QuitCommand.any_instance.expects(:exit!)
7
6
  enter 'quit', 'y'
@@ -1,5 +1,11 @@
1
1
  require_relative 'test_helper'
2
2
 
3
+ class RestartExample
4
+ def concat_args(a, b, c)
5
+ a.to_s + b.to_s + c.to_s
6
+ end
7
+ end
8
+
3
9
  class TestRestart < TestDsl::TestCase
4
10
  describe 'usual restarting' do
5
11
  temporary_change_const Byebug, 'BYEBUG_SCRIPT', 'byebug_script'
@@ -184,7 +184,7 @@ class TestSet < TestDsl::TestCase
184
184
  it 'must show help when typing just "set"' do
185
185
  enter 'set', 'cont'
186
186
  debug_file 'set'
187
- check_output_includes /List of "set" subcommands:/
187
+ check_output_includes(/List of "set" subcommands:/)
188
188
  end
189
189
  end
190
190
  end
@@ -9,7 +9,7 @@ class TestShow < TestDsl::TestCase
9
9
  enter 'show args'
10
10
  debug_file 'show'
11
11
  check_output_includes 'Argument list to give program being debugged ' \
12
- 'when it is started is "foo bar".'
12
+ 'when it is started is "foo bar".'
13
13
  end
14
14
  end
15
15
 
@@ -160,16 +160,16 @@ class TestShow < TestDsl::TestCase
160
160
  end
161
161
 
162
162
  it 'must show history file' do
163
- check_output_includes \
164
- /filename: The command history file is "hist_file\.txt"/
163
+ check_output_includes(
164
+ /filename: The command history file is "hist_file\.txt"/)
165
165
  end
166
166
 
167
167
  it 'must show history save setting' do
168
- check_output_includes /save: Saving of history save is on\./
168
+ check_output_includes(/save: Saving of history save is on\./)
169
169
  end
170
170
 
171
171
  it 'must show history length' do
172
- check_output_includes /size: Byebug history size is 25/
172
+ check_output_includes(/size: Byebug history size is 25/)
173
173
  end
174
174
  end
175
175
 
@@ -217,8 +217,8 @@ class TestShow < TestDsl::TestCase
217
217
  it 'must show records from readline history' do
218
218
  enter 'show commands'
219
219
  debug_file 'show'
220
- check_output_includes /1 aaa/
221
- check_output_includes /6 fff/
220
+ check_output_includes(/1 aaa/)
221
+ check_output_includes(/6 fff/)
222
222
  end
223
223
  end
224
224
 
@@ -228,9 +228,9 @@ class TestShow < TestDsl::TestCase
228
228
  it 'must show last 10 records from readline history' do
229
229
  enter 'show commands'
230
230
  debug_file 'show'
231
- check_output_doesnt_include /3 ddd/
232
- check_output_includes /4 eee/
233
- check_output_includes /13 nnn/
231
+ check_output_doesnt_include(/3 ddd/)
232
+ check_output_includes(/4 eee/)
233
+ check_output_includes(/13 nnn/)
234
234
  end
235
235
  end
236
236
 
@@ -241,17 +241,17 @@ class TestShow < TestDsl::TestCase
241
241
  # Really don't know why it substracts 4, and shows starting from position 6
242
242
  enter 'show commands 10'
243
243
  debug_file 'show'
244
- check_output_doesnt_include /5 fff/
245
- check_output_includes /6 ggg/
246
- check_output_includes /13 nnn/
244
+ check_output_doesnt_include(/5 fff/)
245
+ check_output_includes(/6 ggg/)
246
+ check_output_includes(/13 nnn/)
247
247
  end
248
248
 
249
249
  it 'must adjust first line if it is < 0' do
250
250
  enter 'show commands 3'
251
251
  debug_file 'show'
252
- check_output_includes /1 bbb/
253
- check_output_includes /8 iii/
254
- check_output_doesnt_include /9 jjj/
252
+ check_output_includes(/1 bbb/)
253
+ check_output_includes(/8 iii/)
254
+ check_output_doesnt_include(/9 jjj/)
255
255
  end
256
256
  end
257
257
  end
@@ -261,7 +261,7 @@ class TestShow < TestDsl::TestCase
261
261
  it 'must show help when typing just "show"' do
262
262
  enter 'show', 'cont'
263
263
  debug_file 'show'
264
- check_output_includes /List of "show" subcommands:/
264
+ check_output_includes(/List of "show" subcommands:/)
265
265
  end
266
266
  end
267
267
  end
@@ -1,6 +1,7 @@
1
1
  require_relative 'test_helper'
2
2
 
3
3
  class TestSource < TestDsl::TestCase
4
+ let(:filename) { 'source_example.txt' }
4
5
 
5
6
  before { File.open(filename, 'w') do |f|
6
7
  f.puts 'break 2'
@@ -9,8 +10,6 @@ class TestSource < TestDsl::TestCase
9
10
 
10
11
  after { FileUtils.rm(filename) }
11
12
 
12
- let(:filename) { 'source_example.txt' }
13
-
14
13
  it 'must run commands from file' do
15
14
  enter "source #{filename}"
16
15
  debug_file 'source' do
@@ -28,7 +27,7 @@ class TestSource < TestDsl::TestCase
28
27
  it 'must show an error if file is not found' do
29
28
  enter 'source blabla'
30
29
  debug_file 'source'
31
- check_error_includes /File ".*blabla" not found/
30
+ check_error_includes(/File ".*blabla" not found/)
32
31
  end
33
32
 
34
33
  describe 'Help' do
@@ -1,11 +1,27 @@
1
1
  require_relative 'test_helper'
2
2
 
3
- class TestStepping < TestDsl::TestCase
3
+ class SteppingExample
4
+ def self.a(num)
5
+ num += 2
6
+ b(num)
7
+ end
8
+
9
+ def self.b(num)
10
+ v2 = 5 if 1 == num ; [1, 2, v2].map { |a| a.to_f }
11
+ c(num)
12
+ end
13
+
14
+ def self.c(num)
15
+ num += 4
16
+ num
17
+ end
18
+ end
4
19
 
20
+ class TestStepping < TestDsl::TestCase
5
21
  describe 'Next Command' do
6
22
 
7
23
  describe 'method call behaviour' do
8
- before { enter 'break 10', 'cont' }
24
+ before { enter "break #{__FILE__}:10", 'cont' }
9
25
 
10
26
  it 'must leave on the same line by default' do
11
27
  enter 'next'
@@ -40,6 +56,14 @@ class TestStepping < TestDsl::TestCase
40
56
  debug_file('stepping') { $state.line.must_equal 21 }
41
57
  end
42
58
 
59
+ it 'must inform when not staying in the same frame' do
60
+ enter 'next 2'
61
+ debug_file('stepping')
62
+ check_output_includes \
63
+ 'Next went up a frame because previous frame finished'
64
+ end
65
+
66
+
43
67
  it 'must ignore it if "minus" is specified' do
44
68
  enter 'next-'
45
69
  debug_file('stepping') { $state.line.must_equal 10 }
@@ -48,11 +72,11 @@ class TestStepping < TestDsl::TestCase
48
72
  end
49
73
 
50
74
  describe 'block behaviour' do
51
- before { enter 'break 21', 'cont' }
75
+ before { enter 'break 4', 'cont' }
52
76
 
53
77
  it 'must step over blocks' do
54
78
  enter 'next'
55
- debug_file('stepping') { $state.line.must_equal 25 }
79
+ debug_file('stepping') { $state.line.must_equal 8 }
56
80
  end
57
81
  end
58
82
  end
@@ -60,7 +84,7 @@ class TestStepping < TestDsl::TestCase
60
84
  describe 'Step Command' do
61
85
 
62
86
  describe 'method call behaviour' do
63
- before { enter 'break 10', 'cont' }
87
+ before { enter "break #{__FILE__}:10", 'cont' }
64
88
 
65
89
  it 'must leave on the same line if forced by a setting' do
66
90
  enter 'step'
@@ -98,11 +122,11 @@ class TestStepping < TestDsl::TestCase
98
122
  end
99
123
 
100
124
  describe 'block behaviour' do
101
- before { enter 'break 21', 'cont' }
125
+ before { enter 'break 4', 'cont' }
102
126
 
103
127
  it 'must step into blocks' do
104
128
  enter 'step'
105
- debug_file('stepping') { $state.line.must_equal 22 }
129
+ debug_file('stepping') { $state.line.must_equal 5 }
106
130
  end
107
131
  end
108
132
  end